@caiqueoak/flow 0.3.3 → 0.5.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.
Files changed (45) hide show
  1. package/README.md +44 -42
  2. package/package.json +14 -2
  3. package/skills/flow/SKILL.md +10 -137
  4. package/skills/flow/build/step-01-execute-task.md +9 -0
  5. package/skills/flow/discovery/step-01-project.md +5 -0
  6. package/skills/flow/discovery/step-02-await-approval.md +3 -0
  7. package/skills/flow/engineering/profiles/readability-first.md +20 -0
  8. package/skills/flow/engineering/step-02-synthesize.md +37 -0
  9. package/skills/flow/engineering/step-05-present.md +3 -0
  10. package/skills/flow/engineering/technology-defaults.md +44 -0
  11. package/skills/flow/invariants.md +16 -0
  12. package/skills/flow/migration/step-01-reconcile.md +7 -0
  13. package/skills/flow/planning/step-01-plan-work-item.md +9 -0
  14. package/skills/flow/planning/step-02-prepare-plan.md +33 -0
  15. package/skills/flow/planning/step-03-await-approval.md +3 -0
  16. package/skills/flow/reconcile/step-01-reconcile.md +7 -0
  17. package/skills/flow/review/step-01-review-work-item.md +5 -0
  18. package/src/artifacts/backlog.mjs +162 -0
  19. package/src/artifacts/document.mjs +30 -0
  20. package/src/artifacts/engineering.mjs +26 -0
  21. package/src/artifacts/gates.mjs +28 -0
  22. package/src/artifacts/implementation-plan.mjs +27 -0
  23. package/src/artifacts/prd.mjs +12 -0
  24. package/src/artifacts/state.mjs +63 -0
  25. package/src/artifacts/tasks.mjs +90 -0
  26. package/src/cli.mjs +34 -309
  27. package/src/commands/gates.mjs +68 -0
  28. package/src/commands/graph.mjs +83 -0
  29. package/src/commands/init.mjs +111 -0
  30. package/src/commands/migrate.mjs +189 -0
  31. package/src/commands/route.mjs +135 -0
  32. package/src/commands/status.mjs +32 -0
  33. package/src/commands/trace.mjs +44 -0
  34. package/src/commands/validate.mjs +174 -0
  35. package/src/shared/cli-io.mjs +86 -0
  36. package/src/shared/profiles.mjs +22 -0
  37. package/src/shared/project-config.mjs +39 -0
  38. package/src/shared/project-path.mjs +10 -0
  39. package/src/shared/skill-installer.mjs +34 -0
  40. package/skills/flow/references/build.md +0 -7
  41. package/skills/flow/references/discovery.md +0 -15
  42. package/skills/flow/references/graph.md +0 -62
  43. package/skills/flow/references/planning.md +0 -7
  44. package/skills/flow/references/reconcile.md +0 -5
  45. package/skills/flow/references/review.md +0 -5
@@ -0,0 +1,22 @@
1
+ import fs from 'node:fs';
2
+ import { parse } from 'yaml';
3
+ const text = fs.readFileSync(
4
+ new URL('../../skills/flow/engineering/profiles/readability-first.md', import.meta.url),
5
+ 'utf8'
6
+ );
7
+ export const READABILITY_FIRST_PROFILE = parse(text.match(/^---\n([\s\S]*?)\n---/)[1]);
8
+ export const ENGINEERING_PROFILES = {
9
+ 'readability-first': READABILITY_FIRST_PROFILE,
10
+ [READABILITY_FIRST_PROFILE.id]: READABILITY_FIRST_PROFILE
11
+ };
12
+ export const BROWNFIELD_POLICIES = {
13
+ improve: {
14
+ label: 'Improve existing structure — Recommended',
15
+ description:
16
+ 'Preserve behavior and external contracts; recommend clearer structure where justified. Does not authorize refactoring.'
17
+ },
18
+ preserve: {
19
+ label: 'Keep existing structure',
20
+ description: 'Retain consistent conventions unless a concrete problem warrants an approved change.'
21
+ }
22
+ };
@@ -0,0 +1,39 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { parse, stringify } from 'yaml';
4
+
5
+ export function configPath(root) {
6
+ return path.join(root, '.flow', 'config.yaml');
7
+ }
8
+
9
+ export function defaultConfig() {
10
+ return {
11
+ schema_version: 2,
12
+ runtimes: [],
13
+ engineering: { profile: 'flow/readability-first@1', existing_code_policy: 'not_applicable' }
14
+ };
15
+ }
16
+
17
+ export function readConfig(root) {
18
+ const file = configPath(root);
19
+ if (!fs.existsSync(file)) return null;
20
+ const raw = parse(fs.readFileSync(file, 'utf8')) ?? {};
21
+ const config = defaultConfig();
22
+ config.schema_version = raw.schema_version ?? 1;
23
+ config.runtimes = Array.isArray(raw.runtimes) ? raw.runtimes : [];
24
+ config.engineering = { ...config.engineering, ...(raw.engineering ?? {}) };
25
+ return config;
26
+ }
27
+
28
+ export function writeConfig(root, config) {
29
+ const normalized = {
30
+ schema_version: 2,
31
+ runtimes: config.runtimes ?? [],
32
+ engineering: {
33
+ profile: config.engineering?.profile ?? defaultConfig().engineering.profile,
34
+ existing_code_policy: config.engineering?.existing_code_policy ?? 'not_applicable'
35
+ }
36
+ };
37
+ fs.mkdirSync(path.join(root, '.flow'), { recursive: true });
38
+ fs.writeFileSync(configPath(root), stringify(normalized, { lineWidth: 0 }), 'utf8');
39
+ }
@@ -0,0 +1,10 @@
1
+ import path from 'node:path';
2
+
3
+ export function valueAfter(args, name) {
4
+ const index = args.indexOf(name);
5
+ return index >= 0 ? args[index + 1] : undefined;
6
+ }
7
+
8
+ export function projectRoot(args) {
9
+ return path.resolve(valueAfter(args, '--path') || process.cwd());
10
+ }
@@ -0,0 +1,34 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ function copyDirectory(source, target) {
5
+ fs.mkdirSync(target, { recursive: true });
6
+ for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
7
+ const sourcePath = path.join(source, entry.name);
8
+ const targetPath = path.join(target, entry.name);
9
+ if (entry.isDirectory()) copyDirectory(sourcePath, targetPath);
10
+ else fs.copyFileSync(sourcePath, targetPath);
11
+ }
12
+ }
13
+
14
+ export function installRuntimeSkill(root, runtime, packageRoot) {
15
+ if (
16
+ typeof runtime.skills_path !== 'string' ||
17
+ !runtime.skills_path ||
18
+ path.isAbsolute(runtime.skills_path) ||
19
+ runtime.skills_path.split(/[\\/]/).includes('..')
20
+ )
21
+ throw new Error('Runtime skills_path must remain project-local.');
22
+ const target = path.join(root, runtime.skills_path, 'flow');
23
+ let ancestor = root;
24
+ for (const segment of path.relative(root, target).split(path.sep)) {
25
+ ancestor = path.join(ancestor, segment);
26
+ if (fs.existsSync(ancestor) && fs.lstatSync(ancestor).isSymbolicLink())
27
+ throw new Error('Refusing a symlinked runtime path.');
28
+ }
29
+ if (fs.existsSync(target) && fs.lstatSync(target).isSymbolicLink())
30
+ throw new Error('Refusing to overwrite a symlinked skill.');
31
+ fs.rmSync(target, { recursive: true, force: true });
32
+ copyDirectory(path.join(packageRoot, 'skills', 'flow'), target);
33
+ return target;
34
+ }
@@ -1,7 +0,0 @@
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.yaml`, `BACKLOG.yaml`, `STATE.md`, `GRAPH.md`, and other affected approved canonical artifacts at each meaningful transition. Never create a new document or artifact unless the developer explicitly requested or authorized it. If a consequential new choice emerges, stop only the affected path and present the decision while independent paths continue when safe.
6
-
7
- Do not pause or return control merely to report that a task or work item completed, to announce progress, or to state the next step. Recompute readiness and continue automatically while useful ready work exists. Surface execution status only when developer input is required or execution has actually stopped.
@@ -1,15 +0,0 @@
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
- Update valid canonical artifacts when their truth changes. Create `PRD.md`, `ENGINEERING.md`, `DECISIONS.md`, `BACKLOG.yaml`, `STATE.md`, `GRAPH.md`, work-item artifacts, or gate definitions only when the developer explicitly requested or authorized creation of that artifact class. Never create substitute, progress, summary, handoff, or ad-hoc documents to capture information that belongs in an existing approved artifact.
14
-
15
- `GRAPH.md` is a derived human-readable projection of `BACKLOG.yaml`, not an independent source of truth. Discovery ends when no unresolved global decision is needed for a coherent production-capable MVP and initial work-item DAG.
@@ -1,62 +0,0 @@
1
- # `GRAPH.md` Rules
2
-
3
- Every Flow `GRAPH.md` must be a derived, human-readable projection of
4
- `.flow/BACKLOG.yaml`. It never becomes an independent source of truth.
5
-
6
- ## Card content
7
-
8
- Each Mermaid card contains exactly two lines:
9
-
10
- ```text
11
- <work-item ID>
12
- <work-item title>
13
- ```
14
-
15
- Do not include status, priority, folder, dependency lists, or explanatory
16
- prose inside a card. The title is the canonical `title` value from
17
- `BACKLOG.yaml`.
18
-
19
- ## Status derivation and colors
20
-
21
- Derive status from the backlog and dependencies after every meaningful state
22
- transition.
23
-
24
- | Status | Meaning | Card color | Outgoing arrow style |
25
- | --- | --- | --- | --- |
26
- | Complete | Work item is accepted and complete. | Green (`#16a34a`) | Solid green |
27
- | In progress | Work item has active execution. | Blue (`#2563eb`) | Solid blue, thicker |
28
- | Pending | Every dependency is complete and the item is ready to start. | Yellow (`#d97706`) | Dashed yellow |
29
- | Blocked | The item is neither complete nor in progress and one or more dependencies are incomplete. | Red (`#dc2626`) | Dotted red |
30
-
31
- Use matching fill, stroke, and readable text colors for cards. Every graph
32
- must include a titled status legend using these colors.
33
-
34
- ## Dependencies and arrows
35
-
36
- - Draw one arrow for every `depends_on` relationship in `BACKLOG.yaml`.
37
- - The arrow goes from dependency to dependent item.
38
- - Every outgoing arrow inherits the color and line style of its source card.
39
- - Recalculate Mermaid `linkStyle` indexes whenever edges change; do not leave
40
- a stale style assignment behind.
41
- - Do not add visual-only dependency edges to force layout.
42
-
43
- ## Parallelism and layout
44
-
45
- - Items on the same vertical rank must have no dependency on one another and
46
- are candidates for parallel work.
47
- - Keep independent, ready items on the same vertical rank where Mermaid can
48
- represent the real dependency graph without artificial edges.
49
- - Do not represent blocked items as pending merely because they are planned;
50
- dependency readiness determines their graph status.
51
-
52
- ## Synchronization checklist
53
-
54
- When work-item state, existence, title, or dependencies change:
55
-
56
- 1. Update `BACKLOG.yaml` first.
57
- 2. Recompute derived statuses using the definitions above.
58
- 3. Update `GRAPH.md`, including cards, arrows, styles, legend, and parallel
59
- layout.
60
- 4. Update `STATE.md` when the active path or next ready work changes.
61
- 5. Verify that every backlog item appears exactly once and every dependency
62
- appears exactly once in the graph.
@@ -1,7 +0,0 @@
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
- For an already authorized work-item artifact class, create or update `.flow/work-items/<id>/SPEC.md` with goal, scope/non-goals, relevant decisions, approach, requirements, acceptance criteria, gates, dependencies/impacts, and validation. Create or update `TASKS.yaml` with bounded, testable, independently executable tasks, real blocking dependencies only, and concise acceptance/validation expectations.
6
-
7
- If the required `SPEC.md` or `TASKS.yaml` does not yet exist and the developer has not explicitly requested or authorized creation of that artifact class, request authorization before creating it. Do not create substitute planning documents. After planning, continue automatically into ready execution instead of stopping to report the plan unless a consequential developer decision is required.
@@ -1,5 +0,0 @@
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 approved artifacts whose current truth changed, including the derived `GRAPH.md` whenever work-item existence, dependencies, or status change.
4
-
5
- Never create a new document or artifact during reconciliation unless the developer explicitly requested or authorized it. After reconciliation, recompute readiness and continue execution automatically when safe rather than pausing to report status.
@@ -1,5 +0,0 @@
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.yaml`, `STATE.md`, `GRAPH.md`, and other affected approved canonical artifacts.
4
-
5
- Never create a new document or artifact during review unless the developer explicitly requested or authorized it. Do not stop merely to announce successful validation or the next ready work item; return to orchestration and continue while useful ready work exists.