magi-code 0.96.1

Repository-aware CLI coding agent for terminal work
Documentation
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
use super::*;

pub(super) fn parse_value(kind: FieldType, text: &str) -> Result<Value, &'static str> {
    if kind == FieldType::Paths {
        return Ok(json!(
            text.split(';')
                .map(str::trim)
                .filter(|p| !p.is_empty())
                .collect::<Vec<_>>()
        ));
    }
    if text.trim().is_empty() && kind != FieldType::Probability {
        return Ok(Value::Null);
    }
    match kind {
        FieldType::Number => text
            .trim()
            .parse::<u64>()
            .map(|n| json!(n))
            .map_err(|_| "Enter a non-negative whole number, or leave blank for default."),
        FieldType::Probability => text
            .trim()
            .parse::<f64>()
            .ok()
            .filter(|value| (0.0..=1.0).contains(value))
            .map(|value| json!(value))
            .ok_or("Enter a number between 0 and 1."),
        _ => Ok(json!(text.trim())),
    }
}

pub(crate) fn value_text(value: &Value) -> String {
    match value {
        Value::Null => String::new(),
        Value::String(s) => s.clone(),
        Value::Array(items) => items
            .iter()
            .filter_map(Value::as_str)
            .collect::<Vec<_>>()
            .join("; "),
        _ => value.to_string(),
    }
}

pub(super) fn fields(s: &Settings) -> Vec<SettingsField> {
    use FieldType::*;
    let context = s.context.clone().unwrap_or_default();
    let image = &s.tools.view_image;
    let mut fields = Vec::new();
    macro_rules! field {
        ($tab:expr, $path:literal, $label:literal, $kind:expr, $value:expr, $help:literal $(, $heading:literal)?) => {{
            let value = json!($value);
            fields.push(SettingsField {
                path: $path,
                label: $label,
                help: $help,
                tab: $tab,
                section_heading: None $(.or(Some($heading)))?,
                kind: $kind,
                original: value.clone(),
                value,
            });
        }};
    }
    field!(
        0,
        "agent.compaction.auto.enabled",
        "Automatic compaction",
        Boolean,
        s.compaction.auto.enabled,
        "Summarize older turns automatically.",
        "Compaction"
    );
    field!(
        0,
        "agent.compaction.auto.threshold_percent",
        "Auto-compact threshold (%)",
        Number,
        s.compaction.auto.threshold_percent,
        "1–100; blank disables this threshold."
    );
    field!(
        0,
        "agent.compaction.auto.threshold_tokens",
        "Auto-compact threshold (tokens)",
        Number,
        s.compaction.auto.threshold_tokens,
        "Positive token count; blank disables this threshold."
    );
    field!(
        0,
        "agent.compaction.auto.max_compactions_per_run",
        "Subagent auto compact limit",
        Number,
        s.compaction.auto.max_compactions_per_run,
        "Automatic compactions per run (including subagents). 0 removes the count cap; blank uses default 4."
    );
    field!(
        1,
        "agent.compaction.provider",
        "Compaction provider",
        Hidden,
        s.compaction.provider,
        ""
    );
    field!(
        1,
        "agent.compaction.model",
        "Compaction model",
        Model,
        s.compaction.model,
        "Choose an enabled model, or use the active conversation model. Required from another provider when Claude subscription compaction is off.",
        "Compaction"
    );
    field!(
        1,
        "agent.compaction.claude_subscription.allow_compaction",
        "Allow Claude compaction",
        Boolean,
        s.compaction.claude_subscription.allow_compaction,
        "Allow claude-subscription models to compact. Off requires a Compaction model from another provider.",
        "Claude subscription (202,000-token ceiling)"
    );
    field!(
        1,
        "agent.compaction.claude_subscription.reserve_tokens",
        "Compaction reserve (tokens)",
        Number,
        s.compaction.claude_subscription.reserve_tokens,
        "1–201999; default 16384. Subtracted from 202000 when the compaction provider is claude-subscription."
    );
    field!(
        1,
        "agent.compaction.claude_subscription.threshold_percent",
        "Claude compact threshold (%)",
        Number,
        s.compaction.claude_subscription.threshold_percent,
        "1–100; default 100% of the reduced context limit. Blank disables this trigger; automatic compaction stays enabled."
    );
    field!(
        1,
        "agent.compaction.claude_subscription.threshold_tokens",
        "Claude compact threshold (tokens)",
        Number,
        s.compaction.claude_subscription.threshold_tokens,
        "Default 202000; capped at the reduced context limit. First token or percent threshold reached wins."
    );
    field!(
        0,
        "agent.context.enabled",
        "Fallback context budget",
        Boolean,
        context.enabled,
        "Enable fallback context trimming.",
        "Fallback context"
    );
    field!(
        0,
        "agent.context.max_tokens",
        "Context token limit",
        Number,
        context.max_tokens,
        "Fallback context capacity in tokens."
    );
    field!(
        0,
        "agent.context.reserve_tokens",
        "Reserved output tokens",
        Number,
        context.reserve_tokens,
        "Tokens reserved for output."
    );
    field!(
        0,
        "agent.context.keep_recent_tokens",
        "Keep recent tokens",
        Number,
        context.keep_recent_tokens,
        "Recent conversation tokens to retain."
    );
    field!(
        1,
        "agent.subagents.execution.absolute_paths",
        "Allow outside-project paths",
        Boolean,
        s.tools.subagents.absolute_paths,
        "Allow subagents to access paths outside the project.",
        "Subagents"
    );
    field!(
        1,
        "agent.subagents.execution.max_depth",
        "Maximum nesting depth",
        Number,
        s.tools.subagents.max_depth,
        "Maximum nested subagent depth; validated on save."
    );
    field!(
        1,
        "agent.side.model",
        "Side model",
        Model,
        s.side.model,
        "Choose an enabled model, or inherit the primary provider/model when a side session starts.",
        "Side agent"
    );
    field!(
        1,
        "agent.side.provider",
        "Side provider",
        Hidden,
        s.side.provider,
        ""
    );
    field!(
        1,
        "agent.summarizer.auto_start",
        "Start summarizer automatically",
        Boolean,
        s.summarizer.auto_start,
        "Start session summaries automatically.",
        "Summary agent"
    );
    field!(
        1,
        "agent.summarizer.model",
        "Summary model",
        Model,
        s.summarizer.model,
        "Choose an enabled model, or use the active conversation model."
    );
    field!(
        1,
        "agent.summarizer.provider",
        "Summary provider",
        Hidden,
        s.summarizer.provider,
        ""
    );
    field!(
        1,
        "agent.summarizer.reasoning",
        "Summary reasoning",
        Choice(REASONING_CHOICES),
        s.summarizer.reasoning,
        "default, low, medium, high, x_high, max; blank uses default."
    );
    field!(
        1,
        "sessions.titles.enabled",
        "Generate session titles",
        Boolean,
        s.session_titles.enabled,
        "Automatically name sessions.",
        "Session titles"
    );
    field!(
        1,
        "sessions.titles.model",
        "Title model",
        Model,
        s.session_titles.model,
        "Choose an enabled model. Clear only when session titles are disabled."
    );
    field!(
        1,
        "sessions.titles.provider",
        "Title provider",
        Hidden,
        s.session_titles.provider,
        ""
    );
    field!(
        4,
        "internal_tooling.jev.enabled",
        "Enable Jev tooling",
        Boolean,
        s.jev.enabled,
        "Enable TypeSafe Jev features. Requires TYPESAFE_API_KEY after restart.",
        "Jev"
    );
    field!(
        4,
        "internal_tooling.jev.show_debug_messages",
        "  Show Jev debug messages",
        Boolean,
        s.jev.show_debug_messages,
        "Show successful Jev diagnostics. Warnings remain visible when disabled."
    );
    field!(
        4,
        "internal_tooling.jev.bash_protection.enabled",
        "  Enable Bash protection",
        Boolean,
        s.jev.bash_protection.enabled,
        "Used only when Jev tooling is enabled. Score bash commands before execution and request approval for risky commands.",
        "  Bash protection"
    );
    field!(
        4,
        "internal_tooling.jev.bash_protection.protection_level",
        "  Protection level",
        Choice(PROTECTION_LEVEL_CHOICES),
        s.jev.bash_protection.protection_level,
        "Used only when Jev tooling is enabled. permissive, relaxed, balanced, cautious, or strict."
    );
    field!(
        4,
        "internal_tooling.jev.bash_protection.failure_policy",
        "  API failure policy",
        Choice(FAILURE_POLICY_CHOICES),
        s.jev.bash_protection.failure_policy,
        "Used only when Jev tooling is enabled. auto_approve or auto_deny; defaults to auto_approve."
    );
    field!(
        4,
        "internal_tooling.jev.bash_file_tracking.enabled",
        "  Track Bash file activity",
        Boolean,
        s.jev.bash_file_tracking.enabled,
        "Infer reads, writes, and edits for Session files. Sends bounded, redacted commands to TypeSafe; guesses never grant edit permissions. Requires restart.",
        "  Bash file tracking"
    );
    field!(
        4,
        "internal_tooling.jev.humanize_protection.enabled",
        "  Enable prose protection",
        Boolean,
        s.jev.humanize_protection.enabled,
        "Used only when Jev tooling is enabled. Check comments and documentation before write and hash_edit calls.",
        "  Prose protection"
    );
    field!(
        4,
        "internal_tooling.jev.humanize_protection.content_threshold",
        "  Prose detection threshold",
        Number,
        s.jev.humanize_protection.content_threshold,
        "Used only when Jev tooling is enabled. Probability from 0 to 1 required to treat a change as comments or documentation."
    );
    field!(
        4,
        "internal_tooling.jev.humanize_protection.humanized_threshold",
        "  Humanized threshold",
        Number,
        s.jev.humanize_protection.humanized_threshold,
        "Used only when Jev tooling is enabled. Probability from 0 to 1 required to allow comments or documentation."
    );
    field!(
        4,
        "internal_tooling.jev.humanize_protection.failure_policy",
        "  API failure policy",
        Choice(FAILURE_POLICY_CHOICES),
        s.jev.humanize_protection.failure_policy,
        "Used only when Jev tooling is enabled. auto_approve or auto_deny; defaults to auto_deny."
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.enabled",
        "  Assess tool output",
        Boolean,
        s.jev.prompt_injection_protection.enabled,
        "Assess untrusted tool output for prompt injection. Defaults to observe-only.",
        "  Prompt injection protection"
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.enforcement_enabled",
        "  Enforce decisions",
        Boolean,
        s.jev.prompt_injection_protection.enforcement_enabled,
        "Annotate or withhold risky output from provider context. Leave disabled to observe only."
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.protection_level",
        "  Protection level",
        Choice(PROTECTION_LEVEL_CHOICES),
        s.jev.prompt_injection_protection.protection_level,
        "Choose permissive, relaxed, balanced, cautious, or strict. Balanced is the default."
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.max_assessed_bytes",
        "  Maximum assessed bytes",
        Number,
        s.jev.prompt_injection_protection.max_assessed_bytes,
        "Bound sent to Jev; truncation appears in diagnostics."
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.failure_policy",
        "  API failure policy",
        Choice(PROMPT_INJECTION_FAILURE_POLICY_CHOICES),
        s.jev.prompt_injection_protection.failure_policy,
        "annotate or quarantine; defaults to quarantine."
    );
    field!(
        4,
        "internal_tooling.jev.prompt_injection_protection.tools",
        "  Protected tools",
        MultiChoice(PROMPT_INJECTION_TOOL_CHOICES),
        s.jev.prompt_injection_protection.tools,
        "Select tool outputs assessed for prompt injection. Defaults to web."
    );

    field!(
        4,
        "internal_tooling.jev.completion_verification.enabled",
        "  Verify completions",
        Boolean,
        s.jev.completion_verification.enabled,
        "Assess terminal assistant responses with bounded Jev judgments. Defaults to observe-only.",
        "  Completion verification"
    );
    field!(
        4,
        "internal_tooling.jev.completion_verification.enforcement_enabled",
        "  Enforce completion decisions",
        Boolean,
        s.jev.completion_verification.enforcement_enabled,
        "Allow one bounded corrective continuation or disclose limitations."
    );
    field!(
        4,
        "internal_tooling.jev.completion_verification.threshold",
        "  Completion threshold",
        Probability,
        s.jev.completion_verification.threshold,
        "Probability threshold from 0 to 1 for completion dimensions."
    );
    field!(
        4,
        "internal_tooling.jev.completion_verification.max_state_bytes",
        "  Maximum evidence bytes",
        Number,
        s.jev.completion_verification.max_state_bytes,
        "Maximum bounded evidence sent to Jev."
    );
    field!(
        4,
        "internal_tooling.jev.completion_verification.max_continuations",
        "  Maximum continuations",
        Number,
        s.jev.completion_verification.max_continuations,
        "Maximum verifier-triggered continuations per user turn."
    );
    field!(
        4,
        "internal_tooling.jev.completion_verification.failure_policy",
        "  Verifier failure policy",
        Choice(COMPLETION_VERIFICATION_FAILURE_POLICY_CHOICES),
        s.jev.completion_verification.failure_policy,
        "accept_with_warning or reject_with_warning."
    );

    field!(
        4,
        "internal_tooling.jev.skill_suggestion.enabled",
        "  Suggest skills",
        Boolean,
        s.jev.skill_suggestion.enabled,
        "Used only when Jev tooling is enabled. Before each typed prompt, Jev ranks skills and adds one hint naming the best fit. Off sends requests unchanged.",
        "  Skill suggestion"
    );
    field!(
        4,
        "internal_tooling.jev.skill_suggestion.gate_threshold",
        "  Skill need threshold",
        Number,
        s.jev.skill_suggestion.gate_threshold,
        "Probability from 0 to 1 that a prompt needs any skill before candidates are checked."
    );
    field!(
        4,
        "internal_tooling.jev.skill_suggestion.fit_threshold",
        "  Skill fit threshold",
        Number,
        s.jev.skill_suggestion.fit_threshold,
        "Probability from 0 to 1 that the best candidate fits before it is suggested."
    );

    field!(
        4,
        "internal_tooling.jev.compaction_timing.enabled",
        "  Compact at task boundaries",
        Boolean,
        s.jev.compaction_timing.enabled,
        "Used only when Jev tooling and auto-compaction are enabled. Between the soft threshold and the auto-compaction threshold, compact early when Jev judges the new prompt starts unrelated work. Off keeps current timing.",
        "  Compaction timing"
    );
    field!(
        4,
        "internal_tooling.jev.compaction_timing.soft_threshold_percent",
        "  Soft threshold percent",
        Number,
        s.jev.compaction_timing.soft_threshold_percent,
        "Context percentage from 1 to 99 where early compaction checks begin."
    );
    field!(
        4,
        "internal_tooling.jev.compaction_timing.threshold",
        "  Task boundary threshold",
        Number,
        s.jev.compaction_timing.threshold,
        "Probability from 0 to 1 required to compact early."
    );

    field!(
        4,
        "internal_tooling.jev.reset_cache",
        "Reset Jev cache",
        Action,
        "Reset",
        "Delete all cached Jev responses. New requests will call TypeSafe again."
    );

    field!(
        5,
        "automation.integrations.herdr.enabled",
        "Herdr integration",
        Boolean,
        s.integrations.herdr.enabled,
        "Enable Herdr integration after restart.",
        "Integrations"
    );
    field!(
        3,
        "capabilities.tools.manage",
        "Enable/disable tools",
        Action,
        "Open",
        "Choose which built-in, Code Mode, and MCP tools are available.",
        "Tool availability"
    );
    field!(
        3,
        "capabilities.tools.view_image.absolute_paths",
        "Images outside project",
        Boolean,
        image.absolute_paths,
        "Allow image reads outside the project.",
        "View image"
    );
    field!(
        3,
        "capabilities.tools.view_image.max_image_bytes",
        "Maximum image bytes",
        Number,
        image.max_image_bytes,
        "Positive byte limit; validated on save."
    );
    field!(
        3,
        "capabilities.tools.view_image.vision_model.provider",
        "Image provider",
        Hidden,
        image.vision_model.as_ref().map(|m| &m.provider),
        ""
    );
    field!(
        3,
        "capabilities.tools.view_image.vision_model.model",
        "Image model",
        Model,
        image.vision_model.as_ref().map(|m| &m.model),
        "Choose an enabled model, or clear the image model override."
    );
    field!(
        3,
        "capabilities.tools.code_mode.compact_direct_tools",
        "Compact direct tools",
        Boolean,
        s.tools.code_mode.compact_direct_tools,
        "Hide inventory and MCP tools from direct calls; requires Code Mode.",
        "Code Mode"
    );
    field!(
        3,
        "capabilities.tools.code_mode.nudges_enabled",
        "Suggest mechanical batches",
        Boolean,
        s.tools.code_mode.nudges_enabled,
        "At most one advisory hint per turn; never forces batching."
    );
    field!(
        3,
        "capabilities.tools.code_mode.manage",
        "Manage Code Mode tools",
        Action,
        Value::Null,
        "Choose tools available inside Code Mode, independently of direct tools."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_source_bytes",
        "Maximum source bytes",
        Number,
        s.tools.code_mode.limits.max_source_bytes,
        "1 to 1048576 UTF-8 bytes of JavaScript source."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_inner_calls",
        "Maximum inner calls",
        Number,
        s.tools.code_mode.limits.max_inner_calls,
        "1 to 1000 synchronous calls per batch."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_runtime_ms",
        "JavaScript time budget (milliseconds)",
        Number,
        s.tools.code_mode.limits.max_runtime_ms,
        "1 to 3600000 milliseconds; excludes host-tool wait time."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_memory_bytes",
        "Sandbox memory bytes",
        Number,
        s.tools.code_mode.limits.max_memory_bytes,
        "1048576 to 268435456 bytes; exhausting memory terminates the batch."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_inner_result_bytes",
        "Maximum SDK response bytes",
        Number,
        s.tools.code_mode.limits.max_inner_result_bytes,
        "1 to 16777216 bytes, including discovery responses."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_total_result_bytes",
        "Aggregate SDK response bytes",
        Number,
        s.tools.code_mode.limits.max_total_result_bytes,
        "1 to 67108864 bytes per batch, including discovery."
    );
    field!(
        3,
        "capabilities.tools.code_mode.limits.max_return_bytes",
        "Maximum returned bytes",
        Number,
        s.tools.code_mode.limits.max_return_bytes,
        "1 to 4194304 JSON bytes; host warnings remain separate."
    );
    field!(
        5,
        "interface.tui.subagent_card_rows",
        "Subagent card rows",
        Number,
        s.tui.subagent_card_rows,
        "1–50 rows; blank uses default.",
        "Appearance"
    );
    field!(
        5,
        "interface.tui.autocomplete.respects_gitignore",
        "Autocomplete respects gitignore",
        Boolean,
        s.file_autocomplete_respects_gitignore,
        "Hide ignored files from file completion."
    );
    field!(
        0,
        "knowledge.skills.additional_paths",
        "Additional skill directories",
        Paths,
        s.skills.additional_paths,
        "Separate paths with semicolons; blank clears the list.",
        "Skill directories"
    );
    field!(
        1,
        "providers.streaming.semantic_progress_timeout_seconds",
        "Main stream timeout (seconds)",
        Number,
        s.provider_stream.semantic_progress_timeout_seconds,
        "Seconds without semantic progress; blank uses default.",
        "Streaming"
    );
    field!(
        1,
        "providers.streaming.subagent_semantic_progress_timeout_seconds",
        "Subagent stream timeout (seconds)",
        Number,
        s.provider_stream.subagent_semantic_progress_timeout_seconds,
        "Seconds without semantic progress; blank uses default."
    );
    field!(
        3,
        "capabilities.tools.magi_control.compact",
        "Allow agent-requested compaction",
        Boolean,
        s.tools.magi_control.compact,
        "Allow compact through magi_control. Context usage remains available; disable the whole tool through tool availability.",
        "Magi control"
    );
    fields
}