@nodeint/migent 0.1.4 → 0.1.6

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.
Files changed (48) hide show
  1. package/README.md +194 -138
  2. package/dist/commands/agent.d.ts +8 -1
  3. package/dist/commands/agent.js +381 -56
  4. package/dist/commands/config.js +23 -9
  5. package/dist/commands/execute.d.ts +6 -1
  6. package/dist/commands/execute.js +105 -20
  7. package/dist/commands/init.d.ts +1 -0
  8. package/dist/commands/init.js +70 -63
  9. package/dist/commands/prepare.d.ts +1 -0
  10. package/dist/commands/prepare.js +14 -0
  11. package/dist/commands/repair.d.ts +1 -0
  12. package/dist/commands/repair.js +22 -0
  13. package/dist/commands/service.js +5 -4
  14. package/dist/commands/sessions.d.ts +24 -1
  15. package/dist/commands/sessions.js +165 -13
  16. package/dist/commands/skill.js +58 -32
  17. package/dist/commands/watch.d.ts +2 -1
  18. package/dist/commands/watch.js +130 -67
  19. package/dist/commands/workspace-registry.js +10 -1
  20. package/dist/display.d.ts +1 -0
  21. package/dist/display.js +24 -9
  22. package/dist/errors.d.ts +3 -0
  23. package/dist/errors.js +6 -0
  24. package/dist/exits.d.ts +12 -0
  25. package/dist/exits.js +33 -0
  26. package/dist/follow-log.d.ts +29 -0
  27. package/dist/follow-log.js +172 -0
  28. package/dist/fs-utils.d.ts +3 -0
  29. package/dist/fs-utils.js +26 -0
  30. package/dist/index.js +5 -1
  31. package/dist/migrate.js +2 -17
  32. package/dist/program.js +429 -177
  33. package/dist/session-row.d.ts +20 -0
  34. package/dist/session-row.js +21 -0
  35. package/dist/signals.d.ts +3 -0
  36. package/dist/signals.js +56 -0
  37. package/dist/templates/migent/SKILL.md +163 -56
  38. package/dist/templates/migent/references/config.md +52 -0
  39. package/dist/templates/migent/references/inspect.md +32 -0
  40. package/dist/templates/migent/references/schema-config.yaml +35 -0
  41. package/dist/templates/migent/references/schema-workflow.yaml +71 -0
  42. package/dist/templates/migent/references/sessions.md +65 -0
  43. package/dist/text.d.ts +4 -0
  44. package/dist/text.js +13 -0
  45. package/dist/version.d.ts +1 -0
  46. package/dist/version.js +3 -0
  47. package/dist/workspace.js +5 -12
  48. package/package.json +4 -4
package/README.md CHANGED
@@ -1,193 +1,249 @@
1
1
  # Migent
2
2
 
3
- **Compose AI coding agents into repeatable engineering workflows.**
4
-
5
- Use the right model for each stage of the job.
6
-
7
- Migent connects coding-agent CLIs from different providers through explicit,
8
- repository-defined workflows. One model can plan, another can review, and the
9
- first can revise—while Migent carries artifacts between them and remembers
10
- where the process is.
11
-
12
- ## Contents
13
-
14
- - [Migent](#migent)
15
- - [Contents](#contents)
16
- - [Why Migent?](#why-migent)
17
- - [Supported CLIs](#supported-clis)
18
- - [Quickstart](#quickstart)
19
- - [Install](#install)
20
- - [Create a project](#create-a-project)
21
- - [Run](#run)
22
- - [Next](#next)
23
- - [Concepts](#concepts)
24
- - [Current scope](#current-scope)
25
- - [Documentation](#documentation)
26
- - [Development](#development)
27
- - [License](#license)
28
-
29
- ## Why Migent?
30
-
31
- Calling two agent CLIs from a shell script is easy. Reliably coordinating them
32
- across reviews, revisions, failures, and resumed sessions is not.
33
-
34
- Migent is built around three ideas:
35
-
36
- - **Use models for what they do best.** Assign each role to a provider and model
37
- suited to the work, rather than asking one agent to do everything.
38
- - **Treat AI engineering process as code.** Keep stages, handoffs, review gates,
39
- and revision policies in version control beside the project they govern.
40
- - **Keep orchestration explicit.** The team defines the process; models execute
41
- roles inside it. A supervisor model does not invent or dynamically control
42
- the workflow.
43
-
44
- **Models describe execution. Roles describe intent.** Changing the model behind
45
- a role does not require rewriting the workflow.
46
-
47
- **Common workflow model, native provider capabilities.** Migent coordinates
48
- the process, while each provider CLI remains responsible for authentication,
49
- agent execution, and its own tools and options.
3
+ <p align="center">
4
+ <strong>Autonomous, multi-stage engineering pipelines for your coding agents.</strong><br>
5
+ Repeatable workflows. Multi-agent orchestration. Native CLI execution. Full observability.
6
+ </p>
50
7
 
51
- ```mermaid
52
- flowchart LR
53
- A[Task] --> B[Planner - Codex]
54
- B -->|plan.md| C[Reviewer - Grok]
55
- C -->|revise| B
56
- C -->|approved| D[Complete]
57
- ```
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/@nodeint/migent"><img src="https://img.shields.io/npm/v/@nodeint/migent.svg?style=flat-square" alt="npm version" /></a>
10
+ <a href="https://github.com/nodeint/migent/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License: MIT" /></a>
11
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg?style=flat-square" alt="Node.js 22+" /></a>
12
+ <img src="https://img.shields.io/badge/agents-Multi--Agent_Ready-orange.svg?style=flat-square" alt="Multi-Agent Ready" />
13
+ </p>
14
+
15
+ ---
58
16
 
59
- ## Supported CLIs
17
+ Migent coordinates the coding-agent CLIs you already have into **reusable, verified engineering pipelines**. Instead of juggling tabs, manually copying plans, and pasting test errors back and forth, you define the pipeline as code. Migent orchestrates the handoffs, runs strict local verification gates, handles review loops, and captures deep execution metrics.
60
18
 
61
- Migent drives each provider through its headless CLI. Install and sign in to the
62
- ones your configuration names.
19
+ ### 🌟 Why Migent?
63
20
 
64
- | Provider | CLI |
65
- | -------- | -------- |
66
- | Claude | `claude` |
67
- | Codex | `codex` |
68
- | Grok | `grok` |
21
+ - 🔁 **Automate Recurring Tasks (Workflows & Stages):** Package routine engineering work—bug fixes, refactors, migrations, test authoring—into structured, multi-stage pipelines with deterministic verification gates.
22
+ - 🤖 **Multi-Agent Orchestration & Flexibility:** Assign the best model to each role (`claude` for planning, `codex` for implementation, `grok` for independent review). Run directly through your installed agent CLIs without custom wrappers or API lock-in.
23
+ - 📊 **Observability & Continuous Improvement:** Live-stream running pipelines with `session follow`, and collect token spend, wall-time, and revision counts with `session metrics` to measure and refine your team's workflows.
24
+
25
+ ---
69
26
 
70
27
  ## Quickstart
71
28
 
72
- Requires Node.js 22+ (macOS, Linux, or Windows) and the provider CLIs your
73
- config uses, already signed in.
29
+ ### Option A: Agent-Assisted via `/migent` (Recommended)
74
30
 
75
- ### Install
31
+ Let your coding agent handle the initial configuration using Migent's official Skill.
76
32
 
77
33
  ```bash
34
+ # 1. Install Migent globally
78
35
  npm install -g @nodeint/migent
79
- migent --version
36
+
37
+ # 2. Install the Migent Skill in your repo
38
+ migent skill install
39
+ ```
40
+
41
+ Now open your favorite coding agent CLI (such as Google Antigravity `agy`, Anthropic `claude`, Cursor, or Windsurf) in this repository and type:
42
+
43
+ ```text
44
+ /migent Set up a workflow for this repo: Claude for planning, Codex for coding, Grok for review. Then run a pipeline to resolve issue #42.
80
45
  ```
81
46
 
82
- Upgrade with `npm install -g @nodeint/migent@latest`.
47
+ > **How it works:** `migent skill install` creates `.agents/skills/migent/` containing Migent's schema rules and CLI definitions. Using the `/migent` slash command instructs your agent to inspect your repo, generate valid configuration files under `.migent/`, validate them with `migent doctor`, and launch the workflow.
83
48
 
84
- ### Create a project
49
+ ---
85
50
 
86
- From the repository where agents will work:
51
+ ### Option B: Terminal CLI (Direct Control)
52
+
53
+ Prefer setting it up yourself? Get started in three commands:
87
54
 
88
55
  ```bash
89
- migent init
56
+ # 1. Initialize a workflow preset and validate environment
57
+ migent init --preset plan
58
+ migent doctor
59
+
60
+ # 2. Run your engineering task
61
+ migent session run --workflow plan --task "Implement JWT authentication with refresh tokens"
62
+
63
+ # 3. Stream real-time events or inspect performance metrics
64
+ migent session follow <session-id>
65
+ migent session metrics <session-id> --json
90
66
  ```
91
67
 
92
- In a terminal, `init` walks you through the provider, model, and options, then
93
- offers to install the Migent skill so agents in the project know how to run it.
94
- Without a terminal, pass `--provider` and `--model` together. Pass `--skill` to
95
- install the skill without the prompt.
68
+ ---
96
69
 
97
- It creates:
70
+ ## What Migent Solves
98
71
 
99
- ```text
100
- .migent/
101
- ├── config.yaml # models and roles
102
- ├── .gitignore # keeps sessions/ untracked
103
- └── workflows/
104
- └── plan.yaml # plan-and-review workflow
72
+ | Without Migent | With Migent |
73
+ | :--- | :--- |
74
+ | **Manual handoffs:** Copying plans and pasting stack traces across conversations. | **Automated handoffs:** Upstream artifacts and diffs pass automatically into downstream stages. |
75
+ | **Single-agent bottleneck:** One model handles planning, coding, and review, accumulating context bloat. | **Specialized roles:** Multi-agent pipeline with dedicated models per role (e.g., Planner $\rightarrow$ Coder $\rightarrow$ Reviewer). |
76
+ | **Vendor lock-in & wrappers:** Restricted to one provider or requiring custom API adapters. | **Native CLI execution:** Drives your installed agent CLIs (`agy`, `claude`, `codex`, `grok`) directly in your workspace. |
77
+ | **Blind trust:** Agents claim "all tests pass" without actually running project commands. | **Verification gates:** Real local checks (`pnpm test`, `pytest`, `cargo test`) must succeed before advancing. |
78
+ | **Fragile one-off prompts:** Team members execute tasks with inconsistent, ad-hoc instructions. | **Process as code:** Workflows live in Git (`.migent/workflows/`), making best practices versioned and repeatable. |
79
+ | **No execution visibility:** No record of how long tasks took, why checks failed, or how many retries occurred. | **Telemetry & Metrics:** Append-only event logs, live streaming, and full JSON metrics for duration, retries, and token cost. |
80
+
81
+ ---
105
82
 
106
- .agents/skills/migent/ # only if you install the skill
83
+ ## How It Works
84
+
85
+ A typical software engineering workflow breaks down into structured, verifiable stages:
86
+
87
+ ```mermaid
88
+ flowchart TD
89
+ Task["Task: Fix OAuth Callback"] --> Plan["1. Plan\n(Claude)"]
90
+ Plan -->|"artifact: plan.md"| Implement["2. Implement\n(Codex)"]
91
+ Implement --> Verify{"3. Verification Gate\n(pnpm test)"}
92
+ Verify -->|"Fails (retry <= max)"| Implement
93
+ Verify -->|"Retry limit reached"| Blocked["Stop for inspection"]
94
+ Verify -->|"Passes"| Review["4. Review\n(Grok)"]
95
+ Review -->|"Revise + feedback"| Implement
96
+ Review -->|"Approved"| Done["Workflow Complete"]
107
97
  ```
108
98
 
109
- Commit `config.yaml` and `workflows/`. To add the skill later, run
110
- `migent skill install`.
99
+ 1. **Plan:** A high-reasoning model analyzes the codebase and generates an actionable `plan.md`.
100
+ 2. **Implement:** A coding model applies changes to the working tree according to the plan.
101
+ 3. **Verify Gate:** Migent runs your repository's native verification commands (tests, typecheck, lint).
102
+ 4. **Review & Revision Loop:** An independent reviewer evaluates the git diff against the plan. If changes are requested, feedback routes back to the implementation stage.
111
103
 
112
- ### Run
104
+ ---
113
105
 
114
- From the project or any subdirectory:
106
+ ## Core Capabilities
115
107
 
116
- ```bash
117
- migent start plan --task "Plan the account settings redesign"
118
- ```
108
+ ### 1. Repeatable Workflows as Code
109
+ Define stages, dependencies, artifacts, and routing decisions in declarative YAML stored under `.migent/workflows/`. Version control your engineering processes alongside your application code.
119
110
 
120
- Migent runs each eligible stage until the workflow completes or stops. Progress
121
- goes to stderr; stdout is a single JSON result. Then inspect or resume:
111
+ ### 2. Multi-Agent Orchestration & BYO CLIs
112
+ Decouple **what** a stage does from **which model** executes it. Migent drives the agent CLIs already installed and authenticated on your machine:
122
113
 
123
- ```bash
124
- migent sessions
125
- migent watch <session-id>
126
- migent continue <session-id>
127
- ```
114
+ | Provider | CLI | Typical Role in Pipeline |
115
+ | :--- | :--- | :--- |
116
+ | **Anthropic Claude** | `claude` | High-reasoning architecture planning & refactoring |
117
+ | **Google Antigravity** | `agy` | Deep repository analysis, plan generation & review |
118
+ | **OpenAI Codex** | `codex` | Fast, focused implementation & unit test authoring |
119
+ | **xAI Grok** | `grok` | Independent logic review & edge case discovery |
128
120
 
129
- ### Next
121
+ Switch models anytime in `.migent/config.yaml` without touching your workflow logic.
130
122
 
131
- - [Providers and model configuration](https://github.com/nodeint/migent/blob/main/docs/providers.md)
132
- - [Writing workflows](https://github.com/nodeint/migent/blob/main/docs/workflows.md#complete-example)
133
- - [CLI commands and exit codes](https://github.com/nodeint/migent/blob/main/docs/cli.md)
134
- - [Sessions and workflow composition](https://github.com/nodeint/migent/blob/main/docs/sessions.md)
123
+ ### 3. Observability, Telemetry & Continuous Improvement
124
+ Migent treats engineering runs as first-class observable processes:
125
+ - **Live Monitoring:** `migent session follow <session-id>` streams execution events, stage heartbeats, and runner turns in real time.
126
+ - **Detailed Metrics:** `migent session metrics <session-id> --json` outputs execution wall-time, active runner seconds, verify durations, revision counts, and token usage.
127
+ - **Continuous Refinement:** Use hard metrics from past sessions to optimize prompts, tune retry limits, and pick the most cost-effective models.
128
+ - **Session Recovery:** When rate limits or network issues strike, `migent session continue <session-id>` resumes right where the pipeline stopped.
135
129
 
136
- ## Concepts
130
+ ---
137
131
 
138
- A workflow connects stages through dependencies and explicit decision routes.
132
+ ## Configuration Example
139
133
 
140
- - A **model** identifies a provider model and its execution options.
141
- - A **role** names a kind of work and selects its default model.
142
- - A **stage** assigns work to a role and may declare dependencies, an artifact,
143
- a decision, or both.
144
- - An **artifact** is a named file produced by a successful stage and stored with
145
- the workflow session.
146
- - A **decision** selects the next route, including a route back for revision.
147
- - A **session** records executions, events, decisions, and artifacts so work can
148
- be inspected or resumed.
134
+ Migent separates model/role assignments from pipeline control flow.
149
135
 
150
- Use `depends_on` to give a stage upstream artifacts. Use `session.resume_from`
151
- when the stage must also continue a provider's prior conversational session.
136
+ ### 1. Configure Models and Roles (`.migent/config.yaml`)
152
137
 
153
- ## Current scope
138
+ ```yaml
139
+ schema_version: 2
154
140
 
155
- Migent is a local, file-backed orchestration layer for provider CLIs. It does
156
- not replace their agent runtimes, and it does not hide their distinctive
157
- capabilities behind a lowest-common-denominator API.
141
+ models:
142
+ planning-model:
143
+ provider: claude
144
+ model: opus
158
145
 
159
- Today, Migent supports explicit stage routing, review loops, local session
160
- history, provider-session resume, prerequisite workflows, and standalone role
161
- execution. A machine-local registry service records workspaces
162
- so another tool can ask which projects exist.
146
+ coding-model:
147
+ provider: codex
148
+ model: default
163
149
 
164
- ## Documentation
150
+ review-model:
151
+ provider: grok
152
+ model: grok-4.7
153
+
154
+ roles:
155
+ planner:
156
+ default_model: planning-model
157
+ instructions:
158
+ - Analyze the repository and create an actionable plan with file paths.
165
159
 
166
- - [Writing workflows](https://github.com/nodeint/migent/blob/main/docs/workflows.md)
167
- - [Providers and model configuration](https://github.com/nodeint/migent/blob/main/docs/providers.md)
168
- - [Sessions and workflow composition](https://github.com/nodeint/migent/blob/main/docs/sessions.md)
169
- - [CLI commands and execution controls](https://github.com/nodeint/migent/blob/main/docs/cli.md)
160
+ coder:
161
+ default_model: coding-model
162
+ instructions:
163
+ - Implement changes according to the plan and write regression tests.
164
+
165
+ reviewer:
166
+ default_model: review-model
167
+ instructions:
168
+ - Review the git diff against the plan for correctness, security, and edge cases.
169
+ ```
170
+
171
+ ### 2. Define the Pipeline (`.migent/workflows/feature.yaml`)
172
+
173
+ ```yaml
174
+ schema_version: 2
175
+ id: feature
176
+
177
+ stages:
178
+ - id: plan
179
+ role: planner
180
+ produces:
181
+ artifact: plan.md
182
+
183
+ - id: implement
184
+ role: coder
185
+ depends_on: [plan]
186
+ verify:
187
+ - pnpm test
188
+ max_verify: 3
189
+
190
+ - id: review
191
+ role: reviewer
192
+ depends_on: [implement]
193
+ decision:
194
+ values: [approved, revise]
195
+ routes:
196
+ approved: complete
197
+ revise: implement
198
+
199
+ outputs:
200
+ - name: plan
201
+ from_stage: plan
202
+ artifact: plan.md
203
+ ```
204
+
205
+ ---
206
+
207
+ ## CLI Cheatsheet
208
+
209
+ ```bash
210
+ # Setup & Health
211
+ migent init --preset plan # Initialize starter configuration
212
+ migent doctor # Validate configuration, schemas, and CLI availability
213
+ migent skill install # Install the Migent Skill for coding agents (.agents/skills/migent/)
214
+
215
+ # Execution
216
+ migent session run --workflow <id> --task "<task>" # Run a workflow
217
+ migent session continue <session-id> # Resume an interrupted or blocked session
218
+
219
+ # Monitoring & Telemetry
220
+ migent session list # List recorded sessions and statuses
221
+ migent session follow <session-id> # Live-stream session events and progress
222
+ migent session metrics <session-id> --json # View token spend, duration, and retry metrics
223
+ migent session show <session-id> # Inspect session state and artifact status
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Documentation
170
229
 
171
- Run `migent <command> --help` for the exact command contract, output fields,
172
- and exit codes.
230
+ - [Writing Workflows](https://github.com/nodeint/migent/blob/main/docs/workflows.md) — Stages, dependencies, artifacts, and routing decisions.
231
+ - [Providers and Model Configuration](https://github.com/nodeint/migent/blob/main/docs/providers.md) — Configuring CLIs, models, options, and fallback models.
232
+ - [Sessions and State](https://github.com/nodeint/migent/blob/main/docs/sessions.md) — Manifests, append-only event logs, and recovery.
233
+ - [CLI Reference](https://github.com/nodeint/migent/blob/main/docs/cli.md) — Full command catalog, flags, and JSON modes.
173
234
 
174
- ## Development
235
+ ## Contributing
175
236
 
176
- The pnpm workspace contains four packages: the `@nodeint/migent` CLI and its
177
- internal libraries `@nodeint/migent-kernel`, `@nodeint/migent-adapters`, and
178
- `@nodeint/migent-registry`. The libraries have no stable API; depend on
179
- `@nodeint/migent`.
237
+ Migent is built with TypeScript in a pnpm workspace:
180
238
 
181
239
  ```bash
182
240
  pnpm install
183
241
  pnpm build
184
242
  pnpm test
185
- pnpm migent --help # run the local build
186
243
  ```
187
244
 
188
- See [CONTRIBUTING.md](CONTRIBUTING.md) for testing rules, platform notes, and
189
- the release process.
245
+ See [CONTRIBUTING.md](https://github.com/nodeint/migent/blob/main/CONTRIBUTING.md) for details.
190
246
 
191
247
  ## License
192
248
 
193
- Migent is licensed under the [MIT License](https://github.com/nodeint/migent/blob/main/LICENSE).
249
+ Migent is open source under the [MIT License](https://github.com/nodeint/migent/blob/main/LICENSE).
@@ -1,4 +1,4 @@
1
- import { AgentToolRunner } from "@nodeint/migent-kernel";
1
+ import { AgentToolRunner, type WaitHooks } from "@nodeint/migent-kernel";
2
2
  export declare function dispatchAgent(workspace: string, args: {
3
3
  role: string;
4
4
  task?: string | null;
@@ -11,4 +11,11 @@ export declare function dispatchAgent(workspace: string, args: {
11
11
  promptStdin?: boolean;
12
12
  asJson?: boolean;
13
13
  runner?: AgentToolRunner | null;
14
+ waitHooks?: WaitHooks;
15
+ }): Promise<number>;
16
+ export declare function continueAgent(workspace: string, args: {
17
+ sessionId: string;
18
+ reply: string | null;
19
+ runner?: AgentToolRunner | null;
20
+ waitHooks?: WaitHooks;
14
21
  }): Promise<number>;