@nathapp/nax 0.46.3 → 0.48.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.
@@ -75,6 +75,7 @@ export class ReviewOrchestrator {
75
75
  executionConfig: NaxConfig["execution"],
76
76
  plugins?: PluginRegistry,
77
77
  storyGitRef?: string,
78
+ scopePrefix?: string,
78
79
  ): Promise<OrchestratorReviewResult> {
79
80
  const logger = getSafeLogger();
80
81
 
@@ -95,14 +96,17 @@ export class ReviewOrchestrator {
95
96
  // Use the story's start ref if available to capture auto-committed changes
96
97
  const baseRef = storyGitRef ?? executionConfig?.storyGitRef;
97
98
  const changedFiles = await getChangedFiles(workdir, baseRef);
99
+ const scopedFiles = scopePrefix
100
+ ? changedFiles.filter((f) => f === scopePrefix || f.startsWith(`${scopePrefix}/`))
101
+ : changedFiles;
98
102
  const pluginResults: ReviewResult["pluginReviewers"] = [];
99
103
 
100
104
  for (const reviewer of reviewers) {
101
105
  logger?.info("review", `Running plugin reviewer: ${reviewer.name}`, {
102
- changedFiles: changedFiles.length,
106
+ changedFiles: scopedFiles.length,
103
107
  });
104
108
  try {
105
- const result = await reviewer.check(workdir, changedFiles);
109
+ const result = await reviewer.check(workdir, scopedFiles);
106
110
  // Always log the result so skips/passes are visible in the log
107
111
  logger?.info("review", `Plugin reviewer result: ${reviewer.name}`, {
108
112
  passed: result.passed,
@@ -194,7 +194,27 @@ export function buildSmartTestCommand(testFiles: string[], baseCommand: string):
194
194
  return newParts.join(" ");
195
195
  }
196
196
 
197
- export async function getChangedSourceFiles(workdir: string, baseRef?: string): Promise<string[]> {
197
+ /**
198
+ * Get TypeScript source files changed since the previous commit.
199
+ *
200
+ * Runs `git diff --name-only <ref>` in the given workdir and filters
201
+ * results to only `.ts` files under the relevant source prefix.
202
+ *
203
+ * In a monorepo, git returns paths relative to the git root (e.g.
204
+ * `packages/api/src/foo.ts`). When `packagePrefix` is set to the
205
+ * story's workdir (e.g. `"packages/api"`), the filter is scoped to
206
+ * `<packagePrefix>/src/` instead of just `src/`.
207
+ *
208
+ * @param workdir - Working directory to run git command in
209
+ * @param baseRef - Git ref for diff base (default: HEAD~1)
210
+ * @param packagePrefix - Story workdir relative to repo root (e.g. "packages/api")
211
+ * @returns Array of changed .ts file paths relative to the git root
212
+ */
213
+ export async function getChangedSourceFiles(
214
+ workdir: string,
215
+ baseRef?: string,
216
+ packagePrefix?: string,
217
+ ): Promise<string[]> {
198
218
  try {
199
219
  // FEAT-010: Use per-attempt baseRef for precise diff; fall back to HEAD~1 if not provided
200
220
  const ref = baseRef ?? "HEAD~1";
@@ -204,7 +224,9 @@ export async function getChangedSourceFiles(workdir: string, baseRef?: string):
204
224
 
205
225
  const lines = stdout.trim().split("\n").filter(Boolean);
206
226
 
207
- return lines.filter((f) => f.startsWith("src/") && f.endsWith(".ts"));
227
+ // MW-006: scope filter to package prefix in monorepo
228
+ const srcPrefix = packagePrefix ? `${packagePrefix}/src/` : "src/";
229
+ return lines.filter((f) => f.startsWith(srcPrefix) && f.endsWith(".ts"));
208
230
  } catch {
209
231
  return [];
210
232
  }