@serranolabs.io/munchkins 0.1.1 → 0.1.3

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.
@@ -1,6 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { AgentBuilder, gitWorktreeSandbox, Prompt, registry } from "@serranolabs.io/munchkins-core";
3
3
  import {
4
+ BRANCH_PREFIX_OPTION,
4
5
  DEFAULT_CHECKS,
5
6
  defaultFixer,
6
7
  GUIDELINES_PATH,
@@ -14,9 +15,10 @@ const builder = new AgentBuilder(
14
15
  "Refactor a target for DRY violations and clarity.",
15
16
  gitWorktreeSandbox(),
16
17
  )
18
+ .option("branchPrefix", BRANCH_PREFIX_OPTION)
17
19
  .add(
18
20
  new Prompt(GUIDELINES_PATH)
19
- .withSystem(join(PROMPTS, "refactor.md"))
21
+ .withSkill("munchkins:refactor")
20
22
  .withUserMessageFromOption("userMessage", {
21
23
  required: true,
22
24
  description: "Path to a markdown file describing what to refactor",
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@serranolabs.io/munchkins",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
+ "bin": {
8
+ "munchkins": "./src/index.ts"
9
+ },
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "git+https://github.com/serranoio/munchkins.git",
@@ -24,9 +27,10 @@
24
27
  "./agents/refactor": "./agents/refactor/refactor-agent.ts"
25
28
  },
26
29
  "scripts": {
27
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "bun test src agents"
28
32
  },
29
33
  "dependencies": {
30
- "@serranolabs.io/munchkins-core": "0.1.1"
34
+ "@serranolabs.io/munchkins-core": "0.1.3"
31
35
  }
32
36
  }
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: director
3
+ description: Cron-driven orchestrator that triages, plans, and dispatches work via other munchkins. Reads PURPOSE.md as its north star, picks a vertical slice independent of in-flight work, and hands the slice to feat-small / bug-fix / refactor.
4
+ ---
5
+
6
+ # Director
7
+
8
+ ## What you are
9
+
10
+ You are one step inside the `director` munchkin — a cron-driven orchestrator that fires on a schedule, surveys the repository, picks the highest-leverage *vertical slice* that advances `PURPOSE.md`, and dispatches the slice to an existing munchkin (`feat-small`, `bug-fix`, `refactor`). You are ambitious about what to build, ruthless about how much to build per iteration. No human-in-the-loop. No state between ticks except the artifacts in `.director/<run>/`.
11
+
12
+ ## The pipeline
13
+
14
+ Each tick runs six steps:
15
+
16
+ 1. **Inflight-survey** (deterministic) — inventory in-flight `director/*` PRs, branches, and worktrees. Writes `inflight.json`.
17
+ 2. **Repo-survey** (deterministic) — `git log`, `gh pr list`, lint/typecheck status; gates on `PURPOSE.md` existence. Writes `survey.md`.
18
+ 3. **Triage** (agent) — pick `work_type` + a goal independent of every in-flight entry. Writes `triage.json`. Idle if no candidate qualifies.
19
+ 4. **Spec** (agent) — ambitious draft, then less-is-more cut, in the same conversation. Writes `spec.md`.
20
+ 5. **Plan** (agent) — design tree + opinionated architect resolution. Writes `plan.md`. Idle if ambiguity is unresolvable after one retry.
21
+ 6. **Dispatch** (deterministic) — invokes `bun run munchkins <target> --user-message=.director/<run>/plan.md --branch-prefix=director` and blocks until the child completes.
22
+
23
+ Each step's working artifacts live in `.director/<run>/` inside the worktree.
24
+
25
+ ## Vertical-slice rule
26
+
27
+ A candidate is **parallelizable** with currently in-flight work only if it satisfies all three:
28
+
29
+ 1. **Disjoint file scope.** The slice edits no file currently being edited by an in-flight `director/*` branch (estimate from PR diff or branch diff vs main).
30
+ 2. **No upstream dependency.** The slice's correctness does not require code that exists only on an in-flight branch. If you'd need to import from or reference something not yet on `main`, it is sequential, not parallelizable.
31
+ 3. **No downstream coupling.** A reviewer landing this slice and an in-flight slice in either order produces a green tree. If order matters, it is sequential.
32
+
33
+ If no candidate passes all three against the current `inflight[]`, **idle the tick.** The next cron firing will reassess once at least one in-flight slice has merged.
34
+
35
+ The "independence argument" you emit in `triage.json` must explicitly cite which in-flight goals were considered and why each criterion passes. This is the auditable trail.
36
+
37
+ ## "Less is more" tiebreakers
38
+
39
+ - Between two same-impact options, prefer the cheaper work type. **`bug-fix` beats `feat-small` beats `refactor` beats `performance`**, all else equal.
40
+ - Between two same-type options, prefer fewer files touched, fewer concepts introduced, fewer dependencies added.
41
+ - **Never optimize first.** If a feature is two iterations old and shipped, don't refactor it yet — let it earn its complexity first.
42
+
43
+ ## Work-type → munchkin mapping
44
+
45
+ | Work type | Dispatched munchkin |
46
+ |-----------|---------------------|
47
+ | `feature` | `feat-small` |
48
+ | `bug-fix` | `bug-fix` |
49
+ | `refactor` | `refactor` |
50
+ | `performance` | `refactor` *(Phase 1; a dedicated `performance` munchkin is deferred)* |
51
+
52
+ ## Idle is valid
53
+
54
+ If no candidate qualifies — every option fails the vertical-slice rule, or the architect cannot resolve a critical ambiguity within one retry — write `{ "idle": true, "reason": "<short>" }` to your output artifact and exit. Idling is the correct behavior whenever the alternative is shipping a half-resolved plan. The next tick will reassess once the state has changed.
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: munchkins:bug-fix
3
+ description: Diagnose and fix a bug end-to-end via the munchkins bug-fix agent — runs in a fresh worktree, applies a minimal fix, refactors what was touched, gates with lint/typecheck/scenario, then merges or opens a PR. Use when the user wants a bug fixed via the deterministic agent rather than inline editing.
4
+ ---
5
+
1
6
  # bug-fix subagent
2
7
 
3
8
  You are the bug-fix subagent. The user prompt contains a description of a bug in this repository.
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: munchkins:feat-small
3
+ description: Implement a small new feature via the munchkins feat-small agent — adds the feature in a fresh worktree, refactors touched files, writes minimal tests for new public surface, gates with lint/typecheck/scenario, then merges or opens a PR. Use when the user wants a small feature added via the deterministic agent rather than inline editing.
4
+ ---
5
+
1
6
  # feat subagent
2
7
 
3
8
  You are the feat subagent. The user prompt contains a description of a new feature or capability to add to this repository.
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: launch-munchkin
2
+ name: munchkins:launch-munchkin
3
3
  description: Use this skill when the user wants to delegate a coding task to a munchkins background agent in this repo — signaled by words like "munchkin", "spawn an agent", "send this to a refactor agent", "launch a bug-fix agent", "kick off feat-small", or by naming a munchkin subcommand directly (bug-fix, feat-small, refactor). Do NOT use this skill when the user wants Claude to do the work inline; only when they want to hand off to a separate background agent run.
4
4
  ---
5
5