@caiqueoak/flow 0.2.1 → 0.3.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,134 +1,58 @@
1
1
  # Flow
2
2
 
3
- Flow is a readability-first, agent-agnostic software-development workflow for coding agents. It maximizes autonomous delivery while keeping consequential product and engineering decisions explicit and approved.
3
+ Flow is a readability-first, agent-agnostic software delivery workflow for coding agents. It maximizes autonomous execution while keeping consequential product and engineering decisions under developer control.
4
4
 
5
- ## Workflow
6
-
7
- ```text
8
- idea / existing project
9
-
10
- global discovery
11
- (product + engineering + production constraints)
12
-
13
- independent consequential decisions, batched for approval
14
-
15
- production-capable MVP
16
-
17
- work DAG (feature + technical + maintenance)
18
-
19
- /flow-next
20
-
21
- plan → build → gates → review → fixes → done
22
-
23
- next safe work item automatically
24
- ```
25
-
26
- The agent continues until it reaches a consequential decision, external approval, unrecoverable blocker, or no ready work. Every requested decision must include **Decision, Context, Options, Recommended option, Why recommended, and Impact**.
27
-
28
- ## Project state
29
-
30
- ```text
31
- .flow/
32
- ├── config.yaml
33
- ├── PRD.md
34
- ├── ENGINEERING.md
35
- ├── SUMMARY.md
36
- ├── DECISIONS.yaml
37
- ├── BACKLOG.yaml
38
- ├── STATE.yaml
39
- ├── gates/
40
- └── work-items/
41
- ├── 001F-user-profile/
42
- │ ├── SPEC.md
43
- │ └── TASKS.yaml
44
- ├── 002T-production-baseline/
45
- │ ├── SPEC.md
46
- │ └── TASKS.yaml
47
- └── 003M-auth-reconciliation/
48
- ├── SPEC.md
49
- └── TASKS.yaml
50
- ```
51
-
52
- `F`, `T`, and `M` mean **feature**, **technical**, and **maintenance**. The numeric prefix is a stable readable sequence, not execution order. Dependencies determine execution. `work-items` is intentionally generic enough to cover all three kinds while remaining explicit to readers.
53
-
54
- ## CLI
55
-
56
- The CLI is intentionally small:
5
+ ## Install
57
6
 
58
7
  ```bash
59
- flow init
60
- flow install
61
- flow update
8
+ npm install --save-dev @caiqueoak/flow
9
+ npx flow init
62
10
  ```
63
11
 
64
- ### Requirements
65
-
66
- Flow requires Node.js 18 or newer.
67
-
68
- - `flow init` creates `.flow/`.
69
- - `flow install` installs the bundled skills into a coding-agent skill directory.
70
- - `flow update` fetches the latest published Flow package and replaces the installed Flow skills.
12
+ `flow init` is interactive, or use `--runtime codex,claude` in automation. Built-in adapters install the public `/flow` skill in `.codex/skills/flow/` or `.claude/skills/flow/`; a custom project-local skills directory is also available interactively.
71
13
 
72
- The CLI does **not** plan work, schedule tasks, invoke models, or orchestrate subagents. Those responsibilities stay in the skills and coding-agent runtime.
14
+ Skills are always installed inside the current project. Runtime integration directories never contain project state. If `.flow/` already exists, `flow init` only adds coding-agent integrations and updates `.flow/config.yaml`; it does not modify canonical project artifacts.
73
15
 
74
- Use an explicit skill directory when needed:
16
+ ## Project bootstrap
75
17
 
76
- ```bash
77
- flow install --target .agents/skills
78
- flow update --target .agents/skills
79
- ```
80
-
81
- Then start a project in the coding agent:
18
+ `flow init` creates only:
82
19
 
83
20
  ```text
84
- /flow-new "I want to build a diet app"
21
+ .flow/
22
+ └── config.yaml
85
23
  ```
86
24
 
87
- Normal operation after discovery is primarily:
25
+ It does not create a PRD, engineering guide, backlog, state, decisions, work items, gates, or templates. The `/flow` skill creates those artifacts only when they become valid canonical project information.
88
26
 
89
- ```text
90
- /flow-next
91
- ```
27
+ ## Workflow
92
28
 
93
- ## Parallelism
29
+ There is one public skill:
94
30
 
95
- ```yaml
96
- parallelism:
97
- strategy: maximum_safe
98
- max_concurrent_work_items: auto
99
- max_concurrent_tasks_per_work_item: auto
100
- delegation: allowed
31
+ ```text
32
+ /flow
101
33
  ```
102
34
 
103
- `auto` means the orchestrating agent chooses the largest set it can safely coordinate for the current scheduling cycle. It considers real dependencies, decision dependencies, likely write/contract overlap, uncertainty, runtime/tool capacity, merge risk, and **token/coordination overhead**. It must prefer fewer workers when additional concurrency would waste tokens or lower confidence.
104
-
105
- Before work starts, selected work items/tasks are marked `in_progress` with an execution ID. Another chat or agent must respect those claims and choose other ready work. Flow has no automatic claim timeout and never silently steals in-progress work.
35
+ Use `/flow <intent>` to start or change work, for example `/flow I want to build a diet app`. Use `/flow` with no extra input to continue from `.flow/STATE.md`.
106
36
 
107
- ## Token efficiency
37
+ Flow internally loads only the guidance needed for discovery, planning, build, review, or reconciliation. It asks only for consequential decisions and uses the largest safe degree of parallelism.
108
38
 
109
- Token efficiency is a framework constraint, not an afterthought. Skills must use the smallest sufficient context, avoid repeatedly loading historical documents, prefer targeted repository inspection, keep canonical artifacts concise, reuse accepted decisions, prefer deterministic gates to extra reviewer agents, and spawn subagents only when the expected parallel benefit exceeds duplicated context and coordination cost.
39
+ ## Update
110
40
 
111
- ## Updates
41
+ Updates are explicit:
112
42
 
113
- `flow update` is explicit and deterministic. The default project template also contains:
114
-
115
- ```yaml
116
- updates:
117
- check_on_run: true
118
- auto_update: false
43
+ ```bash
44
+ npx flow update
119
45
  ```
120
46
 
121
- For now, automatic checks are advisory rather than silently changing the installation. This avoids a framework update changing workflow behavior in the middle of active work. Projects can adopt a newer Flow version intentionally with `flow update`.
122
-
123
- ## Package
47
+ `flow update` updates the npm package and refreshes `/flow` for every coding agent configured in `.flow/config.yaml`. There is no background update check or automatic update mechanism.
124
48
 
125
- The executable is `flow`. The npm package is currently `@caiqueoak/flow` so it does not collide with the pre-existing unscoped `flow` package.
49
+ ## CLI
126
50
 
127
- ```bash
128
- npx @caiqueoak/flow install --target .agents/skills
129
- npx @caiqueoak/flow init
51
+ ```text
52
+ flow init
53
+ flow update
54
+ flow --version
55
+ flow --help
130
56
  ```
131
57
 
132
- ## Releases
133
-
134
- Flow follows [Semantic Versioning](https://semver.org/). A merge to `main` publishes only when the version in `package.json` does not already exist on npm. GitHub Actions runs the test and packaging checks, then publishes the package with provenance. Release PRs must update both `package.json` and `package-lock.json`.
58
+ The CLI bootstraps project-local integrations and configuration. The coding agent plus `/flow` owns discovery, planning, scheduling, delegation, build, gates, review, reconciliation, and state synchronization.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caiqueoak/flow",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Readability-first, agent-agnostic software development workflow for coding agents.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,6 @@
13
13
  "files": [
14
14
  "src",
15
15
  "skills",
16
- "templates",
17
16
  "README.md",
18
17
  "LICENSE"
19
18
  ],
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: flow
3
+ description: Autonomous, readability-first software delivery workflow. Continue from project state or incorporate new intent, ask only for consequential decisions, then plan, build, validate, reconcile, and continue as far as safely possible.
4
+ ---
5
+
6
+ # Flow
7
+
8
+ ## Public contract
9
+
10
+ `/flow` is the only public workflow skill.
11
+
12
+ - `/flow` with no additional intent continues from `.flow/STATE.md` as far as safely possible.
13
+ - `/flow <freeform intent>` incorporates the intent into current project context and continues appropriately.
14
+ - If `.flow/STATE.md` does not exist, begin global discovery using the idea, repository, or source documents supplied.
15
+
16
+ Do not require the developer to know or invoke internal workflow phases.
17
+
18
+ ## Core principles
19
+
20
+ 1. **Readability first.** Canonical artifacts must be understandable without Flow internals.
21
+ 2. **Decision ownership.** The developer owns consequential product and engineering decisions; the agent executes within approved rules and obvious conventions.
22
+ 3. **Autonomy by default.** Continue until a consequential decision, external approval, unrecoverable blocker, or no-ready-work condition.
23
+ 4. **Just-in-time detail.** Resolve global decisions during discovery and work-item detail only when that item becomes active.
24
+ 5. **Production-aware MVP.** MVP includes product capability plus the technical, infrastructure, quality, deployment, and operational work needed to run it.
25
+ 6. **Parallelism first.** Execute the largest safe independent set while preserving correctness and token efficiency.
26
+ 7. **Automatic synchronization.** Keep state, decisions, PRD, engineering definition, backlog, specs, and summaries aligned.
27
+
28
+ ## Canonical project artifacts
29
+
30
+ Create artifacts only when they become valid. `flow init` creates only `.flow/config.yaml`.
31
+
32
+ Developer-facing knowledge is Markdown:
33
+
34
+ - `.flow/PRD.md` - current global product truth and MVP boundary.
35
+ - `.flow/ENGINEERING.md` - global engineering truth.
36
+ - `.flow/SUMMARY.md` - concise project overview derived from canonical state.
37
+ - `.flow/DECISIONS.md` - consequential decision record and rationale.
38
+ - `.flow/STATE.md` - concise navigation/status view.
39
+ - `.flow/work-items/<folder>/SPEC.md` - readable lifecycle/specification of one work item.
40
+
41
+ Graph/control data is YAML:
42
+
43
+ - `.flow/BACKLOG.yaml` - work-item DAG.
44
+ - `.flow/work-items/<folder>/TASKS.yaml` - task DAG and execution ownership.
45
+
46
+ Do not create completion logs. Completed `SPEC.md` files retain concise Overview and Validation sections.
47
+
48
+ ## Work item model
49
+
50
+ - `feature` (`F`) - product/user capability.
51
+ - `technical` (`T`) - architecture, infrastructure, platform, quality, deployment, or enabling work.
52
+ - `maintenance` (`M`) - reconciliation, migration, refactor, or corrective work.
53
+
54
+ Folder format is `<three-digit-sequence><kind-code>-<slug>` (for example, `001F-user-profile`). The sequence is a stable readability aid, never execution order. Dependencies determine readiness.
55
+
56
+ ## Decision authority
57
+
58
+ Apply low-impact and conventional choices automatically. A decision requires developer approval when materially different choices affect product behavior or scope; architecture/public contracts; production infrastructure or cost; persistent data; security/privacy; testing strategy or gates; project-wide conventions; or other work-item assumptions.
59
+
60
+ ## Decision presentation protocol
61
+
62
+ Every requested decision must use this readable structure:
63
+
64
+ ### Decision
65
+
66
+ What needs to be chosen.
67
+
68
+ ### Problem
69
+
70
+ The concrete uncertainty.
71
+
72
+ ### Context
73
+
74
+ Relevant product, engineering, production, and existing-decision context.
75
+
76
+ ### Options
77
+
78
+ Realistic alternatives and trade-offs.
79
+
80
+ ### Recommended option
81
+
82
+ Exactly one recommendation when evidence permits.
83
+
84
+ ### Why recommended
85
+
86
+ Concise justification grounded in current goals and constraints.
87
+
88
+ ### Approach
89
+
90
+ The high-level direction following the recommendation.
91
+
92
+ ### Impact
93
+
94
+ Affected definitions, rules, gates, work items, tasks, or implementation.
95
+
96
+ Never hide a consequential choice inside an implementation plan. Batch the largest currently-known set of independent decisions; do not invent hypothetical questions.
97
+
98
+ ## Decision lifecycle and impact
99
+
100
+ Decision states are `candidate`, `pending_user`, `accepted`, `rejected`, and `superseded`. Preserve the rationale in `DECISIONS.md`. Reconcile pending work before execution, stop only affected in-progress paths, and create maintenance work rather than rewriting completed history.
101
+
102
+ ## Internal workflow routing
103
+
104
+ Load only the reference needed for current state:
105
+
106
+ - Missing state or global definition: `references/discovery.md`
107
+ - Ready/unplanned work: `references/planning.md`
108
+ - Ready planned tasks: `references/build.md`
109
+ - Completed implementation awaiting validation: `references/review.md`
110
+ - Decision impact or inconsistent artifacts: `references/reconcile.md`
111
+
112
+ ## Orchestration loop
113
+
114
+ 1. Read `.flow/config.yaml`.
115
+ 2. Read only the minimum navigation context from `.flow/STATE.md` and `.flow/SUMMARY.md` when present.
116
+ 3. Classify new intent and its impact on canonical truth, backlog, active work, or execution detail.
117
+ 4. Respect work/tasks already `in_progress` under another execution ID.
118
+ 5. Route to the minimal internal reference.
119
+ 6. Claim selected work before parallel execution.
120
+ 7. Continue planning, build, gates, review, fixes/reconciliation, and completion without another invocation.
121
+ 8. Recompute readiness after completion and continue if configured.
122
+
123
+ ## Parallelism and gates
124
+
125
+ `auto` means the largest safe concurrency the orchestrator can reliably coordinate, considering dependencies, shared decisions/files/contracts, integration risk, available capacity, context complexity, and token overhead. It is not unlimited. Prefer one primary orchestrator and delegate only where independent substantial work justifies it.
126
+
127
+ Gates may be deterministic commands or agentic policy checks. Define/refine them during discovery or planning when relevant. Build agents know applicable gates before implementation; review validates requirements, integration, and blocking gates.
128
+
129
+ ## Git and token efficiency
130
+
131
+ Follow the approved Git strategy in `ENGINEERING.md`; by default create one atomic commit per completed task. Read the minimum relevant canonical context, avoid repeated large-document ingestion and duplicate prose, reuse accepted decisions, prefer deterministic checks, and delegate only with narrow ownership/context packets.
@@ -0,0 +1,5 @@
1
+ # Canonical Artifact Guidance
2
+
3
+ Create canonical project files only when they become valid. `PRD.md` holds global product truth; `ENGINEERING.md` holds current global engineering truth; `SUMMARY.md` is a concise derived orientation view; `STATE.md` is a concise navigation/status view; and `DECISIONS.md` preserves consequential decisions, options, rationale, and impacts.
4
+
5
+ `BACKLOG.yaml` is the work-item DAG. Each work item has a readable `SPEC.md` and a `TASKS.yaml` task DAG with status, dependencies, acceptance/validation, and optional ownership areas. Do not create a separate completion log: keep delivered behavior and validation in the completed spec.
@@ -0,0 +1,5 @@
1
+ # Build
2
+
3
+ Compute ready tasks, exclude claims by another execution ID, select the largest safe set, and mark it `in_progress` before editing or delegating. Load only relevant specs, decisions, code, and gates. Follow approved conventions, avoid unrelated refactors, run the cheapest relevant deterministic checks, make atomic commits, and mark tasks complete only after acceptance checks pass.
4
+
5
+ Synchronize TASKS, STATE, and affected canonical artifacts at each meaningful transition. If a consequential new choice emerges, stop only the affected path and present the decision while independent paths continue when safe.
@@ -0,0 +1,13 @@
1
+ # Global Discovery
2
+
3
+ ## Goal
4
+
5
+ Define the smallest coherent, production-capable MVP and the global product/engineering rules required to plan it. Do not specify work-item detail prematurely.
6
+
7
+ ## Scope
8
+
9
+ Resolve only consequential global decisions affecting the problem, users, MVP, business constraints, production environment, deployment, architecture, persistence, integrations, security, observability, testing, conventions, documentation, Git strategy, and reusable gates. Infer trivial conventions from the existing codebase or chosen ecosystem.
10
+
11
+ ## Outputs
12
+
13
+ Create or update only valid canonical artifacts: `PRD.md`, `ENGINEERING.md`, `DECISIONS.md`, `BACKLOG.yaml`, `STATE.md`, `SUMMARY.md`, and approved gate definitions. Discovery ends when no unresolved global decision is needed for a coherent production-capable MVP and initial work-item DAG.
@@ -0,0 +1,5 @@
1
+ # Work-item Planning
2
+
3
+ Read only relevant global decisions, backlog context, existing spec/tasks, and source. Ask consequential work-item decisions only when viable answers materially change behavior, contracts, data semantics, technical boundaries, security, UX, or gates.
4
+
5
+ Create `.flow/work-items/<id>/SPEC.md` with goal, scope/non-goals, relevant decisions, approach, requirements, acceptance criteria, gates, dependencies/impacts, and validation. Create `TASKS.yaml` with bounded, testable, independently executable tasks, real blocking dependencies only, and concise acceptance/validation expectations.
@@ -0,0 +1,3 @@
1
+ # Reconciliation
2
+
3
+ Keep canonical truth and active plans aligned when new intent or accepted decisions affect work. Reconcile pending/planned work before execution, preserve unaffected in-progress work, and create maintenance work for completed work that must change. Preserve superseded decisions with links to their replacements. Update only artifacts whose current truth changed.
@@ -0,0 +1,3 @@
1
+ # Review
2
+
3
+ Verify completed work against its spec and applicable gates: inspect task completion and diff, validate requirements and acceptance criteria, run deterministic blocking gates, then applicable agentic gates, and check integration/regressions. Create targeted fix tasks within approved scope; request a decision only for consequential new choices. On success, update the spec Overview and Validation, then synchronize backlog, state, and summary.
package/src/cli.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import fs from 'node:fs';
4
- import os from 'node:os';
5
4
  import path from 'node:path';
6
5
  import { execFileSync } from 'node:child_process';
7
6
  import { fileURLToPath } from 'node:url';
7
+ import readline from 'node:readline/promises';
8
+ import { stdin as inputStream, stdout as outputStream } from 'node:process';
8
9
 
9
10
  const __filename = fileURLToPath(import.meta.url);
10
11
  const __dirname = path.dirname(__filename);
@@ -14,116 +15,170 @@ const VERSION = PACKAGE.version;
14
15
  const PACKAGE_NAME = PACKAGE.name;
15
16
  const args = process.argv.slice(2);
16
17
 
17
- function fail(message, code = 1) {
18
- console.error(`flow: ${message}`);
19
- process.exit(code);
20
- }
18
+ const RUNTIME_DEFINITIONS = {
19
+ codex: { label: 'Codex', skillsPath: '.codex/skills' },
20
+ claude: { label: 'Claude Code', skillsPath: '.claude/skills' }
21
+ };
21
22
 
22
- function info(message) { console.log(message); }
23
+ function fail(message, code = 1) { console.error(`flow: ${message}`); process.exit(code); }
24
+ function info(message = '') { console.log(message); }
23
25
  function hasFlag(name) { return args.includes(name); }
24
26
  function valueAfter(name) { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; }
25
27
  function npmCommand() { return process.platform === 'win32' ? 'npm.cmd' : 'npm'; }
28
+ function projectRoot() { return path.resolve(valueAfter('--path') || process.cwd()); }
29
+ function configPath(root) { return path.join(root, '.flow', 'config.yaml'); }
26
30
 
27
- function copyDir(source, target, { overwrite = false } = {}) {
31
+ function copyDir(source, target) {
28
32
  fs.mkdirSync(target, { recursive: true });
29
33
  for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
30
34
  const src = path.join(source, entry.name);
31
35
  const dst = path.join(target, entry.name);
32
- if (entry.isDirectory()) copyDir(src, dst, { overwrite });
33
- else if (!fs.existsSync(dst) || overwrite) fs.copyFileSync(src, dst);
36
+ if (entry.isDirectory()) copyDir(src, dst);
37
+ else fs.copyFileSync(src, dst);
34
38
  }
35
39
  }
36
40
 
37
- function conventionalSkillTargets(cwd) {
38
- const candidates = [
39
- path.join(cwd, '.agents', 'skills'),
40
- path.join(cwd, '.claude', 'skills'),
41
- path.join(os.homedir(), '.agents', 'skills'),
42
- path.join(os.homedir(), '.claude', 'skills')
43
- ];
44
- return [...new Set(candidates)].filter((candidate) => fs.existsSync(candidate));
41
+ function quoteYaml(value) { return /^[A-Za-z0-9_.\/-]+$/.test(value) ? value : JSON.stringify(value); }
42
+ function defaultConfig() {
43
+ return { frameworkVersion: VERSION, runtimes: [], continueAcrossWorkItems: true, workItemsConcurrency: 'auto', taskConcurrency: 'auto' };
45
44
  }
46
45
 
47
- function resolveInstallTarget() {
48
- const explicit = valueAfter('--target');
49
- if (explicit) return path.resolve(explicit.replace(/^~(?=$|\/|\\)/, os.homedir()));
50
- const detected = conventionalSkillTargets(process.cwd());
51
- if (detected.length === 1) return detected[0];
52
- if (detected.length > 1) fail(`multiple skill directories detected:\n${detected.map((x) => ` - ${x}`).join('\n')}\nUse --target <skills-directory>.`);
53
- fail('no skill directory detected. Use --target <skills-directory>. This keeps Flow runtime-agnostic.');
46
+ function readConfig(root) {
47
+ const file = configPath(root);
48
+ if (!fs.existsSync(file)) return null;
49
+ const text = fs.readFileSync(file, 'utf8');
50
+ const cfg = defaultConfig();
51
+ const v = text.match(/^[ \t]*version:[ \t]*([^\s#]+)[ \t]*$/m);
52
+ if (v) cfg.frameworkVersion = v[1].replace(/^['"]|['"]$/g, '');
53
+ const runtimeBlock = text.match(/^runtimes:\s*\n([\s\S]*?)(?=^[A-Za-z_][A-Za-z0-9_]*:|\Z)/m)?.[1] || '';
54
+ const entries = runtimeBlock.split(/(?=^\s*-\s+type:)/m).filter((x) => /-\s+type:/.test(x));
55
+ for (const entry of entries) {
56
+ const type = entry.match(/-\s+type:\s*([^\s#]+)/)?.[1]?.replace(/^['"]|['"]$/g, '');
57
+ const skillsPath = entry.match(/skills_path:\s*([^\n#]+)/)?.[1]?.trim().replace(/^['"]|['"]$/g, '');
58
+ if (type && skillsPath) cfg.runtimes.push({ type, skills_path: skillsPath });
59
+ }
60
+ return cfg;
54
61
  }
55
62
 
56
- function initProject() {
57
- const projectRoot = path.resolve(valueAfter('--path') || process.cwd());
58
- const flowDir = path.join(projectRoot, '.flow');
59
- if (fs.existsSync(flowDir) && !hasFlag('--force')) fail(`${flowDir} already exists. Use --force only to add missing templates without replacing project state.`);
60
- fs.mkdirSync(flowDir, { recursive: true });
61
- copyDir(path.join(ROOT, 'templates'), flowDir, { overwrite: false });
62
- fs.mkdirSync(path.join(flowDir, 'work-items'), { recursive: true });
63
- fs.mkdirSync(path.join(flowDir, 'gates'), { recursive: true });
64
- info(`Initialized Flow project at ${flowDir}`);
65
- info('Next: open your coding agent and run /flow-new with the idea or existing source documents.');
63
+ function writeConfig(root, config) {
64
+ const lines = ['schema_version: 1', 'framework:', ' name: flow', ` version: ${VERSION}`, 'runtimes:'];
65
+ if (!config.runtimes.length) lines.push(' []');
66
+ else for (const runtime of config.runtimes) {
67
+ lines.push(` - type: ${quoteYaml(runtime.type)}`);
68
+ lines.push(` skills_path: ${quoteYaml(runtime.skills_path)}`);
69
+ }
70
+ lines.push('autonomy:', ' continue_across_work_items: true', ' stop_on:', ' - consequential_decision', ' - external_approval', ' - unrecoverable_blocker', ' - no_ready_work', 'parallelism:', ' strategy: maximum_safe', ' max_concurrent_work_items: auto', ' max_concurrent_tasks_per_work_item: auto', 'efficiency:', ' token_usage: optimize', ' prefer_primary_orchestrator: true', ' delegate_only_when_beneficial: true', '');
71
+ fs.mkdirSync(path.join(root, '.flow'), { recursive: true });
72
+ fs.writeFileSync(configPath(root), lines.join('\n'), 'utf8');
66
73
  }
67
74
 
68
- function installSkills({ force = hasFlag('--force') } = {}) {
69
- const target = resolveInstallTarget();
70
- fs.mkdirSync(target, { recursive: true });
71
- copyDir(path.join(ROOT, 'skills'), target, { overwrite: force });
72
- info(`Installed Flow ${VERSION} skills to ${target}`);
73
- if (!force) info('Existing skill files were preserved. Use --force to replace them.');
75
+ function installRuntimeSkill(root, runtime, packageRoot = ROOT) {
76
+ const target = path.join(root, runtime.skills_path, 'flow');
77
+ copyDir(path.join(packageRoot, 'skills', 'flow'), target);
74
78
  return target;
75
79
  }
80
+ function parseRuntimeFlag() {
81
+ const raw = valueAfter('--runtime');
82
+ return raw ? raw.split(',').map((x) => x.trim().toLowerCase()).filter(Boolean) : null;
83
+ }
76
84
 
77
- function latestPublishedVersion() {
85
+ async function promptMultiSelect(existing) {
86
+ const existingTypes = new Set(existing.map((r) => r.type));
87
+ const options = Object.entries(RUNTIME_DEFINITIONS).filter(([type]) => !existingTypes.has(type)).map(([value, def]) => ({ value, label: def.label }));
88
+ options.push({ value: 'custom', label: 'Custom coding agent / skills path' });
89
+ info(existing.length ? 'Select coding agents to add:' : 'Select coding agents:');
90
+ options.forEach((opt, i) => info(` [ ] ${i + 1}. ${opt.label}`));
91
+ info(' (Select multiple with comma-separated numbers, e.g. 1,2)');
92
+ const rl = readline.createInterface({ input: inputStream, output: outputStream });
78
93
  try {
79
- return execFileSync(npmCommand(), ['view', PACKAGE_NAME, 'version'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 15000 }).trim();
80
- } catch {
81
- return null;
82
- }
94
+ while (true) {
95
+ const answer = (await rl.question('Selection: ')).trim();
96
+ const indices = [...new Set(answer.split(',').map((v) => Number.parseInt(v.trim(), 10)).filter(Number.isInteger))];
97
+ if (indices.length && indices.every((n) => n >= 1 && n <= options.length)) return indices.map((n) => options[n - 1].value);
98
+ info('Choose one or more valid numbers.');
99
+ }
100
+ } finally { rl.close(); }
101
+ }
102
+
103
+ async function promptText(message, defaultValue = '') {
104
+ const rl = readline.createInterface({ input: inputStream, output: outputStream });
105
+ try {
106
+ const answer = (await rl.question(`${message}${defaultValue ? ` [${defaultValue}]` : ''}: `)).trim();
107
+ return answer || defaultValue;
108
+ } finally { rl.close(); }
83
109
  }
84
110
 
85
- function compareVersions(a, b) {
86
- const pa = a.split('.').map((n) => Number.parseInt(n, 10) || 0);
87
- const pb = b.split('.').map((n) => Number.parseInt(n, 10) || 0);
88
- for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
89
- const d = (pa[i] || 0) - (pb[i] || 0);
90
- if (d) return d;
111
+ async function resolveRuntime(type, existing) {
112
+ if (RUNTIME_DEFINITIONS[type]) return { type, skills_path: RUNTIME_DEFINITIONS[type].skillsPath };
113
+ if (type !== 'custom') fail(`unsupported runtime '${type}'. Use codex, claude, or custom.`);
114
+ const fallback = `custom-${existing.filter((r) => r.type.startsWith('custom')).length + 1}`;
115
+ const name = await promptText('Custom coding agent id', fallback);
116
+ while (true) {
117
+ const skillsPath = await promptText('Project-local skills directory', `.${name}/skills`);
118
+ if (!path.isAbsolute(skillsPath) && !skillsPath.split(/[\\/]/).includes('..')) return { type: name, skills_path: skillsPath };
119
+ info('Skills path must be relative and remain inside the project.');
91
120
  }
92
- return 0;
93
121
  }
94
122
 
95
- function update() {
96
- const target = resolveInstallTarget();
97
- const latest = latestPublishedVersion();
98
- if (!latest) fail(`could not read the latest ${PACKAGE_NAME} version from npm.`);
99
- if (compareVersions(latest, VERSION) <= 0) {
100
- copyDir(path.join(ROOT, 'skills'), target, { overwrite: true });
101
- info(`Flow ${VERSION} is already current. Skills refreshed at ${target}`);
102
- return;
123
+ async function initProject() {
124
+ const root = projectRoot();
125
+ const flowDir = path.join(root, '.flow');
126
+ const existed = fs.existsSync(flowDir);
127
+ const config = readConfig(root) || defaultConfig();
128
+ if (existed) {
129
+ info('Flow project already exists. Canonical project artifacts will not be created or modified.');
130
+ if (config.runtimes.length) info(`Configured coding agents: ${config.runtimes.map((r) => r.type).join(', ')}`);
131
+ }
132
+ const selected = parseRuntimeFlag() || await promptMultiSelect(config.runtimes);
133
+ const knownTypes = new Set(config.runtimes.map((r) => r.type));
134
+ const added = [];
135
+ for (const type of selected) {
136
+ if (knownTypes.has(type)) continue;
137
+ const runtime = await resolveRuntime(type, config.runtimes);
138
+ if (knownTypes.has(runtime.type)) continue;
139
+ config.runtimes.push(runtime); knownTypes.add(runtime.type); added.push(runtime);
103
140
  }
141
+ fs.mkdirSync(flowDir, { recursive: true });
142
+ writeConfig(root, config);
143
+ for (const runtime of added) info(`✓ ${runtime.type}: ${path.relative(root, installRuntimeSkill(root, runtime))}`);
144
+ if (!added.length) info('No new coding-agent integration was added.');
145
+ else { info(); info('Flow is ready. Open a configured coding agent and invoke /flow.'); }
146
+ }
104
147
 
105
- info(`Updating Flow skills ${VERSION} → ${latest}...`);
106
- const execArgs = ['exec', '--yes', `--package=${PACKAGE_NAME}@${latest}`, '--', 'flow', 'install', '--target', target, '--force'];
148
+ function dependencySection(root) {
149
+ const file = path.join(root, 'package.json');
150
+ if (!fs.existsSync(file)) return '--save-dev';
107
151
  try {
108
- execFileSync(npmCommand(), execArgs, { stdio: 'inherit' });
109
- } catch {
110
- fail('update failed. Your existing installation was not intentionally removed.');
111
- }
112
- info(`Skills updated to Flow ${latest}.`);
113
- info(`If Flow itself is globally installed, update the CLI with: npm install -g ${PACKAGE_NAME}@latest`);
152
+ const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
153
+ if (pkg.dependencies?.[PACKAGE_NAME]) return '--save';
154
+ if (pkg.optionalDependencies?.[PACKAGE_NAME]) return '--save-optional';
155
+ } catch { /* use default */ }
156
+ return '--save-dev';
157
+ }
158
+
159
+ function update() {
160
+ const root = projectRoot();
161
+ const config = readConfig(root);
162
+ if (!config) fail('this project is not initialized. Run flow init first.');
163
+ if (!config.runtimes.length) fail('no coding agents are configured. Run flow init to add one.');
164
+ info(`Updating ${PACKAGE_NAME}...`);
165
+ try { execFileSync(npmCommand(), ['install', dependencySection(root), `${PACKAGE_NAME}@latest`], { cwd: root, stdio: 'inherit' }); }
166
+ catch { fail('npm update failed. Existing project state and installed skills were not intentionally removed.'); }
167
+ const packageRoot = path.join(root, 'node_modules', '@caiqueoak', 'flow');
168
+ if (!fs.existsSync(path.join(packageRoot, 'package.json'))) fail(`updated package not found at ${path.relative(root, packageRoot)}.`);
169
+ const latest = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
170
+ for (const runtime of config.runtimes) info(`✓ ${runtime.type}: ${path.relative(root, installRuntimeSkill(root, runtime, packageRoot))}`);
171
+ const text = fs.readFileSync(configPath(root), 'utf8');
172
+ fs.writeFileSync(configPath(root), text.replace(/(^framework:\s*\n(?:.*\n)*?\s+version:\s*)[^\n]+/m, `$1${latest.version}`), 'utf8');
173
+ info(`Flow updated to ${latest.version}.`);
114
174
  }
115
175
 
116
176
  function help() {
117
- info(`Flow ${VERSION}\n\nUsage:\n flow init [--path <project>] [--force]\n flow install [--target <skills-directory>] [--force]\n flow update [--target <skills-directory>]\n flow --version\n\nThe CLI only initializes project state and installs/updates skills.\nWorkflow orchestration is performed by the coding agent through the Flow skills.`);
177
+ info(`Flow ${VERSION}\n\nUsage:\n flow init [--path <project>] [--runtime codex,claude]\n flow update [--path <project>]\n flow --version\n\nflow init creates only .flow/config.yaml and installs the project-local /flow skill for selected coding agents.\nIf .flow already exists, init only adds coding-agent integrations.\nThere is no flow install command and no automatic/background update mechanism.`);
118
178
  }
119
179
 
120
- if (args.length === 0 || hasFlag('--help') || hasFlag('-h')) help();
180
+ if (!args.length || hasFlag('--help') || hasFlag('-h')) help();
121
181
  else if (hasFlag('--version') || hasFlag('-v')) info(VERSION);
122
- else {
123
- switch (args[0]) {
124
- case 'init': initProject(); break;
125
- case 'install': installSkills(); break;
126
- case 'update': update(); break;
127
- default: fail(`unknown command '${args[0]}'. Run flow --help.`);
128
- }
129
- }
182
+ else if (args[0] === 'init') await initProject();
183
+ else if (args[0] === 'update') update();
184
+ else fail(`unknown command '${args[0]}'. Run flow --help.`);
@@ -1,73 +0,0 @@
1
- ---
2
- name: flow-build
3
- description: Implement ready tasks with maximum-safe parallelism, approved decisions and gates, token-efficient context packets, automatic claims, tests, commits, and state synchronization.
4
- ---
5
-
6
- # Flow Build
7
-
8
- ## Objective
9
-
10
- Implement an active work item efficiently while preserving approved product/engineering constraints and exploiting safe parallelism without turning parallelism into coordination or token waste.
11
-
12
- ## Context loading
13
-
14
- Start with STATE, the current work item's SPEC/TASKS, and only the relevant global decisions/engineering/gates. Workers or subagents receive the smallest context packet needed for their task.
15
-
16
- ## Claims
17
-
18
- Before implementation/delegation, mark selected tasks `in_progress` and set their `execution_id`. Synchronize state BEFORE code edits. Never take over a task or work item already `in_progress` under another execution ID.
19
-
20
- There is no claim timeout. If ownership appears abandoned or inconsistent, surface it for explicit reconciliation rather than silently reclaiming it.
21
-
22
- ## Maximum-safe parallelism
23
-
24
- The configured limits may be an integer or `auto`.
25
-
26
- `auto` means the orchestrating agent must choose, for each scheduling cycle, the largest concurrency it can reliably coordinate without unacceptable risk. Consider:
27
- - DAG independence;
28
- - likely file/module/contract overlap;
29
- - shared mutable state and migrations;
30
- - unresolved or interacting decisions;
31
- - task size and uncertainty;
32
- - available runtime/subagent capabilities;
33
- - context-window and tool limits;
34
- - expected coordination/merge overhead;
35
- - token efficiency.
36
-
37
- The safe answer may be 1. Do not spawn workers merely because tasks are technically independent. Parallelize when the time/clarity benefit exceeds the context and coordination cost.
38
-
39
- When `auto` is used, record the chosen effective concurrency for the current cycle in `STATE.yaml` so another agent or reader can understand what is happening.
40
-
41
- ## Execution
42
-
43
- 1. Compute all ready tasks.
44
- 2. Exclude tasks owned by another execution.
45
- 3. Determine the maximum-safe set under configuration.
46
- 4. Claim the complete selected set before implementation.
47
- 5. Execute directly or delegate safe independent tasks.
48
- 6. Apply approved conventions automatically; do not ask about already-settled rules.
49
- 7. Run applicable cheap/deterministic gates during implementation where practical.
50
- 8. Implement the smallest changes satisfying each task.
51
- 9. Run narrow relevant checks first, then broader checks when needed.
52
- 10. Create atomic commits when the environment permits; never include unrelated worktree changes.
53
- 11. Mark completed tasks `done`, record commit SHAs when available, recompute readiness, and synchronize state.
54
-
55
- If implementation exposes a consequential unapproved decision, STOP affected work, preserve completed independent work, record the pending decision using the required decision format, and return control to the orchestrator for developer input.
56
-
57
- If implementation reveals additional required work, add a task or backlog work item with real dependencies instead of silently expanding scope.
58
-
59
- ## Scope guard
60
-
61
- Do not opportunistically refactor unrelated code. Record separate technical/maintenance work when useful.
62
-
63
- ## Token-efficiency rules
64
-
65
- Token efficiency is a first-class optimization alongside correctness and maintainability:
66
- - never provide each worker the full project history;
67
- - prefer SUMMARY + exact relevant sections/IDs;
68
- - avoid rereading completed specs and large historical sources;
69
- - avoid multiple agents doing the same repository exploration;
70
- - prefer deterministic tools/tests over reasoning-heavy review where possible;
71
- - do not generate long execution narratives;
72
- - use Git for implementation history;
73
- - choose sequential execution when delegation overhead would cost more than it saves.
@@ -1,104 +0,0 @@
1
- ---
2
- name: flow-new
3
- description: Bootstrap Flow from a broad idea or existing project sources, resolve consequential global product and engineering decisions, define a production-capable MVP, and create the initial work DAG.
4
- ---
5
-
6
- # Flow New
7
-
8
- ## Objective
9
-
10
- Create enough shared product, engineering, infrastructure, and quality context to define a coherent production-capable MVP without prematurely specifying work-item details.
11
-
12
- ## Readability principle
13
-
14
- Flow is readability first. Write canonical artifacts so a reader can understand the project without knowing Flow internals. Prefer clear prose and explicit names over compressed notation.
15
-
16
- ## Inputs
17
-
18
- Support all of these without changing the workflow contract:
19
- - greenfield idea;
20
- - existing PRD/PRFAQ/specifications;
21
- - existing codebase;
22
- - existing codebase plus product documentation.
23
-
24
- Existing source documents are inputs, not permanent runtime context. Synthesize them into small canonical `.flow/` artifacts and refer back to sources only when a later work item requires specific detail.
25
-
26
- ## Global discovery
27
-
28
- Resolve only consequential global decisions needed to define:
29
- - product problem, users, boundaries, and MVP outcome;
30
- - production constraints and deployment model;
31
- - architecture and project/module boundaries;
32
- - infrastructure, persistence, integrations, security/privacy, observability, and operations;
33
- - global testing strategy and documentation expectations;
34
- - reusable quality gates;
35
- - technical constraints that shape product scope or work ordering.
36
-
37
- Do not ask work-item-level questions that can safely wait for just-in-time planning.
38
-
39
- ## Decision authority
40
-
41
- The agent MUST NOT silently make a consequential product or technical decision.
42
-
43
- A decision is consequential when materially different choices can change product scope/behavior, MVP composition, architecture, module boundaries, public contracts, persistent data semantics, production infrastructure, security/privacy, operational cost/model, testing strategy, reusable quality gates, or cross-work assumptions.
44
-
45
- Infer without asking when a choice is low-impact, reversible, and has a clear ecosystem/repository convention. Do not ask trivial convention questions such as kebab-case vs snake_case when the selected language/framework or existing repository establishes a normal choice.
46
-
47
- ## Decision batch protocol
48
-
49
- Ask the largest set of consequential decisions that are CURRENTLY KNOWN and can be answered independently. Do not speculate about future scenarios merely to enlarge a batch.
50
-
51
- If decision B depends on decision A, ask A first and defer B until A is resolved.
52
-
53
- Every decision presented for approval MUST include:
54
- 1. **Decision** — what must be chosen.
55
- 2. **Context** — why the choice exists now and why it matters.
56
- 3. **Options** — realistic alternatives and their meaningful trade-offs.
57
- 4. **Recommended option** — exactly one when a recommendation is possible.
58
- 5. **Why recommended** — concise reasoning grounded in current constraints.
59
- 6. **Impact** — product, engineering, gates, and work items likely affected.
60
-
61
- Record unresolved consequential decisions as `pending_user` in `DECISIONS.yaml`. After a choice is provided, record the accepted choice and synchronize affected canonical artifacts.
62
-
63
- ## MVP rule
64
-
65
- Discovery MUST converge on a production-capable MVP, not only a feature list. Include both product and technical work required to build, validate, deploy, and operate the MVP at its intended scale.
66
-
67
- Stop global discovery when there are no unresolved global decisions necessary to define a coherent production-capable MVP and its initial work DAG.
68
-
69
- ## Work DAG
70
-
71
- Populate `BACKLOG.yaml` with work items of kind:
72
- - `feature` — user/product capability;
73
- - `technical` — enabling architecture, infrastructure, quality, or platform work;
74
- - `maintenance` — reconciliation, migration, refactor, or corrective work created by later decisions.
75
-
76
- Dependencies represent real blockers only. A work item may be impacted by a decision without depending on another work item.
77
-
78
- Use universal IDs (`W001`, `W002`, ...). Work item folders use `<sequence-padded><kind-code>-<slug>` where `F` = feature, `T` = technical, and `M` = maintenance. Examples: `001F-user-profile`, `002T-production-baseline`, `003M-auth-reconciliation`. The numeric prefix is a stable readable sequence, NOT execution order; the DAG controls execution.
79
-
80
- ## Gates
81
-
82
- During discovery, propose reusable gates when they materially increase confidence in approved engineering/product rules. Explicit approval is required for consequential reusable gate policy. Prefer command gates for objectively testable rules and agentic gates for judgment-based policy.
83
-
84
- ## Required outputs
85
-
86
- Synchronize automatically:
87
- - `.flow/PRD.md`
88
- - `.flow/ENGINEERING.md`
89
- - `.flow/SUMMARY.md`
90
- - `.flow/DECISIONS.yaml`
91
- - `.flow/BACKLOG.yaml`
92
- - `.flow/STATE.yaml`
93
- - `.flow/gates/` when gates are approved
94
-
95
- The user must never need to say “update state/docs”.
96
-
97
- ## Token-efficiency rules
98
-
99
- - Synthesize large source documents once; do not keep re-reading them wholesale.
100
- - Read only source sections needed to resolve the current decision.
101
- - Do not map the whole repository when targeted inspection answers the question.
102
- - Avoid duplicated prose across PRD, ENGINEERING, SUMMARY, and decisions.
103
- - `SUMMARY.md` is a concise derived view, not another source of truth.
104
- - Do not spawn subagents unless parallel research/inspection has clear value greater than coordination/context overhead.
@@ -1,55 +0,0 @@
1
- ---
2
- name: flow-next
3
- description: Autonomous Flow orchestrator: advance all currently safe work through planning, build, gates, review, fixes, reconciliation, and completion until a consequential decision or real blocker requires developer input.
4
- ---
5
-
6
- # Flow Next
7
-
8
- ## Objective
9
-
10
- Make Flow autonomous by default. The user should not manually drive feature -> build -> review transitions or remind the agent to synchronize state.
11
-
12
- ## Stop conditions
13
-
14
- Continue automatically until one of the configured conditions occurs:
15
- - consequential decision requires explicit approval;
16
- - external approval/action cannot be safely performed autonomously;
17
- - unrecoverable blocker;
18
- - no ready work remains;
19
- - configuration explicitly says not to continue across work items.
20
-
21
- `continue_across_work_items: true` means that after one work item passes review and closes, immediately recompute the work DAG and continue with the next safe ready work instead of waiting for another command.
22
-
23
- ## Main loop
24
-
25
- 1. Read `config.yaml`, `STATE.yaml`, `BACKLOG.yaml`, `SUMMARY.md`.
26
- 2. Respect all work/tasks already marked `in_progress` under other execution IDs.
27
- 3. If global discovery is incomplete, invoke/follow `flow-new` until it completes or requires a decision.
28
- 4. Reconcile any `needs_reconciliation` work before execution when necessary.
29
- 5. Compute ready work items from dependencies, decision impacts, status, and ownership.
30
- 6. Determine the maximum-safe work-item set under parallelism configuration.
31
- 7. Mark the selected work items `in_progress` with the current run/execution ID BEFORE planning/delegation.
32
- 8. Plan unplanned items via `flow-plan` semantics. If a consequential decision emerges, preserve independent progress and stop only the affected path; present the maximal currently-known independent decision batch.
33
- 9. Build ready planned work via `flow-build` semantics, including safe task parallelism and delegation when beneficial.
34
- 10. Run configured gates and `flow-review` semantics.
35
- 11. If review creates fix tasks, return them automatically to build and review again.
36
- 12. Close passing work items, create maintenance work for completed items impacted by new decisions, synchronize canonical artifacts, and recompute the DAG.
37
- 13. If `continue_across_work_items` is true, continue the loop.
38
-
39
- ## Decision discipline
40
-
41
- Never infer a consequential choice merely to preserve autonomy. Autonomy means doing everything that follows from approved rules; it does not mean owning approved product or engineering decisions.
42
-
43
- Every requested decision uses the six-part format: Decision, Context, Options, Recommended option, Why recommended, Impact.
44
-
45
- Batch the maximum set of currently-known decisions that do not depend on each other. Do not speculate about future decisions to make the batch larger.
46
-
47
- ## Parallelism and token efficiency
48
-
49
- Parallelism-first means exploiting safe independent work, not maximizing agent count. Under `auto`, choose the largest concurrency that can be reliably coordinated given dependencies, overlap, uncertainty, context/tool capacity, merge risk, and token cost. Record the effective choice in state.
50
-
51
- Prefer one primary orchestrator. Spawn subagents/workers only when their independence and expected benefit justify extra context. Give each worker a narrow context packet and explicit ownership.
52
-
53
- ## State synchronization
54
-
55
- Every transition that changes decisions, work status, tasks, gates, PRD, engineering definition, or project overview must synchronize the affected canonical artifacts before continuing. The user should never need to request housekeeping updates.
@@ -1,86 +0,0 @@
1
- ---
2
- name: flow-plan
3
- description: Plan a ready feature, technical, or maintenance work item just in time, resolve consequential local decisions, reconcile cross-work impacts, define gates, and create a dependency-aware task DAG.
4
- ---
5
-
6
- # Flow Plan
7
-
8
- ## Objective
9
-
10
- Turn one ready work item into an implementation-ready specification and task DAG while preserving all approved global product and engineering decisions.
11
-
12
- ## Context loading
13
-
14
- Start with `.flow/STATE.yaml`, `.flow/BACKLOG.yaml`, and `.flow/SUMMARY.md`. Read only the relevant sections of `PRD.md`, `ENGINEERING.md`, `DECISIONS.yaml`, and gates needed for this work item. Do not reload unrelated completed work.
15
-
16
- ## Work item selection
17
-
18
- Plan a requested work item or the highest-priority ready work item selected by the orchestrator. Mark it `in_progress` with the current `execution_id` before beginning mutating work.
19
-
20
- Create `.flow/work-items/<sequence-padded><kind-code>-<slug>/SPEC.md` and `TASKS.yaml` from templates.
21
-
22
- ## Just-in-time discovery
23
-
24
- Ask detailed questions only when answers materially affect this work item's behavior, scope, UX, contracts, data semantics, architecture application, infrastructure interaction, security/reliability, acceptance criteria, or gates.
25
-
26
- Reuse accepted global decisions. Applying an approved rule is not a new decision.
27
-
28
- Do not ask trivial implementation questions when a clear language/framework/repository convention or approved engineering rule provides the answer.
29
-
30
- ## Consequential decisions
31
-
32
- Never silently choose a consequential local or global decision. Use the same six-part decision format as `flow-new`: Decision, Context, Options, Recommended option, Why recommended, Impact.
33
-
34
- Batch the maximum set of currently-known independent decisions; do not invent speculative future cases to create a larger batch.
35
-
36
- If a work-item decision establishes or changes a project-wide rule, treat it as a global technical/product decision, obtain developer approval, record it in `DECISIONS.yaml`, update `PRD.md` or `ENGINEERING.md`, and calculate impacted work.
37
-
38
- ## Reconciliation and cross-work impact
39
-
40
- When a new accepted decision impacts another work item:
41
- - pending/ready/planned item: mark `needs_reconciliation` when its assumptions/spec may be stale;
42
- - in-progress item owned by another execution: do not modify its work; record the impact and surface the coordination issue;
43
- - completed item: create a `maintenance` work item when code/data/config must be reconciled or migrated.
44
-
45
- Decision impact is not the same as dependency. Use dependencies only for actual execution blockers.
46
-
47
- ## Gates
48
-
49
- Resolve all global gates applicable to the work item. During planning, propose work-item-specific gates when needed. If a proposed gate establishes a reusable project-wide standard, it requires developer approval and should be promoted to `.flow/gates/`. Keep one-off validation criteria in `SPEC.md`.
50
-
51
- ## Task DAG
52
-
53
- Each task must include:
54
- - ID and clear title;
55
- - status;
56
- - `depends_on` with only real blockers;
57
- - affected areas when reasonably predictable;
58
- - concise acceptance criteria;
59
- - decision/gate references when relevant;
60
- - execution ID when claimed.
61
-
62
- Validate the DAG is acyclic. Do not create explicit waves; execution groups are derived dynamically from the DAG and conflict analysis.
63
-
64
- ## Specification readability
65
-
66
- `SPEC.md` is the readable lifecycle document for the work item. Use:
67
- - Overview
68
- - Goal
69
- - Scope / Non-Goals
70
- - Product Decisions
71
- - Engineering Decisions
72
- - Requirements
73
- - Acceptance Criteria
74
- - Dependencies & Impact
75
- - Validation Gates
76
- - Validation Result
77
- - Delivery Notes
78
-
79
- Keep it concise. Update `Overview` on completion to reflect what was actually delivered. Do not create a completion-log or separate summary file per work item.
80
-
81
- ## Token-efficiency rules
82
-
83
- - Inspect only code likely relevant to current decisions/tasks.
84
- - Reuse global definitions instead of copying them into the spec.
85
- - Refer to decision/gate IDs instead of duplicating long policies.
86
- - Avoid research unless current evidence is insufficient for a consequential decision.
@@ -1,47 +0,0 @@
1
- ---
2
- name: flow-review
3
- description: Validate implemented work against its spec and configured gates, create targeted fixes or maintenance work, and close the work item automatically when it passes.
4
- ---
5
-
6
- # Flow Review
7
-
8
- ## Objective
9
-
10
- Provide the final safety net after build while avoiding redundant re-analysis already covered by deterministic or approved agentic gates.
11
-
12
- ## Required behavior
13
-
14
- 1. Read the active SPEC/TASKS, relevant diff/commits, applicable gate definitions, and only the global decisions/engineering rules needed to validate them.
15
- 2. Verify every requirement and acceptance criterion.
16
- 3. Run all applicable blocking command gates and targeted checks.
17
- 4. Run applicable agentic gates only for policy that tools cannot determine reliably.
18
- 5. Check cross-task integration, obvious regressions, unexpected scope changes, and contract mismatches.
19
- 6. Produce manual validation steps only where automated/agentic validation cannot establish confidence.
20
-
21
- ## Failure
22
-
23
- If review fails:
24
- - create narrow fix tasks with real dependencies;
25
- - leave the work item `in_progress`;
26
- - return it to build automatically;
27
- - create maintenance work instead of reopening completed unrelated items directly.
28
-
29
- If review exposes a consequential decision, stop the affected path and use the required decision presentation protocol. Never silently resolve it during review.
30
-
31
- ## Success
32
-
33
- When review passes:
34
- - mark the work item `done`;
35
- - update the SPEC `Overview`, `Validation Result`, and concise `Delivery Notes`;
36
- - update BACKLOG and STATE;
37
- - synchronize SUMMARY only when project-level understanding materially changed (for example work-item completion, MVP progress, architecture/production model, or key decision change);
38
- - recompute the ready work graph.
39
-
40
- Do NOT create `COMPLETION-LOG.md` or a separate per-work-item summary.
41
-
42
- ## Token-efficiency rules
43
-
44
- - Do not repeat analysis already proven by command gates.
45
- - Review the smallest relevant diff/contract surface.
46
- - Avoid general-purpose reviewer subagents when a targeted gate answers the question.
47
- - Keep review output concise and write only durable information to canonical artifacts.
@@ -1,26 +0,0 @@
1
- ---
2
- name: flow-status
3
- description: Orient a developer or fresh agent from small readable Flow state without rediscovering the repository.
4
- ---
5
-
6
- # Flow Status
7
-
8
- ## Objective
9
-
10
- Explain where the project is, what is running, what is blocked, and what can run next with minimal context.
11
-
12
- ## Required behavior
13
-
14
- 1. Read `.flow/SUMMARY.md`, `.flow/STATE.yaml`, and `.flow/BACKLOG.yaml`.
15
- 2. Read active work-item TASKS/SPEC only when needed for active progress details.
16
- 3. Report concisely:
17
- - project stage and MVP progress;
18
- - active/in-progress work items and execution IDs;
19
- - ready work items;
20
- - pending consequential decisions;
21
- - blockers/reconciliation work;
22
- - current effective parallelism if work is active;
23
- - recommended next action.
24
- 4. Never scan the whole repository just to report status.
25
- 5. Never silently reclaim another execution's in-progress work.
26
- 6. Repair purely mechanical state inconsistencies only when the correct state is provable from canonical artifacts; otherwise surface the exact inconsistency.
@@ -1,15 +0,0 @@
1
- work_items: []
2
-
3
- # Work item example:
4
- # - id: W001
5
- # sequence: 1
6
- # kind: feature | technical | maintenance
7
- # title: Example
8
- # slug: example
9
- # folder: 001F-example # F=feature, T=technical, M=maintenance
10
- # mvp: true
11
- # priority: high
12
- # status: pending | ready | in_progress | blocked | needs_reconciliation | done
13
- # depends_on: []
14
- # impacted_by: []
15
- # execution_id: null
@@ -1,18 +0,0 @@
1
- decisions: []
2
-
3
- # Consequential decisions only.
4
- # Lifecycle: candidate -> pending_user -> accepted -> superseded | rejected
5
- # Recommended fields:
6
- # - id
7
- # - kind: product | technical
8
- # - scope: global | work_item
9
- # - subject
10
- # - status
11
- # - context
12
- # - options
13
- # - recommendation
14
- # - choice
15
- # - rationale
16
- # - depends_on
17
- # - affects
18
- # - superseded_by
@@ -1,35 +0,0 @@
1
- # Engineering Definition
2
-
3
- ## Overview
4
-
5
- _To be defined by `flow-new` from product requirements, production constraints, existing code, and approved technical decisions._
6
-
7
- ## Production Environment & Constraints
8
-
9
- ## Architecture
10
-
11
- ## Project Structure & Boundaries
12
-
13
- ## Data & Persistence
14
-
15
- ## Integration & Communication Patterns
16
-
17
- ## Infrastructure & Deployment
18
-
19
- ## Security & Privacy Baseline
20
-
21
- ## Observability & Operations
22
-
23
- ## Testing Strategy
24
-
25
- ## Engineering Principles
26
-
27
- ## Naming & Code Conventions
28
-
29
- Record only conventions that are worth making explicit. Infer trivial ecosystem conventions when a clear language/framework/repository standard exists.
30
-
31
- ## Documentation Standards
32
-
33
- ## Quality Gates
34
-
35
- ## Sources
package/templates/PRD.md DELETED
@@ -1,23 +0,0 @@
1
- # Product Definition
2
-
3
- ## Overview
4
-
5
- _To be defined by `flow-new`._
6
-
7
- ## Problem
8
-
9
- ## Target Users
10
-
11
- ## Product Principles
12
-
13
- ## MVP Outcome
14
-
15
- ## MVP Scope
16
-
17
- ## Post-MVP Scope
18
-
19
- ## Global Product Constraints
20
-
21
- ## Non-Goals
22
-
23
- ## Sources
@@ -1,11 +0,0 @@
1
- stage: initialized
2
- active_work_items: []
3
- pending_decisions: []
4
- last_completed_work_item: null
5
- recommended_action: flow-new
6
-
7
- execution:
8
- current_run_id: null
9
- effective_parallelism:
10
- work_items: 0
11
- tasks: {}
@@ -1,29 +0,0 @@
1
- # Project Overview
2
-
3
- ## What We Are Building
4
-
5
- _Not defined yet._
6
-
7
- ## MVP
8
-
9
- _Not defined yet._
10
-
11
- ## Key Product Decisions
12
-
13
- _None yet._
14
-
15
- ## Key Engineering Decisions
16
-
17
- _None yet._
18
-
19
- ## Production Model
20
-
21
- _Not defined yet._
22
-
23
- ## Quality Model
24
-
25
- _Not defined yet._
26
-
27
- ## Current Progress
28
-
29
- Project discovery has not been completed.
@@ -1,13 +0,0 @@
1
- tasks: []
2
-
3
- # Task example:
4
- # - id: T001
5
- # title: Example
6
- # status: pending | ready | in_progress | blocked | done
7
- # depends_on: []
8
- # affected_areas: []
9
- # acceptance: []
10
- # decision_refs: []
11
- # gate_refs: []
12
- # execution_id: null
13
- # commit: null
@@ -1,29 +0,0 @@
1
- # Work Item
2
-
3
- ## Overview
4
-
5
- Concise explanation of what this work item changes and why it exists. On completion, update this section to describe what was actually delivered.
6
-
7
- ## Goal
8
-
9
- ## Scope
10
-
11
- ## Non-Goals
12
-
13
- ## Product Decisions
14
-
15
- ## Engineering Decisions
16
-
17
- ## Requirements
18
-
19
- ## Acceptance Criteria
20
-
21
- ## Dependencies & Impact
22
-
23
- ## Validation Gates
24
-
25
- ## Validation Result
26
-
27
- ## Delivery Notes
28
-
29
- Keep this concise. Git history carries implementation history; do not duplicate it here.
@@ -1,29 +0,0 @@
1
- schema_version: 1
2
- framework_version: 0.2.0
3
-
4
- workflow:
5
- autonomous_until:
6
- - consequential_decision
7
- - external_approval
8
- - unrecoverable_blocker
9
- - no_ready_work
10
- continue_across_work_items: true
11
-
12
- parallelism:
13
- strategy: maximum_safe
14
- max_concurrent_work_items: auto
15
- max_concurrent_tasks_per_work_item: auto
16
- delegation: allowed
17
-
18
- execution:
19
- primary_orchestrator: true
20
-
21
- commands:
22
- test: null
23
- lint: null
24
- typecheck: null
25
- build: null
26
-
27
- updates:
28
- check_on_run: true
29
- auto_update: false
@@ -1,19 +0,0 @@
1
- # Quality Gates
2
-
3
- This directory contains reusable project-wide validation gates created or refined during project discovery and work-item planning.
4
-
5
- A gate should be concise, readable, and actionable. Prefer deterministic command checks when tools can verify a rule reliably; use agentic policy gates only when judgment is required.
6
-
7
- Suggested frontmatter:
8
-
9
- ```yaml
10
- ---
11
- id: architecture-boundaries
12
- kind: agentic # agentic | command
13
- blocking: true
14
- applies_when:
15
- - architecture_changed
16
- ---
17
- ```
18
-
19
- A gate may be introduced during a work item. If it establishes a reusable project-wide rule, treat that as a consequential technical decision and obtain developer approval before promoting it to this directory.