sara-tasks 2.0.0

Sara — folder-aware task manager
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
use schemars::JsonSchema;
use serde::Deserialize;

fn de_id<'de, D>(d: D) -> Result<String, D::Error>
where
    D: serde::Deserializer<'de>,
{
    struct V;
    impl serde::de::Visitor<'_> for V {
        type Value = String;
        fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            f.write_str("a task id as a string or integer")
        }
        fn visit_str<E>(self, v: &str) -> Result<String, E> {
            Ok(v.to_string())
        }
        fn visit_string<E>(self, v: String) -> Result<String, E> {
            Ok(v)
        }
        fn visit_i64<E>(self, v: i64) -> Result<String, E> {
            Ok(v.to_string())
        }
        fn visit_u64<E>(self, v: u64) -> Result<String, E> {
            Ok(v.to_string())
        }
    }
    d.deserialize_any(V)
}

fn de_opt_index<'de, D>(d: D) -> Result<Option<usize>, D::Error>
where
    D: serde::Deserializer<'de>,
{
    #[derive(Deserialize)]
    #[serde(untagged)]
    enum NumOrStr {
        Num(i64),
        Str(String),
    }
    use serde::de::Error;
    match Option::<NumOrStr>::deserialize(d)? {
        None => Ok(None),
        Some(NumOrStr::Num(n)) => usize::try_from(n)
            .map(Some)
            .map_err(|_| D::Error::custom("position must be non-negative")),
        Some(NumOrStr::Str(s)) => s
            .trim()
            .parse::<usize>()
            .map(Some)
            .map_err(|_| D::Error::custom("position must be a 1-based integer")),
    }
}

fn de_opt_string_list<'de, D>(d: D) -> Result<Option<Vec<String>>, D::Error>
where
    D: serde::Deserializer<'de>,
{
    struct V;
    impl<'de> serde::de::Visitor<'de> for V {
        type Value = Option<Vec<String>>;
        fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            f.write_str("an array of strings or a comma-separated string")
        }
        fn visit_none<E>(self) -> Result<Self::Value, E>
        where
            E: serde::de::Error,
        {
            Ok(None)
        }
        fn visit_unit<E>(self) -> Result<Self::Value, E>
        where
            E: serde::de::Error,
        {
            Ok(None)
        }
        fn visit_some<D2>(self, d: D2) -> Result<Self::Value, D2::Error>
        where
            D2: serde::Deserializer<'de>,
        {
            d.deserialize_any(V)
        }
        fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
        where
            E: serde::de::Error,
        {
            Ok(Some(crate::commands::shared::split_csv(v)))
        }
        fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
        where
            E: serde::de::Error,
        {
            self.visit_str(&v)
        }
        fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
        where
            A: serde::de::SeqAccess<'de>,
        {
            let mut out = Vec::new();
            while let Some(s) = seq.next_element::<String>()? {
                out.push(s);
            }
            Ok(Some(out))
        }
    }
    d.deserialize_option(V)
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ListParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "List pending tasks across every project.")]
    pub(crate) all: Option<bool>,
    #[schemars(description = "Project name to list instead of the one at project_path.")]
    pub(crate) project: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct IdParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct AddParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    pub(crate) description: String,
    #[schemars(description = "Project name; defaults to the project at project_path.")]
    pub(crate) project: Option<String>,
    #[schemars(description = "H, M or L.")]
    pub(crate) priority: Option<String>,
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tags: Option<Vec<String>>,
    #[schemars(description = "Recurrence interval, e.g. daily, weekly or 2w.")]
    pub(crate) recur: Option<String>,
    #[schemars(description = "Notes to attach as comments.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) annotations: Option<Vec<String>>,
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) links: Option<Vec<String>>,
    #[schemars(description = "Checklist steps to add.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) checks: Option<Vec<String>>,
    #[schemars(description = "Task UUID prefixes this task is blocked by.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) depends_on: Option<Vec<String>>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct BeginParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    pub(crate) description: String,
    #[schemars(description = "Project name; defaults to the project at project_path.")]
    pub(crate) project: Option<String>,
    #[schemars(description = "H, M or L.")]
    pub(crate) priority: Option<String>,
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tags: Option<Vec<String>>,
    #[schemars(description = "Files the task will touch.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) files: Option<Vec<String>>,
    #[schemars(description = "What was asked, in the requester's words.")]
    pub(crate) assignment: Option<String>,
    #[schemars(description = "Why the task exists.")]
    pub(crate) rationale: Option<String>,
    #[schemars(description = "One acceptance criterion (definition of done).")]
    pub(crate) check: Option<String>,
    #[schemars(description = "Shell command that proves the acceptance criterion.")]
    pub(crate) verify: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct StepsParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "Return only steps 1..until.")]
    pub(crate) until: Option<usize>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct StepDoneParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    #[serde(alias = "task", alias = "task_id", deserialize_with = "de_id")]
    pub(crate) id: String,
    #[schemars(
        description = "1-based position of the step (or acceptance criterion with kind=acceptance). Omit with step_id to complete the current step."
    )]
    #[serde(default, alias = "index", deserialize_with = "de_opt_index")]
    pub(crate) n: Option<usize>,
    #[schemars(description = "Step rowid returned by check; takes precedence over n.")]
    pub(crate) step_id: Option<i64>,
    #[schemars(description = "Evidence of what was done.")]
    pub(crate) result: Option<String>,
    #[schemars(description = "step (default) or acceptance.")]
    pub(crate) kind: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct VerifyParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "Only this 1-based step.")]
    pub(crate) step: Option<usize>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct RecallParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Free-text keyword query; empty returns the most recent memories.")]
    #[serde(default)]
    pub(crate) query: String,
    #[schemars(description = "Only memories with these tags.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tag: Option<Vec<String>>,
    #[schemars(description = "Only memories in these projects.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) project: Option<Vec<String>>,
    #[schemars(
        description = "Only memories bound to these files; a trailing / matches a directory."
    )]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) files: Option<Vec<String>>,
    #[schemars(description = "Maximum hits (default 10).")]
    pub(crate) limit: Option<i64>,
    #[schemars(description = "Also return graph-related memories that share no keyword.")]
    pub(crate) spread: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct AnnotateParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    pub(crate) text: String,
    #[schemars(
        description = "comment (default), finding, decision, constraint, risk, assumption, open_question, ..."
    )]
    pub(crate) kind: Option<String>,
    #[schemars(description = "Defaults to human.")]
    pub(crate) author: Option<String>,
    #[schemars(description = "Anchor: step:N, acceptance:N, anchor:ID or note:ID.")]
    pub(crate) on: Option<String>,
    #[schemars(description = "Flag the note for reconsideration.")]
    pub(crate) reconsider: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct PlanImportParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Plan as a JSON string; see the tool description for its shape.")]
    pub(crate) plan_json: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct DoneParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "Complete even if blocked or targeted from a different branch.")]
    pub(crate) force: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct LinkParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    pub(crate) url: String,
    #[schemars(description = "Optional display text.")]
    pub(crate) label: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct DepParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "on, off or list.")]
    pub(crate) action: String,
    #[schemars(description = "The blocking task's id; required for on/off.")]
    pub(crate) other: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct CheckParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    #[serde(alias = "task", alias = "task_id", deserialize_with = "de_id")]
    pub(crate) id: String,
    #[schemars(description = "The step or criterion text.")]
    pub(crate) text: String,
    #[schemars(description = "step (default) or acceptance.")]
    pub(crate) kind: Option<String>,
    #[schemars(description = "Why this step matters.")]
    pub(crate) intent: Option<String>,
    #[schemars(
        description = "Shell command that proves it; required for validate to pass acceptance criteria."
    )]
    pub(crate) verify: Option<String>,
    #[schemars(description = "human (default) or ai.")]
    pub(crate) source: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ModifyParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    pub(crate) description: Option<String>,
    #[schemars(description = "H, M or L.")]
    pub(crate) priority: Option<String>,
    #[schemars(description = "Due date, e.g. 2026-10-31, today or tomorrow.")]
    pub(crate) due: Option<String>,
    pub(crate) clear_due: Option<bool>,
    #[schemars(description = "Replaces the whole tag set.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tags: Option<Vec<String>>,
    pub(crate) clear_tags: Option<bool>,
    #[schemars(description = "Time estimate, e.g. 30m or 2h.")]
    pub(crate) estimate: Option<String>,
    pub(crate) clear_estimate: Option<bool>,
    #[schemars(description = "Recurrence interval, e.g. daily, weekly or 2w.")]
    pub(crate) every: Option<String>,
    pub(crate) clear_recur: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ResolveParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Annotation id from feedback/info output, not a task id.")]
    pub(crate) feedback_id: i64,
    #[schemars(description = "run_id from record_run that addressed it.")]
    pub(crate) run_id: Option<i64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct RecordRunParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "Free-form label for the interaction, e.g. review.")]
    pub(crate) kind: String,
    pub(crate) model: Option<String>,
    pub(crate) provider: Option<String>,
    pub(crate) prompt: Option<String>,
    pub(crate) response: Option<String>,
    pub(crate) prompt_tokens: Option<i64>,
    pub(crate) completion_tokens: Option<i64>,
    pub(crate) total_tokens: Option<i64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct StepEditParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    #[serde(alias = "task", alias = "task_id", deserialize_with = "de_id")]
    pub(crate) id: String,
    #[schemars(
        description = "1-based position of the step (or acceptance criterion with kind=acceptance)."
    )]
    #[serde(default, alias = "index", deserialize_with = "de_opt_index")]
    pub(crate) n: Option<usize>,
    #[schemars(description = "Step rowid returned by check; takes precedence over n.")]
    pub(crate) step_id: Option<i64>,
    #[schemars(description = "step (default) or acceptance.")]
    pub(crate) kind: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct GuideTextParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    pub(crate) text: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct AttachParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "File path (relative to project_path or absolute) or URL.")]
    pub(crate) path: String,
    pub(crate) reason: Option<String>,
    pub(crate) symbol: Option<String>,
    #[schemars(description = "Line range as start:end, e.g. 10:57.")]
    pub(crate) lines: Option<String>,
    #[schemars(description = "human (default) or ai.")]
    pub(crate) source: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct LearnParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "The insight, one idea, at most 2000 characters.")]
    pub(crate) text: String,
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tags: Option<Vec<String>>,
    #[schemars(
        description = "Project names to scope the memory to; defaults to the current project."
    )]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) projects: Option<Vec<String>>,
    #[schemars(description = "Task UUID prefixes to link.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tasks: Option<Vec<String>>,
    #[schemars(description = "Files to bind; relative paths resolve against project_path.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) files: Option<Vec<String>>,
    #[schemars(description = "Skip the size, secret and overlap checks.")]
    pub(crate) force: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ForgetParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Memory label, e.g. m3.")]
    pub(crate) handle: String,
    #[schemars(description = "Also archive derived_from children of a canonical.")]
    pub(crate) cascade: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct PromoteParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Memory label, e.g. m14.")]
    pub(crate) handle: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct RelearnParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Memory label, e.g. m3.")]
    pub(crate) handle: String,
    #[schemars(description = "New body; omit to keep the current one.")]
    pub(crate) text: Option<String>,
    #[schemars(description = "Replaces the tag set; omit to keep it.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) tags: Option<Vec<String>>,
    #[schemars(description = "Replaces the file set; omit to keep it.")]
    #[serde(default, deserialize_with = "de_opt_string_list")]
    pub(crate) files: Option<Vec<String>>,
    #[schemars(description = "Skip the size and secret checks.")]
    pub(crate) force: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct TagsParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct MemoriesParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ProjectsParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct UnlinkParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Link id shown in info.")]
    pub(crate) link_id: i64,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct DenotateParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Annotation id shown in info.")]
    pub(crate) annotation_id: i64,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct MoveTaskParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Task UUID prefix (stable, preferred) or numeric display id.")]
    pub(crate) id: String,
    #[schemars(description = "Target project name.")]
    pub(crate) project: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct LinkMemoryParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Source memory label, e.g. m3.")]
    pub(crate) from: String,
    #[schemars(description = "supersedes, similar_to, derived_from or used_in.")]
    pub(crate) relation: String,
    #[schemars(description = "Target memory label.")]
    pub(crate) to: String,
    #[schemars(description = "Link weight (default 1.0).")]
    pub(crate) weight: Option<f64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct UnlinkMemoryParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Source memory label.")]
    pub(crate) from: String,
    #[schemars(description = "Relation to remove.")]
    pub(crate) relation: String,
    #[schemars(description = "Target memory label.")]
    pub(crate) to: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct PruneMemoriesParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Preview only (default true).")]
    pub(crate) dry_run: Option<bool>,
    #[schemars(description = "Age before an unlinked weak memory is pruned (default 90).")]
    pub(crate) weak_days: Option<i64>,
    #[schemars(
        description = "Age before an unreviewed provisional memory is pruned (default 30)."
    )]
    pub(crate) provisional_days: Option<i64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ConsolidateParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Days of recall history to sweep (default 30).")]
    pub(crate) window_days: Option<i64>,
    #[schemars(description = "Recalls this many seconds apart count as co-firing (default 5).")]
    pub(crate) bucket_secs: Option<i64>,
    #[schemars(description = "Weight added per co-firing (default 0.1).")]
    pub(crate) delta: Option<f64>,
    #[schemars(description = "Skip buckets with more memories than this (default 5).")]
    pub(crate) max_bucket: Option<usize>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ReflectParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Minimum co_activated weight to cluster on (default 0.5).")]
    pub(crate) min_weight: Option<f64>,
    #[schemars(description = "Maximum memories per cluster (default 8).")]
    pub(crate) max_cluster: Option<usize>,
    #[schemars(description = "Create the proposed derived_from links.")]
    pub(crate) apply: Option<bool>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct DiagnoseMemoriesParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
    #[schemars(description = "Minimum cosine similarity to report (default 0.75).")]
    pub(crate) threshold: Option<f32>,
    #[schemars(description = "Only this project.")]
    pub(crate) project: Option<String>,
    #[schemars(description = "Maximum pairs to return.")]
    pub(crate) limit: Option<usize>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct DoctorParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub(crate) struct ReindexEmbeddingsParams {
    #[schemars(
        description = "Absolute path to the target project's repo; omit to use the server's launch directory."
    )]
    pub(crate) project_path: Option<String>,
}