@magic-ingredients/tiny-brain-local 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,222 +1,78 @@
1
1
  /**
2
2
  * Repository Context Service
3
3
  *
4
- * Manages the tiny-brain section of the context file (CLAUDE.md, etc.)
5
- * Responsible for formatting and storing repository analysis and agent usage.
4
+ * Service for repository context operations including:
5
+ * - Writing workflow sections to CLAUDE.md (commit format, TDD, progress tracking)
6
+ * - Tech context now managed by TechContextService (.tiny-brain/analysis.json, .tiny-brain/tech/*.md)
6
7
  */
7
- import type { RepoAnalysis } from '@magic-ingredients/tiny-brain-core';
8
- import { type TechStackDiff, ConfigService } from '@magic-ingredients/tiny-brain-core';
9
8
  import type { RequestContext } from '../types/request-context.js';
10
- export interface AgentInfo {
11
- name: string;
12
- description: string;
13
- version?: string;
14
- usage?: string;
15
- }
16
- export interface RepoBlock {
17
- rawAnalysis: RepoAnalysis;
18
- analysis: string;
19
- documentation: string | null;
20
- agentUsage: string;
21
- }
22
- export interface InstalledAgent {
23
- name: string;
24
- version: string;
25
- lastUpdated: string;
26
- }
27
- export interface TBStatus extends RepoAnalysis {
28
- installedAgents?: InstalledAgent[];
29
- lastUpdated?: string;
30
- }
31
- export interface PhaseStructure {
32
- phases: {
33
- [phaseKey: string]: {
34
- agents: string[];
35
- handoffs: string[];
36
- };
37
- };
38
- crossPhaseHandoffs: Array<{
39
- from: string;
40
- to: string;
41
- description: string;
42
- }>;
43
- prerequisites: {
44
- [agentName: string]: string[] | string;
45
- };
9
+ export interface WriteWorkflowSectionsOptions {
10
+ contextPath?: string;
46
11
  }
47
12
  /**
48
- * Service for managing repository context in the context file
49
- * Handles the tiny-brain section with analysis and agent usage
13
+ * Service for repository context operations
14
+ * Tech context is now managed by TechContextService
15
+ * Workflow sections are written to CLAUDE.md based on config flags
50
16
  */
51
17
  export declare class RepoService {
52
18
  private context;
53
19
  private static readonly REPO_BLOCK_START;
54
20
  private static readonly REPO_BLOCK_END;
55
- private static readonly ANALYSIS_MARKER_PREFIX;
56
- private static readonly ANALYSIS_MARKER_SUFFIX;
57
- private static readonly SUBAGENT_PROTOCOL_HEADER;
58
- private static readonly AGENT_USAGE_HEADER;
59
- private static readonly REPO_CONTEXT_HEADER;
60
- private static readonly USAGE_TEMPLATE_HEADER;
61
- private static readonly EXAMPLE_HEADER;
62
- private static readonly ANALYSIS_IGNORE_PREFIX;
63
- private static readonly ANALYSIS_IGNORE_SUFFIX;
64
- private static readonly STATUS_IGNORE_PREFIX;
65
- private static readonly STATUS_IGNORE_SUFFIX;
66
21
  private configService;
67
- constructor(context: RequestContext, configService?: ConfigService);
22
+ constructor(context: RequestContext);
68
23
  /**
69
- * Write the repository block to context file with phase-based agent structure
24
+ * Get repository root using the repo-utils helper
25
+ * This is used as fallback when context.repositoryRoot is not set
70
26
  */
71
- writeRepoBlockWithPhases(analysis: RepoAnalysis, agentResponse: any, contextFilePath?: string, version?: string): Promise<string>;
27
+ private getRepositoryRoot;
72
28
  /**
73
- * Write the repository block to context file and return the formatted block (legacy compact format)
74
- */
75
- writeRepoBlockToContextFile(analysis: RepoAnalysis, agents: AgentInfo[], contextFilePath?: string, version?: string): Promise<string>;
76
- /**
77
- * Read the repository block from context file
29
+ * Read the repository block from context file (for legacy migration)
78
30
  */
79
31
  readRepoBlockFromContextFile(contextFilePath?: string): Promise<string | null>;
80
- /**
81
- * Format the repository block with phase-based agent structure
82
- */
83
- private formatRepoBlockWithPhases;
84
- /**
85
- * Format the complete repository block with simplified structure
86
- */
87
- private formatRepoBlock;
88
- /**
89
- * Parse the repository block from context file into structured data
90
- */
91
- parseRepoBlock(contextFilePath?: string): Promise<RepoBlock | null>;
92
- /**
93
- * Format agents with phase-based structure
94
- */
95
- formatAgentsWithPhases(agentResponse: any): string;
96
- /**
97
- * Format agents as a simple table with tech-stack specific "Use for" descriptions
98
- */
99
- private formatAgentTable;
100
- /**
101
- * Generate generic "Use for" description based on agent name
102
- * This is a fallback when TBR doesn't provide contextual usage
103
- */
104
- private generateAgentUseCase;
105
- /**
106
- * Format repository context as clean YAML
107
- */
108
- private formatRepositoryContextYaml;
109
- /**
110
- * Get the analysis version from package.json
111
- */
112
- private getAnalysisVersion;
113
32
  /**
114
33
  * Extract version from tiny-brain block frontmatter
115
34
  * @param content - The content containing the tiny-brain block
116
35
  * @returns Version string or null if not found/invalid
117
36
  */
118
37
  extractTinyBrainVersion(content: string): string | null;
119
- /**
120
- * Format documentation templates section for PRDs and ADRs
121
- * Only includes sections for directories that exist
122
- */
123
- private formatDocumentationTemplatesSection;
124
- /**
125
- * Extract TB_ANALYSIS from content with new IGNORE format
126
- */
127
- extractTBAnalysis(content: string): RepoAnalysis | null;
128
- /**
129
- * Extract TB-STATUS from content with backwards compatibility for TB_ANALYSIS-IGNORE
130
- */
131
- extractTBStatus(content: string): TBStatus | null;
132
- /**
133
- * Generate TB-STATUS-IGNORE format string with current timestamp
134
- */
135
- updateTBStatus(analysis: RepoAnalysis, installedAgents?: InstalledAgent[]): string;
136
- /**
137
- * Check if repository is initialized (has TB-STATUS-IGNORE or TB_ANALYSIS-IGNORE)
138
- */
139
- isRepoInitialized(content: string): boolean;
140
38
  /**
141
39
  * Check if we're in a repository context
142
40
  */
143
41
  isInRepository(): boolean;
144
42
  /**
145
- * Check if repository is initialized (has TB block in context file)
43
+ * Check if repository is initialized (has .tiny-brain/analysis.json)
44
+ * This is the new initialization check - no longer checks CLAUDE.md
146
45
  */
147
46
  isRepositoryInitialized(): Promise<boolean>;
148
47
  /**
149
- * Compare two tech stacks and return differences
150
- */
151
- compareTechStack(previousAnalysis: RepoAnalysis | TBStatus, currentAnalysis: RepoAnalysis): TechStackDiff;
152
- /**
153
- * Migrate legacy TB_ANALYSIS-IGNORE format to new TB-STATUS-IGNORE format
154
- */
155
- migrateToNewFormat(existingContent: string, newAnalysis: RepoAnalysis): string;
156
- /**
157
- * Update agent usage section in CLAUDE.md with phase-based structure
158
- */
159
- updateAgentUsageSection(installedAgents: InstalledAgent[], phaseStructure: PhaseStructure, contextFilePath?: string): Promise<void>;
160
- /**
161
- * Generate phase structure from installed agents
162
- */
163
- generatePhaseStructure(installedAgents: InstalledAgent[]): PhaseStructure;
164
- /**
165
- * Create or update TB-STATUS-IGNORE with analysis and installed agents
166
- */
167
- createOrUpdateTBStatus(analysis: RepoAnalysis, installedAgents: InstalledAgent[], contextFilePath?: string): Promise<void>;
168
- /**
169
- * Migrate legacy TB_ANALYSIS-IGNORE to TB-STATUS-IGNORE format
170
- */
171
- migrateTBAnalysisToTBStatus(existingContent: string, installedAgents: InstalledAgent[], contextFilePath?: string): Promise<void>;
172
- /**
173
- * Get TB status from CLAUDE.md with fallback to legacy format
174
- */
175
- getTBStatus(contextFilePath?: string): Promise<TBStatus | null>;
176
- /**
177
- * Update repository context YAML section with current analysis
178
- */
179
- updateRepositoryContext(analysis: RepoAnalysis, contextFilePath?: string): Promise<void>;
180
- /**
181
- * Format phase-based agent usage content
182
- */
183
- private formatPhaseBasedAgentUsage;
184
- /**
185
- * Update tiny-brain section in content with new agent usage
186
- */
187
- private updateTinyBrainSection;
188
- /**
189
- * Build complete tiny-brain section
190
- */
191
- private buildTinyBrainSection;
192
- /**
193
- * Add TB status to content (create tiny-brain section if needed)
194
- */
195
- private addStatusToContent;
196
- /**
197
- * Generate handoffs for agents within a phase
48
+ * Get the analysis version from package.json
198
49
  */
199
- private generatePhaseHandoffs;
50
+ getAnalysisVersion(): string;
200
51
  /**
201
- * Generate cross-phase handoffs based on available phases
52
+ * Write workflow sections to CLAUDE.md based on config flags
53
+ *
54
+ * Writes the following sections when their respective flags are enabled:
55
+ * - Commit Message Format (when SDD enabled)
56
+ * - TDD Workflow (when TDD enabled)
57
+ * - Progress Tracking Auto-Commit Configuration (when SDD enabled)
58
+ * - Operational Tracking Directory (when SDD enabled)
202
59
  */
203
- private generateCrossPhaseHandoffs;
60
+ writeWorkflowSections(options?: WriteWorkflowSectionsOptions): Promise<void>;
204
61
  /**
205
- * Generate prerequisites for agents
62
+ * Format the Commit Message Format section
206
63
  */
207
- private generatePrerequisites;
64
+ private formatCommitMessageSection;
208
65
  /**
209
- * Get description for an agent (placeholder - could be enhanced)
66
+ * Format the TDD Workflow section
210
67
  */
211
- private getAgentDescription;
68
+ private formatTDDWorkflowSection;
212
69
  /**
213
- * Format workflow sections for CLAUDE.md
214
- * Each section is independent - enabled features appear regardless of other settings
70
+ * Format the Progress Tracking Auto-Commit Configuration section
215
71
  */
216
- private formatPRDWorkflowSection;
72
+ private formatProgressTrackingSection;
217
73
  /**
218
- * Format ADR section (currently empty as ADR info is part of PRD workflow)
74
+ * Format the Operational Tracking Directory section
219
75
  */
220
- private formatADRSection;
76
+ private formatOperationalTrackingSection;
221
77
  }
222
78
  //# sourceMappingURL=repo-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repo-service.d.ts","sourceRoot":"","sources":["../../src/services/repo-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAA0B,KAAK,aAAa,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,YAAY,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,M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