diff_article
Compare EU regulation article versions between dates to identify changes with unified diffs and AI-generated summaries. Requires Ansvar Intelligence Portal.
Instructions
Show what changed in a specific article between two dates, including a unified diff and AI-generated change summary. Premium feature — requires Ansvar Intelligence Portal.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regulation | Yes | Regulation ID (e.g., "NIS2", "DORA", "GDPR") | |
| article | Yes | Article number (e.g., "21", "6") | |
| from_date | Yes | ISO date to diff from (e.g., "2024-01-01") | |
| to_date | No | ISO date to diff to (defaults to today) |
Implementation Reference
- src/tools/version-tracking.ts:124-186 (handler)The handler implementation for diff_article tool.
export async function diffArticle( db: DatabaseAdapter, input: DiffArticleInput, ): Promise<ArticleDiff | { premium: false; message: string }> { if (!isPremiumEnabled()) { return { premium: false, message: PREMIUM_UPGRADE_MESSAGE }; } if (!(await hasVersionsTable(db))) { throw new Error('Version tracking data not available in this database build.'); } const { regulation, article, from_date, to_date } = input; const effectiveToDate = to_date ?? new Date().toISOString().slice(0, 10); const articleResult = await db.query<{ rowid: number }>( 'SELECT rowid FROM articles WHERE regulation = $1 AND article_number = $2', [regulation, article], ); if (articleResult.rows.length === 0) { throw new Error(`Article ${article} not found in ${regulation}`); } const articleId = articleResult.rows[0].rowid; // Find the version closest to the to_date that has a diff const diffResult = await db.query<{ diff_from_previous: string | null; change_summary: string | null; effective_date: string | null; }>( `SELECT diff_from_previous, change_summary, effective_date FROM article_versions WHERE article_id = $1 AND effective_date > $2 AND effective_date <= $3 ORDER BY effective_date DESC LIMIT 1`, [articleId, from_date, effectiveToDate], ); if (diffResult.rows.length === 0) { return { regulation, article, from_date, to_date: effectiveToDate, diff: null, change_summary: 'No changes found in this date range.', }; } const row = diffResult.rows[0]; return { regulation, article, from_date, to_date: effectiveToDate, diff: row.diff_from_previous, change_summary: row.change_summary, }; } - src/tools/version-tracking.ts:13-18 (schema)Input schema definition for diff_article.
export interface DiffArticleInput { regulation: string; article: string; from_date: string; to_date?: string; }