<div align="center">

<a href="https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link">
  <img src="assets/minimax-banner.png" alt="MiniMax Token Plan — Top 3.9% Usage" width="600" />
</a>

<br /><br />

**Built by a Top 3.9% MiniMax power user — 3.15B tokens consumed and counting.**

<br />

[![MiniMax Platform](https://img.shields.io/badge/MiniMax-Platform-FF4D4D?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJ3aGl0ZSI+PHBhdGggZD0iTTEyIDJMMyA3djEwbDkgNSA5LTV2LTEweiIvPjwvc3ZnPg==)](https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link)
[![Pi Package](https://img.shields.io/badge/pi--package-v0.4.0-blue?style=for-the-badge)](https://pi.dev/packages)
[![License: MIT](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)

[Get MiniMax Token Plan](https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link) · [Pi.dev Docs](https://pi.dev/docs/latest/extensions) · [Report Issue](https://github.com/adi805/pi-minimax-pack/issues)

</div>

---

# pi-minimax-pack

Generic Pi agent harness with policy gates, project detection, verification loop, drift protection, artifact validation, memory-to-rule promotion, and installed-resource advice.

The harness is intentionally generic. Project-specific behavior lives in `.pi/minimax-policy.json` and profiles, not in extension code.

## Why MiniMax?

This harness is designed and battle-tested with **MiniMax M2.7** — a model optimized for repo-scale engineering, agent workflows, and long skill adherence. The runtime enforcement features (forced sequencing, auto-correction, context pruning, decomposition) make even weaker models perform reliably under structured constraints.

> 🔗 **[Try MiniMax Platform →](https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link)** — 204K context, ~60 tps standard / ~100 tps highspeed

## Install

```bash
pi install git:https://github.com/adi805/pi-minimax-pack
```

After install, restart Pi. Works globally from any directory.

To refresh after upstream updates:

```bash
pi update git:github.com/adi805/pi-minimax-pack
```

## What it does (automatic, no slash commands needed)

| Feature | Trigger | Behavior |
|---------|---------|----------|
| **Contract injection** | Every turn | Injects solver loop, scope control, verification contract into system prompt |
| **Command gate** | Every bash call | Classifies risk (safe/build/test/install/destructive/deploy/database/network) and applies policy |
| **Read-before-write gate** | edit/write tool | Blocks overwriting existing files without reading first |
| **Forced read-back** | After every write | Auto-steers agent to read back written files |
| **Auto-correction loop** | Verification failure | Sends evidence + hint back to model (max 3 iterations) |
| **Context pruning** | Every LLM call | Collapses old tool results to 1-line summaries |
| **Decomposition** | Complex prompts | Forces step-by-step execution for multi-action requests |
| **Skill auto-routing** | Keyword detection | Injects relevant skill (incident/research/design/web/browser/multimodal) |
| **Status report** | Every response | Auto-appends changed/verified/unverified/blocked labels |
| **Auto-grind** | After code changes | Triggers verification commands (test/lint/build) automatically |
| **Drift detection** | Workstream change | Alerts when task switches without approval |
| **Artifact validation** | After BUILD success | Checks output dirs exist and are non-empty |

## Skills included

| Skill | Triggers on |
|-------|-------------|
| `minimax-incident-triage-harness` | error, crash, bug, failed |
| `minimax-deep-research` | research, investigate, compare, analyze |
| `minimax-anti-slop-design` | ui, design, landing page, layout |
| `minimax-multimodal-toolkit` | image, video, audio, tts, voice |
| `minimax-web-ops` | web search, url, docs, latest |
| `minimax-browser-ops` | browser, click, screenshot, inspect |
| `minimax-m2-self-evolution` | refactor, optimize, iterate, improve |
| `minimax-agentic-coding-guide` | ambiguous/large tasks |

## Prompt templates

| Command | Purpose |
|---------|---------|
| `/minimax-preflight` | Check project type + policy before changes |
| `/minimax-diagnose` | Diagnose failures with evidence-first approach |
| `/minimax-verify` | Run smallest relevant verification |
| `/minimax-risk-fix` | Apply minimal safe fix under policy constraints |
| `/minimax-policy-review` | Review current policy and gate behavior |
| `/minimax-promote-rule` | Turn correction into policy rule |

## Policy

Create `.pi/minimax-policy.json` in any project to customize behavior:

```json
{
  "version": 1,
  "commandPolicy": {
    "safeRead": "allow",
    "build": "preflight",
    "install": "require_reason",
    "destructive": "require_approval",
    "unknown": "ask"
  }
}
```

See [`docs/POLICY_SCHEMA.md`](docs/POLICY_SCHEMA.md) for full schema.

## Development

```bash
npm run smoke         # extension runtime smoke test
npm run test:policy   # policy loader
npm run test:project  # project detector
npm run test:command  # command risk classifier
npm run test:state    # task state machine
npm run test:artifact # artifact validator
npm run test:memory   # memory-to-rule
```

## Links

- 🔗 [MiniMax Platform](https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link) — Get your API key and Token Plan
- 📖 [Pi.dev Extensions Docs](https://pi.dev/docs/latest/extensions)
- 🧠 [MiniMax M2.7 Release Report](https://www.minimax.io/news/minimax-m27-en)
- 📦 [Pi Packages](https://pi.dev/packages)

---

<div align="center">

**Made with 🔥 by [adi805](https://github.com/adi805) — powered by [MiniMax](https://platform.minimax.io/subscribe/token-plan?code=1DFnA0fl4f&source=link)**

</div>
