Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/commands/experiments/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,20 @@ export const getCommand = new Command('get')
'teams',
'tags',
];
const metricListFields = new Set([
'secondary_metrics',
'guardrail_metrics',
'exploratory_metrics',
]);
const deferredMetrics: Array<{ key: string; val: string }> = [];
for (const key of tableFields) {
const val = summary[key];
if (val !== undefined && val !== '' && String(val).replace(/,\s*/g, '').trim()) {
lines.push(`| **${key}** | ${val} |`);
if (metricListFields.has(key)) {
deferredMetrics.push({ key, val: String(val) });
} else {
lines.push(`| **${key}** | ${val} |`);
}
}
}
for (const key of Object.keys(summary)) {
Expand All @@ -94,6 +104,15 @@ export const getCommand = new Command('get')
}
lines.push('');

for (const { key, val } of deferredMetrics) {
const label = key.replace(/_/g, ' ');
lines.push(`## ${label.charAt(0).toUpperCase() + label.slice(1)}`);
for (const metric of val.split(', ')) {
lines.push(`- ${metric}`);
}
Comment on lines +107 to +112
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make metric splitting resilient to spacing/trailing separators.

At Line 110, split(', ') only handles a comma followed by exactly one space. Values like a,b or a, b won’t split correctly, and trailing commas can generate empty bullets.

Proposed fix
 for (const { key, val } of deferredMetrics) {
   const label = key.replace(/_/g, ' ');
   lines.push(`## ${label.charAt(0).toUpperCase() + label.slice(1)}`);
-  for (const metric of val.split(', ')) {
+  for (const metric of val.split(/\s*,\s*/).map((m) => m.trim()).filter(Boolean)) {
     lines.push(`- ${metric}`);
   }
   lines.push('');
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const { key, val } of deferredMetrics) {
const label = key.replace(/_/g, ' ');
lines.push(`## ${label.charAt(0).toUpperCase() + label.slice(1)}`);
for (const metric of val.split(', ')) {
lines.push(`- ${metric}`);
}
for (const { key, val } of deferredMetrics) {
const label = key.replace(/_/g, ' ');
lines.push(`## ${label.charAt(0).toUpperCase() + label.slice(1)}`);
for (const metric of val.split(/\s*,\s*/).map((m) => m.trim()).filter(Boolean)) {
lines.push(`- ${metric}`);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/experiments/get.ts` around lines 107 - 112, The metric-splitting
logic in the deferredMetrics loop (variables key, val, label, lines) uses
val.split(', ') which fails for different spacing and leaves empty items for
trailing commas; replace that with splitting on a regex that trims spaces around
commas (e.g. val.split(/\s*,\s*/)), then map each item to .trim() and filter out
empty strings (e.g. .filter(Boolean)) before pushing bullets so inputs like
"a,b", "a,  b", or "a," produce correct non-empty metric lines.

lines.push('');
}

if (summary.audience && String(summary.audience) !== '') {
lines.push('## Audience');
lines.push('```json');
Expand Down
Loading