@flumecode/runner 0.0.1

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/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@flumecode/runner",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "FlumeCode local runner — claims jobs and drives your local Claude Code against a real checkout.",
6
+ "bin": {
7
+ "flumecode": "dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "skills-plugin"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "provenance": false
19
+ },
20
+ "scripts": {
21
+ "build": "esbuild src/cli.ts --bundle --platform=node --format=esm --target=node20 --packages=external --outfile=dist/cli.js --banner:js=\"#!/usr/bin/env node\"",
22
+ "dev": "tsx src/cli.ts",
23
+ "login": "tsx src/cli.ts login",
24
+ "start": "tsx src/cli.ts start",
25
+ "typecheck": "tsc --noEmit",
26
+ "prepublishOnly": "pnpm build"
27
+ },
28
+ "dependencies": {
29
+ "@anthropic-ai/claude-agent-sdk": "^0.3.0",
30
+ "zod": "4.4.3"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.10.5",
34
+ "esbuild": "^0.24.2",
35
+ "tsx": "^4.19.2",
36
+ "typescript": "^5.7.3"
37
+ }
38
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "flumecode",
3
+ "version": "0.0.0",
4
+ "description": "Global FlumeCode skills available to every agent run."
5
+ }
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: coding-guideline
3
+ description: >-
4
+ General code-quality guidelines an agent must follow whenever it writes or
5
+ changes code: readability first, no speculative abstraction, thin functional
6
+ callbacks, no nested ternaries, reuse before duplication, why-not-what comments,
7
+ and tests on both paths. Injected into edit-mode runs; consumed by code-writing
8
+ skills (e.g. a future implement-plan or refactor).
9
+ ---
10
+
11
+ # Coding Guidelines
12
+
13
+ ## Principles
14
+
15
+ - Readability first.
16
+ - Don't optimize for performance unless asked.
17
+ - Don't introduce abstractions, options, or features the current task doesn't require.
18
+
19
+ ## Functions & files
20
+
21
+ - Extract a function when a block operates at a different level of abstraction than its surroundings, mixes unrelated concerns, or would otherwise need a what-comment. Don't extract just because a function is long.
22
+ - Keep callbacks passed to `.map`/`.filter`/`.reduce`/`.forEach`/etc. thin, and pass named functions by reference (`items.map(toPatchedItem)`). The same triggers as above apply inside an inline arrow: if it branches, mutates outer state, or needs a what-comment, extract it into a named function. A single-expression callback stays inline at one level (`xs.map((x) => x.id)`, `xs.filter(isActive)`). **Never nest one of these callbacks inside another** — `xs.map((x) => x.items.map(...))` is two named functions waiting to be extracted, regardless of whether the inner callback is trivial.
23
+ - Do not nest ternary operators. If a value depends on more than one condition, extract a named function, use `if/else`, or a lookup map — whichever is most readable. "Nested" means a ternary whose `then` or `else` branch is itself a ternary, regardless of formatting. Single-condition ternaries are fine.
24
+ - Prefer top-down organization: exported functions and classes first, non-exported helpers below. Use `function` declarations so hoisting works, or place helpers above their first caller. A helper tightly coupled to one exported function may live adjacent to it.
25
+
26
+ ## Reuse & duplication
27
+
28
+ - Before creating a new component or utility, search the codebase for an existing one and reuse what fits. If you add a new one, the PR description must state what you considered and why it didn't fit.
29
+
30
+ - Prefer duplication over the wrong abstraction. The decision turns on **intent and what differs**, not surface similarity:
31
+ - **Extract a parameterized function** when two or more blocks encode the _same intent_ and differ only in **values** (literals, identifiers, config) while the logic and control flow are identical. Lift the differing values into parameters and call the shared function — this is duplicated _logic_, and it should be removed even when the code is not character-for-character identical.
32
+ - **Leave duplicated** when blocks merely _look_ similar but encode different intent, have diverging control flow, or would evolve independently.
33
+ - Smell test: if you need a boolean/`mode` flag that changes which branch of the extracted body runs, the blocks don't share intent — keep them separate.
34
+
35
+ - **No re-export shims when moving files.** When relocating a module, rewrite every importer to the new canonical path in the same PR and delete the original file. Do not leave a one-line `export *` shim at the old path.
36
+
37
+ ## Comments
38
+
39
+ - Explain _why_, not _what_. If a comment is needed to describe what a block does, extract a named function instead.
40
+
41
+ ## Tests
42
+
43
+ - Add unit tests when adding or changing logic. Pure visual or type-only changes don't need them.
44
+ - Cover both success and failure paths — never only the happy path.
45
+ - For logic-heavy work, prefer TDD: write the failing test first, then make it pass.
46
+
47
+ ## Documentation
48
+
49
+ - When behavior or conventions change, update the matching project docs (`CLAUDE.md` or rule files) in the same PR.
@@ -0,0 +1,164 @@
1
+ ---
2
+ name: document
3
+ description: >-
4
+ Create and maintain the repository's wiki — the committed, source-of-truth
5
+ documentation under `.flumecode/wiki/`. Use on first import to bootstrap it, and
6
+ after each implementation to reconcile it with what changed. The wiki serves
7
+ two readers: humans who need a high-level overview plus low-level detail, and
8
+ agents who need a fast index to load context with minimum effort. Writes
9
+ markdown files; never changes application code.
10
+ ---
11
+
12
+ # document
13
+
14
+ You maintain the repository **wiki** — a set of committed markdown files under
15
+ `.flumecode/wiki/` that are the source of truth for how this system works. You
16
+ write and edit documentation only; you never modify application code, config, or
17
+ tests.
18
+
19
+ The wiki exists to serve two readers at once:
20
+
21
+ 1. **Humans** — a high-level overview of what the system is and how the pieces
22
+ fit, plus low-level explanations of each component. This is the canonical
23
+ place to understand the repository.
24
+ 2. **Agents** — a fast **index** into the codebase. An agent that has just had
25
+ its context reset should be able to read the wiki entry point, follow a few
26
+ links, and know where to look and why — without re-deriving the architecture
27
+ from raw source.
28
+
29
+ Both readers are served by the same principle: **explain intent and structure,
30
+ point to the code, never duplicate it.** The code is the truth of _what_; the
31
+ wiki is the truth of _why_, _where_, and _how it fits_.
32
+
33
+ ## You are stateless — orient yourself first
34
+
35
+ Each run you see the full request thread but keep **no memory** between runs. You
36
+ work in a clone of the repo in your current working directory. Before writing
37
+ anything, determine which mode you are in:
38
+
39
+ - **`.flumecode/wiki/` is absent or effectively empty** → **Bootstrap**. Build
40
+ the wiki from scratch.
41
+ - **`.flumecode/wiki/` already exists** → **Update**. Reconcile it with what
42
+ has changed since it was last synced; do not rewrite it wholesale.
43
+
44
+ Then read the **wiki contract** below before producing anything.
45
+
46
+ ## The wiki contract
47
+
48
+ The wiki lives at `.flumecode/wiki/` in the repository root, alongside any other
49
+ FlumeCode-specific files (the `.flumecode/` folder is FlumeCode's home in a
50
+ client repo, like `.github/` or `.claude/`). Layout:
51
+
52
+ ```
53
+ .flumecode/wiki/
54
+ ├── README.md # Entry point: system summary + the navigation map. Start here.
55
+ ├── architecture.md # How components fit: data flow, boundaries, key decisions, "why".
56
+ ├── glossary.md # Domain terms and their meaning in this codebase.
57
+ └── components/ # One page per major component (app, package, or subsystem).
58
+ └── <name>.md
59
+ ```
60
+
61
+ Adapt the set of `components/` pages to the actual repository — one page per unit
62
+ that a reader would reason about independently (e.g. each app, package, or
63
+ clearly-bounded subsystem). Do not invent structure the repo does not have, and
64
+ do not create empty placeholder pages.
65
+
66
+ ### `.flumecode/wiki/README.md` — the index
67
+
68
+ This is the most important page; it is what an agent reads first. It must
69
+ contain, in this order:
70
+
71
+ 1. **A sync marker** at the very top, so future runs know what the wiki was last
72
+ reconciled to:
73
+
74
+ ```
75
+ <!-- wiki-synced-to: <full-commit-sha> -->
76
+ ```
77
+
78
+ 2. **One short paragraph** stating what the system is and does.
79
+ 3. **A navigation map** — a table that lets a reader (human or agent) jump
80
+ straight to the right place:
81
+
82
+ | Component | What it does | Wiki page | Key paths |
83
+ | --------- | ------------ | -------------------------------------------- | ------------------ |
84
+ | runner | … | [components/runner.md](components/runner.md) | `apps/runner/src/` |
85
+
86
+ 4. **A one-line note for agents** telling them this is the index: start here,
87
+ follow links to the page you need, then open the cited source paths.
88
+
89
+ ### Every page: front-load an "At a glance" block
90
+
91
+ So an agent can grab context in seconds, begin each component page with:
92
+
93
+ ```
94
+ # <component>
95
+
96
+ > **Purpose** — one or two sentences.
97
+ > **Key files** — `path/a.ts`, `path/b.ts` (the entry points worth opening).
98
+ > **Depends on** — what it relies on. **Used by** — what relies on it.
99
+ > **Related** — [other wiki page](other.md).
100
+ ```
101
+
102
+ Then the prose: responsibilities, the important flows, non-obvious decisions and
103
+ their rationale, gotchas, and extension points. Cite real files with their paths
104
+ (`apps/runner/src/run.ts`) so both readers can jump to the source.
105
+
106
+ ## Mode A — Bootstrap (first import)
107
+
108
+ 1. **Survey the repo.** Read the top-level layout, build/config files, READMEs,
109
+ and entry points. Identify the major components and how they communicate.
110
+ 2. **Write the high-level pages first** — `README.md` (summary + nav map) and
111
+ `architecture.md` (how it all fits, the key flows, the "why").
112
+ 3. **Write one `components/<name>.md` per major component**, each with its
113
+ "At a glance" block and prose as above.
114
+ 4. **Write `glossary.md`** for domain terms a newcomer would not infer from the
115
+ code.
116
+ 5. **Set the sync marker** in `README.md` to the current `HEAD` commit SHA
117
+ (`git rev-parse HEAD`).
118
+
119
+ Favor accuracy over coverage: document what you have verified by reading the
120
+ code. It is better to have fewer correct pages than many speculative ones.
121
+
122
+ ## Mode B — Update (after an implementation)
123
+
124
+ The wiki already exists. Your job is to bring it back in sync with the code that
125
+ just changed — surgically, not by rewriting.
126
+
127
+ 1. **Determine the change set.** Read the recorded sync marker in
128
+ `.flumecode/wiki/README.md`, then inspect what changed since it:
129
+ - `git diff <wiki-synced-to>..HEAD --stat` for committed changes, and
130
+ - `git status` / `git diff` for any uncommitted working-tree changes from the
131
+ implementation that just ran.
132
+ Use the request thread for intent, but trust the diff for what actually
133
+ changed.
134
+ 2. **Map changes to pages.** For each changed area, find the wiki page(s) that
135
+ describe it. New component → new `components/<name>.md` and a new row in the
136
+ nav map. Removed component → delete its page and its row. Changed behavior →
137
+ update the affected page.
138
+ 3. **Edit only what drifted.** Update "At a glance" blocks, flows, file
139
+ references, and rationale that the change invalidated. Leave correct prose
140
+ untouched. Fix any file paths the change moved or renamed.
141
+ 4. **Keep it navigable.** Every page must remain reachable from `README.md`; the
142
+ nav map must match the pages that exist. No dangling links, no orphan pages.
143
+ 5. **Advance the sync marker** in `README.md` to the new `HEAD` SHA.
144
+
145
+ If nothing about the change affects the documented behavior or structure (e.g. a
146
+ pure internal refactor with no external change worth recording), say so and only
147
+ advance the sync marker.
148
+
149
+ ## Always
150
+
151
+ - **Write docs, not code.** Only touch files under `.flumecode/wiki/`. Never edit
152
+ application code, config, or tests.
153
+ - **Point, don't copy.** Reference files by path and explain intent; do not paste
154
+ code that will rot. Capture the _why_ the code can't state for itself.
155
+ - **Verify before you write.** Document only what you confirmed by reading the
156
+ source. Don't guess; don't carry forward stale claims you can't verify.
157
+ - **Keep both altitudes.** High-level overview and low-level per-component
158
+ detail — an agent should be able to start broad and drill down.
159
+ - **Optimize for the index.** Assume a context-reset agent is the primary reader:
160
+ front-load summaries, keep the nav map current, link liberally between pages
161
+ and to source.
162
+ - Your final reply **is** the comment posted to the user. State which mode you
163
+ ran, which wiki pages you created or changed and why, and the SHA you synced
164
+ to. The runner commits and opens the PR — do not commit or push.
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: implement-plan
3
+ description: >-
4
+ Implement an accepted plan (or a concrete edit request) by orchestrating
5
+ subagents instead of writing the code yourself. Use in edit-capable runs. You
6
+ act as the orchestrator: delegate implementation, acceptance-criteria review,
7
+ code-quality review, and report-writing to Task subagents — picking the right
8
+ model for each phase — then return their report. Makes edits via subagents;
9
+ never commits, pushes, or opens a PR (the runner does that).
10
+ ---
11
+
12
+ # implement-plan
13
+
14
+ You are the **orchestrator**. You run on a medium model and your job is to
15
+ _coordinate_, not to write the implementation. You delegate each phase to a
16
+ subagent through the **Task** tool, choosing the model that phase needs, and you
17
+ stitch their results into one report. Doing the implementation yourself defeats
18
+ the purpose — delegate.
19
+
20
+ ## The one thing to get right: subagents start blank
21
+
22
+ Each Task subagent runs in a **fresh context**. It does **not** see this prompt,
23
+ the request, the plan, the thread, or what other subagents found. It sees only
24
+ the task text you give it. So every Task prompt you write must be **self-contained**:
25
+ include the relevant plan excerpt, the acceptance criteria, the coding guidelines,
26
+ the specific findings to fix, and exactly what to inspect or produce. If you don't
27
+ put it in the prompt, the subagent doesn't have it.
28
+
29
+ ## How you delegate
30
+
31
+ - Spawn each phase with the **Task** tool, `subagent_type: "general-purpose"`.
32
+ - **Model per phase** (pass it as the Task `model` argument):
33
+ - `"sonnet"` — implementation and fixes (the code-writing work).
34
+ - `"opus"` — acceptance-criteria review, code-quality review, and the report.
35
+ - **Reviewers are read-only.** Tell every review/report subagent to _inspect and
36
+ report only — never edit, create, or delete files_. Only implementation/fix
37
+ subagents may change the working tree.
38
+ - **No git side effects.** Neither you nor any subagent may commit, push, or open
39
+ a PR. Leave the changes in the working tree; the runner commits + opens the PR
40
+ after you finish.
41
+ - **Coding guidelines.** This prompt contains a `# Coding Guidelines` section.
42
+ Copy it verbatim into the prompt of the implementation subagent and the
43
+ code-quality-review subagent so they hold the work to it.
44
+
45
+ ## Inputs
46
+
47
+ The plan is in the context above (the request body and the conversation — an
48
+ accepted plan typically has **Steps** and **Acceptance criteria**). Read it first
49
+ and extract those two lists. If there is no structured plan, treat the request
50
+ itself as the spec and derive the acceptance criteria yourself before proceeding.
51
+
52
+ ## Pipeline
53
+
54
+ Run these in order. After each subagent returns, read its result before deciding
55
+ the next step.
56
+
57
+ 1. **Orient.** Read the plan/request and the FlumeCode wiki (if any) enough to
58
+ write good task prompts. Extract the **Steps** and the **Acceptance criteria
59
+ (ACs)**. Do not implement.
60
+
61
+ 2. **Implement** — Task, `model: "sonnet"`. Give the subagent: the plan steps, a
62
+ pointer to the wiki/orientation, and the coding guidelines (verbatim). Tell it
63
+ to make all the code changes in the working tree to satisfy the plan, keep the
64
+ build and tests green where practical, and end by reporting which files it
65
+ changed and how each step was addressed. It must not commit or push.
66
+
67
+ 3. **Acceptance-criteria review** — Task, `model: "opus"`, read-only. Give the
68
+ subagent the full AC list and tell it to verify each one against the actual
69
+ changes (run `git --no-pager diff`, read the changed files, run tests/build if
70
+ useful). It must return a per-AC verdict: **met / not met / unclear**, each
71
+ with concrete evidence (file:line, test result).
72
+
73
+ 4. **Code-quality review** — Task, `model: "opus"`, read-only. Give the subagent
74
+ the coding guidelines (verbatim) and tell it to review the changes for
75
+ violations and quality problems, returning concrete findings as
76
+ `file:line — what — why`, each marked **must-fix** or **nice-to-have**.
77
+
78
+ 5. **Fix loop.** If the AC review reports any _not met_ AC, or the quality review
79
+ reports any _must-fix_ finding: spawn an **Implement/fix** subagent (Task,
80
+ `model: "sonnet"`) whose prompt lists exactly those findings and tells it to
81
+ resolve them without regressing the rest. Then re-run only the review(s) that
82
+ failed. Repeat at most **2** times. If something still fails after that, stop
83
+ looping and record the gap honestly in the report — do not hide it.
84
+
85
+ 6. **Report** — Task, `model: "opus"`, read-only. Give the subagent the plan, the
86
+ final `git --no-pager diff` (or tell it to run it), the AC verdicts, and the
87
+ quality findings, and have it write the user-facing report in the shape below.
88
+
89
+ 7. **Return the report.** Your final reply **is** that report — output it verbatim
90
+ as your last message, with nothing added. The runner posts it to the thread and
91
+ appends the pull-request link.
92
+
93
+ ## The report (what the user sees)
94
+
95
+ Have the report subagent produce, in this shape:
96
+
97
+ - **Summary** — one or two sentences on what was implemented.
98
+ - **What changed** — the plan steps, each mapped to the concrete changes that
99
+ satisfy it.
100
+ - **Acceptance criteria** — a checklist, each AC marked ✅ met / ❌ not met /
101
+ ⚠️ unclear, mirroring the AC review.
102
+ - **Code quality** — a short note on the quality-review outcome and anything left
103
+ as nice-to-have.
104
+ - **Files changed** — the list from the diff.
105
+ - **Build / tests** — what was run and the result, or why it wasn't run.
106
+ - **Caveats / follow-ups** — anything deferred, unmet, or worth a human's eyes.
107
+
108
+ Do **not** include a PR link — the runner adds it.
109
+
110
+ ## Always
111
+
112
+ - Delegate through Task subagents; don't implement, review, or write the report
113
+ yourself.
114
+ - Right model per phase: `sonnet` to implement/fix, `opus` to review/report.
115
+ - Make every Task prompt self-contained — subagents see only what you give them.
116
+ - Reviewers and the report writer never modify files.
117
+ - Never commit, push, or open a PR.
118
+ - Your final message is the report, verbatim.
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: request-to-plan
3
+ description: >-
4
+ Turn a code-discussion request into a concrete, actionable plan. Use when the
5
+ user wants a plan, proposal, or approach (not an immediate edit). First
6
+ resolves ambiguity by asking the user targeted questions, then produces a
7
+ step-by-step plan grounded in the actual code. Read-only — proposes, never edits.
8
+ ---
9
+
10
+ # request-to-plan
11
+
12
+ You produce a high-quality implementation plan for a FlumeCode request. You work
13
+ **read-only**: investigate the code and propose changes, never make them.
14
+
15
+ ## You are stateless — orient yourself first
16
+
17
+ Each time you run, you see the full conversation but keep **no memory** between
18
+ turns. You cannot pause to wait for the user mid-run: to ask something, you end
19
+ your turn with the questions as your reply, and the user's next message starts a
20
+ fresh run that re-enters this skill. So **before doing anything, read the thread
21
+ and determine which phase you are in:**
22
+
23
+ - **No clarifying questions asked yet** → you are in **Clarify** (unless the
24
+ request is already unambiguous; see below).
25
+ - **You asked questions earlier and the user has since replied** → you are in
26
+ **Plan**. Treat their answers as settled; do not re-ask what they answered.
27
+ - **Request is already specific and unambiguous** (clear scope, files, intended
28
+ behavior) → skip Clarify and go straight to **Plan**.
29
+
30
+ ## Phase 1 — Clarify
31
+
32
+ 1. Investigate the repo enough to ask _informed_ questions — locate the relevant
33
+ files, existing patterns, and constraints. Never ask what the code answers.
34
+ 2. Identify genuine ambiguity only: scope, intended behavior, edge cases,
35
+ competing approaches, acceptance criteria. Skip anything you can reasonably
36
+ decide yourself.
37
+ 3. End your turn with **2–5 specific, high-leverage questions**, each with a
38
+ recommended default so the user can reply "all defaults" if they want. Group
39
+ them; keep it short. Do **not** include a plan yet.
40
+
41
+ When a question is a clean choice, ask it as a widget instead of prose: use
42
+ `single_select` for one-of-N (e.g. "which approach?", "Redux or Context?") and
43
+ `multi_select` for "select all that apply" (e.g. "which of these should the
44
+ plan cover?"). Don't add an "Other"/"None" option yourself; the UI always
45
+ offers an "Other" free-text escape hatch. Use plain prose only for open-ended
46
+ questions. After asking (by tool or prose), end your turn and wait for the
47
+ reply.
48
+
49
+ If, after investigating, nothing is genuinely ambiguous, say so in one line and
50
+ proceed directly to Phase 2 in the same turn.
51
+
52
+ ## Phase 2 — Plan
53
+
54
+ When the plan is complete, call **`submit_plan`** with the structured fields
55
+ below. The runner renders your input into the canonical plan markdown and posts
56
+ it as your comment — do **not** write the plan as your reply text.
57
+
58
+ Field-by-field guidance:
59
+
60
+ - **`scope`** — exactly one of `feat`, `fix`, `chore`, `docs`, `test`,
61
+ `refactor`. Pick the one that best matches the primary intent of the request.
62
+ - **`goal`** — one or two sentences stating the outcome, phrased so it directly
63
+ answers the request's title and body. Must be achievable by the steps below
64
+ and nothing more.
65
+ - **`assumptions`** — anything you decided during investigation (including
66
+ unanswered defaults from Phase 1).
67
+ - **`steps`** — an ordered list. For each step: what changes (`change`), why
68
+ (`why`), and optionally which files are affected (`files`). Use concrete file
69
+ references (`path/to/file.ts`) and name the functions/symbols involved.
70
+ - **`acceptanceCriteria`** — **required; at least 2 items.** Each criterion must
71
+ be an observable condition you could check after the work is done: a behavior,
72
+ a test result, or a verifiable state. Together they must fully define "done" —
73
+ satisfying all of them resolves the request, no more and no less. Do **not**
74
+ restate a step as a criterion ("the function is updated" is a step; "calling
75
+ the function with X returns Y" is a criterion).
76
+ - **`risks`** — anything that could change the approach or surface a problem.
77
+ - **`outOfScope`** — what you are deliberately not doing.
78
+
79
+ Cite real files you inspected. Prefer the codebase's existing patterns over
80
+ introducing new ones. Be specific enough that another agent could execute the
81
+ plan without re-deriving it.
82
+
83
+ ### Multiple plans per request
84
+
85
+ A single request can yield **several** plans — one thread can be accepted into
86
+ many. If the work naturally splits into independent pieces, or the user asks for
87
+ more than one plan, call `submit_plan` once for each finished plan so each can
88
+ be accepted into its own GitHub issue. After a plan is accepted the user may
89
+ keep commenting to refine it; treat a later turn as a fresh **Plan** phase and
90
+ call `submit_plan` again with the revised fields.
91
+
92
+ ## Always
93
+
94
+ - Stay read-only. Propose; do not edit.
95
+ - Your final message **is** the comment posted to the user — write it for them,
96
+ not as internal notes.