Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ These instructions have been tested on a clean machine to ensure a reliable setu

> **Note:** If the repository already includes `.env.example`, you only need to copy it to `.env`. Creating a new `.env.example` is only necessary if the file is missing.


5. **Start the development server:**
```bash
bun dev
Expand Down
62 changes: 28 additions & 34 deletions src/lib/api/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,19 @@ export async function searchIssues(

const issues = data.items
.filter((item) => !item.pull_request)
.map(
(item): Issue => ({
number: item.number,
title: item.title,
body: item.body,
user: item.user,
labels: item.labels,
assignees: item.assignees,
comments_count: item.comments,
created_at: item.created_at,
updated_at: item.updated_at,
html_url: item.html_url,
state: item.state,
}),
);
.map((item): Issue => ({
number: item.number,
title: item.title,
body: item.body,
user: item.user,
labels: item.labels,
assignees: item.assignees,
comments_count: item.comments,
created_at: item.created_at,
updated_at: item.updated_at,
html_url: item.html_url,
state: item.state,
}));

allIssues.push(...issues);

Expand Down Expand Up @@ -190,15 +188,13 @@ export async function fetchIssueComments(

const data = await response.json();

return data.map(
(c: Record<string, unknown>): Comment => ({
id: c.id as number,
user: c.user as Comment['user'],
body: c.body as string,
created_at: c.created_at as string,
updated_at: c.updated_at as string,
}),
);
return data.map((c: Record<string, unknown>): Comment => ({
id: c.id as number,
user: c.user as Comment['user'],
body: c.body as string,
created_at: c.created_at as string,
updated_at: c.updated_at as string,
}));
}

export async function fetchIssueTimeline(
Expand All @@ -217,16 +213,14 @@ export async function fetchIssueTimeline(

const data: Record<string, unknown>[] = await response.json();

return data.map(
(e): TimelineEvent => ({
event: e.event as string,
created_at: e.created_at as string,
actor: e.actor as TimelineEvent['actor'],
source: e.source as TimelineEvent['source'],
commit_id: e.commit_id as string | undefined,
label: e.label as TimelineEvent['label'],
}),
);
return data.map((e): TimelineEvent => ({
event: e.event as string,
created_at: e.created_at as string,
actor: e.actor as TimelineEvent['actor'],
source: e.source as TimelineEvent['source'],
commit_id: e.commit_id as string | undefined,
label: e.label as TimelineEvent['label'],
}));
} catch {
return [];
}
Expand Down
31 changes: 31 additions & 0 deletions src/lib/utils/exporters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,37 @@ describe('exporters utilities', () => {
expect(markdown).toContain(`# Isscope Report — ${mockRepo}`);
expect(markdown).toContain('Total issues analyzed: 0');
});

it('escapes pipes and newlines in issue titles so tables and headings stay intact', () => {
const trickyIssue: RankedIssue = {
number: 99,
title: 'Bug | Critical\nfeat: second line',
body: null,
user: { login: 'u', avatar_url: '', html_url: '' },
labels: [],
assignees: [],
comments_count: 0,
created_at: '2026-05-18T10:00:00Z',
updated_at: '2026-05-18T10:00:00Z',
html_url: 'https://github.com/owner/repo/issues/99',
state: 'open',
score: 60,
analysis: undefined,
};

const markdown = exportToMarkdown([trickyIssue], mockRepo);

// Table row must keep exactly 6 columns: the pipe is escaped
const row = '| 1 | #99 | Bug \\| Critical feat: second line | 60/100 | — | — |';
expect(markdown).toContain(row);
expect(markdown).toContain('## #99 — Bug | Critical feat: second line');

// The title's embedded newline must not spawn a second table row
const tableSection = markdown.split('## Summary Table')[1].split('\n---\n')[0];
const dataRows = tableSection.split('\n').filter((l) => l.startsWith('| 1 |'));
expect(dataRows).toHaveLength(1);
expect(tableSection).not.toContain('\n| feat:');
});
});

describe('downloadMarkdown', () => {
Expand Down
17 changes: 15 additions & 2 deletions src/lib/utils/exporters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import type { RankedIssue } from '../types';
import { statusLabel, complexityLabel, friendlinessLabel, progressLabel } from './formatters';

// GitHub issue titles may contain pipe characters or line breaks; both break
// markdown tables/headings, so normalize before embedding user content.
function escapeTableCell(str: string): string {
return str
.replace(/\|/g, '\\|')
.replace(/[\r\n]+/g, ' ')
.trim();
}

function escapeHeading(str: string): string {
return str.replace(/[\r\n]+/g, ' ').trim();
}

export function exportToMarkdown(issues: RankedIssue[], repoName: string): string {
const lines: string[] = [
`# Isscope Report — ${repoName}`,
Expand All @@ -19,7 +32,7 @@ export function exportToMarkdown(issues: RankedIssue[], repoName: string): strin
issues.forEach((issue, i) => {
const analysis = issue.analysis;
lines.push(
`| ${i + 1} | #${issue.number} | ${issue.title.slice(0, 50)} | ${issue.score}/100 | ${analysis ? statusLabel(analysis.status) : '—'} | ${analysis ? complexityLabel(analysis.complexity) : '—'} |`,
`| ${i + 1} | #${issue.number} | ${escapeTableCell(issue.title).slice(0, 50)} | ${issue.score}/100 | ${analysis ? statusLabel(analysis.status) : '—'} | ${analysis ? complexityLabel(analysis.complexity) : '—'} |`,
);
});

Expand All @@ -28,7 +41,7 @@ export function exportToMarkdown(issues: RankedIssue[], repoName: string): strin
for (const issue of issues) {
const a = issue.analysis;
lines.push(
`## #${issue.number} — ${issue.title}`,
`## #${issue.number} — ${escapeHeading(issue.title)}`,
``,
`- **Doability Score**: ${issue.score}/100`,
`- **URL**: ${issue.html_url}`,
Expand Down
Loading