feat: add zero-config style guide support with VECTORLINT.md#51
feat: add zero-config style guide support with VECTORLINT.md#51oshorefueled merged 15 commits intomainfrom
Conversation
- Add STYLE_GUIDE_FILENAME constant for default style guide file name - Add STYLE_GUIDE_TOKEN_WARNING_THRESHOLD constant for token limit warnings - These constants support the style guide feature for content evaluation
- Import STYLE_GUIDE_FILENAME constant for style guide file detection - Update resolveConfigPath return type to string | undefined instead of throwing error - Return undefined when no config file is found instead of throwing ConfigError - Implement zero-config mode that detects VECTORLINT.md style guide file - Return default configuration with StyleGuide rule when style guide exists - Preserve original error handling for cases where neither config nor style guide exists - Enables users to run vectorlint without explicit configuration file when style guide is present
- Create new StyleGuideLoader boundary module for loading VECTORLINT.md files - Implement estimateTokens utility function using 4 characters per token approximation - Add loadStyleGuide function to read style guide from specified directory - Include token count warnings when style guide exceeds recommended threshold - Return StyleGuideResult interface with content, token estimate, and file path - Handle file not found and read errors gracefully with appropriate warnings - Enables zero-config mode to automatically detect and load project style guides
- Add style guide loading from VECTORLINT.md file during command initialization - Pass loaded style guide content to DefaultRequestBuilder for prompt construction - Implement zero-config mode that creates synthetic style guide prompt when no rules are configured but VECTORLINT.md exists - Add createStyleGuidePrompt helper function to generate style guide compliance evaluation prompts - Update request builder to prepend style guide content to prompt body with proper formatting - Add verbose logging for style guide loading and zero-config mode activation - Improve error messaging to distinguish between missing rules and missing style guide scenarios
- Import STYLE_GUIDE_FILENAME constant for style guide file reference - Add STYLE_GUIDE_TEMPLATE with default writing style, terminology, and tone guidelines - Add --quick option to create only style guide for zero-config usage - Add --full option to create both config and style guide files - Refactor file existence checks to handle both config and style guide files - Update file creation logic to conditionally write config and style guide based on options - Enhance success output to display both created files - Update next steps guidance to include style guide editing instructions - Improve user experience by supporting multiple initialization workflows
…config - Add init-command.test.ts with tests for default, --quick, and --full modes - Test backward compatibility with .vectorlint.ini creation - Test VECTORLINT.md style guide file creation with --quick flag - Test simultaneous creation of both config files with --full flag - Add tests for --force flag to overwrite existing files - Add tests to verify existing files are respected without --force - Add zero-config.test.ts with tests for style guide detection - Test default config generation when only VECTORLINT.md exists - Test preference for .vectorlint.ini when both files are present - Test error handling when neither configuration file exists - Ensure StyleGuide rule is applied in zero-config mode
- Add VECTORLINT.md to .gitignore to prevent accidental commits - Document global style guide feature in CONFIGURATION.md with zero-config and combined modes - Explain automatic style guide detection and synthetic rule creation - Add token limit warning for large VECTORLINT.md files - Restructure README quick start section with numbered steps - Add zero-config mode instructions with --quick flag - Clarify full configuration setup and API key configuration steps - Improve readability with clearer hierarchy and examples
📝 WalkthroughWalkthroughAdds zero‑config support by detecting a local style guide ( Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (commands / init)
participant CL as Config Loader
participant SGL as Style Guide Loader
participant RB as Request Builder
participant LLM as LLM Provider
CLI->>CL: loadConfig(cwd)
CL->>CL: resolveConfigPath()
alt INI config found
CL-->>CLI: return parsed config
else no INI
CL->>SGL: loadStyleGuide(cwd)
alt style guide exists
SGL-->>CL: StyleGuideResult(content,tokens,path)
CL-->>CLI: return default in‑code config
else no style guide
CL-->>CLI: throw ConfigError
end
end
CLI->>SGL: loadStyleGuide(cwd)
SGL-->>CLI: StyleGuideResult
CLI->>RB: new DefaultRequestBuilder(directive, styleGuide?)
RB->>RB: prepend style guide to prompt (if provided)
CLI->>LLM: send composed prompt
LLM-->>CLI: response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
81-101: Inconsistent step numbering in Quick Start section.The section header uses
### 3. Configure API Keys, but line 93 still shows3. **Run a check:**which creates duplicate step 3s. This appears to be leftover content from a previous structure.Consider renumbering or restructuring to maintain consistent flow:
📝 Suggested fix
-3. **Run a check:** +4. **Run a check:**Or restructure as a sub-step under the Configure API Keys section.
🤖 Fix all issues with AI agents
In @.gitignore:
- Line 15: Remove the "VECTORLINT.md" entry from the .gitignore file so the
style guide is tracked in version control; open the .gitignore, delete the line
containing "VECTORLINT.md" (the literal entry shown), commit the change so
VECTORLINT.md can be added and shared across the team and CI.
In @src/boundaries/config-loader.ts:
- Around line 63-84: The zero-config default scan pattern returned when iniPath
is falsy currently uses "**/*.{md,mdx}" but isSupportedPattern validates md,
txt, and mdx; update the default pattern in the object returned (inside the
iniPath falsy branch that checks STYLE_GUIDE_FILENAME) to include txt (e.g.,
"**/*.{md,mdx,txt}") so .txt files are included in zero-config linting; keep the
rest of the returned shape (concurrency, configDir, runRules, overrides)
unchanged.
🧹 Nitpick comments (3)
tests/style-guide/init-command.test.ts (1)
32-43: Potential test isolation issue with Commander's singleton program.Each test dynamically imports
commander'sprogram, but Commander uses a singleton pattern. WhiletestProgram = program.createCommand()creates a new command instance, the repeated dynamic imports and command registrations may lead to subtle test pollution if modules are cached.Consider extracting the setup into a helper or ensuring module cache is reset between tests:
♻️ Alternative approach using fresh Command instance
+ import { Command } from 'commander'; + it('default: creates only .vectorlint.ini (backward compatibility)', async () => { const { registerInitCommand } = await import('../../src/cli/init-command'); - const { program } = await import('commander'); - - const testProgram = program.createCommand(); + const testProgram = new Command(); registerInitCommand(testProgram); await testProgram.parseAsync(['node', 'test', 'init']);src/cli/commands.ts (1)
238-252: Consider making the synthetic prompt body more descriptive or configurable.The
createStyleGuidePromptfunction is well-structured. However, the hardcodedbodystring is relatively brief. If the style guide contains detailed instructions, this prompt body might benefit from being slightly more directive about how to apply those instructions.That said, the current implementation is functional and the style guide content itself (prepended via
DefaultRequestBuilder) provides the detailed context.src/boundaries/style-guide-loader.ts (1)
5-9: Consider adding a Zod schema for the result type.Per coding guidelines for
src/boundaries/**/*.ts, Zod schemas should be used for boundary validation. While the style guide content itself is free-form markdown, you could still define a Zod schema for the result structure for consistency:♻️ Optional Zod schema
import { z } from 'zod'; const StyleGuideResultSchema = z.object({ content: z.string().nullable(), tokenEstimate: z.number(), path: z.string().nullable(), }); export type StyleGuideResult = z.infer<typeof StyleGuideResultSchema>;That said, since this is an internal result type (not parsing external data format), the current TypeScript interface is reasonable.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.gitignoreCONFIGURATION.mdREADME.mdsrc/boundaries/config-loader.tssrc/boundaries/style-guide-loader.tssrc/cli/commands.tssrc/cli/init-command.tssrc/config/constants.tssrc/providers/request-builder.tstests/style-guide/init-command.test.tstests/style-guide/zero-config.test.ts
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/config/constants.tssrc/cli/init-command.tssrc/boundaries/style-guide-loader.tssrc/boundaries/config-loader.tssrc/providers/request-builder.tssrc/cli/commands.ts
tests/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
tests/**/*.test.ts: Write tests using Vitest framework with focus on config parsing, file discovery, schema/structured output, and locator
Use dependency injection in tests: mock providers; do not hit network in unit tests
Files:
tests/style-guide/zero-config.test.tstests/style-guide/init-command.test.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/style-guide-loader.tssrc/boundaries/config-loader.ts
src/providers/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/providers/**/*.ts: Depend onLLMProviderandSearchProviderinterfaces; keep providers thin (transport only)
InjectRequestBuildervia provider constructor to avoid coupling
Files:
src/providers/request-builder.ts
🧠 Learnings (7)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
.gitignoreCONFIGURATION.md
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to tests/**/*.test.ts : Write tests using Vitest framework with focus on config parsing, file discovery, schema/structured output, and locator
Applied to files:
tests/style-guide/zero-config.test.tstests/style-guide/init-command.test.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/**/*.ts : Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/providers/**/*.ts : Inject `RequestBuilder` via provider constructor to avoid coupling
Applied to files:
src/providers/request-builder.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/providers/**/*.ts : Depend on `LLMProvider` and `SearchProvider` interfaces; keep providers thin (transport only)
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Use custom error types with proper inheritance; catch blocks use `unknown` type
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Maintain strict TypeScript with no `any`; use `unknown` + schema validation for external data
Applied to files:
src/cli/commands.ts
🧬 Code graph analysis (6)
tests/style-guide/zero-config.test.ts (1)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)
src/cli/init-command.ts (2)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)src/config/global-config.ts (1)
ensureGlobalConfig(63-76)
src/boundaries/style-guide-loader.ts (1)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)STYLE_GUIDE_TOKEN_WARNING_THRESHOLD(16-16)
src/boundaries/config-loader.ts (2)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)src/errors/index.ts (1)
ConfigError(18-23)
tests/style-guide/init-command.test.ts (2)
src/cli/init-command.ts (1)
registerInitCommand(58-127)src/config/constants.ts (2)
DEFAULT_CONFIG_FILENAME(12-12)STYLE_GUIDE_FILENAME(15-15)
src/cli/commands.ts (4)
src/boundaries/style-guide-loader.ts (1)
loadStyleGuide(23-61)src/config/constants.ts (1)
STYLE_GUIDE_FILENAME(15-15)src/providers/request-builder.ts (1)
DefaultRequestBuilder(7-24)src/prompts/prompt-loader.ts (1)
PromptFile(8-8)
🪛 GitHub Actions: Test
tests/style-guide/zero-config.test.ts
[error] 30-30: AssertionError: expected '/*.{md,mdx}' to be '/*.{md,txt,mdx}'
🪛 GitHub Check: Test
tests/style-guide/zero-config.test.ts
[failure] 30-30: tests/style-guide/zero-config.test.ts > Zero-Config Loading > returns default config when only VECTORLINT.md exists
AssertionError: expected '/*.{md,mdx}' to be '/*.{md,txt,mdx}' // Object.is equality
Expected: "/*.{md,txt,mdx}"
Received: "/*.{md,mdx}"
❯ tests/style-guide/zero-config.test.ts:30:46
🪛 LanguageTool
CONFIGURATION.md
[style] ~77-~77: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...g if the file exceeds ~4,000 tokens, as very large contexts can degrade performance and in...
(EN_WEAK_ADJECTIVE)
🔇 Additional comments (15)
src/providers/request-builder.ts (2)
7-14: LGTM! Clean style guide integration.The optional
styleGuideparameter and field are properly typed and initialized, following TypeScript best practices.
16-23: LGTM! Style guide prepend logic is correct.The style guide is correctly prepended with proper spacing when present, maintaining the original body and directive structure.
src/boundaries/config-loader.ts (1)
32-52: LGTM! Return type updated correctly for zero-config mode.The function now appropriately returns
string | undefinedto support zero-config mode when no configuration file exists.tests/style-guide/zero-config.test.ts (3)
21-33: Test expectation is correct; production code needs fixing.The test correctly expects
**/*.{md,txt,mdx}based on theisSupportedPatternvalidation. The pipeline failure is caused by the production code insrc/boundaries/config-loader.ts(line 73) using**/*.{md,mdx}instead. Fix the production code pattern to include.txtas flagged in the config-loader.ts review.Based on pipeline failures, ensure the fix in
src/boundaries/config-loader.tsresolves this test failure.
35-51: LGTM! Precedence test correctly validates INI file priority.The test properly verifies that when both
VECTORLINT.mdand.vectorlint.iniexist, the INI configuration takes precedence, which is the expected behavior for combined mode.
53-55: LGTM! Error handling test is correct.The test properly validates that an error is thrown when neither configuration file exists, ensuring appropriate user feedback.
src/config/constants.ts (1)
15-16: LGTM!The new constants are well-named and appropriately placed alongside other configuration constants. The token threshold of 4000 is a reasonable default for LLM context considerations.
tests/style-guide/init-command.test.ts (1)
74-92: Good coverage of existing file protection.The test correctly validates that:
- Pre-existing files are not overwritten without
--force- Original content is preserved
- The command exits with an error
The use of
exitOverride()to prevent actual process exit is the right approach for testing error paths.src/cli/commands.ts (2)
81-95: Good integration of style guide loading into the CLI flow.The style guide is loaded early, logged appropriately in verbose mode, and passed correctly to
DefaultRequestBuilder. The|| undefinedcoercion on line 94 properly handles the nullable content for the optional parameter.
147-162: Zero-config mode logic is well-structured.The fallback to a synthetic style guide prompt when no rules are found but a style guide exists provides a smooth zero-config experience. The differentiated error messages based on whether
rulesPathwas configured help users understand what's missing.src/cli/init-command.ts (3)
19-45: Helpful style guide template with practical examples.The template provides a good starting point with clear sections for Writing Style, Terminology, and Tone. The HTML comments explaining how VectorLint uses the file are useful for onboarding.
70-71: Option logic is correct and handles edge cases well.The logic ensures:
- Default (no flags): creates only config (
createConfig=true,createStyleGuide=false)--quick: creates only style guide (createConfig=false,createStyleGuide=true)--full: creates both (createConfig=true,createStyleGuide=true)--quick --full: creates both (full takes precedence)
77-88: Good UX for handling existing files.Aggregating all conflicting files into a single error message (rather than failing on the first one) provides better user feedback. The bulleted list format is clear.
src/boundaries/style-guide-loader.ts (2)
15-17: Token estimation is appropriately documented as approximate.The 4 chars/token heuristic is a reasonable rough estimate. The docstring clearly states it's an approximation, which sets correct expectations. For more accuracy in the future, you could consider using a tokenizer library, but for warning thresholds this approximation is sufficient.
51-59: Good error handling following coding guidelines.The catch block correctly types the error as
unknownand extracts the message safely. Returning the path even on error (line 58) is a thoughtful design choice that lets callers know the file existed but couldn't be read.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @src/boundaries/config-loader.ts:
- Around line 63-79: The zero-config branch returns a hardcoded config when
STYLE_GUIDE_FILENAME exists (the block using iniPath and styleGuidePath) but
never validates it against CONFIG_SCHEMA; update that branch to construct the
same default object and pass it through CONFIG_SCHEMA.parse(...) (same
validation used for INI parsing) before returning, ensuring the default shape
matches future schema changes and referencing the existing symbols iniPath,
STYLE_GUIDE_FILENAME, and CONFIG_SCHEMA.parse to locate where to perform the
validation.
🧹 Nitpick comments (1)
src/boundaries/config-loader.ts (1)
81-84: Consider mentioning the zero-config alternative in the error message.Users unfamiliar with zero-config mode may not realize they can place a
VECTORLINT.mdinstead.💡 Suggested improvement
throw new ConfigError( - `Missing configuration file. Expected ${DEFAULT_CONFIG_FILENAME} in ${cwd}` + `Missing configuration file. Expected ${DEFAULT_CONFIG_FILENAME} or ${STYLE_GUIDE_FILENAME} in ${cwd}` );
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/boundaries/config-loader.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/boundaries/config-loader.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/config-loader.ts
🧠 Learnings (2)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to tests/**/*.test.ts : Write tests using Vitest framework with focus on config parsing, file discovery, schema/structured output, and locator
Applied to files:
src/boundaries/config-loader.ts
🧬 Code graph analysis (1)
src/boundaries/config-loader.ts (2)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)src/errors/index.ts (1)
ConfigError(18-23)
🔇 Additional comments (1)
src/boundaries/config-loader.ts (1)
32-52: LGTM - Clean signature change enabling zero-config mode.The return type
string | undefinedcorrectly signals optional config resolution, and callers handle theundefinedcase appropriately.
…de prompt - Add CONFIG_SCHEMA validation to default config in zero-config mode to ensure type safety - Update style guide prompt body text to clarify evaluation against attached style guide rules - Fix commander import pattern in tests from deprecated `program` to `Command` constructor - Improve consistency across all test cases for style guide initialization
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/boundaries/config-loader.ts (1)
185-186: Remove duplicate comment.There's a duplicated comment on lines 185-186.
Suggested fix
- // Create config object and validate with schema // Create config object and validate with schema const configData = {
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/boundaries/config-loader.tssrc/cli/commands.tstests/style-guide/init-command.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/style-guide/init-command.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/boundaries/config-loader.tssrc/cli/commands.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/config-loader.ts
🧠 Learnings (6)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/**/*.ts : Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/env-parser.ts : All environment variables must be validated via Zod schemas in `src/boundaries/env-parser.ts`
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Maintain strict TypeScript with no `any`; use `unknown` + schema validation for external data
Applied to files:
src/boundaries/config-loader.tssrc/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/providers/**/*.ts : Depend on `LLMProvider` and `SearchProvider` interfaces; keep providers thin (transport only)
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Use custom error types with proper inheritance; catch blocks use `unknown` type
Applied to files:
src/cli/commands.ts
🧬 Code graph analysis (2)
src/boundaries/config-loader.ts (3)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)src/schemas/config-schemas.ts (1)
CONFIG_SCHEMA(4-14)src/errors/index.ts (1)
ConfigError(18-23)
src/cli/commands.ts (5)
src/boundaries/style-guide-loader.ts (1)
loadStyleGuide(23-61)src/config/constants.ts (1)
STYLE_GUIDE_FILENAME(15-15)src/providers/request-builder.ts (1)
DefaultRequestBuilder(7-24)src/schemas/prompt-schemas.ts (1)
PromptFile(80-80)src/prompts/prompt-loader.ts (1)
PromptFile(8-8)
🔇 Additional comments (8)
src/boundaries/config-loader.ts (3)
12-12: LGTM!Import of
STYLE_GUIDE_FILENAMEis correctly added to support zero-config mode detection.
32-52: LGTM!The signature change to return
string | undefinedis appropriate for zero-config support. The caller (loadConfig) correctly handles the undefined case by falling back to style-guide detection.
63-85: LGTM!The zero-config logic is well-structured:
- Correctly checks for
VECTORLINT.mdwhen no config file is found- Default config is properly validated through
CONFIG_SCHEMA.parse()- Error message is clear when neither config nor style guide exists
The default config structure aligns with the schema requirements from
src/schemas/config-schemas.ts.src/cli/commands.ts (5)
10-10: LGTM!Imports are correctly added for the new style guide functionality and related types.
Also applies to: 22-23
81-86: LGTM!Style guide loading is properly integrated with verbose logging to aid debugging.
94-94: LGTM!Correctly converts
nulltoundefinedto match theDefaultRequestBuilderconstructor's optional parameter signature.
147-163: LGTM!Zero-config fallback logic is well-structured:
- Gracefully creates a synthetic prompt when style guide exists but no rules are found
- Preserves original error handling for cases where neither exists
- Verbose logging helps users understand the mode being used
238-252: LGTM!The synthetic prompt is well-defined:
- Uses
StyleGuidepack name matching the zero-configrunRulesconfiguration- Appropriate default severity of
WARNINGfor style guide violations- Body text clearly indicates evaluation against the attached style guide
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/boundaries/config-loader.ts (1)
32-52: Add Zod schema validation for external inputs toresolveConfigPath.The function accepts two pieces of external data (
configPathfrom CLI/env andcwdfrom the process) but does not validate them against a Zod schema before use. Per the coding guidelines, all external data at system boundaries must be validated with Zod schemas. Create a schema for the inputs and apply validation at the function entry point.No external callers of
resolveConfigPathexist outside this file, so the signature change is safe. The internal caller at line 63 properly handles theundefinedreturn value.
🧹 Nitpick comments (1)
src/boundaries/config-loader.ts (1)
63-85: "StyleGuide" rule is correctly created and resolved; optional refactor for magic strings remains valid.Verification confirms the zero-config logic is sound. The hardcoded
"StyleGuide"rule is properly created by thecreateStyleGuidePrompt()function insrc/cli/commands.tswhenVECTORLINT.mdexists and no other rules are found. TheScanPathResolvercorrectly resolvesrunRules: ["StyleGuide"]from the config against available prompts. TheCONFIG_SCHEMA.parse()at line 79 properly validates the default configuration using Zod, following the boundary validation guideline.The optional refactor suggestion to extract magic strings (
"StyleGuide"and the default config object) to named constants remains valid for maintainability and testability, but is not required for functional correctness.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/boundaries/config-loader.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/boundaries/config-loader.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/config-loader.ts
🧠 Learnings (3)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/**/*.ts : Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/env-parser.ts : All environment variables must be validated via Zod schemas in `src/boundaries/env-parser.ts`
Applied to files:
src/boundaries/config-loader.ts
🧬 Code graph analysis (1)
src/boundaries/config-loader.ts (3)
src/config/constants.ts (2)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONFIG_FILENAME(12-12)src/schemas/config-schemas.ts (1)
CONFIG_SCHEMA(4-14)src/errors/index.ts (1)
ConfigError(18-23)
🔇 Additional comments (1)
src/boundaries/config-loader.ts (1)
12-12: LGTM: Clean import of style guide constant.The import of
STYLE_GUIDE_FILENAMEis properly sourced from constants and used consistently in the zero-config logic.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/boundaries/config-loader.ts (1)
36-42: Consider whether input validation schema is necessary here.The
RESOLVE_CONFIG_PATH_SCHEMAvalidates simple string parameters that are already typed by TypeScript. SinceresolveConfigPathis an internal helper function (not exported), and the inputs come from already-validated sources (the publicloadConfigfunction receivescwdwith a default and optionalconfigPath), this Zod validation may be redundant.Per coding guidelines, Zod schemas should validate external data at boundaries. However, these parameters are internal function arguments, not external inputs.
♻️ Consider removing the validation schema
-const RESOLVE_CONFIG_PATH_SCHEMA = z.object({ - cwd: z.string(), - configPath: z.string().optional(), -}); - function resolveConfigPath(cwd: string, configPath?: string): string | undefined { - RESOLVE_CONFIG_PATH_SCHEMA.parse({ cwd, configPath }); if (configPath) {
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/boundaries/config-loader.tssrc/cli/commands.tssrc/config/constants.tstests/config-loader-error.test.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/boundaries/config-loader.tssrc/cli/commands.tssrc/config/constants.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/config-loader.ts
tests/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
tests/**/*.test.ts: Write tests using Vitest framework with focus on config parsing, file discovery, schema/structured output, and locator
Use dependency injection in tests: mock providers; do not hit network in unit tests
Files:
tests/config-loader-error.test.ts
🧠 Learnings (6)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/**/*.ts : Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/env-parser.ts : All environment variables must be validated via Zod schemas in `src/boundaries/env-parser.ts`
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/providers/**/*.ts : Depend on `LLMProvider` and `SearchProvider` interfaces; keep providers thin (transport only)
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Use custom error types with proper inheritance; catch blocks use `unknown` type
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to tests/**/*.test.ts : Write tests using Vitest framework with focus on config parsing, file discovery, schema/structured output, and locator
Applied to files:
tests/config-loader-error.test.ts
🧬 Code graph analysis (3)
src/boundaries/config-loader.ts (3)
src/config/constants.ts (5)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONCURRENCY(20-20)DEFAULT_SCAN_PATTERN(23-23)ZERO_CONFIG_PACK_NAME(21-21)DEFAULT_CONFIG_FILENAME(12-12)src/schemas/config-schemas.ts (1)
CONFIG_SCHEMA(4-14)src/errors/index.ts (1)
ConfigError(18-23)
src/cli/commands.ts (5)
src/boundaries/style-guide-loader.ts (1)
loadStyleGuide(23-61)src/config/constants.ts (3)
STYLE_GUIDE_FILENAME(15-15)ZERO_CONFIG_PROMPT_ID(22-22)ZERO_CONFIG_PACK_NAME(21-21)src/providers/request-builder.ts (1)
DefaultRequestBuilder(7-24)src/schemas/prompt-schemas.ts (1)
PromptFile(80-80)src/prompts/prompt-loader.ts (1)
PromptFile(8-8)
tests/config-loader-error.test.ts (2)
src/boundaries/config-loader.ts (1)
loadConfig(67-214)src/config/constants.ts (2)
DEFAULT_CONFIG_FILENAME(12-12)STYLE_GUIDE_FILENAME(15-15)
🔇 Additional comments (9)
tests/config-loader-error.test.ts (1)
1-26: LGTM! Well-structured test for zero-config error messaging.The test properly validates that the config loader throws an appropriate error message when neither configuration file nor style guide is present. The lifecycle management with temp directory creation and cleanup is correct.
src/boundaries/config-loader.ts (3)
41-62: LGTM! Return type change enables zero-config mode.The change from throwing an error to returning
undefinedwhen no configuration file is found is the key enabler for zero-config mode. This allows the caller (loadConfig) to check forVECTORLINT.mdand return a default configuration. The logic correctly checks explicit path → hidden config → legacy config → undefined.
73-95: LGTM! Zero-config logic correctly implements the feature.The zero-config mode properly:
- Detects when no
.vectorlint.iniexists- Checks for
VECTORLINT.mdas an alternative- Returns a valid default configuration with the synthetic StyleGuide pack
- Falls back to an informative error mentioning both expected filenames
The default configuration structure is validated by
CONFIG_SCHEMA.parse(), ensuring type safety.
193-193: LGTM! Good use of constant over magic number.Replacing the hardcoded default value with
DEFAULT_CONCURRENCYimproves maintainability and consistency with the zero-config default.src/config/constants.ts (1)
15-23: LGTM! Well-organized zero-config constants with DRY improvements.The new constants are correctly defined and support the zero-config feature:
- Style guide filename and token threshold are clearly named
- The refactoring to compute
ALLOWED_EXTSandDEFAULT_SCAN_PATTERNfrom theEXTENSIONSarray improves maintainability by defining the supported extensions in one place- Zero-config pack and prompt identifiers are consistent with usage throughout the codebase
src/cli/commands.ts (4)
81-85: LGTM! Style guide loading properly integrated.The style guide is loaded early in the command execution and logged appropriately when verbose mode is enabled. Including the token estimate in the log helps users understand the impact on API costs.
94-94: LGTM! Style guide correctly passed to request builder.The style guide content is properly threaded into the
DefaultRequestBuilder, which will prepend it to all prompts. The|| undefinedconversion correctly handles the null case fromStyleGuideResult.
148-163: LGTM! Zero-config fallback logic is well-designed.The zero-config mode properly:
- Activates when no rule packs are found but a style guide exists
- Logs the mode activation for user awareness in verbose mode
- Creates a synthetic prompt for style guide compliance
- Provides differentiated error messages based on whether
rulesPathwas configuredThe error messages help users understand whether they need to check their rules directory or configure presets.
238-252: LGTM! Synthetic prompt properly structured for zero-config mode.The
createStyleGuidePrompthelper correctly constructs aPromptFilewith:
- Clear evaluation instruction referencing the Global Style Guide
- Appropriate severity level (WARNING) for zero-config usage
- Consistent use of zero-config constants for identification
- Base evaluator type suitable for general style guide compliance
The warning severity is a good default for zero-config mode, being less aggressive than errors while still flagging issues.
- Update CONFIGURATION.md to clarify that style guide evaluates all content types, not just markdown files - Add prerequisite note in README.md about credential setup before running checks - Remove unused zod schema validation from config-loader.ts resolveConfigPath function - Simplify config path resolution by removing redundant type checking
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
53-105: Fix the spurious list marker on the "Run a check" line.The "3." prefix on line 97 ("3. Run a check:") is a formatting artifact within the Step 3 section and should be removed. Since the entire content block is already nested under "### 3. Configure API Keys", this line should not have its own numbered marker.
🔧 Proposed formatting fix
*Note: You can also use a local `.env` file in your project, which takes precedence over the global config.* -3. **Run a check:** +**Run a check:** ```bash vectorlint doc.md
🤖 Fix all issues with AI agents
In @CONFIGURATION.md:
- Around line 64-79: Documentation notes that VECTORLINT.md is used but lacks a
minimal example; add a short sample snippet to CONFIGURATION.md demonstrating a
basic VECTORLINT.md content (e.g., a few lines for tone, terminology, and
preferred formatting) so users can copy/paste for zero-config mode; ensure the
example mentions the token warning threshold and references the
STYLE_GUIDE_TOKEN_WARNING_THRESHOLD constant semantics to align text with
src/config/constants.ts.
🧹 Nitpick comments (1)
CONFIGURATION.md (1)
77-77: Strengthen the language on the token-limit note.The phrase "very large contexts" uses an over-used intensifier. Consider a more specific or direct alternative (e.g., "large," "substantial," or "excessive").
✏️ Suggested revision
-> **Note:** Keep `VECTORLINT.md` concise. VectorLint will emit a warning if the file exceeds ~4,000 tokens, as large contexts can degrade performance and increase costs. +> **Note:** Keep `VECTORLINT.md` concise. VectorLint will emit a warning if the file exceeds ~4,000 tokens, as large contexts can degrade performance and increase costs.Alternatively, if you want to be even more specific:
-> **Note:** Keep `VECTORLINT.md` concise. VectorLint will emit a warning if the file exceeds ~4,000 tokens, as excessive context can degrade performance and increase costs.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CONFIGURATION.mdREADME.mdsrc/boundaries/config-loader.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/boundaries/config-loader.ts
src/boundaries/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Files:
src/boundaries/config-loader.ts
🧠 Learnings (3)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/**/*.ts : Use Zod schemas for boundary validation of all external data (files, CLI, env, APIs) at system boundaries
Applied to files:
src/boundaries/config-loader.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
src/boundaries/config-loader.tsCONFIGURATION.md
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/boundaries/env-parser.ts : All environment variables must be validated via Zod schemas in `src/boundaries/env-parser.ts`
Applied to files:
src/boundaries/config-loader.ts
🧬 Code graph analysis (1)
src/boundaries/config-loader.ts (3)
src/config/constants.ts (5)
STYLE_GUIDE_FILENAME(15-15)DEFAULT_CONCURRENCY(20-20)DEFAULT_SCAN_PATTERN(23-23)ZERO_CONFIG_PACK_NAME(21-21)DEFAULT_CONFIG_FILENAME(12-12)src/schemas/config-schemas.ts (1)
CONFIG_SCHEMA(4-14)src/errors/index.ts (1)
ConfigError(18-23)
🪛 LanguageTool
CONFIGURATION.md
[style] ~77-~77: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...g if the file exceeds ~4,000 tokens, as very large contexts can degrade performance and in...
(EN_WEAK_ADJECTIVE)
🔇 Additional comments (5)
src/boundaries/config-loader.ts (5)
12-16: LGTM!The new constant imports are well-organized and necessary for the zero-config functionality.
35-35: LGTM!The signature change to
string | undefinedis appropriate for signaling "no config found" without throwing, enabling the zero-config flow.
54-55: LGTM!Returning
undefinedinstead of throwing allows the caller to implement zero-config fallback logic.
186-186: LGTM!Using
DEFAULT_CONCURRENCYconstant ensures consistency between zero-config mode and the fallback for parsed configs.
66-88: Zero-config implementation is correct and properly constrained.The zero-config logic correctly:
- Falls back to VECTORLINT.md when no .ini config exists
- Creates a default config validated through Zod schema (per boundary validation guidelines)
- Uses
DEFAULT_SCAN_PATTERNwhich is hardcoded fromEXTENSIONSconstant (['md', 'txt', 'mdx']), making it inherently safeThe
EXTENSIONSconstant is properly constrained to only the three supported file types, soDEFAULT_SCAN_PATTERNbecomes**/*.{md,txt,mdx}at definition time. Unlike config files loaded from .ini paths (which require runtime validation viaisSupportedPattern), the zero-config pattern cannot include unsupported file types by design and requires no additional validation.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
README.md (1)
76-83: Clarify whatvectorlint initactually creates.The description suggests
vectorlint initcreates both the VectorLint Config (.vectorlint.ini) and the global App Config (~/.vectorlint/config.toml). However, these are typically separate concerns:
- Project-level config (
.vectorlint.ini,VECTORLINT.md) is created byvectorlint init- Global app config (
~/.vectorlint/config.toml) is a separate, user-level setup that users create or edit manuallyThe phrase "This creates:" followed by two items may suggest both are created by the same command, which could mislead users. Consider rewriting to clarify that Step 3 covers the separate global config setup.
✏️ Suggested revision
This creates: -- **VectorLint Config** (`.vectorlint.ini`): Project-specific settings. -- **App Config** (`~/.vectorlint/config.toml`): LLM provider API keys. +- **VectorLint Config** (`.vectorlint.ini`): Project-specific settings for rules and targets. +- **Style Guide** (`VECTORLINT.md`): Your project's style guide and conventions. + +Next, configure your global API credentials in Step 3.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to .vectorlint.ini : Use `[glob/pattern]` sections in `.vectorlint.ini` to specify which packs run on which files
Applied to files:
README.md
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/cli/commands.ts (3)
94-94: Consider using nullish coalescing for clarity.The expression
styleGuide.content || undefinedworks correctly but could be slightly clearer with nullish coalescing:styleGuide.content ?? undefined.♻️ Proposed refactor
- new DefaultRequestBuilder(directive, styleGuide.content || undefined) + new DefaultRequestBuilder(directive, styleGuide.content ?? undefined)
147-162: Zero-config logic is solid, with one minor optimization opportunity.The fallback on line 153 is unnecessary defensive code. When
styleGuide.contentis truthy,styleGuide.pathis guaranteed to be set by the loader's success path. The error messages (lines 155-159) provide clear, context-aware feedback.♻️ Optional: Remove unnecessary fallback
- prompts.push(createStyleGuidePrompt(styleGuide.path || path.resolve(process.cwd(), STYLE_GUIDE_FILENAME))); + prompts.push(createStyleGuidePrompt(styleGuide.path!));Since we're inside the
if (styleGuide.content)block, the path is guaranteed to be non-null from the loader's success path.
237-251: Consider adding JSDoc to document zero-config behavior.The helper function creates a synthetic prompt for zero-config mode, which is a key feature. Adding JSDoc would clarify its purpose, especially regarding:
- When this synthetic prompt is used (no explicit rules, but VECTORLINT.md exists)
- Why severity is set to WARNING
- The relationship between the top-level
idandmeta.idfields📝 Suggested JSDoc
+/** + * Creates a synthetic prompt for zero-config mode. + * Used when no explicit rule files exist but VECTORLINT.md is present. + * Generates a "Style Guide Compliance" rule that evaluates content against the style guide. + * @param fullPath - Absolute path to VECTORLINT.md + * @returns A PromptFile configured for zero-config style guide evaluation + */ function createStyleGuidePrompt(fullPath: string): PromptFile {
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/cli/commands.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Use TypeScript ESM with explicit imports and narrow types
Use 2-space indentation; avoid trailing whitespace
Maintain strict TypeScript with noany; useunknown+ schema validation for external data
Use custom error types with proper inheritance; catch blocks useunknowntype
Files:
src/cli/commands.ts
🧠 Learnings (2)
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/providers/**/*.ts : Depend on `LLMProvider` and `SearchProvider` interfaces; keep providers thin (transport only)
Applied to files:
src/cli/commands.ts
📚 Learning: 2025-12-28T19:43:51.189Z
Learnt from: CR
Repo: TRocket-Labs/vectorlint PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T19:43:51.189Z
Learning: Applies to src/**/*.ts : Use custom error types with proper inheritance; catch blocks use `unknown` type
Applied to files:
src/cli/commands.ts
🧬 Code graph analysis (1)
src/cli/commands.ts (5)
src/boundaries/style-guide-loader.ts (1)
loadStyleGuide(23-61)src/config/constants.ts (3)
STYLE_GUIDE_FILENAME(15-15)ZERO_CONFIG_PROMPT_ID(22-22)ZERO_CONFIG_PACK_NAME(21-21)src/providers/request-builder.ts (1)
DefaultRequestBuilder(7-24)src/schemas/prompt-schemas.ts (1)
PromptFile(80-80)src/prompts/prompt-loader.ts (1)
PromptFile(8-8)
🔇 Additional comments (2)
src/cli/commands.ts (2)
10-10: LGTM! Clean imports following TypeScript ESM conventions.The new imports for style guide support are properly structured with explicit named imports.
Also applies to: 22-23
81-85: LGTM! Style guide loading is clean and informative.The verbose logging provides helpful feedback about token estimates, which aligns with the token warning feature in the loader.
* chore(constants): Add style guide configuration constants - Add STYLE_GUIDE_FILENAME constant for default style guide file name - Add STYLE_GUIDE_TOKEN_WARNING_THRESHOLD constant for token limit warnings - These constants support the style guide feature for content evaluation * feat(config-loader): Support zero-config mode with style guide detection - Import STYLE_GUIDE_FILENAME constant for style guide file detection - Update resolveConfigPath return type to string | undefined instead of throwing error - Return undefined when no config file is found instead of throwing ConfigError - Implement zero-config mode that detects VECTORLINT.md style guide file - Return default configuration with StyleGuide rule when style guide exists - Preserve original error handling for cases where neither config nor style guide exists - Enables users to run vectorlint without explicit configuration file when style guide is present * feat(style-guide-loader): Add style guide loading with token estimation - Create new StyleGuideLoader boundary module for loading VECTORLINT.md files - Implement estimateTokens utility function using 4 characters per token approximation - Add loadStyleGuide function to read style guide from specified directory - Include token count warnings when style guide exceeds recommended threshold - Return StyleGuideResult interface with content, token estimate, and file path - Handle file not found and read errors gracefully with appropriate warnings - Enables zero-config mode to automatically detect and load project style guides * feat(cli): Integrate style guide loading into command execution - Add style guide loading from VECTORLINT.md file during command initialization - Pass loaded style guide content to DefaultRequestBuilder for prompt construction - Implement zero-config mode that creates synthetic style guide prompt when no rules are configured but VECTORLINT.md exists - Add createStyleGuidePrompt helper function to generate style guide compliance evaluation prompts - Update request builder to prepend style guide content to prompt body with proper formatting - Add verbose logging for style guide loading and zero-config mode activation - Improve error messaging to distinguish between missing rules and missing style guide scenarios * feat(cli): Add style guide initialization to init command - Import STYLE_GUIDE_FILENAME constant for style guide file reference - Add STYLE_GUIDE_TEMPLATE with default writing style, terminology, and tone guidelines - Add --quick option to create only style guide for zero-config usage - Add --full option to create both config and style guide files - Refactor file existence checks to handle both config and style guide files - Update file creation logic to conditionally write config and style guide based on options - Enhance success output to display both created files - Update next steps guidance to include style guide editing instructions - Improve user experience by supporting multiple initialization workflows * test(style-guide): Add comprehensive tests for init command and zero-config - Add init-command.test.ts with tests for default, --quick, and --full modes - Test backward compatibility with .vectorlint.ini creation - Test VECTORLINT.md style guide file creation with --quick flag - Test simultaneous creation of both config files with --full flag - Add tests for --force flag to overwrite existing files - Add tests to verify existing files are respected without --force - Add zero-config.test.ts with tests for style guide detection - Test default config generation when only VECTORLINT.md exists - Test preference for .vectorlint.ini when both files are present - Test error handling when neither configuration file exists - Ensure StyleGuide rule is applied in zero-config mode * docs: Add VECTORLINT.md style guide documentation and update quick start - Add VECTORLINT.md to .gitignore to prevent accidental commits - Document global style guide feature in CONFIGURATION.md with zero-config and combined modes - Explain automatic style guide detection and synthetic rule creation - Add token limit warning for large VECTORLINT.md files - Restructure README quick start section with numbered steps - Add zero-config mode instructions with --quick flag - Clarify full configuration setup and API key configuration steps - Improve readability with clearer hierarchy and examples * chore: Add txt file format for VECTORLINT.md * fix(config-loader,cli): Validate default config and improve style guide prompt - Add CONFIG_SCHEMA validation to default config in zero-config mode to ensure type safety - Update style guide prompt body text to clarify evaluation against attached style guide rules - Fix commander import pattern in tests from deprecated `program` to `Command` constructor - Improve consistency across all test cases for style guide initialization * chore: Update config error to include VECTORLINT.md * chore: clean up * docs: Clarify style guide setup and remove unnecessary validation - Update CONFIGURATION.md to clarify that style guide evaluates all content types, not just markdown files - Add prerequisite note in README.md about credential setup before running checks - Remove unused zod schema validation from config-loader.ts resolveConfigPath function - Simplify config path resolution by removing redundant type checking * docs: Clean up readme * chore: Update readme * chore: Remove unwanted comments
This PR introduces a "Zero-Config" mode that allows users to start linting immediately by placing a VECTORLINT.md file in their project root. It eliminates the need for a .vectorlint.ini file for simple use cases while ensuring global style instructions are respected across all evaluations.
Key Changes
How to Test
Run without existing config
vectorlint init --quick
(Add some rules to VECTORLINT.md)
vectorlint README.md
2. Combined Mode:
vectorlint init --full
Run evaluations; VECTORLINT.md content will be included in the prompt context
Motivation
Simplifies the onboarding process for new users and provides a standard way to define global style instructions (like "Voice and Tone") that apply to every rule in the system.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.