fix(profile): correct template paths, field names, and evidence key in profile-output (#1095)
Three bugs preventing /gsd:profile-user from generating complete profiles: 1. Template path resolves to bin/templates/ (doesn't exist) instead of templates/ — __dirname is bin/lib/, needs two levels up not one 2. write-profile reads analysis.projects_list and analysis.message_count but the profiler agent outputs projects_analyzed and messages_analyzed 3. Evidence block checks dim.evidence but profiler outputs evidence_quotes Fixes all three with fallback patterns (accepts both old and new field names) so existing and future analysis formats both work. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -427,7 +427,7 @@ function cmdWriteProfile(cwd, options, raw) {
|
|||||||
process.stderr.write(`Sensitive content redacted: ${redactedCount} pattern(s) removed from evidence quotes\n`);
|
process.stderr.write(`Sensitive content redacted: ${redactedCount} pattern(s) removed from evidence quotes\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const templatePath = path.join(__dirname, '..', 'templates', 'user-profile.md');
|
const templatePath = path.join(__dirname, '..', '..', 'templates', 'user-profile.md');
|
||||||
if (!fs.existsSync(templatePath)) error(`Template not found: ${templatePath}`);
|
if (!fs.existsSync(templatePath)) error(`Template not found: ${templatePath}`);
|
||||||
let template = fs.readFileSync(templatePath, 'utf-8');
|
let template = fs.readFileSync(templatePath, 'utf-8');
|
||||||
|
|
||||||
@@ -467,11 +467,11 @@ function cmdWriteProfile(cwd, options, raw) {
|
|||||||
|
|
||||||
template = template.replace(/\{\{generated_at\}\}/g, new Date().toISOString());
|
template = template.replace(/\{\{generated_at\}\}/g, new Date().toISOString());
|
||||||
template = template.replace(/\{\{data_source\}\}/g, analysis.data_source || 'session_analysis');
|
template = template.replace(/\{\{data_source\}\}/g, analysis.data_source || 'session_analysis');
|
||||||
template = template.replace(/\{\{projects_list\}\}/g, (analysis.projects_list || []).join(', '));
|
template = template.replace(/\{\{projects_list\}\}/g, (analysis.projects_list || analysis.projects_analyzed || []).join(', '));
|
||||||
template = template.replace(/\{\{message_count\}\}/g, String(analysis.message_count || 0));
|
template = template.replace(/\{\{message_count\}\}/g, String(analysis.message_count || analysis.messages_analyzed || 0));
|
||||||
template = template.replace(/\{\{summary_instructions\}\}/g, summaryInstructions);
|
template = template.replace(/\{\{summary_instructions\}\}/g, summaryInstructions);
|
||||||
template = template.replace(/\{\{profile_version\}\}/g, analysis.profile_version);
|
template = template.replace(/\{\{profile_version\}\}/g, analysis.profile_version);
|
||||||
template = template.replace(/\{\{projects_count\}\}/g, String((analysis.projects_list || []).length));
|
template = template.replace(/\{\{projects_count\}\}/g, String((analysis.projects_list || analysis.projects_analyzed || []).length));
|
||||||
template = template.replace(/\{\{dimensions_scored\}\}/g, String(dimensionsScored));
|
template = template.replace(/\{\{dimensions_scored\}\}/g, String(dimensionsScored));
|
||||||
template = template.replace(/\{\{high_confidence_count\}\}/g, String(highCount));
|
template = template.replace(/\{\{high_confidence_count\}\}/g, String(highCount));
|
||||||
template = template.replace(/\{\{medium_confidence_count\}\}/g, String(mediumCount));
|
template = template.replace(/\{\{medium_confidence_count\}\}/g, String(mediumCount));
|
||||||
@@ -487,8 +487,9 @@ function cmdWriteProfile(cwd, options, raw) {
|
|||||||
const summary = dim.summary || '';
|
const summary = dim.summary || '';
|
||||||
|
|
||||||
let evidenceBlock = '';
|
let evidenceBlock = '';
|
||||||
if (dim.evidence && Array.isArray(dim.evidence) && dim.evidence.length > 0) {
|
const evidenceArr = dim.evidence_quotes || dim.evidence;
|
||||||
const evidenceLines = dim.evidence.map(ev => {
|
if (evidenceArr && Array.isArray(evidenceArr) && evidenceArr.length > 0) {
|
||||||
|
const evidenceLines = evidenceArr.map(ev => {
|
||||||
const signal = ev.signal || ev.pattern || '';
|
const signal = ev.signal || ev.pattern || '';
|
||||||
const quote = ev.quote || ev.example || '';
|
const quote = ev.quote || ev.example || '';
|
||||||
const project = ev.project || 'unknown';
|
const project = ev.project || 'unknown';
|
||||||
@@ -619,7 +620,7 @@ function cmdGenerateDevPreferences(cwd, options, raw) {
|
|||||||
learning_style: 'Learning Support',
|
learning_style: 'Learning Support',
|
||||||
};
|
};
|
||||||
|
|
||||||
const templatePath = path.join(__dirname, '..', 'templates', 'dev-preferences.md');
|
const templatePath = path.join(__dirname, '..', '..', 'templates', 'dev-preferences.md');
|
||||||
if (!fs.existsSync(templatePath)) error(`Template not found: ${templatePath}`);
|
if (!fs.existsSync(templatePath)) error(`Template not found: ${templatePath}`);
|
||||||
let template = fs.readFileSync(templatePath, 'utf-8');
|
let template = fs.readFileSync(templatePath, 'utf-8');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user