🔬 Deep-Inspection Generator: Multi-Iteration Intelligence Report Architecture#1163
🔬 Deep-Inspection Generator: Multi-Iteration Intelligence Report Architecture#1163
Conversation
…ence reports - Add --depth CLI parameter (1-4) to config.ts, exported as analysisDepth - Add buildExecutiveSummary() for decision-maker briefs (depth ≥ 3), all 14 languages - Add buildPredictiveAssessment() with confidence %, coalition stability, risk scenarios (depth ≥ 2), all 14 languages - Add buildHistoricalContext() with precedent analysis and Nordic/EU benchmarking (depth ≥ 2), all 14 languages - Add buildMethodologySection() with data sources, iteration log, confidence score (depth ≥ 3), all 14 languages - Add deriveConfidence() heuristic (0-100) with named constants for weights - Extend buildStrategicImplications() from 5 languages to all 14 - Add new DEEP_SECTION_LABELS for executiveSummary, predictiveAssessment, historicalContext, methodology - Update generateDeepInspectionContent() to accept depth parameter with depth-gated sections - Create scripts/deep-inspection/index.ts with DeepInspectionPipeline class - Add 13 tests in tests/deep-inspection-pipeline.test.ts Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Refactors the deep-inspection generator into a depth-gated (1–4) multi-iteration intelligence report with new sections and expanded 14-language template coverage, and introduces a small DeepInspectionPipeline wrapper plus initial Vitest coverage.
Changes:
- Added
--depthCLI parsing (analysisDepth) and used it to gate new deep-inspection sections (executive summary, predictive assessment, historical context, methodology/confidence). - Expanded
buildStrategicImplications()templates from 5 to 14 languages. - Introduced
scripts/deep-inspection/index.tspipeline wrapper and added a new test suite.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
scripts/generate-news-enhanced/config.ts |
Parses --depth into analysisDepth (1–4) for deep-inspection runs. |
scripts/generate-news-enhanced/generators.ts |
Adds depth-gated deep-inspection sections + 14-language strategic implications templates. |
scripts/deep-inspection/index.ts |
Adds DeepInspectionPipeline wrapper API around generateDeepInspection(). |
tests/deep-inspection-pipeline.test.ts |
Adds Vitest coverage for config depth, pipeline exports, and template compilation. |
| : Math.max(MIN_PASSAGE_PROBABILITY, BASE_PASSAGE_PROBABILITY - motCount * OPPOSITION_MOTION_PENALTY); | ||
| const blockPct = 100 - passagePct; | ||
|
|
||
| const topicStr = topic ? esc(topic) : (lang === 'sv' ? 'detta område' : 'this area'); |
| da: `${topicStr ? `<strong>${topicStr}</strong> er del af` : 'Denne politik er del af'} en lang tradition for dansk parlamentarisk reform. ${domainList.length > 0 ? `I nordisk kontekst har ${domainList.join(', ')} historisk nydt gavn af tværpolitisk konsensus.` : ''} Trendanalyse viser, at politikken på dette område accelererer.`, | ||
| no: `${topicStr ? `<strong>${topicStr}</strong> er en del av` : 'Denne politikken er en del av'} en lang tradisjon for norsk parlamentarisk reform. ${domainList.length > 0 ? `I nordisk kontekst har ${domainList.join(', ')} historisk nytt godt av tverrpolitisk konsensus.` : ''} Trendanalyse indikerer at politikk på dette området akselererer.`, | ||
| fi: `${topicStr ? `<strong>${topicStr}</strong> on osa` : 'Tämä politiikka on osa'} pitkää suomalaista parlamentaarista uudistusperinnettä. ${domainList.length > 0 ? `Pohjoismaisessa kontekstissa ${domainList.join(', ')} aloilla on historiallisesti hyöty puolueiden välisestä yhteisymmärryksestä.` : ''} Trendanalyysi osoittaa, että tämän alan politiikka kiihtyy.`, |
| da: ['Overfladeanalyse (hændelser og aktører identificeret)', 'Dybdeanalyse (motivationer og strategiske implikationer)', 'Prædiktiv analyse (prognoser og risikoscenarier)', 'Kvalitetsgennemgang (bias-tjek og fuldstændighedsverificering)'], | ||
| no: ['Overflateanalyse (hendelser og aktører identifisert)', 'Dybdeanalyse (motivasjoner og strategiske implikasjoner)', 'Prediktiv analyse (prognoser og risikoscenarier)', 'Kvalitetsgjennomgang (bias-sjekk og fullstendighetsverifisering)'], | ||
| fi: ['Pintaanalyysi (tapahtumat ja toimijat tunnistettu)', 'Syväanalyysi (motiivit ja strategiset vaikutukset)', 'Ennakoiva analyysi (ennusteet ja riskiskenaariot)', 'Laaduntarkistus (vinoutumien tarkistus ja kattavuuden varmennus)'], | ||
| de: ['Oberflächenanalyse (Ereignisse und Akteure identifiziert)', 'Tiefenanalyse (Motivationen und strategische Implikationen)', 'Prädiktive Analyse (Prognosen und Risikoszernarien)', 'Qualitätsprüfung (Bias-Prüfung und Vollständigkeitsverifikation)'], |
| * languages: ['en', 'sv'], | ||
| * }); | ||
| * const result = await pipeline.run(); | ||
| * ``` | ||
| * |
| // We test the confidence logic indirectly via buildMethodologySection exports. | ||
| // The function is module-private, so test observable behavior via content checks. | ||
| describe('confidence score derivation (via section HTML)', () => { | ||
| it('confidence is between 0 and 100', () => { | ||
| // Heuristic formula: min(100, Math.round(enrichmentRate * 70) + docBonus) | ||
| // Test boundary: 0 docs → 0 | ||
| const confOf = (enriched: number, total: number): number => { | ||
| if (total === 0) return 0; | ||
| const enrichmentRate = enriched / total; | ||
| const docBonus = Math.min(30, Math.round((total / 10) * 30)); | ||
| return Math.min(100, Math.round(enrichmentRate * 70) + docBonus); | ||
| }; | ||
| expect(confOf(0, 0)).toBe(0); | ||
| expect(confOf(5, 5)).toBe(85); // enrichment=100% (70pts) + docBonus=15 = 85 | ||
| expect(confOf(0, 5)).toBe(15); // enrichment=0% + docBonus=15 = 15 | ||
| expect(confOf(5, 10)).toBe(65); // enrichment=50% (35pts) + docBonus=30 = 65 | ||
| expect(confOf(10, 10)).toBe(100); // enrichment=100% (70pts) + docBonus=30 = 100 |
| // It's async (returns Promise) | ||
| const result = pipeline.run(); | ||
| expect(result).toBeInstanceOf(Promise); | ||
| // We don't await it because it requires a live MCP connection; | ||
| // just verify it returns a Promise. | ||
| result.catch(() => {}); |
| async run(): Promise<DeepInspectionResult> { | ||
| const depth = this.params.depth ?? 1; | ||
| const topic = this.params.focusTopic; | ||
|
|
||
| console.log(`🔬 DeepInspectionPipeline starting — depth ${depth}: ${this.phaseLabel(depth)}`); | ||
| if (topic) console.log(` Topic: ${topic}`); | ||
|
|
||
| const result = await generateDeepInspection(); | ||
|
|
||
| return { | ||
| ...result, | ||
| depth, | ||
| topic, | ||
| }; |
| const headingPredictive = deepLabel('predictiveAssessment', lang); | ||
| const headingOutcome = deepLabel('likelyOutcome', lang); | ||
| const headingCoalition = deepLabel('coalitionStability', lang); | ||
| const headingRisk = deepLabel('riskScenarios', lang); |
|
@copilot apply changes based on the comments in this thread and TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request) |
- Add likelyOutcome/coalitionStability/riskScenarios labels to DEEP_SECTION_LABELS (all 14 langs) - Localize topicStr fallback per language in buildPredictiveAssessment (was English-only) - Fix da/no/fi historical context: use "svensk Riksdagsreform" / "Ruotsin valtiopäivien" (not Danish/Norwegian/Finnish) - Fix German typo: "Risikoszernarien" → "Risikoszenarien" - Fix pipeline example: remove non-existent languages property - Pipeline run() now uses config analysisDepth instead of constructor param - Fix pipeline test: check AsyncFunction without invoking run() - Fix CI: update agentic-workflow-mcp-queries.test.ts for merged workflow changes Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
All review comments addressed and CI failure fixed in fd4b967:
|
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Adds an analysis-depth concept to the deep-inspection generator to produce a more “intelligence report”-style output (executive summary, predictive assessment, historical context, methodology), and introduces a DeepInspectionPipeline wrapper module with accompanying test updates.
Changes:
- Added
--depthCLI parsing (analysisDepth1–4) and wired it into deep-inspection generation. - Expanded deep-inspection HTML generation with depth-gated intelligence sections + 14-language strategic-implications/templates and new DEEP_SECTION_LABELS.
- Added
scripts/deep-inspection/module entrypoint (DeepInspectionPipeline) and new/updated tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/deep-inspection-pipeline.test.ts | Adds coverage for analysisDepth parsing and new deep-inspection pipeline/module exports. |
| tests/agentic-workflow-mcp-queries.test.ts | Updates workflow pattern assertions to match the current workflow doc content. |
| scripts/generate-news-enhanced/generators.ts | Implements depth-gated deep-inspection sections, 14-language strategic implications, and logs depth. |
| scripts/generate-news-enhanced/config.ts | Adds --depth parsing and exports analysisDepth (1–4). |
| scripts/deep-inspection/index.ts | Introduces DeepInspectionPipeline wrapper class and types. |
| const hasEnactedLaw = sfsDocs.length > 0; | ||
| const govLed = propCount > motCount; | ||
| const highScrutiny = betCount > 0; | ||
|
|
||
| const templates: Partial<Record<Language, string>> = { | ||
| en: `This deep-inspection intelligence report analyses ${docs.length} parliamentary document${docs.length !== 1 ? 's' : ''}${topic ? ` on <strong>${esc(topic)}</strong>` : ''}${domainPhrase ? `, spanning ${domainPhrase}` : ''}. Of these, ${enriched} ${enriched === 1 ? 'was' : 'were'} enriched with full text to enable substantive analysis. The legislative posture is ${govLed ? 'government-led' : 'opposition-driven'}, with ${propCount} proposition${propCount !== 1 ? 's' : ''} advancing the executive agenda${betCount > 0 ? `, ${betCount} committee report${betCount !== 1 ? 's' : ''} providing parliamentary scrutiny` : ''}${motCount > 0 ? `, and ${motCount} opposition motion${motCount !== 1 ? 's' : ''} challenging the direction` : ''}. ${hasEnactedLaw ? `${sfsDocs.length} statute${sfsDocs.length !== 1 ? 's' : ''} have already been enacted, establishing a legal baseline.` : highScrutiny ? 'Committee engagement indicates that the policy is under active parliamentary review, signalling that key decisions are imminent.' : 'The legislative pipeline remains at an early stage, requiring close monitoring for acceleration signals.'} ${domainPhrase ? `Policy domains engaged — ${domainPhrase} — reflect the cross-cutting nature of this initiative.` : 'The documents reflect focused policy engagement in this area.'} Decision-makers should prioritise tracking committee deliberations and chamber voting patterns as the most reliable forward indicators.`, | ||
| sv: `Denna djupanalys granskar ${docs.length} riksdagsdokument${topic ? ` rörande <strong>${esc(topic)}</strong>` : ''}${domainPhrase ? ` inom ${domainPhrase}` : ''}. Av dessa berikades ${enriched} med fulltext. Det lagstiftande läget är ${govLed ? 'regeringsledet' : 'oppositionsdrivet'} med ${propCount} proposition${propCount !== 1 ? 'er' : ''}, ${betCount > 0 ? `${betCount} utskottsbetänkande${betCount !== 1 ? 'n' : ''} som ger parlamentarisk granskning, ` : ''}${motCount > 0 ? `och ${motCount} opposition${motCount !== 1 ? 'smotioner' : 'smotion'} som ifrågasätter inriktningen` : ''}. ${hasEnactedLaw ? `${sfsDocs.length} lag${sfsDocs.length !== 1 ? 'ar' : ''} har redan antagits och fastställt ett rättsligt ramverk.` : highScrutiny ? 'Utskottsengagemanget visar att policyn är under aktiv parlamentarisk granskning.' : 'Lagstiftningspipelinen befinner sig i ett tidigt skede.'} Beslutsfattare bör prioritera att följa utskottens arbete och omröstningar i kammaren.`, |
| const sfsDocs = docs.filter(d => (d.doktyp || d.documentType) === 'sfs'); | ||
| const confidence = deriveConfidence(docs); | ||
|
|
||
| // Passage likelihood heuristic: if committee reports exceed motions → likely passage | ||
| const passageLikely = betCount > motCount || sfsDocs.length > 0; | ||
| const passagePct = passageLikely |
| const betCount = docs.filter(d => (d.doktyp || d.documentType) === 'bet').length; | ||
| const motCount = docs.filter(d => (d.doktyp || d.documentType) === 'mot').length; | ||
| const sfsDocs = docs.filter(d => (d.doktyp || d.documentType) === 'sfs'); | ||
| const enriched = docs.filter(d => d.contentFetched).length; |
| */ | ||
| function buildMethodologySection(docs: RawDocument[], topic: string | null, lang: Language, depth: number): string { | ||
| const esc = escapeHtml; | ||
| const enriched = docs.filter(d => d.contentFetched).length; |
| it('pipeline run() is an async function without side effects on construction', async () => { | ||
| const { DeepInspectionPipeline } = await import('../scripts/deep-inspection/index.js'); | ||
| const pipeline = new DeepInspectionPipeline(); | ||
| // Verify run is an async function by checking its constructor name | ||
| expect(pipeline.run.constructor.name).toBe('AsyncFunction'); | ||
| }); |
| const sfsDocs = docs.filter(d => (d.doktyp || d.documentType) === 'sfs'); | ||
| const propCount = docs.filter(d => (d.doktyp || d.documentType) === 'prop').length; | ||
| const allDomains = new Set<string>(); | ||
| docs.forEach(d => detectPolicyDomains(d, lang).forEach(dom => allDomains.add(dom))); | ||
| const domainList = [...allDomains].slice(0, 3).map(d => esc(d)); | ||
| const hasEnacted = sfsDocs.length > 0; | ||
| const topicStr = topic ? esc(topic) : null; |
| function deriveConfidence(docs: RawDocument[]): number { | ||
| if (docs.length === 0) return 0; | ||
| const enriched = docs.filter(d => d.contentFetched).length; | ||
| const enrichmentRate = enriched / docs.length; // 0–1 | ||
| const docBonus = Math.min(MAX_DOCUMENT_BONUS, Math.round((docs.length / DOCUMENT_BONUS_DIVISOR) * MAX_DOCUMENT_BONUS)); | ||
| return Math.min(100, Math.round(enrichmentRate * ENRICHMENT_WEIGHT) + docBonus); |
| /** | ||
| * Analysis depth (1–4): | ||
| * 1 — surface analysis (what happened) — default, fastest | ||
| * 2 — adds predictive assessment and historical context | ||
| * 3 — adds executive intelligence summary and methodology section | ||
| * 4 — full multi-iteration intelligence report with all sections | ||
| * | ||
| * **Note**: This must match the `--depth` CLI arg passed at process start, | ||
| * since config.ts reads it at module load time. Setting this here only | ||
| * affects log labels, not the actual generation depth. | ||
| */ | ||
| depth?: 1 | 2 | 3 | 4; | ||
| } |
| async run(): Promise<DeepInspectionResult> { | ||
| const depth = analysisDepth; | ||
| const topic = this.params.focusTopic; | ||
|
|
||
| console.log(`🔬 DeepInspectionPipeline starting — depth ${depth}: ${this.phaseLabel(depth)}`); | ||
| if (topic) console.log(` Topic: ${topic}`); | ||
|
|
||
| const result = await generateDeepInspection(); | ||
|
|
||
| return { | ||
| ...result, | ||
| depth, | ||
| topic, | ||
| }; |
|
@copilot apply changes based on the comments in this thread |
…eline API, test mock
- Fix SFS detection in buildExecutiveSummary, buildPredictiveAssessment, buildHistoricalContext,
buildStrategicImplications to use dokumentnamn.startsWith('SFS') fallback (aligns with
buildDeepInspectionSections pattern)
- Fix enrichment counting: use `fullText || fullContent` instead of `contentFetched` in
deriveConfidence, buildExecutiveSummary, buildStrategicImplications, buildMethodologySection
(contentFetched can be true without full text)
- Remove unused `depth`/`focusTopic` from DeepInspectionPipelineParams — these were
misleading since the effective values come from CLI config
- Pipeline run() now sources topic from config.focusTopic instead of constructor params
- Replace fragile AsyncFunction constructor name test with mock-based approach: vi.mock
generators at top level, assert pipeline.run() returns Promise and result has valid depth
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Implemented all requested updates in 02056de.
Validation run:
No UI changes were made in this update, so there is no UI screenshot. |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
This PR extends the deep-inspection generator to support configurable multi-iteration “intelligence report” output (depth 1–4), adds new depth-gated report sections (executive summary, historical context, predictive assessment, methodology/confidence), and introduces a thin programmatic DeepInspectionPipeline wrapper with updated tests to validate the new behavior.
Changes:
- Add
--depth=1..4CLI parsing (analysisDepth) and pass it into deep-inspection rendering to gate advanced sections. - Expand deep-inspection content with new localized section labels and new section builders (executive summary, historical context, predictive assessment, methodology/confidence).
- Add/adjust Vitest coverage to assert depth-gating behavior and MCP workflow documentation requirements; introduce
scripts/deep-inspection/index.tswrapper.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/generate-news-enhanced/config.ts |
Adds --depth parsing and exports analysisDepth (1–4, default 1). |
scripts/generate-news-enhanced/generators.ts |
Implements depth-gated deep-inspection sections + 14-language strategic implications; exports test hooks. |
scripts/deep-inspection/index.ts |
Adds DeepInspectionPipeline wrapper delegating to generateDeepInspection(). |
tests/deep-inspection-pipeline.test.ts |
Adds behavioral tests for depth gating, labels, and pipeline exports. |
tests/agentic-workflow-mcp-queries.test.ts |
Tightens/extends workflow-doc assertions for post-query filtering and cross-referencing. |
| // Should have explicit >= fromDate filtering guidance | ||
| expect(content).toMatch(/>=\s*fromDate/); | ||
| // Should reference Filter results instruction | ||
| expect(content).toMatch(/Filter results/i); |
| it('depth 4 includes the quality-review methodology iteration', async () => { | ||
| const html = await render(4, 'en'); | ||
| expect(html).toContain('Quality review (bias check and completeness verification)'); |
| expect(html).toContain('Likely Outcome'); | ||
| expect(html).toContain('Coalition Stability Forecast'); | ||
| expect(html).toContain('Risk Scenarios'); |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Addressed in commit I made the requested assertions less brittle by switching to semantic/structural checks:
Validation run:
No UI files were changed in this update, so no screenshot applies. |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Enhances the deep-inspection generator toward a multi-iteration “intelligence report” model by introducing depth-gated narrative sections, expanding section labels/templates to all 14 languages, and adding a thin DeepInspectionPipeline programmatic entrypoint plus new behavioral tests.
Changes:
- Add
--depth=1..4parsing and depth-gated deep-inspection narrative sections (executive summary, historical context, predictive assessment, methodology/confidence). - Expand
DEEP_SECTION_LABELSand strategic-implications templates to cover all 14 supported languages. - Add a
scripts/deep-inspection/entrypoint wrapper and new/updated Vitest tests for depth gating and workflow documentation patterns.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/deep-inspection-pipeline.test.ts | Adds behavioral tests for depth parsing, pipeline exports, and depth-gated section rendering. |
| tests/agentic-workflow-mcp-queries.test.ts | Strengthens assertions around post-query date filtering and cross-referencing guidance in workflow docs. |
| scripts/generate-news-enhanced/generators.ts | Introduces new deep-inspection section builders, depth-gated rendering, and 14-language labels/templates (but currently contains duplicate imports/vars). |
| scripts/generate-news-enhanced/config.ts | Adds --depth parsing (but currently collides with existing analysisDepth export). |
| scripts/deep-inspection/index.ts | Adds a thin DeepInspectionPipeline wrapper around generateDeepInspection(). |
Comments suppressed due to low confidence (2)
scripts/generate-news-enhanced/generators.ts:2213
contentis declared twice in the same scope (first calling generateDeepInspectionContent(..., analysisDepth), then again calling generateDeepInspectionContent(...)). This is a compile-time error and also discards the new depth-aware rendering. Remove the old duplicate declaration and keep the depth-aware call.
// Topic-focused deep-inspection content (NOT generic content)
const content: string = generateDeepInspectionContent(enrichedDocs, sanitizedTopic, lang, analysisDepth);
// Topic-focused deep-inspection content (template-driven body text).
// At this stage the AI pipeline supplies structured sections (SWOT,
// dashboard, mindmap, Sankey, watch points) while the main narrative
// body is still produced by generateDeepInspectionContent(). Wiring
// AI-derived narrative into the article body is the next phase.
const content: string = generateDeepInspectionContent(enrichedDocs, sanitizedTopic, lang);
scripts/generate-news-enhanced/config.ts:116
config.tsnow exportsanalysisDepthtwice with different types/meanings: a numeric deep-inspection depth (1–4) and the existing AI iteration depth (AnalysisDepth= quick/standard/deep). This name collision will fail compilation and makes imports ambiguous. Rename one of them (e.g.deepInspectionDepthfor 1–4, keepanalysisDepthfor AI iterations) and update all imports/usages accordingly.
/**
* Analysis depth for deep-inspection (1–4).
* 1 — surface analysis (what happened) — default, fastest
* 2 — adds predictive assessment and historical context
* 3 — adds executive intelligence summary and methodology (3 iterations)
* 4 — full report: adds quality-review iteration in methodology (4 iterations)
*/
const rawDepth: string = parseArgValue(depthArg);
const depthArgProvided: boolean = !!depthArg;
const parsedDepthNum: number = rawDepth ? Number(rawDepth) : NaN;
const depthIsValid: boolean = Number.isInteger(parsedDepthNum) && parsedDepthNum >= 1 && parsedDepthNum <= 4;
if (depthArgProvided && !depthIsValid) {
console.warn(`Invalid --depth value "${rawDepth}" (expected integer 1–4), falling back to default 1.`);
}
const safeDepth: number = depthIsValid ? parsedDepthNum : 1;
export const analysisDepth: 1 | 2 | 3 | 4 =
safeDepth === 4 ? 4 :
safeDepth === 3 ? 3 :
safeDepth === 2 ? 2 :
1;
// ---------------------------------------------------------------------------
// Analysis depth (controls number of AI analysis iterations)
// ---------------------------------------------------------------------------
/**
* --analysis-depth=<quick|standard|deep>
*
* Controls how many AI analysis iterations run for deep-inspection articles:
* - `quick` — 1 pass (initial analysis only; fast)
* - `standard` — 2 passes (initial + SWOT refinement; default)
* - `deep` — 3 passes (initial + refinement + stakeholder validation)
*/
const analysisDepthArg: string | undefined = args.find(arg => arg.startsWith('--analysis-depth='));
const rawAnalysisDepth: string = parseArgValue(analysisDepthArg ?? '').toLowerCase();
const VALID_ANALYSIS_DEPTHS: readonly AnalysisDepth[] = ['quick', 'standard', 'deep'];
function parseAnalysisDepth(raw: string): AnalysisDepth {
if ((VALID_ANALYSIS_DEPTHS as readonly string[]).includes(raw)) {
return raw as AnalysisDepth;
}
if (raw && raw !== '') {
console.warn(`⚠️ Unknown --analysis-depth value "${raw}", falling back to "standard". Valid values: ${VALID_ANALYSIS_DEPTHS.join(', ')}`);
}
return 'standard';
}
export const analysisDepth: AnalysisDepth = parseAnalysisDepth(rawAnalysisDepth);
| import type { Language } from '../types/language.js'; | ||
| import type { GenerationResult, DateRange, ArticleCategory, TemplateSection, SwotEntry } from '../types/article.js'; | ||
| import type { TitleSet } from './types.js'; | ||
| import { languages, stats, getSharedClient, requireMcp, toISODate, documentIds, documentUrls, focusTopic, analysisDepth } from './config.js'; |
Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…ressions Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Implemented in
Validation:
No UI files changed in this update. |
1 similar comment
Implemented in
Validation:
No UI files changed in this update. |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
This PR extends the deep-inspection generator into a depth-gated “intelligence report” flow by adding new report sections, introducing a --depth=1..4 CLI parameter, and adding a thin DeepInspectionPipeline programmatic entrypoint, with tests covering the new behavior.
Changes:
- Add numeric deep-inspection
analysisDepthparsing (--depth=1..4) and rename the existing quick/standard/deep setting toanalysisMode. - Expand deep-inspection content generation with new depth-gated sections (executive summary, historical context, predictive assessment, methodology/confidence) and 14-language labels/templates.
- Add
scripts/deep-inspection/index.tswrapper and new Vitest coverage for depth gating + exports.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/generate-news-enhanced/generators.ts |
Adds depth-gated intelligence sections, labels, and wires depth into deep-inspection generation + metadata writing. |
scripts/generate-news-enhanced/config.ts |
Introduces --depth parsing (analysisDepth 1–4) and renames the existing --analysis-depth output to analysisMode. |
scripts/deep-inspection/index.ts |
Adds a thin DeepInspectionPipeline class delegating to generateDeepInspection(). |
tests/deep-inspection-pipeline.test.ts |
Adds behavioral tests for depth parsing, exported hooks, section gating, and pipeline exports. |
tests/agentic-workflow-mcp-queries.test.ts |
Tightens workflow-doc assertions around post-query date filtering and cross-referencing guidance. |
| import { languages, stats, getSharedClient, requireMcp, toISODate, documentIds, documentUrls, focusTopic, analysisDepth, METADATA_DIR } from './config.js'; | ||
| import { runAnalysisPipeline } from '../ai-analysis/pipeline.js'; | ||
| import type { AnalysisResult, AnalysisIterationMetadata, AnalysisDepth } from '../ai-analysis/types.js'; | ||
| import { languages, stats, getSharedClient, requireMcp, toISODate, documentIds, documentUrls, focusTopic, analysisIterations } from './config.js'; |
| focusTopic: sanitizedTopic, | ||
| }); | ||
| const pipelineDuration = iterationDurationsMs.reduce((a, b) => a + b, 0); | ||
| console.log(` 🌐 Generating ${lang.toUpperCase()} version...`); |
| focusTopic: sanitizedTopic, | ||
| completedAt: analysis.completedAt, | ||
| }; | ||
| writeAnalysisMetadata(slug, iterationMetadata); |
| // Topic-focused deep-inspection content (NOT generic content) | ||
| const content: string = generateDeepInspectionContent(enrichedDocs, sanitizedTopic, lang, analysisDepth); | ||
| // Topic-focused deep-inspection content (uses AI strategic implications & takeaways) | ||
| const content: string = generateDeepInspectionContent(enrichedDocs, sanitizedTopic, lang, aiResult); | ||
|
|
| @@ -1564,6 +2132,24 @@ export async function generateDeepInspection(): Promise<GenerationResult> { | |||
| console.log(` 🤖 AI analysis: ${aiResult.iterations} iteration(s), analysis score ${aiResult.analysisScore}`); | |||
| } | |||
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Applied in I addressed the review thread items by:
Validation on this commit:
No UI files were changed in this update. |
Original prompt
This section details on the original issue you should resolve
<issue_title>🔬 Deep-Inspection Generator Enhancement — Multi-Iteration AI Intelligence Reports</issue_title>
<issue_description>## 📋 Issue Type
Feature / Intelligence Enhancement
🎯 Objective
Enhance the deep-inspection generator (
generators.ts:642-1690) to produce comprehensive AI-driven political intelligence reports with multi-iteration analysis, document cross-referencing, historical context, and predictive insights. Transform deep-inspection from a document summary tool into a full political intelligence assessment platform.📊 Current State
generateDeepInspection()performs single-pass document analysisgenerateDeepInspectionContent()creates 5 sections via template logic:generateDeepPolicyAnalysis()generateDeepAnalysisSection()cross-document synthesisbuildDeepInspectionSections()creates 4 template sections:🚀 Desired State
Deep Intelligence Report Architecture
Phase 1: Document Intelligence Collection
Phase 2: Multi-Iteration AI Analysis
Phase 3: Multi-Perspective Intelligence Sections
Architecture Changes
generateDeepInspection()into modular pipeline:generators.tsto dedicated module:scripts/deep-inspection/pipeline.ts,analysis.ts,sections.ts,types.ts--depthCLI parameter:quick(1 iteration),standard(3),deep(4+)🔧 Implementation Approach
scripts/deep-inspection/module directoryDeepInspectionPipelineclass with configurable depth📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.