Skip to content
Merged
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
333 changes: 95 additions & 238 deletions packages/mcp-server/src/adapters/__tests__/plan-adapter.test.ts

Large diffs are not rendered by default.

455 changes: 102 additions & 353 deletions packages/mcp-server/src/adapters/built-in/plan-adapter.ts

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions packages/subagents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ export * from './github/utils';
export { CoordinatorLogger } from './logger';
// Agent modules
export { PlannerAgent } from './planner';
// Types - Context Assembler
export type {
CodebasePatterns,
ContextAssemblyOptions,
ContextMetadata,
ContextPackage,
IssueComment,
IssueContext,
RelatedHistory,
RelevantCodeContext,
} from './planner/context-types';
// Types - Planner
export type {
Plan,
Expand All @@ -60,6 +71,7 @@ export type {
// Planner utilities
export {
addEstimatesToTasks,
assembleContext,
breakdownIssue,
calculateTotalEstimate,
cleanDescription,
Expand All @@ -68,6 +80,7 @@ export {
extractEstimate,
extractTechnicalRequirements,
fetchGitHubIssue,
formatContextPackage,
formatEstimate,
formatJSON,
formatMarkdown,
Expand Down
142 changes: 142 additions & 0 deletions packages/subagents/src/planner/context-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/**
* Context Assembler Types
* Types for assembling context packages for LLM consumption
*
* Philosophy: Provide raw, structured context - let the LLM do the reasoning
*/

/**
* GitHub issue with full context
*/
export interface IssueContext {
/** Issue number */
number: number;
/** Issue title */
title: string;
/** Issue body (markdown) */
body: string;
/** Labels attached to the issue */
labels: string[];
/** Issue author username */
author: string;
/** ISO timestamp of creation */
createdAt: string;
/** ISO timestamp of last update */
updatedAt: string;
/** Issue state */
state: 'open' | 'closed';
/** Comments on the issue */
comments: IssueComment[];
}

/**
* A comment on an issue
*/
export interface IssueComment {
/** Comment author */
author: string;
/** Comment body */
body: string;
/** ISO timestamp */
createdAt: string;
}

/**
* Relevant code found via semantic search
*/
export interface RelevantCodeContext {
/** File path */
file: string;
/** Component name (function, class, etc.) */
name: string;
/** Component type */
type: string;
/** Code snippet */
snippet: string;
/** Semantic similarity score (0-1) */
relevanceScore: number;
/** Why this code is relevant */
reason: string;
}

/**
* Patterns detected in the codebase
*/
export interface CodebasePatterns {
/** Test file naming pattern (e.g., "*.test.ts") */
testPattern?: string;
/** Test location pattern (e.g., "__tests__/") */
testLocation?: string;
/** Common import patterns */
importPatterns?: string[];
/** Detected naming conventions */
namingConventions?: string;
}

/**
* Related historical issue or PR
*/
export interface RelatedHistory {
/** Issue or PR */
type: 'issue' | 'pr';
/** Number */
number: number;
/** Title */
title: string;
/** Current state */
state: 'open' | 'closed' | 'merged';
/** Relevance score (0-1) */
relevanceScore: number;
/** Brief summary if available */
summary?: string;
}

/**
* Complete context package for LLM consumption
*/
export interface ContextPackage {
/** The GitHub issue with full details */
issue: IssueContext;
/** Relevant code from semantic search */
relevantCode: RelevantCodeContext[];
/** Detected codebase patterns */
codebasePatterns: CodebasePatterns;
/** Related closed issues/PRs */
relatedHistory: RelatedHistory[];
/** Metadata about the context assembly */
metadata: ContextMetadata;
}

/**
* Metadata about context assembly
*/
export interface ContextMetadata {
/** When the context was assembled */
generatedAt: string;
/** Approximate token count */
tokensUsed: number;
/** Whether code search was used */
codeSearchUsed: boolean;
/** Whether history search was used */
historySearchUsed: boolean;
/** Repository path */
repositoryPath: string;
}

/**
* Options for context assembly
*/
export interface ContextAssemblyOptions {
/** Include code snippets from search (default: true) */
includeCode?: boolean;
/** Include related issues/PRs (default: true) */
includeHistory?: boolean;
/** Include codebase patterns (default: true) */
includePatterns?: boolean;
/** Maximum code results (default: 10) */
maxCodeResults?: number;
/** Maximum history results (default: 5) */
maxHistoryResults?: number;
/** Token budget for output (default: 4000) */
tokenBudget?: number;
}
1 change: 1 addition & 0 deletions packages/subagents/src/planner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,6 @@ export class PlannerAgent implements Agent {
}
}

export type * from './context-types';
// Export types
export type * from './types';
11 changes: 11 additions & 0 deletions packages/subagents/src/planner/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
* Type definitions for GitHub issue analysis and task planning
*/

/**
* GitHub issue comment
*/
export interface GitHubComment {
author?: string;
body: string;
createdAt?: string;
}

/**
* GitHub issue data from gh CLI
*/
Expand All @@ -13,8 +22,10 @@ export interface GitHubIssue {
state: 'open' | 'closed';
labels: string[];
assignees: string[];
author?: string;
createdAt: string;
updatedAt: string;
comments?: GitHubComment[];
}

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/subagents/src/planner/utils/breakdown.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
/**
* Task Breakdown Utilities
* Pure functions for breaking issues into actionable tasks
*
* @deprecated These utilities use heuristics that duplicate LLM capabilities.
* Use assembleContext() to provide raw context and let the LLM do reasoning.
*/

import type { BreakdownOptions, GitHubIssue, PlanTask } from '../types';

/**
* Break down a GitHub issue into tasks
*
* @deprecated Use assembleContext() instead - let LLMs do task breakdown
*/
export function breakdownIssue(
issue: GitHubIssue,
Expand Down
Loading