newaflux 1.0.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/bin/install.js ADDED
@@ -0,0 +1,216 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const os = require("os");
6
+
7
+ const VERSION = "1.0.0";
8
+ const PACKAGE_DIR = path.resolve(__dirname, "..");
9
+
10
+ // --- Colors ---
11
+ const c = {
12
+ reset: "\x1b[0m",
13
+ bold: "\x1b[1m",
14
+ dim: "\x1b[2m",
15
+ green: "\x1b[32m",
16
+ cyan: "\x1b[36m",
17
+ yellow: "\x1b[33m",
18
+ red: "\x1b[31m",
19
+ magenta: "\x1b[35m",
20
+ };
21
+
22
+ function log(msg) {
23
+ console.log(msg);
24
+ }
25
+ function success(msg) {
26
+ log(`${c.green} ✓${c.reset} ${msg}`);
27
+ }
28
+ function warn(msg) {
29
+ log(`${c.yellow} !${c.reset} ${msg}`);
30
+ }
31
+ function error(msg) {
32
+ log(`${c.red} ✗${c.reset} ${msg}`);
33
+ }
34
+
35
+ // --- Args ---
36
+ const args = process.argv.slice(2);
37
+ const flags = new Set(args.map((a) => a.toLowerCase()));
38
+
39
+ const isUninstall = flags.has("--uninstall") || flags.has("-u");
40
+ const isLocal = flags.has("--local") || flags.has("-l");
41
+ const isGlobal = flags.has("--global") || flags.has("-g");
42
+ const isHelp = flags.has("--help") || flags.has("-h");
43
+
44
+ if (isHelp) {
45
+ log(`
46
+ ${c.bold}${c.cyan}Newa Flux${c.reset} v${VERSION}
47
+ Simplified multi-agent workflow for Claude Code.
48
+
49
+ ${c.bold}Usage:${c.reset}
50
+ npx newaflux Install globally (default)
51
+ npx newaflux --local Install in current project
52
+ npx newaflux --uninstall Remove installation
53
+ npx newaflux --help Show this help
54
+
55
+ ${c.bold}Options:${c.reset}
56
+ -g, --global Install to ~/.claude/ (all projects)
57
+ -l, --local Install to ./.claude/ (current project)
58
+ -u, --uninstall Remove Newa Flux files
59
+ -h, --help Show help
60
+ `);
61
+ process.exit(0);
62
+ }
63
+
64
+ // --- Determine target ---
65
+ function getTargetDir() {
66
+ if (isLocal) {
67
+ return path.join(process.cwd(), ".claude");
68
+ }
69
+ return path.join(os.homedir(), ".claude");
70
+ }
71
+
72
+ const targetDir = getTargetDir();
73
+ const scope = isLocal ? "local" : "global";
74
+
75
+ // --- File manifest ---
76
+ const AGENTS = ["fluxn-researcher.md", "fluxn-executor.md", "fluxn-verifier.md"];
77
+
78
+ const COMMANDS = [
79
+ "init.md",
80
+ "research.md",
81
+ "plan.md",
82
+ "execute.md",
83
+ "verify.md",
84
+ "go.md",
85
+ ];
86
+
87
+ // --- Copy helper ---
88
+ function copyFile(src, dest) {
89
+ const destDir = path.dirname(dest);
90
+ if (!fs.existsSync(destDir)) {
91
+ fs.mkdirSync(destDir, { recursive: true });
92
+ }
93
+ fs.copyFileSync(src, dest);
94
+ }
95
+
96
+ // --- Install ---
97
+ function install() {
98
+ log("");
99
+ log(
100
+ `${c.bold}${c.cyan} ⚡ Newa Flux${c.reset} ${c.dim}v${VERSION}${c.reset}`
101
+ );
102
+ log(
103
+ `${c.dim} Simplified multi-agent workflow for Claude Code${c.reset}`
104
+ );
105
+ log("");
106
+ log(` Installing ${c.bold}${scope}${c.reset} → ${c.dim}${targetDir}${c.reset}`);
107
+ log("");
108
+
109
+ let copied = 0;
110
+
111
+ // Copy agents
112
+ const agentsDir = path.join(targetDir, "agents");
113
+ for (const file of AGENTS) {
114
+ const src = path.join(PACKAGE_DIR, "agents", file);
115
+ const dest = path.join(agentsDir, file);
116
+ if (!fs.existsSync(src)) {
117
+ error(`Source not found: ${file}`);
118
+ continue;
119
+ }
120
+ copyFile(src, dest);
121
+ success(`agents/${file}`);
122
+ copied++;
123
+ }
124
+
125
+ // Copy commands
126
+ const commandsDir = path.join(targetDir, "commands", "fluxn");
127
+ for (const file of COMMANDS) {
128
+ const src = path.join(PACKAGE_DIR, "commands", "fluxn", file);
129
+ const dest = path.join(commandsDir, file);
130
+ if (!fs.existsSync(src)) {
131
+ error(`Source not found: ${file}`);
132
+ continue;
133
+ }
134
+ copyFile(src, dest);
135
+ success(`commands/fluxn/${file}`);
136
+ copied++;
137
+ }
138
+
139
+ // Write version file
140
+ const versionFile = path.join(targetDir, "newaflux-version.txt");
141
+ fs.writeFileSync(versionFile, VERSION, "utf8");
142
+
143
+ log("");
144
+ log(
145
+ ` ${c.green}${c.bold}Done!${c.reset} ${copied}/9 files installed.`
146
+ );
147
+ log("");
148
+ log(` ${c.bold}Commands available:${c.reset}`);
149
+ log(` ${c.cyan}/fluxn:init${c.reset} Map your project`);
150
+ log(` ${c.cyan}/fluxn:research${c.reset} Research a task`);
151
+ log(` ${c.cyan}/fluxn:plan${c.reset} Create execution plan`);
152
+ log(` ${c.cyan}/fluxn:execute${c.reset} Execute phases`);
153
+ log(` ${c.cyan}/fluxn:verify${c.reset} Verify implementation`);
154
+ log(` ${c.cyan}/fluxn:go${c.reset} Research + Plan in one shot`);
155
+ log("");
156
+ log(
157
+ ` ${c.dim}Start with: /fluxn:init in Claude Code${c.reset}`
158
+ );
159
+ log("");
160
+ }
161
+
162
+ // --- Uninstall ---
163
+ function uninstall() {
164
+ log("");
165
+ log(`${c.bold}${c.yellow} Uninstalling Newa Flux${c.reset} (${scope})`);
166
+ log("");
167
+
168
+ let removed = 0;
169
+
170
+ // Remove agents
171
+ for (const file of AGENTS) {
172
+ const fp = path.join(targetDir, "agents", file);
173
+ if (fs.existsSync(fp)) {
174
+ fs.unlinkSync(fp);
175
+ success(`Removed agents/${file}`);
176
+ removed++;
177
+ }
178
+ }
179
+
180
+ // Remove commands dir
181
+ const commandsDir = path.join(targetDir, "commands", "fluxn");
182
+ if (fs.existsSync(commandsDir)) {
183
+ for (const file of COMMANDS) {
184
+ const fp = path.join(commandsDir, file);
185
+ if (fs.existsSync(fp)) {
186
+ fs.unlinkSync(fp);
187
+ success(`Removed commands/fluxn/${file}`);
188
+ removed++;
189
+ }
190
+ }
191
+ // Remove fluxn dir if empty
192
+ try {
193
+ fs.rmdirSync(commandsDir);
194
+ success("Removed commands/fluxn/");
195
+ } catch {
196
+ // not empty, that's fine
197
+ }
198
+ }
199
+
200
+ // Remove version file
201
+ const versionFile = path.join(targetDir, "newaflux-version.txt");
202
+ if (fs.existsSync(versionFile)) {
203
+ fs.unlinkSync(versionFile);
204
+ }
205
+
206
+ log("");
207
+ log(` ${c.green}${c.bold}Done!${c.reset} ${removed} files removed.`);
208
+ log("");
209
+ }
210
+
211
+ // --- Run ---
212
+ if (isUninstall) {
213
+ uninstall();
214
+ } else {
215
+ install();
216
+ }
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: "Execute plan phases: /fluxn:execute [phase-number | all]"
3
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob, Task
4
+ ---
5
+
6
+ # /fluxn:execute — Phase Execution
7
+
8
+ $ARGUMENTS
9
+
10
+ You are the **execution orchestrator** for Newa Flux. Your job: spawn a fresh `fluxn-executor` agent for each phase, providing it with full context to work independently.
11
+
12
+ ## Step 1: Load Context
13
+
14
+ Read these files:
15
+ 1. `.fluxn/PROJECT.md` — project map
16
+ 2. `.fluxn/STATE.md` — current state
17
+ 3. `.fluxn/PLAN.md` — the execution plan (must exist)
18
+
19
+ If PLAN.md doesn't exist, tell the user to run `/fluxn:plan` first.
20
+
21
+ ## Step 2: Determine Target Phase
22
+
23
+ Parse the argument from **$ARGUMENTS**:
24
+ - **A number** (e.g., `1`, `3`): execute that specific phase
25
+ - **`all`**: execute all pending phases sequentially
26
+ - **Empty/no argument**: find the next pending phase from the Checkpoint Summary table in PLAN.md
27
+
28
+ If all phases are already done, tell the user and suggest `/fluxn:verify`.
29
+
30
+ ## Step 3: Load Previous Phase Context
31
+
32
+ Read all existing `.fluxn/phases/phase-*-done.md` files. These contain:
33
+ - What was built in previous phases
34
+ - Handoff context for the current phase
35
+ - Any deviations or issues from previous phases
36
+
37
+ ```bash
38
+ mkdir -p .fluxn/phases
39
+ ```
40
+
41
+ ## Step 4: Execute Phase
42
+
43
+ For the target phase, spawn ONE `fluxn-executor` agent:
44
+
45
+ ```
46
+ subagent_type: "fluxn-executor"
47
+ prompt: |
48
+ # Execute Phase [N]: [Phase Name]
49
+
50
+ ## Project Rules (CLAUDE.md)
51
+ [paste CLAUDE.md content, or "No CLAUDE.md found"]
52
+
53
+ ## Project Context (PROJECT.md)
54
+ [paste PROJECT.md content]
55
+
56
+ ## Previous Phases
57
+ [paste all phase-done.md summaries, or "This is the first phase"]
58
+
59
+ ## Your Phase
60
+ [paste the EXACT phase content from PLAN.md — Goal, Tasks, Files, Verification, Context]
61
+
62
+ ## Instructions
63
+ 1. Execute all tasks in this phase
64
+ 2. Commit after each logical unit (follow commit protocol)
65
+ 3. Run all verification checks
66
+ 4. Write your report to: .fluxn/phases/phase-[N]-done.md
67
+ 5. Return a brief summary
68
+ ```
69
+
70
+ ## Step 5: Update State After Phase Completes
71
+
72
+ After the executor finishes:
73
+
74
+ ### Update PLAN.md Checkpoint Summary
75
+ Change the phase's status from `pending` to `done` in the Checkpoint Summary table.
76
+ Use Edit tool to update just that line.
77
+
78
+ ### Update STATE.md
79
+ ```markdown
80
+ # Newa Flux State
81
+ **Project:** [project name]
82
+ **Task:** [task description]
83
+ **Status:** executing
84
+ **Phase:** [completed]/[total]
85
+ **Last activity:** [today's date] — Phase [N] completed: [phase name]
86
+
87
+ ## Current Task
88
+ [task description]
89
+ Type: [type]
90
+ Phases: [completed]/[total]
91
+
92
+ ## Blockers
93
+ [any issues from phase-done.md, or "None"]
94
+
95
+ ## Last Milestone
96
+ [keep existing or "None"]
97
+ ```
98
+
99
+ ## Step 6: Route Next
100
+
101
+ **If executing `all` and more phases remain:**
102
+ - Read the phase-done.md just written (for context passing)
103
+ - Go back to Step 4 for the next phase
104
+
105
+ **If the current phase was `partial`:**
106
+ - Tell the user what failed
107
+ - Suggest: fix the issue manually, then re-run `/fluxn:execute [N]` to retry
108
+
109
+ **If all phases are complete:**
110
+ - Tell the user: "All [N] phases complete. Run `/fluxn:verify` to verify the implementation."
111
+
112
+ **If only the requested phase is done (not `all`):**
113
+ - Report phase results
114
+ - Tell the user: "Phase [N] complete. Next: `/fluxn:execute` for the next phase, or `/fluxn:execute all` for remaining phases."
@@ -0,0 +1,173 @@
1
+ ---
2
+ description: "Quick start: research + plan in one shot: /fluxn:go <task description>"
3
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob, Task
4
+ ---
5
+
6
+ # /fluxn:go — Research + Plan (Quick Start)
7
+
8
+ $ARGUMENTS
9
+
10
+ You are the **go orchestrator** for Newa Flux. This is a shortcut that combines `/fluxn:research` and `/fluxn:plan` into one flow without pausing between them.
11
+
12
+ The task description comes from the user's arguments: **$ARGUMENTS**
13
+
14
+ If no arguments were provided, ask the user what they want to work on.
15
+
16
+ ---
17
+
18
+ ## PART 1: Research (same as /fluxn:research)
19
+
20
+ ### 1.1: Load Context
21
+
22
+ Read these files if they exist:
23
+ - `.fluxn/PROJECT.md` — project map (if missing, warn but continue)
24
+ - `.fluxn/STATE.md` — current state
25
+
26
+ ### 1.2: Classify Task Type
27
+
28
+ Classify based on the task description:
29
+ - **new-project**: Building something from scratch ("create", "build", "new", "scaffold", "start")
30
+ - **bug**: Fixing something broken ("fix", "bug", "error", "broken", "crash", "not working")
31
+ - **feature**: Adding to or modifying existing code ("add", "implement", "update", "change", "improve", "refactor")
32
+
33
+ Default to **feature** if ambiguous.
34
+
35
+ ### 1.3: Setup
36
+
37
+ ```bash
38
+ mkdir -p .fluxn/research
39
+ rm -f .fluxn/research/agent-*.md
40
+ ```
41
+
42
+ ### 1.4: Launch 4 Researchers in Parallel
43
+
44
+ Spawn 4 `fluxn-researcher` agents using the Task tool, ALL IN PARALLEL.
45
+
46
+ **If new-project:**
47
+ | Agent | Focus | Output File |
48
+ |-------|-------|-------------|
49
+ | 1 | Stack & tools research (web) | `.fluxn/research/agent-1-stack.md` |
50
+ | 2 | Architecture patterns (web) | `.fluxn/research/agent-2-architecture.md` |
51
+ | 3 | Feature implementation (web) | `.fluxn/research/agent-3-features.md` |
52
+ | 4 | Common pitfalls & best practices (web) | `.fluxn/research/agent-4-pitfalls.md` |
53
+
54
+ **If bug:**
55
+ | Agent | Focus | Output File |
56
+ |-------|-------|-------------|
57
+ | 1 | Symptom analysis & reproduction | `.fluxn/research/agent-1-symptoms.md` |
58
+ | 2 | Codebase investigation | `.fluxn/research/agent-2-codebase.md` |
59
+ | 3 | Git history & recent changes | `.fluxn/research/agent-3-history.md` |
60
+ | 4 | Known solutions & patterns (web) | `.fluxn/research/agent-4-solutions.md` |
61
+
62
+ **If feature:**
63
+ | Agent | Focus | Output File |
64
+ |-------|-------|-------------|
65
+ | 1 | Existing codebase analysis | `.fluxn/research/agent-1-codebase.md` |
66
+ | 2 | Existing patterns to follow | `.fluxn/research/agent-2-patterns.md` |
67
+ | 3 | Dependencies & impact analysis | `.fluxn/research/agent-3-impact.md` |
68
+ | 4 | Best practices & references (web) | `.fluxn/research/agent-4-practices.md` |
69
+
70
+ Each agent receives PROJECT.md content as base context in their prompt:
71
+ ```
72
+ FOCUS: [focus area]
73
+ AGENT: [N] of 4
74
+ OUTPUT FILE: [file path]
75
+ TASK: [full task description]
76
+ TYPE: [codebase | web | hybrid]
77
+
78
+ PROJECT CONTEXT:
79
+ [PROJECT.md content or "No PROJECT.md — explore from scratch"]
80
+
81
+ SPECIFIC INSTRUCTIONS:
82
+ [Investigation items for this focus area]
83
+
84
+ Write findings to [file path]
85
+ ```
86
+
87
+ ### 1.5: Update STATE.md (after agents complete)
88
+
89
+ Update `.fluxn/STATE.md` with status: researching, task info.
90
+
91
+ ---
92
+
93
+ ## PART 2: Plan (same as /fluxn:plan, runs inline)
94
+
95
+ ### 2.1: Read All Research
96
+
97
+ Read all `.fluxn/research/agent-*.md` files that the researchers just created.
98
+
99
+ ### 2.2: Synthesize and Plan
100
+
101
+ From research findings, extract key decisions, approach, risks, dependencies.
102
+
103
+ Break work into 2-6 phases following the same rules as `/fluxn:plan`:
104
+ - Each phase completable by a fresh agent
105
+ - Clear, verifiable goals
106
+ - Explicit file paths in tasks
107
+ - Executable verification commands
108
+ - Complete handoff between phases
109
+
110
+ ### 2.3: Write PLAN.md
111
+
112
+ Write `.fluxn/PLAN.md` using the standard plan template:
113
+
114
+ ```markdown
115
+ # Newa Flux Plan
116
+ **Task:** [task description]
117
+ **Type:** [type]
118
+ **Phases:** [N]
119
+ **Created:** [today's date]
120
+
121
+ ## Research Summary
122
+ [3-5 sentences]
123
+
124
+ **Key decisions:**
125
+ - [Decision: what and why]
126
+
127
+ ---
128
+
129
+ ## Phase 1: [Name]
130
+ **Goal:** [one sentence]
131
+
132
+ ### Tasks
133
+ 1. [specific task with file paths]
134
+
135
+ ### Files to Create/Modify
136
+ - `path` — [purpose]
137
+
138
+ ### Verification
139
+ - [ ] `[command]`
140
+
141
+ ### Context for Next Phase
142
+ [handoff]
143
+
144
+ ---
145
+
146
+ [... more phases]
147
+
148
+ ---
149
+
150
+ ## Checkpoint Summary
151
+ | Phase | Goal | Verification | Status |
152
+ |-------|------|-------------|--------|
153
+ | 1 | ... | ... | pending |
154
+
155
+ ## Completion Criteria
156
+ - [ ] [criterion]
157
+ ```
158
+
159
+ ### 2.4: Update STATE.md
160
+
161
+ Update `.fluxn/STATE.md` with status: planned, phase count.
162
+
163
+ ---
164
+
165
+ ## PART 3: Report
166
+
167
+ Tell the user:
168
+ - Research + plan complete for: [task description]
169
+ - Task type: [type]
170
+ - Plan: [N] phases
171
+ - Brief summary of each phase (1 line each)
172
+ - Checkpoint summary table
173
+ - Next step: Run `/fluxn:execute` to start phase 1, or `/fluxn:execute all` for all phases.