fix: additional CodeRabbit review fixes for primer

- Fix Python detection to use correct source file (pyproject.toml, requirements.txt, or setup.py)
- Escape regex special characters in glob pattern matching (e.g., *.module.css)
- Derive ALL_AGENTS from AGENT_CONFIG to avoid divergence
- Map agent config format to template format based on file extension
This commit is contained in:
Rohit Ghumare
2026-01-29 18:45:43 +00:00
parent 8a51c73f2a
commit e9b5c647e2
2 changed files with 22 additions and 37 deletions
+9 -2
View File
@@ -232,10 +232,15 @@ export class PrimerAnalyzer {
}
if (this.hasFile('pyproject.toml') || this.hasFile('requirements.txt') || this.hasFile('setup.py')) {
const source = this.hasFile('pyproject.toml')
? 'pyproject.toml'
: this.hasFile('requirements.txt')
? 'requirements.txt'
: 'setup.py';
languages.push({
name: 'python',
confidence: 100,
source: 'pyproject.toml',
source,
});
}
@@ -597,7 +602,9 @@ export class PrimerAnalyzer {
private hasFile(name: string): boolean {
if (name.includes('*')) {
const regex = new RegExp(name.replace(/\*/g, '.*'));
const regex = new RegExp(
name.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')
);
for (const file of this.files) {
if (regex.test(file)) return true;
}
+13 -35
View File
@@ -12,40 +12,7 @@ import type {
import { AGENT_INSTRUCTION_TEMPLATES } from './types.js';
import { analyzePrimer } from './analyzer.js';
const ALL_AGENTS: AgentType[] = [
'claude-code',
'cursor',
'codex',
'gemini-cli',
'opencode',
'antigravity',
'amp',
'clawdbot',
'droid',
'github-copilot',
'goose',
'kilo',
'kiro-cli',
'roo',
'trae',
'windsurf',
'universal',
'cline',
'codebuddy',
'commandcode',
'continue',
'crush',
'factory',
'mcpjam',
'mux',
'neovate',
'openhands',
'pi',
'qoder',
'qwen',
'vercel',
'zencoder',
];
const ALL_AGENTS: AgentType[] = Object.keys(AGENT_CONFIG) as AgentType[];
export class PrimerGenerator {
private projectPath: string;
@@ -172,10 +139,21 @@ export class PrimerGenerator {
}
private getDefaultTemplate(agent: AgentType, config: AgentDirectoryConfig): AgentInstructionTemplate {
const formatMap: Record<string, 'markdown' | 'json' | 'mdc' | 'xml'> = {
'.md': 'markdown',
'.json': 'json',
'.mdc': 'mdc',
'.xml': 'xml',
};
const ext = config.configFile.includes('.')
? '.' + config.configFile.split('.').pop()
: '.md';
const format = formatMap[ext] || 'markdown';
return {
agent,
filename: config.configFile,
format: 'markdown',
format,
sectionOrder: ['overview', 'stack', 'commands', 'conventions', 'structure', 'guidelines'],
};
}