Skip to content

Latest commit

Β 

History

522 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SFFMC

SFFMC

OpenCode plugins ported from Xiaomi MiMo-Code β€” drop in, no fork required

πŸš€ Quick start Β· πŸ“– Docs Β· πŸ’¬ Changelog Β· 🀝 Contributing

GitHub release npm Bun Tests License: MIT Stars

πŸ‡¬πŸ‡§ English Β· πŸ‡·πŸ‡Ί Русский


⚑ TL;DR

# 1. Install all five packages
npm install -g @sffmc/runtime @sffmc/cognition @sffmc/memory @sffmc/safety @sffmc/utilities

# 2. Add to ~/.config/opencode/opencode.json
# 3. Restart OpenCode
# 4. Verify

That's it. No fork, no patches, no rebuild.


πŸ€” Why SFFMC?

Vanilla OpenCode OpenCode + SFFMC
Manual workflow scripts βš™οΈ 7 built-in workflows (`deep-research`, `security-audit`, `refactor`, `plan`, `tdd`, `doc-gen`, `lib-migrate`)
Forgotten context between sessions πŸ’Ύ FTS5 memory + dream consolidation
Dangerous tool calls slip through πŸ›‘οΈ 5-layer safety gate + auto-max escalation
One answer per question 🧠 Max-mode with LLM-as-judge, picks the best of N candidates
No health visibility πŸ”¬ 13 monorepo diagnostics

The name is a small wink at the upstream project: Some Feature from Mimo Code.


✨ What's in the box?

βš™οΈ Workflow engine

Sandboxed JS scripts with budget caps, resume, and child workflows. Write your own or copy one of the 7 built-ins.

πŸ›‘οΈ Safety gates

Catch destructive operations before they hit the disk. Auto-recover from tool failures. Auto-escalate to max-mode when the model is stuck.

πŸ’Ύ Cross-session memory

FTS5 search, checkpoint journaling, dream consolidation. Your context survives between chats β€” the model remembers yesterday's decisions.

🧠 Max-mode reasoning

Generate N parallel candidates, pick the best with an LLM-as-judge. Higher quality answers without paying for retries.

πŸ“– See the full feature list β†’


πŸ“¦ The 5 packages

Package Role Type Version
@sffmc/runtime Sandboxed JS workflow orchestrator + 7 built-in workflows Standalone plugin npm
@sffmc/cognition Max-mode reasoning, compose skills, health diagnostics Standalone plugin npm
@sffmc/memory Cross-session memory, judge, dream, checkpoint Composite plugin npm
@sffmc/safety Watchdog, safety gates, auto-max Composite plugin npm
@sffmc/utilities Shared SDK β€” config, event-bus, hooks, paths Library (no plugin slot) npm

Composite plugins can read state from other SFFMC plugins but only write to their own slot. utilities is consumed by the other four and never appears in your plugin array.


πŸš€ Quick start

Pick the install path that fits you best:

Option A β€” npm (simplest)

npm install -g @sffmc/runtime @sffmc/cognition @sffmc/memory @sffmc/safety @sffmc/utilities

Then add the four plugins to ~/.config/opencode/opencode.json (the order matters β€” composites first):

{
  "plugin": [
    "@sffmc/safety",    // composite: catches destructive ops
    "@sffmc/memory",    // composite: loads past context
    "@sffmc/runtime",   // standalone: workflow engine
    "@sffmc/cognition"  // standalone: max-mode reasoning
  ]
}

Restart OpenCode. Verify the install:

/sffmc_health

You should see 13 diagnostics run in the terminal. βœ…

Option B β€” one-liner (clones repo + auto-configures)

# macOS / Linux (requires SSH key on GitHub)
curl -fsSL https://raw.githubusercontent.com/Rahspide/sffmc/main/install.sh | sh

# Windows PowerShell
irm https://raw.githubusercontent.com/Rahspide/sffmc/main/install.ps1 | iex

The script clones the repo, runs sffmc init, and edits opencode.json for you. Override the target branch with SFFMC_VERSION=v0.16.3.

Option C β€” from source

git clone https://github.com/Rahspide/sffmc.git ~/.sffmc/plugins/sffmc
cd ~/.sffmc/plugins/sffmc
./install.sh

πŸ“– Full install guide (version pinning, troubleshooting, platform notes): docs/install.md β†’


πŸ”§ CLI reference

Every install ships a sffmc binary:

Command What it does
sffmc init Re-sync opencode.json with the 4 plugins
sffmc init --all Install all 5 packages (including utilities library)
sffmc init --yes Skip the confirmation prompt
sffmc update git pull + re-run init
sffmc doctor Run the 9-check diagnostic
sffmc uninstall Remove all SFFMC entries from opencode.json

πŸ’‘ Run sffmc doctor after any OpenCode upgrade β€” it catches plugin loading order issues, missing dependencies, and config drift.


πŸ—οΈ Architecture

SFFMC follows a composite pattern:

  • Each plugin reads freely from other plugins' state.
  • Each plugin writes only to its own slot β€” no shared mutable state.
  • Hot-pluggable β€” add or remove a package without touching the others.

SFFMC plugin architecture

Hook categories (dispatched by mergeHooks from @sffmc/utilities):

Category Semantics Hook keys
TRANSFORM Chain (first β†’ last) experimental.chat.messages.transform, experimental.chat.system.transform, experimental.text.complete
GATE First-truthy-wins tool.execute.before, tool.execute.after, permission.ask, command.execute.before
SIDE_EFFECT All run, return discarded config, event, experimental.session.start, experimental.session.end
tool Later-wins with warn registered tool definitions

πŸ“– Full SDK reference: CONTRIBUTING.md β†’


🎬 Demo: safety gate catches rm -rf

SFFMC safety gate intercepts a destructive rm -rf command

Real SFFMC session β€” @sffmc/safety immediately denies rm -rf / (the Error: [Rules] DENIED: ... line is the verbatim output from packages/safety/src/rules/index.ts). For a less-dangerous rm -rf /tmp/build it asks (logs a WARN, then OpenCode shows its built-in permission dialog where the user clicks Deny).


πŸ§ͺ Quality gates

Every commit runs a 6-step gate chain. The precommit script runs the same gates locally:

# Gate What it checks
1 🚿 Cleanroom Banned identifiers, external URLs, workflow-term regex
2 ⚑ ReDoS audit safe-regex over the redaction-rules catalogue
3 πŸ”— Load-order audit AST-based hook-conflict detection
4 πŸ§ͺ Test suite 1946 tests across 109 files
5 πŸ’š Health summary 13 monorepo diagnostics
6 πŸ“ Typecheck bun build --no-bundle
bun run precommit   # runs gates 1–6 locally before push

bun.lock is regenerated on every version bump to keep workspace pins in sync with manifests.


πŸ“š Documentation

Doc What's inside
πŸ“₯ Getting started Install, first workflow, debugging
βš™οΈ Dynamic workflow Sandbox internals, budgets, error model
πŸ§ͺ Workflow examples 5 copy-paste workflows
πŸ“₯ Install guide Manual install, platform notes
πŸš€ Drone CI CI pipeline reference
✨ MiMo features What's ported, what's not

🀝 Contributing

  1. Fork the repo.
  2. Branch with a descriptive name: feature/<slug> or fix/<slug>.
  3. Code with tests β€” coverage matters. New hook category? Add a regression test and re-run bun run audit:load-order.
  4. Run the local gate: bun run precommit.
  5. Push and open a PR β€” CI runs the same 7 gates.

See CONTRIBUTING.md for the plugin SDK reference, hook categories, and architectural decisions.

Local dev workflow β€” clone the repo, then add file:// entries to your opencode.json pointing at your working copy:

{
  "plugin": [
    "file:///path/to/sffmc/packages/safety",
    "file:///path/to/sffmc/packages/memory",
    "file:///path/to/sffmc/packages/runtime",
    "file:///path/to/sffmc/packages/cognition"
  ]
}

Your edits hot-reload β€” no need to re-run the installer.


πŸ“ License

MIT β€” see the file for full text. Some functionality is adapted from Xiaomi MiMo-Code under the upstream license.


Built with 🧑 by @Rahspide · Powered by Bun · Inspired by Xiaomi MiMo-Code

About

OpenCode plugins ported from MiMo-Code. 5 packages: runtime, cognition, memory, safety, utilities. MIT, Bun-powered.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages