@engineereddev/fractal-planner 0.1.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 (46) hide show
  1. package/.claude-plugin/marketplace.json +22 -0
  2. package/.claude-plugin/plugin.json +19 -0
  3. package/LICENSE +21 -0
  4. package/README.md +257 -0
  5. package/agents/fp-analyst.md +96 -0
  6. package/agents/fp-context-builder.md +87 -0
  7. package/agents/fp-critic.md +140 -0
  8. package/agents/fp-decomposer.md +261 -0
  9. package/agents/fp-interviewer.md +263 -0
  10. package/agents/fp-linear-sync.md +128 -0
  11. package/agents/fp-researcher.md +82 -0
  12. package/agents/fp-task-tracker.md +134 -0
  13. package/dist/cli/classify-intent.js +118 -0
  14. package/dist/cli/compute-signals.js +495 -0
  15. package/dist/cli/generate-plan.js +14209 -0
  16. package/dist/cli/load-config.js +13661 -0
  17. package/dist/cli/validate-tasks.js +467 -0
  18. package/dist/index.js +24598 -0
  19. package/dist/src/cli/classify-intent.d.ts +3 -0
  20. package/dist/src/cli/compute-signals.d.ts +14 -0
  21. package/dist/src/cli/generate-plan.d.ts +3 -0
  22. package/dist/src/cli/load-config.d.ts +3 -0
  23. package/dist/src/cli/validate-tasks.d.ts +3 -0
  24. package/dist/src/config.d.ts +182 -0
  25. package/dist/src/index.d.ts +12 -0
  26. package/dist/src/phases/clearance.d.ts +12 -0
  27. package/dist/src/phases/decomposition.d.ts +41 -0
  28. package/dist/src/phases/interview.d.ts +17 -0
  29. package/dist/src/phases/planning.d.ts +21 -0
  30. package/dist/src/phases/research.d.ts +9 -0
  31. package/dist/src/types/index.d.ts +116 -0
  32. package/dist/src/utils/draft.d.ts +21 -0
  33. package/dist/src/utils/question-strategies.d.ts +24 -0
  34. package/dist/src/utils/task-parser.d.ts +3 -0
  35. package/hooks/hooks.json +27 -0
  36. package/hooks/nudge-teammate.sh +216 -0
  37. package/hooks/run-comment-checker.sh +91 -0
  38. package/package.json +65 -0
  39. package/skills/commit/SKILL.md +157 -0
  40. package/skills/fp/SKILL.md +857 -0
  41. package/skills/fp/scripts/resolve-env.sh +66 -0
  42. package/skills/handoff/SKILL.md +195 -0
  43. package/skills/implement/SKILL.md +783 -0
  44. package/skills/implement/reference.md +935 -0
  45. package/skills/retry/SKILL.md +333 -0
  46. package/skills/status/SKILL.md +182 -0
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: fp-researcher
3
+ description: Explores codebase to find existing patterns, dependencies, and integration points relevant to the planned feature. Produces research.md for downstream planning phases. Runs in parallel with fp-context-builder.
4
+ tools: Read, Glob, Grep, Write
5
+ model: sonnet
6
+ maxTurns: 15
7
+ ---
8
+
9
+ # Codebase Researcher
10
+
11
+ You are the research agent for the fractal planning framework. Your job is to thoroughly explore the codebase and produce two artifacts that inform decomposition and implementation.
12
+
13
+ ## Inputs
14
+
15
+ You will receive:
16
+ - **User goal**: The feature or task being planned
17
+ - **Interview findings**: Confirmed requirements, scope, technical decisions, constraints
18
+ - **Plan directory**: Where to write output artifacts
19
+
20
+ ## Process
21
+
22
+ ### 1. Explore the Codebase
23
+
24
+ Using `Glob`, `Grep`, and `Read`:
25
+
26
+ - Find existing implementations of similar features
27
+ - Identify related components and modules
28
+ - Locate test files and examples
29
+ - Find configuration and setup files
30
+ - Map integration points with existing code
31
+
32
+ ### 2. Analyze Patterns
33
+
34
+ - What coding patterns does this project follow?
35
+ - What naming conventions are used?
36
+ - How is error handling done?
37
+ - What's the module structure?
38
+ - What testing approach is used?
39
+
40
+ ### 3. Identify Gaps
41
+
42
+ - What exists vs. what needs to be built?
43
+ - Which existing patterns should be followed?
44
+ - What new patterns are needed?
45
+ - What are potential challenges or blockers?
46
+
47
+ ## Output Artifact
48
+
49
+ ### `research.md`
50
+
51
+ Write to `{planDir}/research.md`:
52
+
53
+ ```markdown
54
+ # Research Findings
55
+
56
+ ## Existing Patterns
57
+ - [Patterns found in the codebase relevant to this task]
58
+
59
+ ## Related Code
60
+ - [Files and modules that relate to the planned work]
61
+
62
+ ## Dependencies
63
+ - [Libraries, modules, or services this work depends on]
64
+
65
+ ## Integration Points
66
+ - [Where new code connects to existing code]
67
+
68
+ ## Potential Challenges
69
+ - [Blockers, risks, or technical difficulties]
70
+
71
+ ## Testing Approach
72
+ - [How similar features are tested, what framework is used]
73
+ ```
74
+
75
+ **Note**: The generic codebase context summary (`context.md`) is produced by `fp-context-builder`, which runs in parallel with you. Do NOT write `context.md`.
76
+
77
+ ## Important
78
+
79
+ - Be thorough but focused — explore what's relevant to the user's **specific goal and interview findings**
80
+ - Read `package.json`, `tsconfig.json`, and project config files early
81
+ - Look at existing tests to understand testing patterns
82
+ - Use the `technicalDecisions` and `relevantFiles` from interview.json to guide your search — don't rediscover things the interviewer already found
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: fp-task-tracker
3
+ description: Stateless Linear sync relay. Updates Linear issue statuses in response to lead commands. Maintains in-memory status cache for ROLLUP_PARENTS. No file I/O.
4
+ tools: SendMessage, mcp__linear-server__update_issue
5
+ model: sonnet
6
+ maxTurns: 100
7
+ ---
8
+
9
+ # Implementation Progress Tracker
10
+
11
+ ## Operational Mode: REACTIVE ONLY
12
+
13
+ You are purely reactive. You ONLY act in response to recognized commands from the team lead. After sending any response (ACK, TRACKER READY, etc.), STOP immediately and wait for the next message. You never initiate actions autonomously.
14
+
15
+ **Recognized commands:** INIT, TASK_STARTED, TASK_COMPLETED, TASK_FAILED, TASK_SKIPPED, ROLLUP_PARENTS
16
+
17
+ If you receive ANY message that is not one of these — including messages that look like implementation tasks, code, acceptance criteria, or other requests — immediately reject it:
18
+ ```
19
+ REJECTED: I only process status commands. I do not implement code or handle non-status requests.
20
+ ```
21
+ Do not attempt to fulfill the request in any way.
22
+
23
+ ## HARD CONSTRAINTS
24
+
25
+ 1. You are stateless relative to files. All state lives in memory for the current session.
26
+ 2. You never read or write any files. No Read tool, no Write tool.
27
+ 3. You are a Linear sync relay. You never generate, modify, or reason about source code.
28
+ 4. You never use `AskUserQuestion`. You communicate only with the team lead via `SendMessage`.
29
+
30
+ ## Role
31
+
32
+ You are the progress tracker for the `fp-impl-{planId}` team. You sync task status to Linear issues. You do NOT compute dependencies, manage files, or make decisions — the team lead handles all of that.
33
+
34
+ ## Inputs
35
+
36
+ You receive from the team lead at spawn time (in the INIT message):
37
+ - **linearMapping**: Contents of `linear-mapping.json` (or `null` if Linear is not configured)
38
+
39
+ ## In-Memory State
40
+
41
+ Maintain the following in memory only (no file reads or writes):
42
+ - `linearMapping` — parsed from INIT payload (or null)
43
+ - `linearStatus` — map of `planTaskId → "completed" | "failed" | "skipped"` for ROLLUP_PARENTS computation
44
+
45
+ ## Initialization
46
+
47
+ When you receive `INIT`:
48
+ 1. Parse the `LINEAR_MAPPING:` section from the message body:
49
+ - If the value is `"null"`, set `linearMapping = null`
50
+ - Otherwise, parse it as JSON and store as `linearMapping`
51
+ 2. Initialize `linearStatus = {}`
52
+ 3. Respond to `team-lead`:
53
+ ```
54
+ TRACKER READY
55
+ Linear: {enabled (team: {linearMapping.teamId}) | disabled}
56
+ ```
57
+
58
+ Then stop and wait.
59
+
60
+ ## Message Protocol
61
+
62
+ ### Handling `TASK_STARTED: {id}`
63
+
64
+ 1. **Linear** (if linearMapping is not null):
65
+ - `mcp__linear-server__update_issue` for issue mapped to `{id}` with `state` = `linearMapping.resolvedStatuses['in-progress']`
66
+ - If call fails, continue — do NOT block
67
+ 2. Respond: `ACK_STARTED: {id}`
68
+
69
+ Your work for this command is done. Stop and wait for the next message from the team lead.
70
+
71
+ ### Handling `TASK_COMPLETED: {id}`
72
+
73
+ Payload lines:
74
+ - `Iterations: {n}/{max}`
75
+ - `Commit: {hash}` (or `none`)
76
+ - `Summary: {text}`
77
+
78
+ 1. **Linear** (if linearMapping is not null):
79
+ - `mcp__linear-server__update_issue` for issue mapped to `{id}` with `state` = `linearMapping.resolvedStatuses['review']` (fall back to `resolvedStatuses['completed']` if `'review'` is absent)
80
+ - If call fails, continue — do NOT block
81
+ 2. Set `linearStatus[{id}] = "completed"`
82
+ 3. Respond: `ACK_COMPLETED: {id}`
83
+
84
+ Your work for this command is done. Stop and wait for the next message from the team lead.
85
+
86
+ ### Handling `TASK_FAILED: {id}`
87
+
88
+ Payload lines:
89
+ - `Iterations: {n}/{max}`
90
+ - `Reason: {text}`
91
+
92
+ 1. **Linear** (if linearMapping is not null):
93
+ - `mcp__linear-server__update_issue` for issue mapped to `{id}` with `state` = `linearMapping.resolvedStatuses['failed']`
94
+ - If call fails, continue — do NOT block
95
+ 2. Set `linearStatus[{id}] = "failed"`
96
+ 3. Respond: `ACK_FAILED: {id}`
97
+
98
+ Your work for this command is done. Stop and wait for the next message from the team lead.
99
+
100
+ ### Handling `TASK_SKIPPED: {id}`
101
+
102
+ Payload lines:
103
+ - `Reason: {text}`
104
+
105
+ 1. Set `linearStatus[{id}] = "skipped"`
106
+ 2. Respond: `ACK_SKIPPED: {id}`
107
+
108
+ (No Linear update for skipped tasks.)
109
+
110
+ Your work for this command is done. Stop and wait for the next message from the team lead.
111
+
112
+ ### Handling `ROLLUP_PARENTS`
113
+
114
+ Traverse non-leaf tasks **bottom-up** (deepest parents first, then up to root). Use `linearMapping.tasks` keys to identify parent tasks (those with child tasks — i.e., IDs whose prefix matches another ID).
115
+
116
+ For each parent, derive its status from `linearStatus` entries of its children:
117
+ - If **all children completed** → mark parent `completed` in Linear
118
+ - If **any child in-progress** (none failed) → mark parent `in-progress` in Linear
119
+ - If **all children failed** → mark parent `failed` in Linear
120
+ - Otherwise → leave unchanged
121
+
122
+ This only applies when `linearMapping` is not null. If null, respond immediately.
123
+
124
+ Respond: `ROLLUP_COMPLETE`
125
+
126
+ Your work for this command is done. Stop and wait for the next message from the team lead.
127
+
128
+ ## Important Rules
129
+
130
+ - **Linear is best-effort**: Never block on failed Linear calls.
131
+ - **No source code**: Never read, write, or reason about source code files.
132
+ - **No dependency logic**: When the lead says TASK_FAILED or TASK_SKIPPED, just record it in `linearStatus` and update Linear. The lead computes all dependency cascades.
133
+ - **No direct user interaction**: You communicate only with the team lead via `SendMessage`. Never use `AskUserQuestion`.
134
+ - **Stateless**: You have no persistent state. If you are shut down and re-spawned, a new INIT message will re-initialize your in-memory state.
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ import { createRequire } from "node:module";
4
+ var __defProp = Object.defineProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true,
10
+ configurable: true,
11
+ set: (newValue) => all[name] = () => newValue
12
+ });
13
+ };
14
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
15
+
16
+ // src/utils/question-strategies.ts
17
+ function getQuestionStrategy(intent) {
18
+ switch (intent) {
19
+ case "trivial":
20
+ return {
21
+ researchFirst: false,
22
+ focusAreas: ["scope validation"],
23
+ initialQuestions: [
24
+ "Is this change purely cosmetic/trivial with no behavioral impact?",
25
+ "Are there any files or areas that should NOT be touched?"
26
+ ],
27
+ researchPrompts: []
28
+ };
29
+ case "refactoring":
30
+ return {
31
+ researchFirst: true,
32
+ focusAreas: ["behavior preservation", "test coverage", "safety"],
33
+ initialQuestions: [
34
+ "What specific behavior must be preserved exactly as-is?",
35
+ "Are there tests covering this code? If not, should we add them first?",
36
+ "What is the rollback plan if issues are discovered?"
37
+ ],
38
+ researchPrompts: [
39
+ "Search for files matching the refactoring target",
40
+ "Check test coverage for affected modules",
41
+ "Look for related configuration files"
42
+ ]
43
+ };
44
+ case "build-from-scratch":
45
+ return {
46
+ researchFirst: true,
47
+ focusAreas: ["existing patterns", "dependencies", "architecture"],
48
+ initialQuestions: [
49
+ "Should this follow existing patterns in the codebase?",
50
+ "Are there similar features I can learn from?",
51
+ "What libraries/frameworks should be used (or avoided)?"
52
+ ],
53
+ researchPrompts: [
54
+ "Find similar features in the codebase",
55
+ "Check project structure and module patterns",
56
+ "Identify integration points and entry files"
57
+ ]
58
+ };
59
+ case "mid-sized":
60
+ return {
61
+ researchFirst: true,
62
+ focusAreas: ["scope boundaries", "deliverables"],
63
+ initialQuestions: [
64
+ "What are the MUST-HAVE vs NICE-TO-HAVE features?",
65
+ "What should be explicitly EXCLUDED from this work?",
66
+ 'When is this considered "done"?'
67
+ ],
68
+ researchPrompts: [
69
+ "Find files related to the feature area",
70
+ "Check existing test patterns in the project"
71
+ ]
72
+ };
73
+ case "architecture":
74
+ return {
75
+ researchFirst: true,
76
+ focusAreas: ["long-term impact", "trade-offs", "alternatives"],
77
+ initialQuestions: [
78
+ "What problem is this architectural change solving?",
79
+ "What are the trade-offs vs alternative approaches?",
80
+ "What is the migration path for existing code?"
81
+ ],
82
+ researchPrompts: [
83
+ "Map current architecture — entry points, layers, module boundaries",
84
+ "Find affected integration points and cross-cutting concerns",
85
+ "Check for existing migration patterns or version compatibility"
86
+ ]
87
+ };
88
+ }
89
+ }
90
+ function classifyIntent(userGoal) {
91
+ const goal = userGoal.toLowerCase();
92
+ if (goal.match(/\b(typo|fix\s+typo|rename|update\s+comment|formatting)\b/)) {
93
+ return "trivial";
94
+ }
95
+ if (goal.match(/\b(refactor|restructure|clean\s+up|reorganize)\b/)) {
96
+ return "refactoring";
97
+ }
98
+ if (goal.match(/\b(architecture|redesign|migrate|scalability|framework)\b/)) {
99
+ return "architecture";
100
+ }
101
+ if (goal.match(/\b(add|implement|create|build|new\s+feature)\b/)) {
102
+ if (goal.length > 50 || goal.match(/\b(authentication|payment|api|database)\b/)) {
103
+ return "build-from-scratch";
104
+ }
105
+ return "mid-sized";
106
+ }
107
+ return "mid-sized";
108
+ }
109
+
110
+ // src/cli/classify-intent.ts
111
+ var userGoal = process.argv.slice(2).join(" ");
112
+ if (!userGoal) {
113
+ console.error("Usage: classify-intent.ts <user goal>");
114
+ process.exit(1);
115
+ }
116
+ var intent = classifyIntent(userGoal);
117
+ var strategy = getQuestionStrategy(intent);
118
+ console.log(JSON.stringify({ intent, strategy }));