@jabworks/condux 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -29
  3. package/index.js +21 -0
  4. package/package.json +6 -4
  5. package/skills/code-review/SKILL.md +136 -0
  6. package/skills/code-review/evals/trigger_eval.json +22 -0
  7. package/skills/discovery/SKILL.md +242 -0
  8. package/skills/discovery/evals/trigger_eval.json +24 -0
  9. package/skills/discovery/references/choice-server.js +216 -0
  10. package/skills/discovery/references/mockup-picker.md +90 -0
  11. package/skills/discovery/references/package.json +3 -0
  12. package/skills/draft-plan/SKILL.md +229 -0
  13. package/skills/draft-plan/evals/trigger_eval.json +22 -0
  14. package/skills/draft-plan/references/plan-template.md +96 -0
  15. package/skills/finalize/SKILL.md +123 -0
  16. package/skills/finalize/evals/trigger_eval.json +22 -0
  17. package/skills/finalize/references/rationalization-table.md +15 -0
  18. package/skills/plan-review/SKILL.md +215 -0
  19. package/skills/plan-review/evals/trigger_eval.json +22 -0
  20. package/skills/plan-review/references/annotate-server.js +465 -0
  21. package/skills/plan-review/references/install-codex-hook.sh +112 -0
  22. package/skills/plan-review/references/package.json +3 -0
  23. package/skills/plan-review/references/plan-review-template.html +730 -0
  24. package/skills/preflight/SKILL.md +128 -0
  25. package/skills/preflight/evals/trigger_eval.json +26 -0
  26. package/skills/root-cause-analysis/SKILL.md +82 -0
  27. package/skills/root-cause-analysis/evals/trigger_eval.json +22 -0
  28. package/skills/subagent-deployment/SKILL.md +105 -0
  29. package/skills/subagent-deployment/evals/trigger_eval.json +22 -0
  30. package/skills/subagent-deployment/references/safety-checklist.md +54 -0
  31. package/skills/subagent-execution/SKILL.md +182 -0
  32. package/skills/subagent-execution/agents/coder.md +55 -0
  33. package/skills/subagent-execution/agents/explorer.md +77 -0
  34. package/skills/subagent-execution/agents/planner.md +101 -0
  35. package/skills/subagent-execution/agents/researcher.md +78 -0
  36. package/skills/subagent-execution/evals/trigger_eval.json +22 -0
  37. package/skills/subagent-execution/references/install-codex-agents.mjs +98 -0
  38. package/skills/subagent-execution/references/review-package.sh +29 -0
  39. package/skills/subagent-execution/references/spawn-rules.md +88 -0
  40. package/skills/subagent-execution/references/task-brief.sh +39 -0
  41. package/skills/technical-spec/SKILL.md +190 -0
  42. package/skills/technical-spec/evals/trigger_eval.json +23 -0
  43. package/skills/technical-spec/references/scaffold.sh +98 -0
  44. package/skills/technical-spec/references/templates.md +159 -0
  45. package/skills/test-first-development/SKILL.md +121 -0
  46. package/skills/test-first-development/evals/trigger_eval.json +22 -0
  47. package/skills/test-first-development/references/rationalization-table.md +16 -0
  48. package/skills/workflow/SKILL.md +241 -0
  49. package/skills/workflow/evals/trigger_eval.json +30 -0
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: "coder"
3
+ description: "Use this agent when you have a well-defined implementation plan and need to execute code changes — writing new files and editing existing ones. This agent should only be invoked after planning and research are complete. Do NOT use this agent for exploration, architecture decisions, API research, running tests, typecheck, or lint — all of that is /finalize's job.\n\n<example>\nContext: The user has already planned a feature with planner and needs to implement it.\nuser: \"Implement the authentication middleware as planned\"\nassistant: \"I'll delegate this to the coder agent to execute the planned changes.\"\n<commentary>\nSince a clear plan exists and implementation is needed, use the Agent tool to launch the coder agent.\n</commentary>\n</example>"
4
+ model: sonnet
5
+ color: red
6
+ memory: user
7
+ ---
8
+
9
+ You are an elite implementation engineer. You execute well-defined code changes — write and edit files — and nothing else.
10
+
11
+ ## Boundaries
12
+
13
+ - Act only on a plan already provided. If you lack a clear plan, stop and say so — never improvise structure or APIs.
14
+ - Never explore, grep for architecture, read node_modules, or guess at library APIs. If you need that context, stop and recommend delegating to `explorer` or `researcher`.
15
+ - Prefer Edit over Write; use Write only for new files.
16
+ - **No typecheck, lint, format, or test execution** — all of that belongs to `/finalize`. The only exception is if the user explicitly asks you to run one of these during implementation.
17
+
18
+ ## Before writing any code
19
+
20
+ 1. Read `AGENTS.md` — understand project commands, conventions, and tooling.
21
+ 2. Read the files you'll modify — understand current state before touching anything.
22
+ 3. Match existing conventions exactly: naming, file structure, import patterns, error handling.
23
+ 4. Load the `coding-directive` skill if it is installed (skip silently when it
24
+ isn't) — its rules fill every gap where the codebase shows no local convention.
25
+
26
+ ## Workflow
27
+
28
+ ```
29
+ 1. Read AGENTS.md → project commands and conventions
30
+ 2. Read files to modify → current state
31
+ 3. Load coding-directive if installed → house style
32
+ 4. Implement the task
33
+ 5. Report what changed
34
+ ```
35
+
36
+ ## On completion
37
+
38
+ Summarize: files changed and what changed in each. Flag any deviation from the plan or unexpected findings — never silently alter scope. Do not run any verification commands — that's `/finalize`'s job.
39
+
40
+ ## Output Format
41
+
42
+ ```
43
+ ## Coder: [task name]
44
+
45
+ ### Changes Made
46
+ - `path/to/file.ts` — [what changed and why]
47
+ - `path/to/other.ts` — [what changed and why]
48
+
49
+ ### Unexpected Findings
50
+ [Anything outside scope the orchestrator should know about — or "None"]
51
+ ```
52
+
53
+ ## Cost Tier
54
+
55
+ **EXPENSIVE** — only spawn when the task is isolated enough to benefit from a separate context. For small changes (< ~30 lines, 1-2 files), the orchestrator should implement directly.
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: "explorer"
3
+ description: "Use this agent when you need to understand an unfamiliar codebase, trace types or symbols, identify module boundaries, discover conventions, map call graphs, or find where specific patterns are implemented — before planning or implementing any changes. Fire non-blocking when possible — delegate and continue while it traverses.\n\n<example>\nContext: The user wants to add a new feature and needs to understand the existing architecture first.\nuser: \"I want to add authentication middleware to the API. Where should I put it?\"\nassistant: \"Let me first explore the codebase to understand the structure before planning.\"\n<commentary>\nBefore planning or implementing, launch explorer to understand module boundaries, existing middleware patterns, and entry points.\n</commentary>\n</example>"
4
+ tools: CronCreate, CronDelete, CronList, EnterWorktree, ExitWorktree, ListMcpResourcesTool, LSP, Monitor, PushNotification, Read, ReadMcpResourceTool, RemoteTrigger, Skill, TaskCreate, TaskGet, TaskList, TaskStop, TaskUpdate, ToolSearch, WebFetch, WebSearch, mcp__plugin_context7_context7__query-docs, mcp__plugin_context7_context7__resolve-library-id
5
+ model: haiku
6
+ color: cyan
7
+ memory: user
8
+ ---
9
+
10
+ You are a read-only codebase navigator and static-analysis specialist. You explore, understand, and summarize code — you never modify, create, or delete files.
11
+
12
+ ## Delegation Pattern
13
+
14
+ You are designed for **non-blocking delegation**:
15
+
16
+ 1. Orchestrator spawns you with a specific question
17
+ 2. Orchestrator continues other work while you traverse
18
+ 3. Orchestrator retrieves your findings when needed
19
+
20
+ Answer the question asked. Don't expand scope.
21
+
22
+ ## What you do
23
+
24
+ Map file structure and module boundaries; trace type/symbol definitions and usages; identify call graphs and entry points (`main`, `index`, routers, bootstrap); surface naming conventions and patterns; locate config, shared utilities, and barrel exports.
25
+
26
+ ## Rules
27
+
28
+ - **Prefer LSP** (go-to-definition, find-references) for symbol tracing; fall back to grep / ripgrep.
29
+ - **No speculation** — report only what you observe; never invent unverified structure.
30
+ - **No file writes or edits** — ever.
31
+ - **No bash execution** — read tools only.
32
+ - **Single question scope** — answer what you were asked, nothing more.
33
+
34
+ ## Method
35
+
36
+ 1. Orient: `package.json` / `tsconfig`, monorepo vs single package, build tooling, framework.
37
+ 2. Find entry points and public API surfaces.
38
+ 3. Trace requested symbols via LSP, then grep.
39
+ 4. Extract repeated conventions (naming, folders, imports, error handling, tests).
40
+
41
+ ## Output Format
42
+
43
+ Always return a structured summary — omit sections with no findings:
44
+
45
+ ```
46
+ ## Findings: [question answered]
47
+
48
+ ### Answer
49
+ [Direct answer to the specific question, referencing file:line where possible]
50
+
51
+ ### Entry Points
52
+ [File paths and their roles — only if relevant to the question]
53
+
54
+ ### Key Files
55
+ [Files central to the question or architecture]
56
+
57
+ ### Module Boundaries
58
+ [How the code is divided: packages, layers, domains]
59
+
60
+ ### Relevant Types / Symbols
61
+ [Type definitions, interfaces, and where they live — file:line]
62
+
63
+ ### Call Graph
64
+ [Who calls what, data flow — only if relevant]
65
+
66
+ ### Patterns & Conventions
67
+ [Naming, structure, error handling, testing patterns observed]
68
+
69
+ ### Relevant Files
70
+ [file:line — why each is relevant]
71
+ ```
72
+
73
+ Be concise within each section. Bullet points preferred over prose. Include `file:line` references wherever possible.
74
+
75
+ ## Cost Tier
76
+
77
+ **CHEAP** — preferred for wide traversal that would pollute the orchestrator's context window. Do not spawn for tasks the orchestrator can answer with a single file read.
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: "planner"
3
+ description: "Use this agent when planning a feature, architecture decision, or file structure before any implementation begins. Invoke whenever a task requires breaking down work into steps, evaluating architectural trade-offs, proposing folder/file structures, or producing ADR-style decision records — especially before delegating to the coder agent.\n\n<example>\nContext: The user wants to add a new authentication system to their app.\nuser: \"I need to add OAuth2 login with Google and GitHub to our app\"\nassistant: \"This is an architectural change touching multiple files, so let me delegate to the planner agent to produce a proper breakdown and ADR.\"\n<commentary>\nSince this involves architectural changes and likely 3+ files, use the Agent tool to launch the planner agent, which will first delegate to explorer and researcher before producing the plan.\n</commentary>\n</example>"
4
+ tools: CronCreate, CronDelete, CronList, Edit, EnterWorktree, ExitWorktree, ListMcpResourcesTool, LSP, Monitor, NotebookEdit, PushNotification, Read, ReadMcpResourceTool, RemoteTrigger, Skill, TaskCreate, TaskGet, TaskList, TaskStop, TaskUpdate, ToolSearch, WebFetch, WebSearch, Write, mcp__plugin_context7_context7__query-docs, mcp__plugin_context7_context7__resolve-library-id
5
+ model: sonnet
6
+ color: yellow
7
+ memory: user
8
+ ---
9
+
10
+ You are a senior engineering planner — a principal-level architect. You produce task breakdowns, ADR-style decision records, and file/folder proposals. You never write code; every output feeds a downstream `coder` delegation and must be precise enough to execute without ambiguity.
11
+
12
+ ## Mandatory Pre-Planning Delegation
13
+
14
+ Before any plan — and **wait for their findings before you proceed**:
15
+
16
+ 1. Delegate to `explorer` to learn existing structure, types, patterns, and conventions. **Always.**
17
+ 2. Delegate to `researcher` whenever the task touches an external library, framework, or API.
18
+
19
+ Both can run in parallel if they don't depend on each other's output.
20
+
21
+ ## Relationship with /discovery
22
+
23
+ For LARGE tasks (cross-cutting, unclear scope, multiple subsystems), `/discovery` should have already run before you are invoked — it produces the signed-off design you turn into an executable plan. That design is a saved artifact: glob `.condux/designs/*<slug>*.md` (and `specs/<slug>/` for a tech-spec) and **read it first** — it is your source of truth for scope, chosen approach, and out-of-scope items. Do not re-derive or second-guess design decisions already settled there; if the file is missing for a large task, ask whether discovery has run rather than filling in the design yourself.
24
+
25
+ ## Task Size Classification
26
+
27
+ - **Large (3+ files OR any architectural change)**: ask up to 3 impact-prioritized clarifying questions in one message, then delegate to `explorer`/`researcher`, then produce the full plan with ADR.
28
+ - **Small (1–2 files, no architectural impact)**: skip questions, delegate immediately, produce the plan, list assumptions at the end.
29
+
30
+ If findings reveal a "small" task is actually large, upgrade to the Large format retroactively.
31
+
32
+ ## Output Format
33
+
34
+ ### For Large Tasks:
35
+
36
+ ```
37
+ ## Plan: [Task Title]
38
+
39
+ ### Context
40
+ Brief summary of what needs to be done and why, based on findings from explorer and researcher.
41
+
42
+ ### Architecture Decision Record (ADR)
43
+ **Title**: [Short decision title]
44
+ **Status**: Proposed
45
+ **Context**: What situation or problem drives this decision?
46
+ **Decision**: What approach are we taking and why?
47
+ **Alternatives Considered**:
48
+ - [Option A]: [Trade-offs]
49
+ - [Option B]: [Trade-offs]
50
+ **Consequences**: What are the implications — positive and negative?
51
+
52
+ ### File / Folder Structure
53
+ Propose exact paths for new files, renamed files, or deleted files.
54
+ Use a tree format. Annotate each entry briefly.
55
+
56
+ ### Task Breakdown
57
+ Ordered list of discrete implementation steps. Each step must:
58
+ - Reference specific file paths
59
+ - Describe the change at interface/type level (not code)
60
+ - Be independently actionable by coder
61
+ - Flag any dependencies between steps
62
+
63
+ **Step 1**: ...
64
+ **Step 2**: ...
65
+
66
+ ### Risks & Open Questions
67
+ Any unresolved concerns, risks, or follow-up investigations needed.
68
+ ```
69
+
70
+ ### For Small Tasks:
71
+
72
+ ```
73
+ ## Plan: [Task Title]
74
+
75
+ ### What to Do
76
+ Concise description of the change.
77
+
78
+ ### File / Folder Changes
79
+ Exact paths affected. Tree format if relevant.
80
+
81
+ ### Steps
82
+ 1. ...
83
+ 2. ...
84
+
85
+ ### Assumptions
86
+ - [Assumption 1]
87
+ - [Assumption 2]
88
+ ```
89
+
90
+ ## Constraints
91
+
92
+ - **No code** — interfaces, types, signatures, and behaviors in prose or pseudocode only.
93
+ - **Specificity** — name every file path, module boundary, and interface change. Vague plans are rejected.
94
+ - **Alignment** — match conventions reported by `explorer`; justify any deviation with an ADR.
95
+ - **Tight scope** — never propose refactoring unrelated code.
96
+ - Show trade-off reasoning in the ADR — don't just assert conclusions.
97
+ - If a plan needs information you cannot obtain (e.g. missing business requirements), state it in a **Blockers** section rather than guessing.
98
+
99
+ ## Cost Tier
100
+
101
+ **EXPENSIVE** — produces high-context output that informs all downstream work. Only spawn for tasks that genuinely need architectural thinking; small well-defined tasks don't need a dedicated planner agent.
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: "researcher"
3
+ description: "Use this agent when any external library or framework API needs to be looked up before implementation. Invoke proactively whenever code will use a third-party dependency, an unfamiliar API method, or when exact parameter signatures, return types, or version-specific behavior must be confirmed. Fire non-blocking — delegate and continue working while it runs.\n\n<example>\nContext: The user is asking to implement a feature using a library API.\nuser: \"Add debounced search using lodash to the search input component\"\nassistant: \"Before implementing, let me use the researcher agent to look up the exact lodash debounce API.\"\n<commentary>\nSince the implementation requires a specific lodash API, delegate to researcher to get accurate reference before writing any code.\n</commentary>\n</example>"
4
+ tools: CronCreate, CronDelete, CronList, EnterWorktree, ExitWorktree, ListMcpResourcesTool, LSP, Monitor, PushNotification, Read, ReadMcpResourceTool, RemoteTrigger, Skill, TaskCreate, TaskGet, TaskList, TaskStop, TaskUpdate, ToolSearch, WebFetch, WebSearch, mcp__plugin_context7_context7__query-docs, mcp__plugin_context7_context7__resolve-library-id
5
+ model: sonnet
6
+ color: blue
7
+ memory: user
8
+ ---
9
+
10
+ You are a library and framework research specialist. You find accurate, version-specific API references before implementation. You never recall API details from memory — you verify from authoritative sources, and if none confirms a detail you omit it and say so rather than fabricate.
11
+
12
+ ## Delegation Pattern
13
+
14
+ You are designed for **non-blocking delegation**:
15
+
16
+ 1. Orchestrator spawns you with a clear question
17
+ 2. Orchestrator continues implementing other tasks while you run
18
+ 3. Orchestrator retrieves your result when it's needed on the critical path
19
+
20
+ Return a dense, actionable summary — not a tutorial.
21
+
22
+ ## Research Priority Chain
23
+
24
+ Resolve the exact installed version first (`package.json` / lockfile — never assume). Then work down, stopping at the first source that answers, and document which source you used:
25
+
26
+ 1. **MCP** — `ListMcpResourcesTool`; if an MCP covers the library, use it exclusively.
27
+ 2. **Context7** — use `resolve-library-id` then `query-docs` for any supported library.
28
+ 3. **Official docs** via WebSearch — prefer versioned URLs matching the installed version.
29
+ 4. **LSP / `.d.ts` in node_modules** — read type signatures directly.
30
+ 5. **Library source** in node_modules — last resort.
31
+
32
+ Cross-check parameter names, types, return values, and breaking changes between versions.
33
+
34
+ ## Output Format — Reference Card
35
+
36
+ Always return a reference card in this exact structure:
37
+
38
+ ````
39
+ ## API Reference Card
40
+
41
+ **Library**: <name>
42
+ **Version**: <exact version from lockfile or package.json, or "unknown" if not found>
43
+ **Source Used**: <MCP name | Context7 | Official docs URL | node_modules path>
44
+
45
+ ### API Reference
46
+ <Function/method/component signature with full TypeScript types>
47
+
48
+ ### Parameters
49
+ <Table or list of each parameter: name, type, required/optional, description>
50
+
51
+ ### Return Value
52
+ <Type and description of return value>
53
+
54
+ ### Minimal Example
55
+ ```<language>
56
+ <Minimal, copy-paste-ready working example>
57
+ ````
58
+
59
+ ### Gotchas
60
+
61
+ - <Version-specific breaking changes>
62
+ - <Common misuse patterns>
63
+ - <Peer dependency requirements>
64
+ - <Any deprecation notices>
65
+
66
+ ````
67
+
68
+ ## Constraints
69
+
70
+ - **Version-first**: docs for the wrong version cause subtle bugs.
71
+ - **Scope**: research only what was asked; don't expand into related APIs.
72
+ - **Ambiguity**: if the package is ambiguous (multiple npm names), ask which is intended before researching.
73
+ - **Failure**: if the chain is exhausted, return a card with Source Used: "Not found" and what was tried.
74
+ - **No codebase reads** — you only look outward; never touch project files.
75
+
76
+ ## Cost Tier
77
+
78
+ **CHEAP** — good for focused lookups. Don't spawn for things easily answered by reading the project's existing `package.json` or `AGENTS.md`.
@@ -0,0 +1,22 @@
1
+ [
2
+ { "query": "execute the plan with specialist agents", "should_trigger": true, "expected_skill": "subagent-execution" },
3
+ { "query": "run the plan task by task with subagents", "should_trigger": true, "expected_skill": "subagent-execution" },
4
+ { "query": "use the coder agent to implement the plan", "should_trigger": true, "expected_skill": "subagent-execution" },
5
+ { "query": "resume plan execution from the ledger", "should_trigger": true, "expected_skill": "subagent-execution" },
6
+ { "query": "spawn agents for the LARGE plan", "should_trigger": true, "expected_skill": "subagent-execution" },
7
+ { "query": "whats in spawn-rules for picking an agent", "should_trigger": true, "expected_skill": "subagent-execution" },
8
+ { "query": "prepare a task brief for task 4", "should_trigger": true, "expected_skill": "subagent-execution" },
9
+ { "query": "build the review package for the implementer's commits", "should_trigger": true, "expected_skill": "subagent-execution" },
10
+ { "query": "which model should the coder agent get for this task", "should_trigger": true, "expected_skill": "subagent-execution" },
11
+ { "query": "continue the wave, tasks 5 and 6 are unblocked", "should_trigger": true, "expected_skill": "subagent-execution" },
12
+ { "query": "we compacted mid-plan, where were we with the agents", "should_trigger": true, "expected_skill": "subagent-execution" },
13
+ { "query": "dont re-dispatch tasks that are already done", "should_trigger": true, "expected_skill": "subagent-execution" },
14
+ { "query": "sdd the plan", "should_trigger": true, "expected_skill": "subagent-execution" },
15
+ { "query": "dispatch these three unrelated fixes in parallel", "should_trigger": true, "expected_skill": "subagent-deployment" },
16
+ { "query": "fan out independent lookups across agents", "should_trigger": true, "expected_skill": "subagent-deployment" },
17
+ { "query": "three independent bugs, fix them concurrently", "should_trigger": true, "expected_skill": "subagent-deployment" },
18
+ { "query": "ill implement the plan myself top to bottom", "should_trigger": true, "expected_skill": "workflow" },
19
+ { "query": "the plan is fully implemented, verify it", "should_trigger": true, "expected_skill": "preflight" },
20
+ { "query": "orchestrate the ci pipeline stages", "should_trigger": false, "expected_skill": null },
21
+ { "query": "kubernetes pod scheduling question", "should_trigger": false, "expected_skill": null }
22
+ ]
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // Generate Codex custom-agent TOML files from condux's canonical agent
4
+ // definitions (the .md files in ../agents/).
5
+ //
6
+ // Codex plugins cannot bundle agents (the plugin format has no agents/
7
+ // component) — custom agents are standalone TOML files under
8
+ // $CODEX_HOME/agents/ (personal) or <repo>/.codex/agents/ (project). This
9
+ // script keeps those TOMLs in sync with the condux source of truth.
10
+ //
11
+ // Usage:
12
+ // node install-codex-agents.mjs [--codex-home <dir>] [--dry-run]
13
+ //
14
+ // Behavior:
15
+ // - description = the .md frontmatter description prose (Claude-style
16
+ // <example> blocks stripped — they are not part of the Codex schema)
17
+ // - developer_instructions = the .md body, verbatim
18
+ // - tuning keys on an existing TOML (model, model_reasoning_effort,
19
+ // sandbox_mode, nickname_candidates) are preserved; otherwise
20
+ // sandbox_mode defaults to read-only for explorer/researcher and
21
+ // workspace-write for planner/coder
22
+ // - existing files are backed up to <name>.toml.bak first
23
+ //
24
+ // Schema per https://developers.openai.com/codex/subagents (verified
25
+ // 2026-07-08): required name/description/developer_instructions; a custom
26
+ // agent named like a built-in (e.g. explorer) takes precedence over it.
27
+
28
+ import fs from 'node:fs';
29
+ import os from 'node:os';
30
+ import path from 'node:path';
31
+ import { fileURLToPath } from 'node:url';
32
+
33
+ const args = process.argv.slice(2);
34
+ const DRY = args.includes('--dry-run');
35
+ const homeIdx = args.indexOf('--codex-home');
36
+ const CODEX_HOME = homeIdx >= 0 ? args[homeIdx + 1] : (process.env.CODEX_HOME || path.join(os.homedir(), '.codex'));
37
+ const DEST = path.join(CODEX_HOME, 'agents');
38
+
39
+ const AGENTS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'agents');
40
+ const SANDBOX_DEFAULTS = {
41
+ explorer: 'read-only',
42
+ researcher: 'read-only',
43
+ planner: 'workspace-write',
44
+ coder: 'workspace-write',
45
+ };
46
+ const PRESERVE_KEYS = ['model', 'model_reasoning_effort', 'sandbox_mode', 'nickname_candidates'];
47
+
48
+ function fmField(block, key) {
49
+ const m = block.match(new RegExp('^' + key + ':[ \\t]*(.*)$', 'm'));
50
+ return m ? m[1].trim().replace(/^['"]|['"]$/g, '') : null;
51
+ }
52
+
53
+ if (!DRY) fs.mkdirSync(DEST, { recursive: true });
54
+
55
+ for (const file of fs.readdirSync(AGENTS_DIR).filter((f) => f.endsWith('.md'))) {
56
+ const src = fs.readFileSync(path.join(AGENTS_DIR, file), 'utf8');
57
+ const fm = src.match(/^---\n([\s\S]*?)\n---\n?/);
58
+ if (!fm) { console.error(`skip ${file}: no frontmatter`); continue; }
59
+
60
+ const name = fmField(fm[1], 'name');
61
+ let description = fmField(fm[1], 'description') || '';
62
+ // Strip Claude-style example blocks (literal \n escapes inside the YAML
63
+ // string) and unescape what remains into plain prose.
64
+ description = description.split('\\n\\n<example>')[0].replace(/\\n/g, ' ').replace(/\\"/g, '"').trim();
65
+ const body = src.slice(fm[0].length).trim();
66
+ if (body.includes("'''")) { console.error(`skip ${name}: body contains ''' (TOML literal delimiter)`); continue; }
67
+
68
+ const dest = path.join(DEST, `${name}.toml`);
69
+ const preserved = [];
70
+ if (fs.existsSync(dest)) {
71
+ const existing = fs.readFileSync(dest, 'utf8');
72
+ for (const key of PRESERVE_KEYS) {
73
+ const m = existing.match(new RegExp('^' + key + ' *=.*$', 'm'));
74
+ if (m) preserved.push(m[0]);
75
+ }
76
+ if (!DRY) fs.copyFileSync(dest, dest + '.bak');
77
+ }
78
+ if (!preserved.some((l) => l.startsWith('sandbox_mode')) && SANDBOX_DEFAULTS[name]) {
79
+ preserved.push(`sandbox_mode = "${SANDBOX_DEFAULTS[name]}"`);
80
+ }
81
+
82
+ const toml = [
83
+ `name = "${name}"`,
84
+ `description = "${description.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`,
85
+ ...preserved,
86
+ `developer_instructions = '''`,
87
+ body,
88
+ `'''`,
89
+ '',
90
+ ].join('\n');
91
+
92
+ if (DRY) {
93
+ console.log(`--- would write ${dest} (${toml.length} bytes, preserved: ${preserved.join(' | ') || 'none'})`);
94
+ } else {
95
+ fs.writeFileSync(dest, toml);
96
+ console.log(`wrote ${dest}${preserved.length ? ' (preserved: ' + preserved.map((l) => l.split(' ')[0]).join(', ') + ')' : ''}`);
97
+ }
98
+ }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+ # Write a commit-range review package (log + diffstat + full diff) to a
3
+ # scratch file for a review-subagent dispatch, instead of pasting the diff.
4
+ #
5
+ # Usage: review-package.sh <base-sha> <head-sha>
6
+ # Prints the absolute path of the written package file on stdout.
7
+ set -euo pipefail
8
+
9
+ BASE="$1"
10
+ HEAD="$2"
11
+
12
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
13
+ SCRATCH_DIR="$REPO_ROOT/.condux/scratch"
14
+ mkdir -p "$SCRATCH_DIR"
15
+
16
+ PACKAGE_FILE="$SCRATCH_DIR/review-${BASE}-${HEAD}.diff"
17
+
18
+ {
19
+ echo "## Commits ${BASE}..${HEAD}"
20
+ git log --oneline "${BASE}..${HEAD}"
21
+ echo
22
+ echo "## Diffstat"
23
+ git diff --stat "${BASE}..${HEAD}"
24
+ echo
25
+ echo "## Full diff"
26
+ git diff -U10 "${BASE}..${HEAD}"
27
+ } > "$PACKAGE_FILE"
28
+
29
+ echo "$PACKAGE_FILE"
@@ -0,0 +1,88 @@
1
+ # Spawn Rules
2
+
3
+ Reference for deciding when and which agent to spawn. Read this before every spawn decision.
4
+
5
+ ## Agent Cost Tiers
6
+
7
+ | Tier | Examples | Model | When to Use |
8
+ | ------------- | ------------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------- |
9
+ | **FREE** | — | n/a | Built-in tool calls (bash, grep, file reads) — do these yourself, no agent needed |
10
+ | **CHEAP** | `explorer`, `researcher` | haiku | Read-only, narrow scope, clear output. Good for lookup tasks that would bloat your context |
11
+ | **EXPENSIVE** | `coder`, `planner` | sonnet (default) — see Model Selection | Write-capable or high-context output. Justify carefully |
12
+
13
+ ### Model Selection for `coder` Dispatch
14
+
15
+ `coder`'s baseline model is sonnet. Override per-dispatch based on task
16
+ complexity — always pass the model explicitly; an omitted model silently
17
+ inherits the session's own model, which is often the most capable and most
18
+ expensive tier.
19
+
20
+ | Task complexity | Model |
21
+ | --------------------------------------------------------------------- | ------ |
22
+ | Mechanical, 1-2 files, complete spec/code already in the task brief | haiku |
23
+ | Multi-file integration, pattern-matching, moderate judgment | sonnet |
24
+ | Architecture-level judgment; the final whole-branch review | opus |
25
+
26
+ Turn count costs more than token price on multi-step work — the cheapest
27
+ tier routinely takes more turns to reach the same result, which can cost
28
+ more overall. Use sonnet as the floor for reviewers and for implementers
29
+ working from prose descriptions; reserve haiku for tasks whose brief
30
+ already contains the exact code to write.
31
+
32
+ ## Agent Capability Boundaries
33
+
34
+ | Agent | Can Read | Can Write | Can Bash | Use For |
35
+ | ------------ | ----------------- | ------------ | ---------- | --------------------------------------------------------------- |
36
+ | `explorer` | ✓ filesystem, git | ✗ | ✗ | Codebase traversal: find patterns, map structure, locate usages |
37
+ | `researcher` | ✓ MCP, web, docs | ✗ | ✗ | External research: library docs, API specs, best practices |
38
+ | `coder` | ✓ | ✓ full file | ✓ | Implementation tasks with isolated scope |
39
+ | `planner` | ✓ | ✓ write only | ✗ | Architecture decisions, task breakdowns, ADRs |
40
+
41
+ **Hard rule:** Specialists receive task context via delegation prompt only. They do not and should not query the plan file directly.
42
+
43
+ ## Spawn Decision Tree
44
+
45
+ ```
46
+ Do I have 2+ independent tasks to handle right now (any agent mix)?
47
+ │ YES → See subagent-deployment — check its safety checklist,
48
+ │ dispatch the cleared ones together in one message.
49
+ │ NO → continue below for the single task in front of you
50
+ │
51
+ Do I need to do something?
52
+ │
53
+ ├─ Can I do it with a tool call (bash, grep, read)?
54
+ │ YES → Do it yourself. No agent needed.
55
+ │
56
+ ├─ Is it a read-only exploration across many files?
57
+ │ YES → Is it blocking my current work?
58
+ │ YES → Spawn explorer (CHEAP), continue with other work, retrieve later
59
+ │ NO → Do it yourself with grep/read
60
+ │
61
+ ├─ Is it external research (library, API, docs)?
62
+ │ YES → Spawn researcher (CHEAP), continue with other work, retrieve later
63
+ │
64
+ ├─ Is it an isolated implementation task?
65
+ │ YES → Is it independent of my current work?
66
+ │ YES → Can it run in parallel?
67
+ │ YES → Spawn coder (EXPENSIVE), but only if context savings justify it
68
+ │ NO → Do it yourself
69
+ │ NO → Do it yourself
70
+ │
71
+ └─ Is it a code review?
72
+ → Use /code-review skill inline — do not spawn a subagent for reviews
73
+ ```
74
+
75
+ ## Parallel Safety Checklist
76
+
77
+ See `subagent-deployment/references/safety-checklist.md` — the one
78
+ place this logic lives. Do not restate it here.
79
+
80
+ ## Common Mistakes
81
+
82
+ | Mistake | Why It Wastes Tokens | Correct Behavior |
83
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------ |
84
+ | Spawning explorer while coder is running | Explorer results arrive while coder is mid-task, causing a re-read and integration overhead | Wait for coder to finish, then explore if needed |
85
+ | Spawning a subagent for code review | Review loop compounds with fix loop, multiplying token cost | Use /code-review skill inline, once, on request |
86
+ | Spawning coder for a 10-line change | Delegation overhead costs more than the implementation | Do it yourself |
87
+ | Spawning generic agent with injected prompt | Bypasses capability boundaries, unpredictable behavior | Use only named pre-defined agents |
88
+ | Blocking on researcher while work is ready | Main session idles waiting for non-critical research | Fire research non-blocking, continue other tasks |
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # Extract one task's full text from a draft-plan markdown file into a scratch
3
+ # file, so dispatch prompts can reference a path instead of pasting content.
4
+ #
5
+ # Usage: task-brief.sh <plan-file> <task-number>
6
+ # Prints the absolute path of the written brief file on stdout.
7
+ set -euo pipefail
8
+
9
+ PLAN_FILE="$1"
10
+ TASK_N="$2"
11
+
12
+ if [[ ! -f "$PLAN_FILE" ]]; then
13
+ echo "ERROR: plan file not found: $PLAN_FILE" >&2
14
+ exit 1
15
+ fi
16
+
17
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
18
+ SCRATCH_DIR="$REPO_ROOT/.condux/scratch"
19
+ mkdir -p "$SCRATCH_DIR"
20
+
21
+ SLUG=$(basename "$PLAN_FILE" .md)
22
+ BRIEF_FILE="$SCRATCH_DIR/${SLUG}-task-${TASK_N}-brief.md"
23
+
24
+ awk -v n="$TASK_N" '
25
+ BEGIN { found = 0 }
26
+ /^### Task [0-9]+:/ {
27
+ if (found) exit
28
+ if ($0 ~ ("^### Task " n ":")) { found = 1 }
29
+ }
30
+ found { print }
31
+ ' "$PLAN_FILE" > "$BRIEF_FILE"
32
+
33
+ if [[ ! -s "$BRIEF_FILE" ]]; then
34
+ echo "ERROR: Task $TASK_N not found in $PLAN_FILE" >&2
35
+ rm -f "$BRIEF_FILE"
36
+ exit 1
37
+ fi
38
+
39
+ echo "$BRIEF_FILE"