import type { Spine, StepContext } from '../types.js'; const q = (ctx: StepContext) => String(ctx.input.question); const repoLine = (ctx: StepContext) => (ctx.input.repoPath ? ` Repo/focus: ${String(ctx.input.repoPath)}.` : ''); /** * Han `architectural-analysis` — assess a module/system across static structure, * runtime behaviour, and concurrency, then synthesise architecture changes. * The analyst angles fan out (behaviour at medium, concurrency at large), a * code fold collects them, and software-architect synthesises the recommendation. */ export const architecturalAnalysis: Spine = { name: 'architectural-analysis', description: 'structure + behaviour + concurrency → architecture synthesis', angles: [ { id: 'structural', agent: 'structural-analyst', label: 'Static structure (structural-analyst)', task: (ctx) => `Analyse the STATIC structure of the focus below — module boundaries, coupling, dependency direction, abstractions, duplication. Numbered findings, cite repo/path:line.${repoLine(ctx)}\n\nFOCUS: ${q(ctx)}`, }, { id: 'behavioral', agent: 'behavioral-analyst', label: 'Runtime behaviour (behavioral-analyst)', minBand: 'medium', task: (ctx) => `Analyse the RUNTIME behaviour of the focus below — data flow, error propagation, state management, integration boundaries. Numbered findings, cite repo/path:line.${repoLine(ctx)}\n\nFOCUS: ${q(ctx)}`, }, { id: 'concurrency', agent: 'concurrency-analyst', label: 'Concurrency (concurrency-analyst)', minBand: 'large', task: (ctx) => `Analyse CONCURRENCY/async risks in the focus below — races, shared-resource contention, lock ordering, deadlock potential, async error handling. Numbered findings, cite repo/path:line.${repoLine(ctx)}\n\nFOCUS: ${q(ctx)}`, }, ], synthesizer: { agent: 'software-architect', label: 'Architecture synthesis (software-architect)', task: (ctx) => [ 'Synthesise the analyses below into recommended INTRA-codebase architecture changes — module boundaries, class/interface design, abstraction/extension points, refactoring paths — grounded in high cohesion, loose coupling, and SOLID. Cross-reference the findings you build on; give pseudocode sketches for proposed boundaries.', '', '----- ANALYSES -----', ctx.results.fold ?? '', ].join('\n'), }, };