-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefinitions.ts
More file actions
2365 lines (2295 loc) · 77.9 KB
/
Copy pathdefinitions.ts
File metadata and controls
2365 lines (2295 loc) · 77.9 KB
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
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* MCP Tool Definitions
*
* All tool registrations (names, descriptions, JSON schemas) for the GitMem MCP server.
* Extracted from server.ts for maintainability.
*/
import {
hasBatchOperations,
hasTranscripts,
hasCacheManagement,
hasSupabase,
hasFullAliases,
} from "../services/tier.js";
/**
* Tool definitions for MCP
*/
export const TOOLS = [
{
name: "recall",
description: "Check institutional memory for relevant scars before taking action. Returns matching scars and their lessons. Integrates variant assignment when issue_id provided.",
inputSchema: {
type: "object" as const,
properties: {
plan: {
type: "string",
description: "What you're about to do (e.g., 'implement auth layer', 'deploy to production')",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
match_count: {
type: "number",
description: "Number of scars to return (default: 3)",
},
issue_id: {
type: "string",
description: "Linear issue identifier for variant assignment (e.g., 'PROJ-123'). When provided, scars with variants will be randomly assigned and formatted accordingly.",
},
similarity_threshold: {
type: "number",
description: "Minimum similarity score (0-1) to include results. Weak matches below threshold are suppressed. Default: 0.4 (free tier BM25), 0.35 (pro tier embeddings).",
},
},
required: ["plan"],
},
},
{
name: "confirm_scars",
description: "Confirm surfaced scars with APPLYING/N_A/REFUTED decisions and evidence. REQUIRED after recall() before consequential actions. Each recalled scar must be addressed. APPLYING: past-tense evidence of compliance. N_A: explain why scar doesn't apply. REFUTED: acknowledge risk of overriding.",
inputSchema: {
type: "object" as const,
properties: {
confirmations: {
type: "array",
items: {
type: "object",
properties: {
scar_id: {
type: "string",
description: "UUID of the surfaced scar (from recall result)",
},
decision: {
type: "string",
enum: ["APPLYING", "N_A", "REFUTED"],
description: "APPLYING: scar is relevant, evidence of compliance. N_A: scar doesn't apply, explain why. REFUTED: overriding scar, acknowledge risk.",
},
evidence: {
type: "string",
description: "Past-tense evidence (APPLYING), scenario comparison (N_A), or risk acknowledgment (REFUTED). Minimum 50 characters.",
},
relevance: {
type: "string",
enum: ["high", "low", "noise"],
description: "How relevant was this scar to your plan? high=directly applicable, low=tangentially related, noise=not relevant to this context. Helps improve future recall quality.",
},
},
required: ["scar_id", "decision", "evidence"],
},
description: "One confirmation per recalled scar. All recalled scars must be addressed.",
},
},
required: ["confirmations"],
},
},
{
name: "reflect_scars",
description: "End-of-session scar reflection — the closing counterpart to confirm_scars. Mirrors CODA-1's [Scar Reflection] protocol. Call BEFORE session_close to provide evidence of how each surfaced scar was handled. OBEYED: concrete evidence of compliance (min 15 chars). REFUTED: why it didn't apply + what was done instead (min 30 chars). Session close uses reflections to set execution_successful accurately.",
inputSchema: {
type: "object" as const,
properties: {
reflections: {
type: "array",
items: {
type: "object",
properties: {
scar_id: {
type: "string",
description: "UUID of the surfaced scar (from recall or session_start)",
},
outcome: {
type: "string",
enum: ["OBEYED", "REFUTED"],
description: "OBEYED: followed the scar with evidence. REFUTED: scar didn't apply, explain why.",
},
evidence: {
type: "string",
description: "Concrete evidence of compliance (OBEYED, min 15 chars) or explanation of why scar didn't apply (REFUTED, min 30 chars).",
},
},
required: ["scar_id", "outcome", "evidence"],
},
description: "One reflection per surfaced scar.",
},
},
required: ["reflections"],
},
},
{
name: "session_start",
description: "Initialize session, detect agent, load institutional context (last session, recent decisions, open threads). Scars surface on-demand via recall(). DISPLAY: The result includes a pre-formatted 'display' field visible in the tool result. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
agent_identity: {
type: "string",
enum: ["cli", "desktop", "autonomous", "local", "cloud"],
description: "Override agent identity (auto-detects if not provided)",
},
linear_issue: {
type: "string",
description: "Current Linear issue identifier (e.g., PROJ-123)",
},
issue_title: {
type: "string",
description: "Issue title for scar context",
},
issue_description: {
type: "string",
description: "Issue description for scar context",
},
issue_labels: {
type: "array",
items: { type: "string" },
description: "Issue labels for scar context",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
force: {
type: "boolean",
description: "Force create new session even if one already exists",
},
},
},
},
{
name: "session_refresh",
description: "Re-surface institutional context (threads, decisions) for the current active session without creating a new session. Use mid-session when you need to remember where you left off, after context compaction, or after a long gap. DISPLAY: The result includes a pre-formatted 'display' field visible in the tool result. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
project: {
type: "string",
description: "Project namespace (default: from active session). Free-form string (e.g., 'my-project').",
},
},
},
},
{
name: "session_close",
description: "Persist session with compliance validation. IMPORTANT: Before calling this tool, write all heavy payload data (closing_reflection, human_corrections, scars_to_record, open_threads, decisions, learnings_created) to {gitmem_dir}/closing-payload.json using your file write tool — the gitmem_dir path is returned by session_start (also shown in session start display as 'Payload path'). Then call this tool with ONLY session_id and close_type. The tool reads the payload file automatically and deletes it after processing. task_completion is auto-generated from closing_reflection timestamps and human_corrections — do NOT write it to the payload. DISPLAY: The result includes a pre-formatted 'display' field. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
session_id: {
type: "string",
description: "Session ID from session_start",
},
close_type: {
type: "string",
enum: ["standard", "quick", "autonomous"],
description: "Type of close (standard requires full reflection)",
},
linear_issue: {
type: "string",
description: "Associated Linear issue",
},
ceremony_duration_ms: {
type: "number",
description: "End-to-end ceremony duration from agent perspective (in milliseconds)",
},
},
required: ["session_id", "close_type"],
},
},
{
name: "create_learning",
description: "Create scar, win, or pattern entry in institutional memory. Frame as 'what we now know' — lead with the factual/architectural discovery, not what went wrong. Good: 'Fine-grained PATs are scoped to one resource owner'. Bad: 'Should have checked PAT type first'.",
inputSchema: {
type: "object" as const,
properties: {
learning_type: {
type: "string",
enum: ["scar", "win", "pattern", "anti_pattern"],
description: "Type of learning",
},
title: {
type: "string",
description: "Frame as a knowledge discovery — what we now know. Lead with the factual insight, not self-criticism.",
},
description: {
type: "string",
description: "Detailed description. Include the architectural/behavioral fact that makes this retrievable by domain.",
},
severity: {
type: "string",
enum: ["critical", "high", "medium", "low"],
description: "Severity level (required for scars)",
},
scar_type: {
type: "string",
enum: ["process", "incident", "context"],
description: "Scar type (process, incident, or context). Defaults to 'process'.",
},
counter_arguments: {
type: "array",
items: { type: "string" },
description: "Counter-arguments for scars (min 2 required)",
},
problem_context: {
type: "string",
description: "Problem context (for wins)",
},
solution_approach: {
type: "string",
description: "Solution approach (for wins)",
},
applies_when: {
type: "array",
items: { type: "string" },
description: "When this pattern applies",
},
domain: {
type: "array",
items: { type: "string" },
description: "Domain tags",
},
keywords: {
type: "array",
items: { type: "string" },
description: "Search keywords",
},
source_linear_issue: {
type: "string",
description: "Source Linear issue",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
required: ["learning_type", "title", "description"],
},
},
{
name: "create_decision",
description: "Log architectural/operational decision to institutional memory",
inputSchema: {
type: "object" as const,
properties: {
title: {
type: "string",
description: "Decision title",
},
decision: {
type: "string",
description: "What was decided",
},
rationale: {
type: "string",
description: "Why this decision was made",
},
alternatives_considered: {
type: "array",
items: { type: "string" },
description: "Alternatives that were rejected",
},
personas_involved: {
type: "array",
items: { type: "string" },
description: "Personas involved in decision",
},
docs_affected: {
type: "array",
items: { type: "string" },
description:
"Docs/files affected by this decision (relative paths from repo root)",
},
linear_issue: {
type: "string",
description: "Associated Linear issue",
},
session_id: {
type: "string",
description: "Current session ID",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
required: ["title", "decision", "rationale"],
},
},
{
name: "record_scar_usage",
description: "Track scar application for effectiveness measurement",
inputSchema: {
type: "object" as const,
properties: {
scar_id: {
type: "string",
description: "UUID of the scar",
},
issue_id: {
type: "string",
description: "Linear issue UUID",
},
issue_identifier: {
type: "string",
description: "Linear issue identifier (e.g., PROJ-123)",
},
surfaced_at: {
type: "string",
description: "ISO timestamp when scar was retrieved",
},
acknowledged_at: {
type: "string",
description: "ISO timestamp when scar was acknowledged",
},
reference_type: {
type: "string",
enum: ["explicit", "implicit", "acknowledged", "refuted", "none"],
description: "How the scar was referenced",
},
reference_context: {
type: "string",
description: "How the scar was applied (1-2 sentences)",
},
execution_successful: {
type: "boolean",
description: "Whether the task succeeded after applying scar",
},
session_id: {
type: "string",
description: "GitMem session UUID (for non-issue session tracking)",
},
agent: {
type: "string",
description: "Agent identity (e.g., cli, desktop, autonomous)",
},
variant_id: {
type: "string",
description: "UUID of the assigned variant from scar_enforcement_variants (for A/B testing)",
},
},
required: ["scar_id", "surfaced_at", "reference_type", "reference_context"],
},
},
{
name: "record_scar_usage_batch",
description: "Track multiple scar applications in a single batch operation (reduces session close latency)",
inputSchema: {
type: "object" as const,
properties: {
scars: {
type: "array",
items: {
type: "object",
properties: {
scar_identifier: {
type: "string",
description: "UUID or title/description of scar (tool resolves to UUID)",
},
issue_id: {
type: "string",
description: "Linear issue UUID",
},
issue_identifier: {
type: "string",
description: "Linear issue identifier (e.g., PROJ-123)",
},
surfaced_at: {
type: "string",
description: "ISO timestamp when scar was retrieved",
},
acknowledged_at: {
type: "string",
description: "ISO timestamp when scar was acknowledged",
},
reference_type: {
type: "string",
enum: ["explicit", "implicit", "acknowledged", "refuted", "none"],
description: "How the scar was referenced",
},
reference_context: {
type: "string",
description: "How the scar was applied (1-2 sentences)",
},
execution_successful: {
type: "boolean",
description: "Whether the task succeeded after applying scar",
},
session_id: {
type: "string",
description: "GitMem session UUID (for non-issue session tracking)",
},
agent: {
type: "string",
description: "Agent identity (e.g., cli, desktop, autonomous)",
},
},
required: ["scar_identifier", "surfaced_at", "reference_type", "reference_context"],
},
description: "Array of scar usage entries to record",
},
project: {
type: "string",
description: "Project scope for scar resolution",
},
},
required: ["scars"],
},
},
{
name: "save_transcript",
description: "Save full session transcript to storage for training data and post-mortems",
inputSchema: {
type: "object" as const,
properties: {
session_id: {
type: "string",
description: "Session ID to associate transcript with",
},
transcript: {
type: "string",
description: "Full conversation transcript content",
},
format: {
type: "string",
enum: ["json", "markdown"],
description: "Transcript format (default: json)",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
required: ["session_id", "transcript"],
},
},
{
name: "get_transcript",
description: "Retrieve a session transcript from storage",
inputSchema: {
type: "object" as const,
properties: {
session_id: {
type: "string",
description: "Session ID to retrieve transcript for",
},
},
required: ["session_id"],
},
},
{
name: "search_transcripts",
description: "Semantic search over session transcript chunks. Generates embedding for query and calls match_transcript_chunks RPC to find relevant conversation fragments across all indexed sessions.",
inputSchema: {
type: "object" as const,
properties: {
query: {
type: "string",
description: "Natural language search query (e.g., 'deployment verification discussion', 'what was decided about caching')",
},
match_count: {
type: "number",
description: "Maximum number of chunks to return (default: 10, max: 50)",
},
similarity_threshold: {
type: "number",
description: "Minimum similarity score 0-1 (default: 0.3). Higher values return more relevant results.",
},
project: {
type: "string",
description: "Project namespace to filter by (e.g., 'my-project')",
},
},
required: ["query"],
},
},
// ============================================================================
// SEARCH & LOG TOOLS
// ============================================================================
{
name: "search",
description: "Search institutional memory by query. Unlike recall (which is action-oriented), search is exploration-oriented — returns matching scars/wins/patterns without side effects.",
inputSchema: {
type: "object" as const,
properties: {
query: {
type: "string",
description: "Natural language search query (e.g., 'deployment failures', 'Supabase RLS')",
},
match_count: {
type: "number",
description: "Number of results to return (default: 5)",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
severity: {
type: "string",
enum: ["critical", "high", "medium", "low"],
description: "Filter by severity level",
},
learning_type: {
type: "string",
enum: ["scar", "win", "pattern", "anti_pattern"],
description: "Filter by learning type",
},
},
required: ["query"],
},
},
{
name: "log",
description: "List recent learnings chronologically (like git log). Shows scars, wins, and patterns ordered by creation date.",
inputSchema: {
type: "object" as const,
properties: {
limit: {
type: "number",
description: "Number of entries to return (default: 10)",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
learning_type: {
type: "string",
enum: ["scar", "win", "pattern", "anti_pattern"],
description: "Filter by learning type",
},
severity: {
type: "string",
enum: ["critical", "high", "medium", "low"],
description: "Filter by severity level",
},
since: {
type: "number",
description: "Days to look back (e.g., 7 = last week)",
},
},
},
},
// ============================================================================
// PREPARE CONTEXT
// ============================================================================
{
name: "prepare_context",
description: "Generate portable memory payload for sub-agent injection. Formats institutional memory into compact or gate payloads that fit in Task tool prompts.",
inputSchema: {
type: "object" as const,
properties: {
plan: {
type: "string",
description: "What the team is about to do (e.g., 'review auth middleware', 'deploy edge function')",
},
format: {
type: "string",
enum: ["full", "compact", "gate"],
description: "Output format: full (rich markdown), compact (~500 tokens, one-line per scar), gate (~100 tokens, blocking scars only)",
},
max_tokens: {
type: "number",
description: "Token budget for payload (default: 500 for compact, 100 for gate, unlimited for full)",
},
agent_role: {
type: "string",
description: "Sub-agent role for relevance filtering (e.g., 'reviewer', 'deployer') — reserved for Phase 3",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
required: ["plan", "format"],
},
},
// ============================================================================
// ABSORB OBSERVATIONS (GitMem v2 Phase 2)
// ============================================================================
{
name: "absorb_observations",
description: "Capture observations from sub-agents and teammates. The lead agent parses findings from sub-agent responses, then calls this to persist and analyze them. Identifies scar candidates.",
inputSchema: {
type: "object" as const,
properties: {
task_id: {
type: "string",
description: "Linear issue or task identifier (optional)",
},
observations: {
type: "array",
items: {
type: "object",
properties: {
source: { type: "string", description: 'Who made this observation (e.g., "Sub-Agent: code review")' },
text: { type: "string", description: "What was observed" },
severity: { type: "string", enum: ["info", "warning", "scar_candidate"], description: "Observation severity" },
context: { type: "string", description: "File, function, or area (optional)" },
},
required: ["source", "text", "severity"],
},
description: "Array of observations from sub-agents/teammates",
},
},
required: ["observations"],
},
},
// --- Thread Lifecycle Tools () ---
{
name: "list_threads",
description:
"List open threads across recent sessions. Shows unresolved work items that carry over between sessions. Use resolve_thread to mark threads as done.",
inputSchema: {
type: "object" as const,
properties: {
status: {
type: "string",
enum: ["open", "resolved"],
description: "Filter by status (default: open)",
},
include_resolved: {
type: "boolean",
description: "Include recently resolved threads (default: false)",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
},
},
{
name: "resolve_thread",
description:
"Mark an open thread as resolved. Use thread_id for exact match or text_match for fuzzy matching. Updates session state and .gitmem/threads.json.",
inputSchema: {
type: "object" as const,
properties: {
thread_id: {
type: "string",
description: 'Thread ID (e.g., "t-a1b2c3d4") for exact resolution',
},
text_match: {
type: "string",
description:
"Fuzzy text match against thread descriptions (fallback if no thread_id)",
},
resolution_note: {
type: "string",
description: "Brief note explaining how/why thread was resolved",
},
},
},
},
{
name: "create_thread",
description:
"Create an open thread to track unresolved work across sessions. Includes semantic dedup: if a similar open thread exists (cosine similarity > 0.85), returns the existing thread instead. Check the 'deduplicated' field in the response.",
inputSchema: {
type: "object" as const,
properties: {
text: {
type: "string",
description: "Thread description — what needs to be tracked or resolved",
},
linear_issue: {
type: "string",
description: "Associated Linear issue (e.g., PROJ-123)",
},
},
required: ["text"],
},
},
// --- Thread Suggestion Tools (Phase 5: Implicit Thread Detection) ---
{
name: "promote_suggestion",
description:
"Promote a suggested thread to an open thread. Takes a suggestion_id from session_start's suggested_threads list and creates a real thread from it.",
inputSchema: {
type: "object" as const,
properties: {
suggestion_id: {
type: "string",
description: 'Suggestion ID (e.g., "ts-a1b2c3d4") from suggested_threads list',
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
},
required: ["suggestion_id"],
},
},
{
name: "dismiss_suggestion",
description:
"Dismiss a suggested thread. Incremented dismiss count — suggestions dismissed 3+ times are permanently suppressed.",
inputSchema: {
type: "object" as const,
properties: {
suggestion_id: {
type: "string",
description: 'Suggestion ID (e.g., "ts-a1b2c3d4") from suggested_threads list',
},
},
required: ["suggestion_id"],
},
},
// --- Thread Lifecycle Cleanup Tool (Phase 6) ---
{
name: "cleanup_threads",
description:
"Triage open threads by lifecycle health. Groups threads as active/cooling/dormant with vitality scores. Use auto_archive=true to archive threads dormant 30+ days. Review and resolve stale threads to keep your thread list healthy.",
inputSchema: {
type: "object" as const,
properties: {
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
auto_archive: {
type: "boolean",
description: "If true, auto-archive threads that have been dormant for 30+ days",
},
},
},
},
// --- Effect Health Tool ---
{
name: "health",
description:
"Show write health for the current session. Reports success/failure rates for all tracked fire-and-forget operations (metrics, cache, triple writes, embeddings, scar usage). Use this to diagnose silent failures.",
inputSchema: {
type: "object" as const,
properties: {
failure_limit: {
type: "number",
description: "Max number of recent failures to return (default: 10)",
},
},
},
},
// ============================================================================
// SHORT ALIASES (gitmem-*)
// Self-documenting: each description includes both alias and full name
// ============================================================================
{
name: "gitmem-r",
description: "gitmem-r (recall) - Check institutional memory for relevant scars before taking action",
inputSchema: {
type: "object" as const,
properties: {
plan: {
type: "string",
description: "What you're about to do (e.g., 'implement auth layer', 'deploy to production')",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
match_count: {
type: "number",
description: "Number of scars to return (default: 3)",
},
},
required: ["plan"],
},
},
{
name: "gitmem-cs",
description: "gitmem-cs (confirm_scars) - Confirm recalled scars with APPLYING/N_A/REFUTED decisions",
inputSchema: {
type: "object" as const,
properties: {
confirmations: {
type: "array",
items: {
type: "object",
properties: {
scar_id: { type: "string", description: "UUID of the surfaced scar" },
decision: { type: "string", enum: ["APPLYING", "N_A", "REFUTED"], description: "Confirmation decision" },
evidence: { type: "string", description: "Evidence (min 50 chars)" },
},
required: ["scar_id", "decision", "evidence"],
},
description: "One confirmation per recalled scar",
},
},
required: ["confirmations"],
},
},
{
name: "gitmem-rf",
description: "gitmem-rf (reflect_scars) - End-of-session scar reflection (OBEYED/REFUTED with evidence)",
inputSchema: {
type: "object" as const,
properties: {
reflections: {
type: "array",
items: {
type: "object",
properties: {
scar_id: { type: "string", description: "UUID of the surfaced scar" },
outcome: { type: "string", enum: ["OBEYED", "REFUTED"], description: "Reflection outcome" },
evidence: { type: "string", description: "Evidence (OBEYED min 15 chars, REFUTED min 30 chars)" },
},
required: ["scar_id", "outcome", "evidence"],
},
description: "One reflection per surfaced scar",
},
},
required: ["reflections"],
},
},
{
name: "gitmem-ss",
description: "gitmem-ss (session_start) - Initialize session with institutional context. DISPLAY: The result includes a pre-formatted 'display' field. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
agent_identity: {
type: "string",
enum: ["cli", "desktop", "autonomous", "local", "cloud"],
description: "Override agent identity (auto-detects if not provided)",
},
linear_issue: {
type: "string",
description: "Current Linear issue identifier (e.g., PROJ-123)",
},
issue_title: {
type: "string",
description: "Issue title for scar context",
},
issue_description: {
type: "string",
description: "Issue description for scar context",
},
issue_labels: {
type: "array",
items: { type: "string" },
description: "Issue labels for scar context",
},
project: {
type: "string",
description: "Project namespace (e.g., 'my-project'). Scopes sessions and searches.",
},
force: {
type: "boolean",
description: "Force create new session even if one already exists",
},
},
},
},
{
name: "gitmem-sr",
description: "gitmem-sr (session_refresh) - Refresh institutional context for the active session without creating a new session. DISPLAY: The result includes a pre-formatted 'display' field. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
project: {
type: "string",
description: "Project namespace (default: from active session). Free-form string (e.g., 'my-project').",
},
},
},
},
{
name: "gitmem-sc",
description: "gitmem-sc (session_close) - Close session with compliance validation. IMPORTANT: Write all heavy payload data (closing_reflection, task_completion, human_corrections, scars_to_record, open_threads, decisions, learnings_created) to {gitmem_dir}/closing-payload.json BEFORE calling this tool — gitmem_dir is from session_start. Only pass session_id and close_type inline. DISPLAY: The result includes a pre-formatted 'display' field. Output the display field verbatim as your response — tool results are collapsed in the CLI.",
inputSchema: {
type: "object" as const,
properties: {
session_id: {
type: "string",
description: "Session ID from session_start",
},
close_type: {
type: "string",
enum: ["standard", "quick", "autonomous"],
description: "Type of close (standard requires full reflection)",
},
linear_issue: {
type: "string",
description: "Associated Linear issue",
},
ceremony_duration_ms: {
type: "number",
description: "End-to-end ceremony duration from agent perspective (in milliseconds)",
},
},
required: ["session_id", "close_type"],
},
},
{
name: "gitmem-cl",
description: "gitmem-cl (create_learning) - Create scar/win/pattern. Frame as 'what we now know' — factual discovery, not self-criticism.",
inputSchema: {
type: "object" as const,
properties: {
learning_type: {
type: "string",
enum: ["scar", "win", "pattern", "anti_pattern"],
description: "Type of learning",
},
title: {
type: "string",
description: "Learning title",
},
description: {
type: "string",
description: "Detailed description",
},
severity: {
type: "string",
enum: ["critical", "high", "medium", "low"],
description: "Severity level (required for scars)",
},
scar_type: {
type: "string",
enum: ["process", "incident", "context"],
description: "Scar type (process, incident, or context). Defaults to 'process'.",
},
counter_arguments: {
type: "array",
items: { type: "string" },
description: "Counter-arguments for scars (min 2 required)",
},
problem_context: {
type: "string",
description: "Problem context (for wins)",
},
solution_approach: {
type: "string",
description: "Solution approach (for wins)",
},
applies_when: {
type: "array",
items: { type: "string" },
description: "When this pattern applies",
},
domain: {
type: "array",