@mrpatronz/nexusflow 0.1.0 → 0.1.2

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 (69) hide show
  1. package/.github/dependabot.yml +25 -0
  2. package/.github/workflows/release.yml +90 -0
  3. package/.vscode/launch.json +17 -0
  4. package/.vscode/tasks.json +17 -0
  5. package/README.md +1 -1
  6. package/dist/commands/commit.d.ts +18 -0
  7. package/dist/commands/commit.d.ts.map +1 -0
  8. package/dist/commands/commit.js +105 -0
  9. package/dist/commands/commit.js.map +1 -0
  10. package/dist/commands/diff.d.ts +11 -0
  11. package/dist/commands/diff.d.ts.map +1 -0
  12. package/dist/commands/diff.js +101 -0
  13. package/dist/commands/diff.js.map +1 -0
  14. package/dist/commands/sync.d.ts +11 -0
  15. package/dist/commands/sync.d.ts.map +1 -0
  16. package/dist/commands/sync.js +96 -0
  17. package/dist/commands/sync.js.map +1 -0
  18. package/dist/generators/base.d.ts.map +1 -1
  19. package/dist/generators/base.js +3 -0
  20. package/dist/generators/base.js.map +1 -1
  21. package/dist/generators/index.d.ts +5 -2
  22. package/dist/generators/index.d.ts.map +1 -1
  23. package/dist/generators/index.js +88 -38
  24. package/dist/generators/index.js.map +1 -1
  25. package/dist/generators/plan-generator.d.ts +40 -0
  26. package/dist/generators/plan-generator.d.ts.map +1 -0
  27. package/dist/generators/plan-generator.js +312 -0
  28. package/dist/generators/plan-generator.js.map +1 -0
  29. package/dist/gui/assets/index-B9Ph2bHH.css +2 -0
  30. package/dist/gui/assets/index-s4nRkpqY.js +21 -0
  31. package/dist/gui/index.html +2 -2
  32. package/dist/index.js +57 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +141 -1
  36. package/dist/server.js.map +1 -1
  37. package/dist/types.d.ts +13 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/utils/multi-git.d.ts +108 -0
  40. package/dist/utils/multi-git.d.ts.map +1 -0
  41. package/dist/utils/multi-git.js +206 -0
  42. package/dist/utils/multi-git.js.map +1 -0
  43. package/extension/package-lock.json +2811 -0
  44. package/extension/package.json +61 -0
  45. package/extension/src/extension.ts +168 -0
  46. package/extension/tsconfig.json +19 -0
  47. package/gui/src/App.tsx +377 -24
  48. package/gui/src/features/changes/ChangesViewer.tsx +212 -0
  49. package/gui/src/features/knowledge/KnowledgeBase.tsx +84 -0
  50. package/gui/src/features/onboarding/OnboardingWizard.tsx +230 -0
  51. package/gui/src/features/plan/ImplementationPlan.tsx +32 -0
  52. package/gui/src/features/services/ServiceConsole.tsx +159 -0
  53. package/gui/src/features/sessions/SessionHistory.tsx +195 -0
  54. package/gui/src/features/workspace/WorkspaceBuilder.tsx +414 -0
  55. package/gui/src/features/workspace/WorkspaceList.tsx +382 -0
  56. package/gui/src/types.ts +61 -0
  57. package/package.json +6 -4
  58. package/src/commands/commit.ts +131 -0
  59. package/src/commands/diff.ts +125 -0
  60. package/src/commands/sync.ts +110 -0
  61. package/src/generators/base.ts +3 -0
  62. package/src/generators/index.ts +95 -40
  63. package/src/generators/plan-generator.ts +390 -0
  64. package/src/index.ts +59 -0
  65. package/src/server.ts +152 -1
  66. package/src/types.ts +17 -0
  67. package/src/utils/multi-git.ts +306 -0
  68. package/dist/gui/assets/index-Cq9V485S.js +0 -21
  69. package/dist/gui/assets/index-Dh1b5gSZ.css +0 -2
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @module commands/diff
3
+ * Displays diff summaries across all repositories in a workspace.
4
+ */
5
+
6
+ import chalk from 'chalk';
7
+ import { select } from '@inquirer/prompts';
8
+ import * as path from 'node:path';
9
+ import * as fs from 'node:fs/promises';
10
+
11
+ import { loadConfig } from '../core/config.js';
12
+ import { listWorkspaces, loadFeatureConfig } from '../core/workspace.js';
13
+ import { getWorkspaceRepos, getRepoStatus, getDiffSummary } from '../utils/multi-git.js';
14
+
15
+ /**
16
+ * Executes the diff command.
17
+ *
18
+ * @param workspaceArg - Optional workspace path.
19
+ */
20
+ export async function diffCommand(workspaceArg?: string): Promise<void> {
21
+ console.log(chalk.bold.cyan('\nšŸ” NexusFlow — Workspace Diff Summary\n'));
22
+
23
+ const workspacePath = await resolveWorkspace(workspaceArg);
24
+ if (!workspacePath) return;
25
+
26
+ const feature = await loadFeatureConfig(workspacePath);
27
+ if (!feature) {
28
+ console.error(chalk.red('āœ– Failed to load workspace configuration.'));
29
+ return;
30
+ }
31
+
32
+ const repos = await getWorkspaceRepos(workspacePath);
33
+ let cleanCount = 0;
34
+
35
+ const results: Array<{
36
+ name: string;
37
+ filesChanged: number;
38
+ additions: number;
39
+ deletions: number;
40
+ summary: string;
41
+ }> = [];
42
+
43
+ for (const repo of repos) {
44
+ const status = await getRepoStatus(repo.path);
45
+ if (!status.hasChanges) {
46
+ cleanCount++;
47
+ continue;
48
+ }
49
+
50
+ const diff = await getDiffSummary(repo.path);
51
+ results.push({
52
+ name: repo.name,
53
+ filesChanged: status.changedFiles.length,
54
+ additions: diff.additions,
55
+ deletions: diff.deletions,
56
+ summary: diff.summary,
57
+ });
58
+ }
59
+
60
+ if (results.length === 0) {
61
+ console.log(chalk.green('āœ… All repositories are clean.\n'));
62
+ return;
63
+ }
64
+
65
+ // Print unified table
66
+ console.log(chalk.bold('Repository'.padEnd(25) + ' | ' + 'Files'.padEnd(6) + ' | ' + 'Additions'.padEnd(10) + ' | ' + 'Deletions'.padEnd(10)));
67
+ console.log(chalk.dim('─'.repeat(61)));
68
+
69
+ for (const res of results) {
70
+ const fileStr = res.filesChanged.toString().padEnd(6);
71
+ const addStr = `+${res.additions}`.padEnd(10);
72
+ const delStr = `-${res.deletions}`.padEnd(10);
73
+ console.log(
74
+ chalk.bold(res.name.padEnd(25)) + ' | ' +
75
+ fileStr + ' | ' +
76
+ chalk.green(addStr) + ' | ' +
77
+ chalk.red(delStr)
78
+ );
79
+ }
80
+
81
+ console.log('\n' + chalk.bold('Detailed Diff Stats:'));
82
+ for (const res of results) {
83
+ console.log(`\nšŸ“‚ ${chalk.bold.cyan(res.name)}:`);
84
+ console.log(chalk.dim(res.summary.split('\n').map(l => ` ${l}`).join('\n')));
85
+ }
86
+
87
+ console.log();
88
+ }
89
+
90
+ /**
91
+ * Resolves workspace path.
92
+ */
93
+ async function resolveWorkspace(workspaceArg?: string): Promise<string | null> {
94
+ if (workspaceArg) {
95
+ const absolutePath = path.resolve(workspaceArg);
96
+ try {
97
+ await fs.access(path.join(absolutePath, 'nexusflow.json'));
98
+ return absolutePath;
99
+ } catch {
100
+ console.error(chalk.red(`āœ– Invalid workspace: No nexusflow.json found at ${absolutePath}`));
101
+ return null;
102
+ }
103
+ }
104
+
105
+ const cwdFeature = await loadFeatureConfig(process.cwd());
106
+ if (cwdFeature) return process.cwd();
107
+
108
+ const config = await loadConfig();
109
+ const workspaces = await listWorkspaces(config.workspacesDir);
110
+
111
+ if (workspaces.length === 0) {
112
+ console.log(chalk.yellow('No workspaces found.\n'));
113
+ return null;
114
+ }
115
+
116
+ const selected = await select({
117
+ message: 'Select a workspace to view diff:',
118
+ choices: workspaces.map((ws) => ({
119
+ name: `${ws.branchName} ${chalk.dim(`(${ws.repos.length} repos)`)}`,
120
+ value: ws.workspacePath,
121
+ })),
122
+ });
123
+
124
+ return selected;
125
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @module commands/sync
3
+ * Syncs the active workspace by fetching and rebasing all repos onto their base branch.
4
+ */
5
+
6
+ import chalk from 'chalk';
7
+ import { select } from '@inquirer/prompts';
8
+ import * as path from 'node:path';
9
+ import * as fs from 'node:fs/promises';
10
+
11
+ import { loadConfig } from '../core/config.js';
12
+ import { listWorkspaces, loadFeatureConfig } from '../core/workspace.js';
13
+ import { getWorkspaceRepos, rebaseRepo } from '../utils/multi-git.js';
14
+
15
+ /**
16
+ * Executes the sync command.
17
+ *
18
+ * @param workspaceArg - Optional workspace path from CLI.
19
+ */
20
+ export async function syncCommand(workspaceArg?: string): Promise<void> {
21
+ console.log(chalk.bold.cyan('\nšŸ”„ NexusFlow — Syncing Workspace\n'));
22
+
23
+ const workspacePath = await resolveWorkspace(workspaceArg);
24
+ if (!workspacePath) return;
25
+
26
+ const feature = await loadFeatureConfig(workspacePath);
27
+ if (!feature) {
28
+ console.error(chalk.red('āœ– Failed to load workspace configuration. Ensure nexusflow.json exists.'));
29
+ return;
30
+ }
31
+
32
+ console.log(chalk.bold(`Syncing workspace: ${chalk.cyan(feature.branchName)}`));
33
+ console.log(chalk.dim(`Path: ${workspacePath}\n`));
34
+
35
+ let repos;
36
+ try {
37
+ repos = await getWorkspaceRepos(workspacePath);
38
+ } catch (error) {
39
+ console.error(chalk.red(`āœ– Failed to retrieve repos: ${error instanceof Error ? error.message : String(error)}`));
40
+ return;
41
+ }
42
+
43
+ let syncedCount = 0;
44
+ let conflictCount = 0;
45
+
46
+ for (const repo of repos) {
47
+ console.log(`Repository: ${chalk.bold(repo.name)}`);
48
+ // Ideally we rebase on the repo's default branch, which is often 'main' or 'master'
49
+ // Let's assume 'main' as default unless we fetch/read it.
50
+ const defaultBranch = 'main'; // We can default to 'main' as specified in requirements
51
+
52
+ const spinner = chalk.dim(' Rebasing...');
53
+ process.stdout.write(spinner);
54
+
55
+ const result = await rebaseRepo(repo.path, defaultBranch);
56
+
57
+ // Clear rebase message line
58
+ process.stdout.write('\r' + ' '.repeat(spinner.length) + '\r');
59
+
60
+ if (result.success) {
61
+ console.log(` ${chalk.green('āœ…')} Synced (${result.message})`);
62
+ syncedCount++;
63
+ } else {
64
+ console.log(` ${chalk.red('āš ļø')} Conflict: ${result.message}`);
65
+ if (result.conflict) {
66
+ console.log(chalk.dim(result.conflict.split('\n').map(l => ` ${l}`).slice(0, 5).join('\n')));
67
+ }
68
+ conflictCount++;
69
+ }
70
+ }
71
+
72
+ console.log(`\nšŸ“Š ${chalk.bold('Summary:')} ${syncedCount} synced, ${conflictCount} conflict(s)\n`);
73
+ }
74
+
75
+ /**
76
+ * Resolves a workspace path from argument, cwd, or user prompt.
77
+ */
78
+ async function resolveWorkspace(workspaceArg?: string): Promise<string | null> {
79
+ if (workspaceArg) {
80
+ const absolutePath = path.resolve(workspaceArg);
81
+ try {
82
+ await fs.access(path.join(absolutePath, 'nexusflow.json'));
83
+ return absolutePath;
84
+ } catch {
85
+ console.error(chalk.red(`āœ– Invalid workspace: No nexusflow.json found at ${absolutePath}`));
86
+ return null;
87
+ }
88
+ }
89
+
90
+ const cwdFeature = await loadFeatureConfig(process.cwd());
91
+ if (cwdFeature) return process.cwd();
92
+
93
+ const config = await loadConfig();
94
+ const workspaces = await listWorkspaces(config.workspacesDir);
95
+
96
+ if (workspaces.length === 0) {
97
+ console.log(chalk.yellow('No workspaces found.\n'));
98
+ return null;
99
+ }
100
+
101
+ const selected = await select({
102
+ message: 'Select a workspace to sync:',
103
+ choices: workspaces.map((ws) => ({
104
+ name: `${ws.branchName} ${chalk.dim(`(${ws.repos.length} repos)`)}`,
105
+ value: ws.workspacePath,
106
+ })),
107
+ });
108
+
109
+ return selected;
110
+ }
@@ -176,6 +176,8 @@ Once you have created \`nexusflow-overview.md\` and compiled your questions, ask
176
176
 
177
177
  ## Guidelines
178
178
 
179
+ - **Workspace Knowledge**: Read \`nexusflow-knowledge.md\` at the start of every session. It serves as the persistent memory for this feature. Before ending your session, append significant architecture decisions, discovered gotchas, and checklist progress to \`nexusflow-knowledge.md\`. Never delete or overwrite existing knowledge/decisions — only append.
180
+ - **Implementation Plan**: Refer to \`nexusflow-plan.md\` for the suggested implementation order based on dependency analysis. Follow the phased implementation order to avoid blocking yourself on cross-repo dependencies.
179
181
  - Read each project's existing \`README.md\` and any doc files before proposing changes.
180
182
  - When modifying a shared library, check every downstream consumer for breakage.
181
183
  - Prefer small, focused commits that touch one repo at a time when possible.
@@ -183,5 +185,6 @@ Once you have created \`nexusflow-overview.md\` and compiled your questions, ask
183
185
 
184
186
 
185
187
 
188
+
186
189
  `;
187
190
  }
@@ -7,6 +7,7 @@ import { generateCodexConfig } from './codex.js';
7
7
  import { generateCopilotConfig } from './copilot.js';
8
8
  import { generateCursorConfig } from './cursor.js';
9
9
  import { buildContextContent } from './base.js';
10
+ import { generateImplementationPlan } from './plan-generator.js';
10
11
 
11
12
  /** Maps each assistant to its generator function and the file it produces. */
12
13
  const GENERATORS: Record<
@@ -23,11 +24,83 @@ const GENERATORS: Record<
23
24
  cursor: { generate: generateCursorConfig, outputFile: '.cursor/rules/nexusflow.mdc' },
24
25
  };
25
26
 
27
+ /**
28
+ * Builds the nexusflow-knowledge.md content — a persistent AI memory file.
29
+ */
30
+ function buildKnowledgeContent(ctx: WorkspaceContext): string {
31
+ const { feature, repos, analysis } = ctx;
32
+
33
+ // Build repo list with tech stack info if available
34
+ const repoList = repos.map((r) => {
35
+ if (analysis && analysis.has(r.path)) {
36
+ const a = analysis.get(r.path)!;
37
+ const tech = a.techStack.frameworks.length > 0
38
+ ? ` (${a.techStack.languages.join(', ')} — ${a.techStack.frameworks.join(', ')})`
39
+ : a.techStack.languages[0] !== 'other'
40
+ ? ` (${a.techStack.languages.join(', ')})`
41
+ : '';
42
+ return `- **${r.name}**${tech}`;
43
+ }
44
+ return `- **${r.name}**`;
45
+ }).join('\n');
46
+
47
+ // Build initial progress checklist
48
+ const progressItems = repos.map((r) => `- [ ] ${r.name} — changes implemented and tested`).join('\n');
49
+
50
+ return `# Workspace Knowledge — ${feature.id}
51
+
52
+ > **This file is a living document.** AI assistants should read this at the
53
+ > start of each session and append new learnings at the end.
54
+ > It preserves context across sessions so decisions aren't lost or repeated.
55
+
56
+ ## Feature Goal
57
+
58
+ ${feature.description}
59
+
60
+ **Branch:** \`${feature.branchName}\`
61
+ **Created:** ${feature.createdAt}
62
+
63
+ ## Repos in This Workspace
64
+
65
+ ${repoList}
66
+
67
+ ## Architecture Decisions
68
+
69
+ <!-- AI assistants: append decisions here as they are made during development.
70
+ Format: ### YYYY-MM-DD — Decision Title
71
+ **Decision:** What was decided
72
+ **Alternatives considered:** What else was evaluated
73
+ **Reasoning:** Why this choice was made -->
74
+
75
+ _(No decisions recorded yet.)_
76
+
77
+ ## Implementation Progress
78
+
79
+ ${progressItems}
80
+
81
+ ## Known Gotchas
82
+
83
+ <!-- AI assistants: append any gotchas, workarounds, or "watch out for" items
84
+ discovered during development. These help future sessions avoid repeating
85
+ the same debugging. -->
86
+
87
+ _(No gotchas recorded yet.)_
88
+
89
+ ## Open Questions
90
+
91
+ <!-- Add questions that need human input before the AI can proceed. -->
92
+
93
+ _(No open questions.)_
94
+ `;
95
+ }
96
+
26
97
  /**
27
98
  * Generates AI context files for each of the selected assistants.
28
99
  *
29
- * Iterates over the provided assistant list, invokes the corresponding
30
- * generator, and logs success / failure for each one.
100
+ * Also generates:
101
+ * - WORKSPACE.md — universal context file
102
+ * - nexusflow-knowledge.md — persistent AI memory across sessions
103
+ * - nexusflow-plan.md — implementation order based on dependency analysis
31
104
  *
32
105
  * @param ctx - The workspace context (feature + repos).
33
106
  * @param assistants - Which AI assistants to generate context files for.
@@ -48,44 +121,14 @@ export async function generateContextFiles(
48
121
  `Generated universal ${chalk.bold('WORKSPACE.md')}`,
49
122
  );
50
123
 
51
- // Generate session.md template if it does not exist
52
- const sessionPath = path.join(workspacePath, 'session.md');
53
- if (!(await fse.pathExists(sessionPath))) {
54
- const sessionContent = `# AI Session Handover Memo
55
-
56
- - **Feature Branch**: \`${ctx.feature.branchName}\`
57
- - **Session Started**: ${new Date().toLocaleDateString()}
58
- - **Last Modified Files**: None (Start of session)
59
-
60
- ## Summary of Accomplished Work
61
- - Setup workspace with ${ctx.repos.length} mapped repositories.
62
-
63
- ## Active State & Blockers
64
- - No active blockers.
65
-
66
- ## Next Steps
67
- 1. Open this workspace in your selected editor.
68
- 2. Ask the assistant to read \`WORKSPACE.md\` and \`session.md\` to get started.
69
- `;
70
- await fse.writeFile(sessionPath, sessionContent, 'utf-8');
71
- console.log(chalk.green(' āœ”'), `Generated initial session.md`);
72
- }
73
-
74
- // Generate plan.md template if it does not exist
75
- const planPath = path.join(workspacePath, 'plan.md');
76
- if (!(await fse.pathExists(planPath))) {
77
- const planContent = `# Feature Development Plan
78
-
79
- ## Checklist
80
- - [ ] Read \`WORKSPACE.md\` and analyze the codebase structure.
81
- - [ ] Initialize context by creating \`nexusflow-overview.md\` outlining assumptions and raising clarifying questions.
82
- - [ ] Review user's responses to clarifying questions.
83
- - [ ] Implement feature logic.
84
- - [ ] Verify build and run tests.
85
- - [ ] Compile final changes in the session handover memo.
86
- `;
87
- await fse.writeFile(planPath, planContent, 'utf-8');
88
- console.log(chalk.green(' āœ”'), `Generated initial plan.md`);
124
+ // Generate nexusflow-knowledge.md if it does not exist
125
+ const knowledgePath = path.join(workspacePath, 'nexusflow-knowledge.md');
126
+ if (!(await fse.pathExists(knowledgePath))) {
127
+ const knowledgeContent = buildKnowledgeContent(ctx);
128
+ await fse.writeFile(knowledgePath, knowledgeContent, 'utf-8');
129
+ console.log(chalk.green(' āœ”'), `Generated ${chalk.bold('nexusflow-knowledge.md')} (persistent AI memory)`);
130
+ } else {
131
+ console.log(chalk.gray(' ā—‹'), `nexusflow-knowledge.md already exists — preserving existing content`);
89
132
  }
90
133
  } catch (error) {
91
134
  const message = error instanceof Error ? error.message : String(error);
@@ -112,6 +155,17 @@ export async function generateContextFiles(
112
155
  );
113
156
  }
114
157
  }
158
+
159
+ // Generate implementation plan from dependency analysis (if analysis data available)
160
+ try {
161
+ await generateImplementationPlan(ctx, workspacePath);
162
+ } catch (error) {
163
+ const message = error instanceof Error ? error.message : String(error);
164
+ console.error(
165
+ chalk.red(' āœ–'),
166
+ `Failed to generate implementation plan: ${message}`,
167
+ );
168
+ }
115
169
  }
116
170
 
117
171
  // Re-export individual generators for direct use
@@ -120,3 +174,4 @@ export { generateCodexConfig } from './codex.js';
120
174
  export { generateCopilotConfig } from './copilot.js';
121
175
  export { generateCursorConfig } from './cursor.js';
122
176
  export { buildContextContent } from './base.js';
177
+ export { generateImplementationPlan } from './plan-generator.js';