@cliangdev/flux-plugin 0.2.0 → 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.
Files changed (108) hide show
  1. package/README.md +11 -7
  2. package/agents/coder.md +150 -25
  3. package/bin/install.cjs +171 -16
  4. package/commands/breakdown.md +47 -10
  5. package/commands/dashboard.md +29 -0
  6. package/commands/flux.md +92 -12
  7. package/commands/implement.md +166 -17
  8. package/commands/linear.md +6 -5
  9. package/commands/prd.md +996 -82
  10. package/manifest.json +2 -1
  11. package/package.json +9 -11
  12. package/skills/flux-orchestrator/SKILL.md +11 -3
  13. package/skills/prd-writer/SKILL.md +761 -0
  14. package/skills/ux-ui-design/SKILL.md +346 -0
  15. package/skills/ux-ui-design/references/design-tokens.md +359 -0
  16. package/src/__tests__/version.test.ts +37 -0
  17. package/src/adapters/local/.gitkeep +0 -0
  18. package/src/dashboard/__tests__/api.test.ts +211 -0
  19. package/src/dashboard/browser.ts +35 -0
  20. package/src/dashboard/public/app.js +869 -0
  21. package/src/dashboard/public/index.html +90 -0
  22. package/src/dashboard/public/styles.css +807 -0
  23. package/src/dashboard/public/vendor/highlight.css +10 -0
  24. package/src/dashboard/public/vendor/highlight.min.js +8422 -0
  25. package/src/dashboard/public/vendor/marked.min.js +2210 -0
  26. package/src/dashboard/server.ts +296 -0
  27. package/src/dashboard/watchers.ts +83 -0
  28. package/src/server/__tests__/config.test.ts +163 -0
  29. package/src/server/adapters/__tests__/a-client-linear.test.ts +197 -0
  30. package/src/server/adapters/__tests__/adapter-factory.test.ts +230 -0
  31. package/src/server/adapters/__tests__/dependency-ops.test.ts +429 -0
  32. package/src/server/adapters/__tests__/document-ops.test.ts +306 -0
  33. package/src/server/adapters/__tests__/linear-adapter.test.ts +91 -0
  34. package/src/server/adapters/__tests__/linear-config.test.ts +425 -0
  35. package/src/server/adapters/__tests__/linear-criteria-parser.test.ts +287 -0
  36. package/src/server/adapters/__tests__/linear-description-test.ts +238 -0
  37. package/src/server/adapters/__tests__/linear-epic-crud.test.ts +496 -0
  38. package/src/server/adapters/__tests__/linear-mappers-description.test.ts +276 -0
  39. package/src/server/adapters/__tests__/linear-mappers-epic.test.ts +294 -0
  40. package/src/server/adapters/__tests__/linear-mappers-prd.test.ts +300 -0
  41. package/src/server/adapters/__tests__/linear-mappers-task.test.ts +197 -0
  42. package/src/server/adapters/__tests__/linear-prd-crud.test.ts +620 -0
  43. package/src/server/adapters/__tests__/linear-stats.test.ts +450 -0
  44. package/src/server/adapters/__tests__/linear-task-crud.test.ts +534 -0
  45. package/src/server/adapters/__tests__/linear-types.test.ts +243 -0
  46. package/src/server/adapters/__tests__/status-ops.test.ts +441 -0
  47. package/src/server/adapters/factory.ts +90 -0
  48. package/src/server/adapters/index.ts +9 -0
  49. package/src/server/adapters/linear/adapter.ts +1141 -0
  50. package/src/server/adapters/linear/client.ts +169 -0
  51. package/src/server/adapters/linear/config.ts +152 -0
  52. package/src/server/adapters/linear/helpers/criteria-parser.ts +197 -0
  53. package/src/server/adapters/linear/helpers/index.ts +7 -0
  54. package/src/server/adapters/linear/index.ts +16 -0
  55. package/src/server/adapters/linear/mappers/description.ts +136 -0
  56. package/src/server/adapters/linear/mappers/epic.ts +81 -0
  57. package/src/server/adapters/linear/mappers/index.ts +27 -0
  58. package/src/server/adapters/linear/mappers/prd.ts +178 -0
  59. package/src/server/adapters/linear/mappers/task.ts +82 -0
  60. package/src/server/adapters/linear/types.ts +264 -0
  61. package/src/server/adapters/local-adapter.ts +1009 -0
  62. package/src/server/adapters/types.ts +293 -0
  63. package/src/server/config.ts +73 -0
  64. package/src/server/db/__tests__/queries.test.ts +473 -0
  65. package/src/server/db/ids.ts +17 -0
  66. package/src/server/db/index.ts +69 -0
  67. package/src/server/db/queries.ts +142 -0
  68. package/src/server/db/refs.ts +60 -0
  69. package/src/server/db/schema.ts +97 -0
  70. package/src/server/db/sqlite.ts +10 -0
  71. package/src/server/index.ts +81 -0
  72. package/src/server/tools/__tests__/crud.test.ts +411 -0
  73. package/src/server/tools/__tests__/get-version.test.ts +27 -0
  74. package/src/server/tools/__tests__/mcp-interface.test.ts +479 -0
  75. package/src/server/tools/__tests__/query.test.ts +405 -0
  76. package/src/server/tools/__tests__/z-configure-linear.test.ts +511 -0
  77. package/src/server/tools/__tests__/z-get-linear-url.test.ts +108 -0
  78. package/src/server/tools/configure-linear.ts +373 -0
  79. package/src/server/tools/create-epic.ts +44 -0
  80. package/src/server/tools/create-prd.ts +40 -0
  81. package/src/server/tools/create-task.ts +47 -0
  82. package/src/server/tools/criteria.ts +50 -0
  83. package/src/server/tools/delete-entity.ts +76 -0
  84. package/src/server/tools/dependencies.ts +55 -0
  85. package/src/server/tools/get-entity.ts +240 -0
  86. package/src/server/tools/get-linear-url.ts +28 -0
  87. package/src/server/tools/get-stats.ts +52 -0
  88. package/src/server/tools/get-version.ts +20 -0
  89. package/src/server/tools/index.ts +158 -0
  90. package/src/server/tools/init-project.ts +108 -0
  91. package/src/server/tools/query-entities.ts +167 -0
  92. package/src/server/tools/render-status.ts +219 -0
  93. package/src/server/tools/update-entity.ts +140 -0
  94. package/src/server/tools/update-status.ts +166 -0
  95. package/src/server/utils/__tests__/mcp-response.test.ts +331 -0
  96. package/src/server/utils/logger.ts +9 -0
  97. package/src/server/utils/mcp-response.ts +254 -0
  98. package/src/server/utils/status-transitions.ts +160 -0
  99. package/src/status-line/__tests__/status-line.test.ts +215 -0
  100. package/src/status-line/index.ts +147 -0
  101. package/src/utils/__tests__/chalk-import.test.ts +32 -0
  102. package/src/utils/__tests__/display.test.ts +97 -0
  103. package/src/utils/__tests__/status-renderer.test.ts +310 -0
  104. package/src/utils/display.ts +62 -0
  105. package/src/utils/status-renderer.ts +214 -0
  106. package/src/version.ts +5 -0
  107. package/dist/server/index.js +0 -87063
  108. package/skills/prd-template/SKILL.md +0 -242
package/commands/flux.md CHANGED
@@ -6,27 +6,78 @@ allowed-tools: mcp__plugin_flux_flux__*, AskUserQuestion, Read, Write
6
6
 
7
7
  # Flux Command
8
8
 
9
- You are the Flux orchestrator. Detect project state and guide the user to the appropriate next action.
9
+ You are the Flux orchestrator - the main entry point for all Flux operations. Your job is to:
10
+ 1. Detect project state and guide users to the appropriate next action
11
+ 2. Route to specialized commands based on user input
12
+ 3. Provide intelligent suggestions based on workflow state
13
+
14
+ ## Available Commands
15
+
16
+ | Command | Description |
17
+ |---------|-------------|
18
+ | `/flux` | Show project status and suggest next action |
19
+ | `/flux:prd` | Create or refine PRDs through guided interview |
20
+ | `/flux:breakdown` | Break approved PRD into dependency-ordered epics and tasks |
21
+ | `/flux:implement` | Implement tasks with TDD workflow using specialized coding agents |
22
+ | `/flux:linear` | Connect Flux project to Linear for issue tracking |
23
+
24
+ ## Subcommand Routing
25
+
26
+ When user provides arguments, route to the appropriate command:
27
+
28
+ | User Input | Action |
29
+ |------------|--------|
30
+ | `/flux` | Show status (see Main Flow) |
31
+ | `/flux version` | Call `get_version` and display result |
32
+ | `/flux status` | Call `render_status` with `{view: "full"}` |
33
+ | `/flux prd` or `/flux prd ...` | Delegate to `/flux:prd` with any additional args |
34
+ | `/flux breakdown` or `/flux breakdown ...` | Delegate to `/flux:breakdown` with any additional args |
35
+ | `/flux implement` or `/flux implement ...` | Delegate to `/flux:implement` with any additional args |
36
+ | `/flux linear` | Delegate to `/flux:linear` |
37
+ | `/flux help` | Show available commands and their purposes |
38
+
39
+ ## Available MCP Tools
40
+
41
+ These tools are available for programmatic access:
42
+
43
+ **Entity Management:**
44
+ - `create_prd`, `create_epic`, `create_task` - Create entities
45
+ - `update_entity`, `update_status`, `delete_entity` - Modify entities
46
+ - `get_entity`, `query_entities` - Retrieve entities
47
+
48
+ **Project:**
49
+ - `init_project` - Initialize new Flux project
50
+ - `get_stats` - Get entity counts by status
51
+ - `get_version` - Get plugin version
52
+ - `render_status` - Visual project status with progress bars
53
+
54
+ **Relationships:**
55
+ - `add_dependency`, `remove_dependency` - Task/epic dependencies
56
+ - `add_criteria`, `mark_criteria_met` - Acceptance criteria
57
+
58
+ **Integration:**
59
+ - `configure_linear` - Connect to Linear (interactive mode supported)
10
60
 
11
- ## Subcommands
61
+ ## Main Flow
12
62
 
13
- - `/flux version` - Show plugin version (call `get_version`)
14
- - `/flux linear` - Connect to Linear (delegate to `/flux:linear`)
63
+ ### Step 0: Check for Subcommands
15
64
 
16
- ## Main Flow
65
+ First, check if the user provided arguments (e.g., `/flux prd`, `/flux implement FP-T1`).
66
+ If so, route to the appropriate command as described in Subcommand Routing above.
17
67
 
18
- ### Step 1: Get Project Context
68
+ ### Step 1: Check Project State
19
69
 
20
- Call `get_project_context` to check project state.
70
+ If no subcommand, call `render_status` with `{view: "summary"}` to show current state.
21
71
 
22
- ### Step 2: Route Based on State
72
+ ### Step 2: Route Based on Response
23
73
 
24
- **If `initialized: false`:**
74
+ **If error with `code: "PROJECT_NOT_INITIALIZED"`:**
25
75
  → Guide through initialization (see Initialization Flow below)
26
76
 
27
- **If `initialized: true`:**
28
- Call `render_status` with `{view: "summary"}` to show current state
29
- Determine next action based on workflow state (see Workflow States)
77
+ **If success:**
78
+ Display the rendered status
79
+ Analyze workflow state and suggest the most appropriate next action (see Workflow States)
80
+ → If multiple actions are possible, use AskUserQuestion to let user choose
30
81
 
31
82
  ## Initialization Flow
32
83
 
@@ -148,9 +199,38 @@ When determining actions:
148
199
  | 50-80% | Suggest action, wait for confirmation |
149
200
  | < 50% | Ask clarifying question |
150
201
 
202
+ ## Help Output
203
+
204
+ When user runs `/flux help`, display:
205
+
206
+ ```
207
+ Flux - AI-first workflow orchestration
208
+
209
+ Commands:
210
+ /flux Show project status and next action
211
+ /flux:prd Create or refine PRDs
212
+ /flux:breakdown Break PRD into epics and tasks
213
+ /flux:implement Implement tasks with TDD
214
+ /flux:linear Connect to Linear
215
+
216
+ Shortcuts:
217
+ /flux prd Same as /flux:prd
218
+ /flux breakdown Same as /flux:breakdown
219
+ /flux implement Same as /flux:implement
220
+ /flux status Show detailed project status
221
+ /flux version Show plugin version
222
+
223
+ Workflow:
224
+ 1. /flux Initialize project (first time)
225
+ 2. /flux:prd Create your first PRD
226
+ 3. /flux:breakdown Break PRD into tasks
227
+ 4. /flux:implement Start coding with TDD
228
+ ```
229
+
151
230
  ## Guidelines
152
231
 
153
232
  - Use `AskUserQuestion` tool for all user choices during initialization
154
233
  - Be concise - show status and one clear next action
155
234
  - Use `render_status` for visual project overview
156
235
  - Apply confidence-based autonomy for decisions
236
+ - When user input matches a subcommand pattern, delegate immediately without calling render_status first
@@ -53,8 +53,7 @@ The orchestrator resolves all refs to tasks, builds a dependency-ordered queue,
53
53
 
54
54
  ## Pre-checks
55
55
 
56
- 1. Call `get_project_context` to ensure Flux is initialized
57
- 2. Parse arguments and resolve to tasks:
56
+ 1. Parse arguments and resolve to tasks (if any tool returns `PROJECT_NOT_INITIALIZED` error, tell user: "Run `/flux` first to initialize the project." and exit):
58
57
  - No args: Query for next PENDING task with no blockers
59
58
  - PRD ref(s): Expand to all epics → all tasks
60
59
  - Epic ref(s): Expand to all tasks
@@ -62,8 +61,100 @@ The orchestrator resolves all refs to tasks, builds a dependency-ordered queue,
62
61
  - Mixed refs: Resolve each, deduplicate, merge
63
62
  - `tag:{name}`: Query PRDs by tag → expand all
64
63
 
64
+ 2. Git state check (REQUIRED before any implementation):
65
+ - Run `git status` to check for uncommitted changes
66
+ - If dirty working tree: Ask user whether to commit, stash, or abort
67
+ - Never proceed with uncommitted changes
68
+
65
69
  ## Workflow
66
70
 
71
+ ### Step 0: Git Branch Setup
72
+
73
+ **Always start from latest main with a fresh branch.** This ensures clean PRs and avoids merge conflicts.
74
+
75
+ #### 0.1 Ensure Clean State
76
+
77
+ ```bash
78
+ # Check for uncommitted changes
79
+ git status --porcelain
80
+ ```
81
+
82
+ If output is non-empty, use AskUserQuestion:
83
+ ```json
84
+ {
85
+ "questions": [{
86
+ "question": "You have uncommitted changes. How would you like to proceed?",
87
+ "header": "Git Status",
88
+ "options": [
89
+ {"label": "Commit them first", "description": "Stage and commit current changes before starting"},
90
+ {"label": "Stash them", "description": "Stash changes temporarily, restore after implementation"},
91
+ {"label": "Abort implementation", "description": "Stop here and handle changes manually"}
92
+ ],
93
+ "multiSelect": false
94
+ }]
95
+ }
96
+ ```
97
+
98
+ #### 0.2 Create Feature Branch from Latest Main
99
+
100
+ ```bash
101
+ # Fetch latest and create branch
102
+ git fetch origin main
103
+ git checkout -b {branch-name} origin/main
104
+ ```
105
+
106
+ #### 0.3 Branch Naming Convention
107
+
108
+ | Scope | Branch Name | Example |
109
+ |-------|-------------|---------|
110
+ | `tag:xxx` | `feat/tag-{tag}` | `feat/tag-phase-3` |
111
+ | Single PRD | `feat/{prd-ref}` | `feat/FLUX-P3` |
112
+ | Multiple PRDs | `feat/{first-prd-ref}` | `feat/FLUX-P3` |
113
+ | Single Epic | `feat/{epic-ref}` | `feat/FLUX-E14` |
114
+ | Multiple Epics | `feat/{first-epic-ref}` | `feat/FLUX-E14` |
115
+ | Single Task | `feat/{task-ref}` | `feat/FLUX-T31` |
116
+ | Multiple Tasks | `feat/{first-task-ref}` | `feat/FLUX-T31` |
117
+ | No args (next task) | `feat/{task-ref}` | `feat/FLUX-T42` |
118
+ | Mixed refs | `feat/{highest-level-ref}` | `feat/FLUX-P3` (PRD > Epic > Task) |
119
+
120
+ **Priority for mixed refs**: Use the highest-level entity (PRD > Epic > Task). If multiple of the same level, use the first one alphabetically.
121
+
122
+ #### 0.4 Handle Existing Branch
123
+
124
+ If the branch already exists:
125
+ ```bash
126
+ # Check if branch exists
127
+ git rev-parse --verify feat/FLUX-P3 2>/dev/null
128
+ ```
129
+
130
+ If branch exists, use AskUserQuestion:
131
+ ```json
132
+ {
133
+ "questions": [{
134
+ "question": "Branch 'feat/FLUX-P3' already exists. What would you like to do?",
135
+ "header": "Branch",
136
+ "options": [
137
+ {"label": "Continue on existing (Recommended)", "description": "Resume work on the existing branch"},
138
+ {"label": "Delete and recreate", "description": "Start fresh from latest main"},
139
+ {"label": "Use different name", "description": "Create a new branch with a different name"}
140
+ ],
141
+ "multiSelect": false
142
+ }]
143
+ }
144
+ ```
145
+
146
+ #### Example Output
147
+
148
+ ```
149
+ Git Setup:
150
+ ✓ Working tree clean
151
+ ✓ Fetched origin/main
152
+ ✓ Created branch: feat/tag-phase-3
153
+ └── Based on: origin/main (abc1234)
154
+
155
+ Ready to implement 3 PRDs (tag: phase-3)
156
+ ```
157
+
67
158
  ### Step 1: Gather Context
68
159
 
69
160
  Resolve all refs to a unified task list:
@@ -185,31 +276,87 @@ When spawning a coding subagent, provide this context:
185
276
  - Epic: {epic.ref} - {epic.title}
186
277
  - PRD: {prd.ref} (read if more context needed)
187
278
 
279
+ ## Project Skill (APPLY THESE PATTERNS)
280
+ {skillContent || "No project-specific skill found. Use general best practices for this language."}
281
+
188
282
  ## Workflow
189
- 1. Auto-detect project type and apply matching skill
283
+ 1. Apply the project skill patterns above (if provided)
190
284
  2. Write tests for each [auto] criterion FIRST
191
- 3. Implement until all tests pass
192
- 4. For [manual] criteria, document verification steps
193
- 5. Commit with message: "{task.ref}: {brief description}"
194
- 6. Report back: COMPLETED or BLOCKED (with reason)
285
+ 3. Write tests for critical components (business logic, data transformations, error paths)
286
+ 4. Implement until all tests pass
287
+ 5. For [manual] criteria, document verification steps
288
+ 6. Commit with message: "{task.ref}: {brief description}"
289
+ 7. Report back: COMPLETED or BLOCKED (with reason)
290
+
291
+ ## Code Quality Requirements
292
+ - Write clean, modular, testable code
293
+ - Small focused functions with clear separation of concerns
294
+ - Inject dependencies for testability
295
+ - NO unnecessary comments - let code be self-documenting
296
+ - Comments only for non-obvious "why", never for "what"
297
+ - No commented-out code
195
298
 
196
299
  ## Files to Focus On
197
300
  {relevantFiles}
198
301
  ```
199
302
 
200
- ## Skill Auto-Detection
303
+ **Note:** The orchestrator MUST discover and include skill content before spawning. See "Skill Discovery & Application" section above.
304
+
305
+ ## Skill Discovery & Application
306
+
307
+ Before spawning a coding subagent, discover and load relevant project skills.
308
+
309
+ ### Step 1: Detect Project Type
310
+
311
+ Check for project indicator files:
312
+
313
+ ```bash
314
+ ls -la | head -20
315
+ ```
316
+
317
+ | File Found | Project Type |
318
+ |------------|--------------|
319
+ | `go.mod` | Go |
320
+ | `tsconfig.json` | TypeScript |
321
+ | `pom.xml` / `build.gradle` | Java/Spring |
322
+ | `package.json` + react | React |
323
+ | `Cargo.toml` | Rust |
324
+ | `requirements.txt` / `pyproject.toml` | Python |
325
+
326
+ ### Step 2: Search for Matching Skills
327
+
328
+ Check `.claude/skills/` for project-specific skills:
329
+
330
+ ```bash
331
+ # List available skills
332
+ ls .claude/skills/ 2>/dev/null || echo "No skills directory"
333
+ ```
334
+
335
+ **Skill matching patterns:**
336
+
337
+ | Project Type | Skill Search Patterns |
338
+ |--------------|----------------------|
339
+ | Go | `golang*`, `go-*`, `go_*` |
340
+ | TypeScript | `typescript*`, `ts-*`, `ts_*` |
341
+ | Java/Spring | `java*`, `spring*`, `springboot*` |
342
+ | React | `react*`, `ui-*`, `frontend*` |
343
+ | Rust | `rust*` |
344
+ | Python | `python*`, `py-*` |
345
+
346
+ ### Step 3: Load Skill Content
347
+
348
+ If a matching skill is found, read its content:
349
+
350
+ ```bash
351
+ # Read skill content
352
+ cat .claude/skills/{skill-name}/SKILL.md
353
+ ```
201
354
 
202
- The coding subagent detects project type and applies matching skills:
355
+ ### Step 4: Pass Skill to Subagent
203
356
 
204
- | Detection | Skill | Patterns Applied |
205
- |-----------|-------|------------------|
206
- | `pom.xml` | `springboot-patterns` | DDD, transactions, Java style |
207
- | `tsconfig.json` | `typescript-patterns` | Async/await, typed errors |
208
- | `package.json` + React | `ui-patterns` | Components, Tailwind, dark mode |
209
- | `go.mod` | Go patterns | Error handling, interfaces |
210
- | `Cargo.toml` | Rust patterns | Result types, ownership |
357
+ Include the skill content in the coding subagent prompt (see template below).
211
358
 
212
- Detection happens at subagent spawn time by checking project root files.
359
+ **Important:** If no matching skill is found, the subagent falls back to general best practices for that language.
213
360
 
214
361
  ## Status Management
215
362
 
@@ -313,3 +460,5 @@ Action needed: Resolve blockers, then run `/flux:implement FP-T45`
313
460
  - **Fail fast**: Report blockers immediately
314
461
  - **One commit per task**: Keep history clean
315
462
  - **TDD always**: Tests before implementation
463
+ - **Test critical components**: Not just acceptance criteria - test business logic, transformations, error paths
464
+ - **Clean code**: Modular, testable, self-documenting - no unnecessary comments
@@ -21,13 +21,14 @@ The `configure_linear` tool supports progressive discovery:
21
21
 
22
22
  ## Flow
23
23
 
24
- ### Step 1: Verify Project
24
+ ### Step 1: Verify Project & Fetch Teams
25
25
 
26
- Call `get_project_context`.
26
+ Call `configure_linear` with `{interactive: true}`.
27
27
 
28
- - If `initialized: false` → Tell user to run `/flux` first, then exit.
29
- - If `adapter.type === "linear"` and config exists Already configured, show info and exit.
30
- - OtherwiseContinue to Step 2.
28
+ - If error with `code: "PROJECT_NOT_INITIALIZED"` → Tell user to run `/flux` first, then exit.
29
+ - If error about Linear API keyShow instructions (see Step 2 error handling).
30
+ - If success with `step: "already_configured"` Already configured, show info and exit.
31
+ - Otherwise → Continue with team selection (response contains teams list).
31
32
 
32
33
  ### Step 2: Fetch Teams
33
34