@shigar/muaz 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,635 @@
1
1
  # muaz
2
2
 
3
- **Coming soon.**
3
+ A terminal-first LLM agent platform. Chat with AI agents, run multi-agent pipelines, and install plugins — all from a single binary. Agents are model-agnostic and bind to a model through named provider profiles (OpenAI-compatible, Google Gemini, local Ollama, or AWS Bedrock).
4
4
 
5
- This npm package reserves the `@shigar/muaz` name. The official SDK is not published yet.
5
+ ## Installation
6
+
7
+ **macOS / Linux**
8
+ ```bash
9
+ curl --proto '=https' --tlsv1.2 -LsSf \
10
+ https://github.com/shigar-dev/releases-muaz/releases/latest/download/muaz-installer.sh | sh
11
+ ```
12
+
13
+ **macOS (Homebrew)**
14
+ ```bash
15
+ brew tap shigar-dev/muaz
16
+ brew install muaz
17
+ ```
18
+
19
+ **Windows (PowerShell)**
20
+ ```powershell
21
+ irm https://github.com/shigar-dev/releases-muaz/releases/latest/download/muaz-installer.ps1 | iex
22
+ ```
23
+
24
+ **Windows (MSI)**
25
+
26
+ Download `muaz-x86_64-pc-windows-msvc.msi` from the
27
+ [releases page](https://github.com/shigar-dev/releases-muaz/releases) and run
28
+ the installer.
29
+
30
+ **npm (any platform)**
31
+ ```bash
32
+ npm install -g @shigar/muaz
33
+ ```
34
+
35
+ **From source**
36
+ ```bash
37
+ git clone https://github.com/shigar-dev/muaz
38
+ cd muaz
39
+ cargo build --release -p muaz
40
+ cp target/release/muaz ~/.local/bin/ # or anywhere on $PATH
41
+ ```
42
+
43
+ On first run, `muaz` bootstraps `~/.muaz/` with sensible defaults.
44
+
45
+ ## Quick start
46
+
47
+ ```bash
48
+ export OPENAI_API_KEY=sk-...
49
+
50
+ muaz chat # open the default (starter) agent
51
+ muaz chat --agent coding # open the auto-sde coding agent
52
+ muaz chat --incognito # don't save the session to disk
53
+ muaz chat --session <id> # resume a previous session
54
+ ```
55
+
56
+ The REPL opens immediately. Type your message and press Enter. Use `/help` to see all slash commands.
57
+
58
+ ## Directory layout
59
+
60
+ After the first run, `~/.muaz/` looks like this. Authored content lives inside
61
+ plugins — your own in the `local` workspace, shared ones under `plugins/`, and
62
+ read-only defaults under `builtins/`:
63
+
64
+ ```
65
+ ~/.muaz/
66
+ ├── config.yaml # global settings (default agent + provider, approval, telemetry)
67
+ ├── providers.yaml # named provider profiles (model connections)
68
+ ├── plugins.yaml # per-plugin state (enabled / priority / trusted / source)
69
+ ├── mcp.json # global MCP server registry
70
+ ├── builtins/
71
+ │ └── default/ # embedded read-only `default` agent (refreshed each start)
72
+ ├── plugins/
73
+ │ ├── local/ # YOUR workspace
74
+ │ │ ├── agents/ # agents you create
75
+ │ │ ├── skills/ # each skill is a dir with a SKILL.md
76
+ │ │ ├── pipelines/ # multi-agent pipeline definitions
77
+ │ │ ├── prompts/
78
+ │ │ └── commands/ # custom slash commands
79
+ │ ├── coding/ # seeded example plugin (editable)
80
+ │ └── <installed>/ # plugins you install
81
+ ├── sessions/ # saved sessions + index.json
82
+ ├── runtimes/ # on-demand Node.js / uv runtimes for MCP servers
83
+ └── memory/ # reserved for future memory backends
84
+ ```
85
+
86
+ ## Configuration
87
+
88
+ ### Global config (`~/.muaz/config.yaml`)
89
+
90
+ ```yaml
91
+ # The agent used when no --agent flag is passed
92
+ default_agent: starter
93
+
94
+ # Provider/model selection. default_provider names a profile from providers.yaml;
95
+ # agent_providers overrides specific agents. See "Providers" below.
96
+ default_provider: gemini-main
97
+ agent_providers:
98
+ coding:
99
+ profile: bedrock-work
100
+
101
+ # Override the remote plugin registry index (else $MUAZ_PLUGIN_REGISTRY, else default)
102
+ # plugin_registry: "https://example.com/muaz-plugins/index.json"
103
+
104
+ # Global tool approval policy (per-agent settings override these)
105
+ tool_approval:
106
+ auto_approve:
107
+ - "fetch_webpage:*" # always approve without prompting
108
+ auto_deny:
109
+ - "shell:rm -rf *" # always deny without prompting
110
+ prompt:
111
+ - "shell:*" # ask the user every time
112
+ - "edit_file:*"
113
+ - "patch_file:*"
114
+ ```
115
+
116
+ ### Provider profiles (`~/.muaz/providers.yaml`)
117
+
118
+ Agents are model-agnostic. Define named provider profiles once and bind them via
119
+ `default_provider` / `agent_providers` above:
120
+
121
+ ```yaml
122
+ gemini-main:
123
+ type: gemini
124
+ model: gemini-2.5-pro
125
+ api_key: ${GEMINI_API_KEY}
126
+
127
+ bedrock-work:
128
+ type: bedrock
129
+ region: us-east-1
130
+ model: anthropic.claude-3-5-sonnet-20241022-v2:0
131
+ profile: work
132
+ ```
133
+
134
+ Effective provider for an agent resolves as: per-agent override → `default_provider`
135
+ → the agent's own inline `provider:` block → error.
136
+
137
+ ### MCP registry (`~/.muaz/mcp.json`)
138
+
139
+ MCP server definitions live in their own JSON file. Use `muaz mcp install` to manage entries, or edit it directly:
140
+
141
+ ```json
142
+ [
143
+ {
144
+ "transport": "stdio",
145
+ "name": "filesystem",
146
+ "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
147
+ },
148
+ {
149
+ "transport": "http",
150
+ "name": "my-api",
151
+ "url": "http://localhost:3000/mcp"
152
+ }
153
+ ]
154
+ ```
155
+
156
+ ### Agent config (`~/.muaz/plugins/local/agents/<name>.yaml`)
157
+
158
+ ```yaml
159
+ name: coding
160
+ description: "An expert coding assistant"
161
+
162
+ # Provider is OPTIONAL — omit it to stay model-agnostic and use the global
163
+ # default profile. Include it only to pin a model for this agent:
164
+ # provider:
165
+ # type: openai-compatible
166
+ # model: gpt-4o
167
+ # api_key: "${OPENAI_API_KEY}" # ${ENV_VAR} interpolation supported
168
+
169
+ # system_prompt: path (~/…, /…, ./…, ../…) OR inline text. Co-locate and use a
170
+ # relative path so the agent is portable across namespaces.
171
+ system_prompt: "./coding.md"
172
+
173
+ # Optional: path to a markdown SOP file appended after system_prompt
174
+ sop_file: "./coding-sop.md"
175
+
176
+ streaming: true # stream tokens as they arrive (default: true)
177
+
178
+ # Agentic loop limits (null = use built-in default)
179
+ max_iterations: 20 # tool-call rounds before giving up
180
+ max_concurrent_tools: 4 # parallel tool executions per round
181
+
182
+ # LLM inference parameters (null = use model default)
183
+ max_tokens: ~
184
+ temperature: ~
185
+
186
+ # Compact conversation history when accumulated input tokens exceed this threshold.
187
+ # null disables compaction.
188
+ compaction_token_threshold: 80000
189
+
190
+ # Custom compaction summarization instructions (null = use built-in default)
191
+ compaction_summary_prompt: ~
192
+
193
+ # Agent Skills configuration
194
+ # skills:
195
+ # paths: [] # extra search paths
196
+ # allow: [] # allowlist by name
197
+ # deny: [] # denylist by name
198
+
199
+ # Restrict to a subset of built-in tools
200
+ built_in_tools:
201
+ include_tools:
202
+ - edit_file
203
+ - shell
204
+ - fetch_webpage
205
+
206
+ # MCP server filter for this agent
207
+ mcp_servers:
208
+ - name: filesystem
209
+
210
+ # Per-agent tool approval (evaluated before global policy)
211
+ tool_approval:
212
+ auto_approve:
213
+ - "fetch_webpage:*"
214
+ - "shell:git *"
215
+ - "shell:cargo *"
216
+ prompt:
217
+ - "shell:*"
218
+ - "edit_file:*"
219
+ auto_deny:
220
+ - "shell:rm *"
221
+ ```
222
+
223
+ **Approval pattern format:** `"tool_name:glob"` where the glob is matched against the JSON-serialised args. `*` matches everything. Examples:
224
+
225
+ | Pattern | Matches |
226
+ |---|---|
227
+ | `fetch_webpage:*` | any `fetch_webpage` call |
228
+ | `shell:*git*` | shell commands containing `git` |
229
+ | `shell:rm -rf *` | exact prefix match |
230
+
231
+ **Resolution order:** session-approved → agent auto_approve → agent auto_deny → global auto_approve → global auto_deny → interactive prompt.
232
+
233
+ At the interactive prompt:
234
+ - `a` — approve once
235
+ - `s` — approve for this session
236
+ - `d` — deny once
237
+ - `D` — deny always (persisted to `config.yaml`)
238
+
239
+ ### Supported providers
240
+
241
+ | `type` | Notes |
242
+ |---|---|
243
+ | `openai-compatible` | OpenAI, Together.ai, Groq, Ollama, any OpenAI-compatible endpoint |
244
+ | `bedrock` | AWS Bedrock (uses ambient AWS credentials) |
245
+ | `gemini` | Google Gemini (generativelanguage.googleapis.com) |
246
+ | `ollama` | Locally-running Ollama server |
247
+
248
+ Each provider type accepts only its own fields — unknown fields are rejected with a clear error.
249
+
250
+ **Bedrock example:**
251
+
252
+ ```yaml
253
+ provider:
254
+ type: bedrock
255
+ model: us.anthropic.claude-sonnet-4-6-20251001-v1:0
256
+ region: us-east-1 # optional; falls back to AWS_DEFAULT_REGION → AWS_REGION → us-east-1
257
+ timeout_secs: 120 # optional
258
+ profile: my-aws-profile # optional; AWS credential profile
259
+ endpoint_url: "https://vpce-xxx.bedrock-runtime.us-east-1.vpce.amazonaws.com" # optional; VPC endpoint
260
+ ```
261
+
262
+ **Gemini example:**
263
+
264
+ ```yaml
265
+ provider:
266
+ type: gemini
267
+ model: gemini-2.5-flash
268
+ api_key: "${GEMINI_API_KEY}"
269
+ timeout_secs: 60
270
+ thinking_budget: 8192 # token budget for extended thinking (0 = off)
271
+ # thinking_mode: "medium" # alternative: low / medium / high / max
272
+ ```
273
+
274
+ **Ollama example:**
275
+
276
+ ```yaml
277
+ provider:
278
+ type: ollama
279
+ base_url: "http://localhost:11434"
280
+ model: llama3.2
281
+ timeout_secs: 120
282
+ keep_alive: "5m" # optional; how long Ollama keeps the model loaded
283
+ think: "high" # optional; thinking mode: enabled / high / medium / low
284
+ ```
285
+
286
+ ## CLI reference
287
+
288
+ ```
289
+ muaz <COMMAND>
290
+
291
+ Commands:
292
+ chat Start an interactive chat session
293
+ run Run one non-interactive turn and print the result (scriptable)
294
+ pipeline Run or list multi-agent pipelines
295
+ agents Manage agents
296
+ skills Manage Agent Skills
297
+ plugins Install and manage plugins (agents, skills, pipelines, prompts)
298
+ config View and edit global configuration
299
+ mcp Manage MCP server registrations
300
+ runtime Manage bundled MCP runtimes (Node.js, uv)
301
+ gateway Start the web server with browser UI
302
+ doctor Diagnose config, runtimes, and MCP server health
303
+ ```
304
+
305
+ Running bare `muaz` (no subcommand) starts interactive chat with the default agent.
306
+
307
+ ### `muaz chat`
308
+
309
+ ```
310
+ muaz chat [OPTIONS]
311
+
312
+ Options:
313
+ -a, --agent <AGENT> Agent to load (default: value in config.yaml)
314
+ --incognito Do not save session to disk
315
+ --session <SESSION> Resume an existing session by ID
316
+ --remember-approvals Persist "approve for session" grants into the
317
+ session file and restore them on resume
318
+ ```
319
+
320
+ ### `muaz run`
321
+
322
+ Run a single non-interactive turn and print the result. Useful for scripting and piping.
323
+
324
+ ```
325
+ muaz run [PROMPT] [OPTIONS]
326
+
327
+ Arguments:
328
+ [PROMPT] The prompt (combined with piped stdin when both are present)
329
+
330
+ Options:
331
+ -a, --agent <AGENT> Agent to use (default: value in config.yaml)
332
+ --session <SESSION> Append this turn to an existing session
333
+ --output <FORMAT> text (default) or json
334
+ --incognito Do not save the session
335
+
336
+ Examples:
337
+ muaz run "summarise this file" < README.md
338
+ git diff | muaz run "review this change"
339
+ muaz run "what day is it?" --output json
340
+ ```
341
+
342
+ ### `muaz pipeline`
343
+
344
+ ```
345
+ muaz pipeline <COMMAND>
346
+
347
+ Commands:
348
+ run <name> [input] Run a pipeline (reads stdin when input is omitted and piped)
349
+ list List pipelines in your local workspace
350
+ ```
351
+
352
+ ### `muaz gateway`
353
+
354
+ Start the Axum web server with the embedded React UI. The first browser request
355
+ opens the UI at `http://localhost:<port>`.
356
+
357
+ ```
358
+ muaz gateway [OPTIONS]
359
+
360
+ Options:
361
+ -p, --port <PORT> Port to listen on (default: 7878)
362
+ --host <HOST> Bind address (default: 127.0.0.1; use 0.0.0.0 to expose
363
+ to the network — muaz will warn you)
364
+ --token <TOKEN> Shared secret for all requests (default: $MUAZ_GATEWAY_TOKEN,
365
+ else a freshly generated token printed at startup)
366
+ ```
367
+
368
+ ### `muaz doctor`
369
+
370
+ Check the installation: config validity, bootstrapped layout, bundled runtime
371
+ status, and MCP server reachability.
372
+
373
+ ```
374
+ muaz doctor
375
+ ```
376
+
377
+ ### `muaz agents`
378
+
379
+ ```
380
+ muaz agents <COMMAND>
381
+
382
+ Commands:
383
+ list List all available agents
384
+ create Create a new agent interactively
385
+ show <name> Show the full config of an agent
386
+ edit <name> Open an agent config in $EDITOR
387
+ ```
388
+
389
+ ### `muaz skills`
390
+
391
+ ```
392
+ muaz skills <COMMAND>
393
+
394
+ Commands:
395
+ list List all discovered skills
396
+ create Create a new skill interactively
397
+ show <name> Show the SKILL.md of a skill
398
+ edit <name> Open a skill's SKILL.md in $EDITOR
399
+ ```
400
+
401
+ ### `muaz plugins`
402
+
403
+ Install and manage [plugins](https://shigar.co.uk/muaz/docs/concepts/plugins/) —
404
+ bundles of agents, skills, pipelines, and prompts.
405
+
406
+ ```
407
+ muaz plugins <COMMAND>
408
+
409
+ Commands:
410
+ install <target> Install from a local .zip path, or by registry name (name@version)
411
+ search <query> Search the remote registry
412
+ list List installed plugins (enabled/disabled, trusted) + built-ins
413
+ show <id> Show a plugin's manifest and contents
414
+ enable <id> Enable a disabled plugin
415
+ disable <id> Disable a plugin without uninstalling it
416
+ uninstall <id> Uninstall a plugin (deletes its directory)
417
+
418
+ Options (install):
419
+ --force Overwrite an existing plugin with the same id
420
+ ```
421
+
422
+ Provider profiles have no dedicated subcommand — edit `~/.muaz/providers.yaml` and
423
+ `muaz config edit`, or use the browser UI's Providers page.
424
+
425
+ ### `muaz config`
426
+
427
+ ```
428
+ muaz config [COMMAND]
429
+
430
+ Commands:
431
+ show Print the current config.yaml
432
+ edit Edit config fields interactively (default)
433
+ validate Check config.yaml, agents, mcp.json, and pipelines for problems
434
+ ```
435
+
436
+ ### `muaz mcp`
437
+
438
+ ```
439
+ muaz mcp <COMMAND>
440
+
441
+ Commands:
442
+ install <spec> Register an MCP server (npm package, uvx package, or HTTP URL)
443
+ list List all registered MCP servers
444
+ remove <name> Remove a registered MCP server by name
445
+
446
+ Options (install):
447
+ --name <name> Override the derived server name
448
+ --uvx Use uvx (uv tool run) instead of npx
449
+ [args...] Extra arguments passed to the server process (stdio only)
450
+ ```
451
+
452
+ ### `muaz runtime`
453
+
454
+ Manages the Node.js and uv runtimes that muaz downloads on demand for MCP servers.
455
+
456
+ ```
457
+ muaz runtime <COMMAND>
458
+
459
+ Commands:
460
+ list Show installed runtime status and pinned versions
461
+ install [name] Download a runtime now (node | uv; omit to install what's needed)
462
+ update Re-download installed runtimes to refresh pinned versions
463
+ clean Remove all downloaded runtimes
464
+ ```
465
+
466
+ ## Slash commands
467
+
468
+ | Command | Description |
469
+ |---|---|
470
+ | `/help` | Show all commands |
471
+ | `/agents` | List agents across all namespaces |
472
+ | `/switch <name>` | Load a different agent, start a fresh session |
473
+ | `/mcp` | Show MCP server connection status |
474
+ | `/tools` | List registered tools and their approval policy |
475
+ | `/session` | Show current session metadata (id, model, message count) |
476
+ | `/sessions` | Browse recent sessions; choose one to resume |
477
+ | `/run <name> [input]` | Run a multi-agent pipeline |
478
+ | `/pipelines` | List pipelines in your local workspace |
479
+ | `/skills` | List available Agent Skills |
480
+ | `/skill <name>` | Show the body of a skill's SKILL.md |
481
+ | `/incognito` | Toggle incognito mode (session not saved) |
482
+ | `/compact` | Summarize and compact conversation history now |
483
+ | `/usage` | Show token and latency stats for this session |
484
+ | `/clear` | Start a fresh session (old transcript stays saved) |
485
+ | `/exit` | Exit muaz |
486
+
487
+ Custom commands defined in `~/.muaz/commands/<name>.yaml` also appear in `/help`.
488
+
489
+ ## Built-in tools
490
+
491
+ | Tool | Description |
492
+ |---|---|
493
+ | `edit_file` | Overwrite a file with new content (creates if missing) |
494
+ | `patch_file` | Apply a unified diff patch to an existing file |
495
+ | `shell` | Execute a shell command via `sh -c` and return combined stdout/stderr |
496
+ | `fetch_webpage` | Fetch a URL and return the page content as plain text |
497
+
498
+ MCP tools are also registered when MCP servers are connected.
499
+
500
+ ## Agent Skills
501
+
502
+ Skills are reusable instruction sets that the agent can load on demand. Each skill lives in its own directory containing a `SKILL.md` file.
503
+
504
+ ### Skill discovery paths
505
+
506
+ Skills are discovered from these locations (in order of precedence):
507
+
508
+ 1. `<cwd>/.muaz/skills/` and `<cwd>/.agents/skills/` — project-level
509
+ 2. `~/.muaz/plugins/local/skills/` — your local workspace
510
+ 3. installed plugin `skills/` directories
511
+ 4. built-in `skills/` directories
512
+
513
+ Local/project skills are trusted automatically; a plugin skill's `allowed-tools`
514
+ are pre-approved only when the plugin is trusted.
515
+
516
+ ### SKILL.md format
517
+
518
+ ```markdown
519
+ ---
520
+ name: my-skill
521
+ description: A short description shown in listings
522
+ compatibility: muaz>=1.0 # optional
523
+ allowed-tools: shell:git * fetch_webpage:* # optional; space-separated tool patterns
524
+ ---
525
+
526
+ # my-skill
527
+
528
+ Full skill instructions go here. The agent reads this file when it wants to use the skill.
529
+ ```
530
+
531
+ ### Skill catalog in prompts
532
+
533
+ When skills are discovered, the agent's system prompt gets an appended `## Available Skills` block listing each skill's name, description, and SKILL.md path. The agent reads the file when it wants to invoke a skill.
534
+
535
+ ### Managing skills via CLI
536
+
537
+ ```bash
538
+ muaz skills list # show all discovered skills with scope
539
+ muaz skills create # interactive wizard to create a new skill
540
+ muaz skills show my-skill # print the SKILL.md of a skill
541
+ muaz skills edit my-skill # open SKILL.md in $EDITOR
542
+ ```
543
+
544
+ From within the REPL:
545
+
546
+ ```
547
+ /skills list available skills
548
+ /skill my-skill print a skill's SKILL.md
549
+ ```
550
+
551
+ ## Pipelines
552
+
553
+ Pipelines wire multiple agents together for complex workflows. Define them as YAML files in `~/.muaz/plugins/local/pipelines/` and run with `/run <name> [input]`.
554
+
555
+ ### Sequential pipeline
556
+
557
+ Each agent's output becomes the next agent's input.
558
+
559
+ ```yaml
560
+ # ~/.muaz/plugins/local/pipelines/research-and-write.yaml
561
+ name: research-and-write
562
+ pattern: sequential
563
+ steps:
564
+ - agent: researcher # resolved across namespaces (local, plugins, built-ins)
565
+ pass: last_message # pass only the last output (default)
566
+ - agent: writer
567
+ pass: full_history # prepend all prior step I/O as context
568
+ ```
569
+
570
+ `pass` modes:
571
+ - `last_message` — the previous agent's response becomes the next agent's input (default)
572
+ - `full_history` — all prior step inputs and outputs are prepended as context
573
+
574
+ ### Parallel pipeline
575
+
576
+ All agents run concurrently with the same input. Results are merged with per-agent section headers.
577
+
578
+ ```yaml
579
+ name: multi-review
580
+ pattern: parallel
581
+ agents:
582
+ - reviewer-a
583
+ - reviewer-b
584
+ - reviewer-c
585
+ merge: concat # default; 'summary' will be added in a future release
586
+ ```
587
+
588
+ ### Router pipeline
589
+
590
+ A router agent reads the input and returns a JSON routing decision. The message is then forwarded to the selected downstream agent.
591
+
592
+ ```yaml
593
+ name: smart-dispatch
594
+ pattern: router
595
+ router_agent: dispatcher # must be a fast, cheap model (e.g. gpt-4o-mini)
596
+ routes:
597
+ coding: coding-agent # key → agent name
598
+ research: research-agent
599
+ default: default-agent # fallback if no route matches
600
+ ```
601
+
602
+ The router agent automatically receives routing instructions appended to its system prompt and is expected to reply with:
603
+
604
+ ```json
605
+ {"route": "coding", "message": "Fix the authentication bug"}
606
+ ```
607
+
608
+ If the response cannot be parsed, the input is forwarded to the `default` route.
609
+
610
+ ## Custom slash commands
611
+
612
+ Drop a YAML file in `~/.muaz/plugins/local/commands/` to add a custom `/` command:
613
+
614
+ ```yaml
615
+ # ~/.muaz/plugins/local/commands/deploy.yaml
616
+ name: deploy
617
+ description: "Deploy to staging"
618
+ command: "cd ~/project && make deploy-staging"
619
+ ```
620
+
621
+ The command runs via `sh -c`. Environment variables available:
622
+
623
+ | Variable | Value |
624
+ |---|---|
625
+ | `MUAZ_SESSION_ID` | Current session UUID |
626
+ | `MUAZ_AGENT_NAME` | Current agent name |
627
+ | `MUAZ_MODEL` | Current model identifier |
628
+
629
+ ## Session management
630
+
631
+ Sessions are saved to `~/.muaz/sessions/` as JSON files (one per session). An `index.json` tracks metadata for the last 20 sessions.
632
+
633
+ - Use `--session <id>` to resume a session on startup
634
+ - Use `/sessions` to browse and resume from within the REPL
635
+ - Use `--incognito` or `/incognito` to skip saving