Skip to content

Commit ba57231

Browse files
committed
feat: enhance stack detection by integrating convention values for improved heuristics
1 parent a3f8878 commit ba57231

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/scan-flow.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ This document outlines how repository scans are transformed into AI instruction
66

77
1. **Scan the repository** (`app/api/scan-repo/route.ts`)
88
- Detect languages, frameworks, tooling, structure hints, and enriched metadata.
9+
- Use stack conventions (`collectConventionValues`) to cross-check detection lists (e.g., testing tools) so any signal we add in `conventions/<stack>.json` becomes discoverable with minimal code changes.
10+
- Reuse convention values to expand stack-specific heuristics (e.g., Python’s Behave directories, Next.js routing shapes), so each conventions file remains the source of truth for new detections.
911
- Infer the primary stack using `inferStackFromScan`.
1012
- Load stack conventions (`loadStackConventions`) to determine which structure hints matter and whether stack-specific rules exist.
1113
- Attach `summary.conventions` so the UI knows which directories to highlight and whether a conventions file was found.
1214

1315
2. **Build wizard defaults** (`lib/scan-to-wizard.ts`)
1416
- Start with an empty `WizardResponses` object.
1517
- Apply convention defaults from `conventions/<stack>.json` + `default.json`.
16-
- Layer in detections from the scan (tooling, testing, naming signals, etc.).
18+
- Layer in detections from the scan (tooling, testing, naming signals, etc.), matching scan values against convention-provided options so stack JSON remains the single source of truth.
1719
- Run convention rules to tweak values based on detected tooling/testing.
1820
- Pull default answers directly from the stack’s question set (`buildStepsForStack`) and fill any remaining empty responses. We track which questions were auto-defaulted (`defaultedQuestionIds`) so the summary can explain why.
1921

@@ -32,13 +34,14 @@ This document outlines how repository scans are transformed into AI instruction
3234
| Location | Purpose |
3335
| --- | --- |
3436
| `conventions/default.json` & `/conventions/<stack>.json` | Declarative defaults + rules for each stack (tooling choices, structure hints, apply-to glob, etc.). |
37+
| `lib/convention-values.ts` | Helpers that normalize and aggregate convention values (e.g., testingUT/testingE2E) for both the scanner and the wizard. |
3538
| `data/stacks.json` | List of stacks exposed to the wizard; each should have a matching conventions file. |
3639
| `data/questions/<stack>.json` | Stack-specific questions with default answers and metadata. These defaults are now honored automatically when scan data is missing. |
3740

3841
## Extending the Flow
3942

4043
- **Add a new stack**: create `conventions/<stack>.json`, add questions under `data/questions/<stack>.json`, and register the stack in `data/stacks.json`. The pipeline will pick it up automatically.
41-
- **Add scan heuristics**: update `app/api/scan-repo/route.ts` (e.g., detect tooling) so conventions rules have richer signals to work with.
44+
- **Add scan heuristics**: update `app/api/scan-repo/route.ts` (e.g., detect tooling/testing) so conventions rules have richer signals to work with. Shared helpers mean you can usually expand detection by tweaking the convention file plus a small matcher (see `detectPythonTestingSignals` for the current pattern).
4245
- **Adjust defaults**: edit the stack’s question JSON to set a new `isDefault` answer; the scan pipeline will adopt it whenever the repo lacks an explicit signal.
4346
- **Customize templates**: templates consume the final `WizardResponses`, so any new fields surfaced via conventions should be represented there before referencing them in markdown/JSON output.
4447

0 commit comments

Comments
 (0)