Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Changelog

## v1.7.0 (2026-04-14)

### Memory System v2 (Claude Code inspired)
- **Memory categories**: project, user, feedback, reference — organized facts
- **Self-skeptical prompt**: "Treat memory as hints — verify against actual code"
- **Dream cleanup**: `memory.compact()` deduplicates, keeps newest
- **Auto-compact on start**: runs when >150 facts accumulated
- **Auto-categorized detection**: 15+ patterns auto-classify facts
- **Critical fix**: MemoryStore was never initialized — all memory features were dead

### System Prompt Hardening
- **All 30 tools described** (was 12/30) in 5 categories
- **Security section**: prompt injection detection, no untrusted execution
- **What NOT to Do**: 7 negative rules (no write for small edits, no guess, etc.)
- **Cost Awareness**: prefer cheap operations, edit over write
- **Section reorder**: important rules at end for max model attention

### Security & Quality CI
- **cargo-audit**: dependency vulnerability scanning on every PR
- **cargo-deny**: license compliance (allowlist), supply chain checks
- **dependency-review**: block PRs adding high-severity vulns or GPL deps
- **Strict clippy**: correctness + suspicious as errors
- **Dependabot alerts**: enabled

### New Features
- **Browser automation**: headless Playwright (navigate, screenshot, click, type, eval JS)
- **Debug mode**: hypothesis-driven structured debugging (4 phases)
- **GitHub integration**: `/gh prs`, `/gh issues`, `/gh status`, `/gh checks`
- **Agent profiles**: `/profile save/load/list`
- **Context pinning**: `/pin` — pinned messages survive compaction
- **Auto-skill creation**: auto-generate skills after complex tasks
- **Cross-session FTS search**: `/search-all` across all saved sessions
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The changelog states that /search-all searches across "all saved sessions," but the implementation in mc-core/src/fts.rs (line 41) limits the search to the 100 most recent sessions and stops after finding 20 results (line 93). This discrepancy should be clarified in the documentation or the implementation should be updated to match the description.

- **Configurable notifications**: `notifications` toggle + webhook (Slack/Discord)

### UX Improvements
- **Animated spinner** during streaming/tool execution
- **Bell notification** when agent finishes
- **Categorized /help** (Navigation, Session, Agent, Code, Tools, Workflow, Config)
- **Quit confirmation** for unsaved sessions
- **Ctrl+R** reverse history search

### Infrastructure
- **tree-sitter** AST symbol extraction (Rust, Python, JS/TS, Go)
- **arboard** cross-platform clipboard (replaces shell pbcopy/xclip)
- **GitHub templates**: bug report, feature request, PR template
- **SECURITY.md**: vulnerability reporting policy
- **274 tests**, 50% coverage, 0 warnings
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

A test coverage of 50% is relatively low for a release that emphasizes "Security & Quality CI" and "Strict clippy." Increasing test coverage would better align with the project's stated quality goals.


## v1.6.0 (2026-04-12)

### Managed Agents & Agentic AI
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ magic-code "fix the bug in auth.rs" # single-shot mode
### Multi-Provider
Works with **15 providers**: Anthropic, OpenAI, Gemini, Groq, DeepSeek, Mistral, xAI, OpenRouter, Together, Perplexity, Cohere, Cerebras, Ollama, LM Studio, llama.cpp. Switch mid-session with `/model`.

### 29 Built-in Tools
### 30 Built-in Tools
| Tool | Description |
|------|-------------|
| `bash` | Execute shell commands (streaming output) |
Expand Down
12 changes: 6 additions & 6 deletions mc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "1.6.0"
version = "1.7.0"
edition = "2021"
license = "MIT"
publish = false
Expand Down
66 changes: 66 additions & 0 deletions mc/docs/guides/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Getting Started

## Install

### Quick install (Linux/macOS)
```bash
curl -fsSL https://raw.githubusercontent.com/kienbui1995/mc-code/main/install.sh | sh
```

### Build from source
```bash
git clone https://github.com/kienbui1995/mc-code.git
cd mc-code/mc
cargo install --path crates/mc-cli
```

## Setup

Set your API key:
```bash
export ANTHROPIC_API_KEY="your-key"
# or: OPENAI_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, etc.
```

## First run

```bash
magic-code # interactive TUI
magic-code "fix the bug in auth.rs" # single-shot mode
echo "explain this" | magic-code --pipe # pipe mode
```

## Key concepts

- **Tools**: Agent has 30 built-in tools (bash, file ops, search, browser, debug, etc.)
- **Memory**: Persistent project facts across sessions (`/memory`)
- **Skills**: Reusable coding patterns (`.magic-code/skills/*.md`)
- **Agents**: Named agent configs (`agents/*.md`)
- **Sessions**: Save/load/branch conversations

## Essential commands

| Command | Description |
|---------|-------------|
| `/help` | Show all commands (categorized) |
| `/model` | Switch LLM model |
| `/plan` | Toggle plan mode (think before acting) |
| `/save` | Save current session |
| `/undo` | Undo last file changes |
| `/cost` | Show session cost |
| `/compact` | Compress context when running low |
| `/debug` | Enter structured debugging mode |
| `/gh` | GitHub integration |

## Configuration

Create `.magic-code/config.toml` in your project:
```toml
[default]
model = "claude-sonnet-4-20250514"
max_tokens = 8192
provider = "anthropic"
notifications = true
```

See [Configuration Reference](reference/config.md) for all options.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the relative link path to the config reference.

Line 66 currently links to reference/config.md, which is incorrect from mc/docs/guides/. Use ../reference/config.md to avoid a broken docs link.

Proposed fix
-See [Configuration Reference](reference/config.md) for all options.
+See [Configuration Reference](../reference/config.md) for all options.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
See [Configuration Reference](reference/config.md) for all options.
See [Configuration Reference](../reference/config.md) for all options.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mc/docs/guides/getting-started.md` at line 66, The relative link
"reference/config.md" in the getting-started document is incorrect; update the
link target used in the line 'See [Configuration Reference](reference/config.md)
for all options.' to use the correct relative path "../reference/config.md" so
the Configuration Reference resolves from mc/docs/guides/getting-started.md.

90 changes: 90 additions & 0 deletions mc/docs/guides/memory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Memory System

magic-code has a 3-layer memory system inspired by Claude Code's architecture.

## Layer 1: Semantic Memory (Project Facts)

Persistent key-value facts organized in 4 categories:

| Category | What it stores | Example |
|----------|---------------|---------|
| **project** | Architecture, tools, conventions | `test_cmd = "cargo test"` |
| **user** | Preferences, role, style | `coding_style = "prefer functional"` |
| **feedback** | Corrections from user | `"always use snake_case"` |
| **reference** | File locations, endpoints | `api_endpoint = "localhost:8080"` |

### Usage
```
/memory # list all facts
/memory get test_cmd # get specific fact
/memory set test_cmd "pytest" # save fact
/memory delete old_key # remove fact
```

Comment on lines +17 to +23
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add language identifiers to plain fenced code blocks.

Several fenced blocks (Lines 17, 51, 59, 72, 84) omit language tags, which will keep triggering lint warnings.

Suggested update pattern
-```
+```text
 /memory                     # list all facts
 ...

Apply similarly to the directory tree and command-list blocks.
</details>


Also applies to: 51-56, 59-66, 72-78, 84-88

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @mc/docs/guides/memory.md around lines 17 - 23, The fenced code blocks
showing CLI examples and directory trees (e.g., the block with "/memory",
"/memory get test_cmd", "/memory set test_cmd "pytest"", and "/memory delete
old_key" and the other blocks at lines referenced) are missing language
identifiers; update each fenced block to include an appropriate language tag
(use "text" or "bash" for shell/command examples and "text" for the directory
tree) so lint stops flagging them—apply this to the blocks around the shown
commands and the other blocks mentioned (lines 51–56, 59–66, 72–78, 84–88).


</details>

<!-- fingerprinting:phantom:triton:puma:06ee9ad6-cb94-4b18-bd94-909a13511a94 -->

<!-- This is an auto-generated comment by CodeRabbit -->

Agent can also use `memory_write` tool with category:
```json
{"key": "db", "value": "PostgreSQL 15", "category": "project"}
```

### Auto-memory
Agent automatically saves facts detected in its output:
- "project uses..." → project category
- "convention is..." → feedback category
- "running on port..." → reference category
- "user prefers..." → user category

### Self-skeptical
Memory is injected into the system prompt with a warning:
> *Treat as hints — verify against actual code before acting.*

This prevents hallucination from stale memory.

### Dream cleanup
When memory exceeds 150 facts, auto-compact runs on session start:
- Deduplicates by key (keeps newest)
- Removes stale entries

## Layer 2: Episodic Memory (Session History)

Past conversations saved as JSON files.

```
~/.local/share/magic-code/sessions/
├── last.json # auto-saved
├── my-feature.json # /save my-feature
└── debug-auth.json # /save debug-auth
```

### Commands
```
/save <name> # save session
/load <name> # resume session
/sessions # list saved sessions
/search-all <query> # FTS across all sessions
/fork # branch current session
/branches # list branches
```

## Layer 3: Procedural Memory (Skills)

Reusable coding patterns stored as markdown files.

```
.magic-code/skills/
├── setup-nextjs.md # user-created
├── deploy-aws.md # user-created
└── auto/
└── auto-3t-8-1713000000.md # auto-generated
```

### Auto-skill creation
After complex successful turns (≥6 tool calls, no errors), agent auto-generates a skill file. Next time it encounters a similar task, it loads the skill.

### Named agents
```
agents/
├── reviewer.md # code review specialist
└── architect.md # system design specialist
```

Each agent has its own model, tools, and instructions defined in YAML frontmatter.
68 changes: 68 additions & 0 deletions mc/docs/reference/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Configuration Reference

## Config file locations (priority order)
1. `.magic-code/config.toml` (project — highest)
2. `~/.config/magic-code/config.toml` (user)
3. Built-in defaults (lowest)

## All options

```toml
[default]
# LLM
model = "claude-sonnet-4-20250514"
max_tokens = 8192
provider = "anthropic"
base_url = "" # custom API endpoint
fallback_provider = "" # secondary provider
fallback_model = "" # secondary model

# Permissions
permission_mode = "auto" # auto | allow | deny | prompt

# Context
compaction_threshold = 0.8 # compact at 80% context usage
compaction_preserve_recent = 4 # keep last 4 messages

# Notifications
notifications = true # bell + desktop notifications
notification_webhook = "" # Slack/Discord webhook URL

Comment on lines +11 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

[default] section documents unsupported keys and wrong section placement.

Lines 16–30 include fields that are not loaded from [default] (base_url, fallback_provider, fallback_model, notifications, notification_webhook, compaction_*). This will mislead users because these settings won’t take effect as documented.

Proposed docs correction
 [default]
 # LLM
 model = "claude-sonnet-4-20250514"
 max_tokens = 8192
 provider = "anthropic"
-base_url = ""                    # custom API endpoint
-fallback_provider = ""           # secondary provider
-fallback_model = ""              # secondary model
 
 # Permissions
 permission_mode = "auto"         # auto | allow | deny | prompt
-
-# Context
-compaction_threshold = 0.8       # compact at 80% context usage
-compaction_preserve_recent = 4   # keep last 4 messages
-
-# Notifications
-notifications = true             # bell + desktop notifications
-notification_webhook = ""        # Slack/Discord webhook URL
+
+[compaction]
+auto_compact_threshold = 0.8
+preserve_recent_messages = 4

Also add a short note that fallback provider/model and notifications are runtime defaults unless explicitly supported by current config schema.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mc/docs/reference/config.md` around lines 11 - 30, The [default] example
documents unsupported keys and misplaces fields: remove or relocate the entries
base_url, fallback_provider, fallback_model, notifications,
notification_webhook, compaction_threshold, and compaction_preserve_recent from
the [default] block and place them in their correct sections or a “Runtime
defaults” section; update the [default] snippet to only show keys actually
loaded from [default] (e.g., model, max_tokens, provider, permission_mode) and
add a short note that fallback provider/model and notifications are runtime
defaults and only applied when the current config schema explicitly supports
them.

# Managed Agents
[managed_agents]
enabled = false
executor_model = "claude-haiku-3-5-20241022"
executor_max_turns = 5
max_concurrent = 3
budget_usd = 1.0
```

## Environment variables

| Variable | Description |
|----------|-------------|
| `ANTHROPIC_API_KEY` | Anthropic API key |
| `OPENAI_API_KEY` | OpenAI API key |
| `GEMINI_API_KEY` | Google Gemini API key |
| `GROQ_API_KEY` | Groq API key |
| `DEEPSEEK_API_KEY` | DeepSeek API key |
| `OPENROUTER_API_KEY` | OpenRouter API key |
| `XAI_API_KEY` | xAI (Grok) API key |

## CLI flags

```
--model <MODEL> LLM model
--provider <PROVIDER> Provider name
--max-tokens <N> Max tokens per response
--resume Resume last session
--session-id <ID> Resume specific session
--pipe Read from stdin
--json JSON output mode
--yes Auto-approve (CI/CD)
--trace Debug logging
--validate-config Validate and exit
--max-budget-usd <N> Cost limit
--max-turns <N> Turn limit
--add-dir <DIR> Grant access to extra directories
```
Comment on lines +54 to +68
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language identifier to the fenced CLI block.

Line 54 starts a fenced code block without language, which triggers markdown lint warnings.

Proposed fix
-```
+```text
 --model <MODEL>          LLM model
 --provider <PROVIDER>    Provider name
 ...
 --add-dir <DIR>          Grant access to extra directories
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion

🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 54-54: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mc/docs/reference/config.md` around lines 54 - 68, The fenced code block that
lists CLI flags (the triple-backtick block starting at the options list) lacks a
language identifier and triggers markdown-lint warnings; update that block to
use a language tag (e.g., add "text" after the opening triple backticks) so the
block becomes ```text ... ``` to silence the lint and preserve plain-text
formatting.

Loading
Loading