@magic-ingredients/tiny-brain-local 0.16.1 → 0.18.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.
@@ -114,5 +114,14 @@ export declare class MCPServer {
114
114
  private handleListPrompts;
115
115
  private handleGetPrompt;
116
116
  private handleSetLogLevel;
117
+ /**
118
+ * Get the TTY by walking up the process tree
119
+ * Child processes don't inherit TTY directly, but we can find it from parent processes
120
+ */
121
+ private getTtyFromProcessTree;
122
+ /**
123
+ * Update sessions.json with the active persona for the current TTY
124
+ */
125
+ private updatePersonaSession;
117
126
  }
118
127
  //# sourceMappingURL=mcp-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/core/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH,OAAO,KAAK,EAA4B,QAAQ,EAAkC,MAAM,oCAAoC,CAAC;AAE7H,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAQ5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAAa;IAC3B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I,OAAO,CAAC,IAAI,CAAC;IAsBjC;;;;;;;OAOG;YACW,sBAAsB;IA+DpC;;OAEG;YACW,iBAAiB;IAW/B;;;OAGG;YACW,oBAAoB;IA6BlC;;OAEG;YACW,oBAAoB;IAkHlC;;;;;;OAMG;YACW,yBAAyB;IA+CvC;;OAEG;YACW,kBAAkB;IAsBhC;;OAEG;YACW,wBAAwB;IA8BtC;;OAEG;YACW,mBAAmB;IA8BjC;;OAEG;IACG,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAiBjB,eAAe;YAMf,cAAc;YA+Fd,iBAAiB;YAMjB,eAAe;YAqEf,iBAAiB;IAS/B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAkD7B"}
@@ -4,7 +4,8 @@
4
4
  * Simplified MCP server for local execution without deployment complexity
5
5
  */
6
6
  import * as path from 'path';
7
- import { existsSync, cpSync, readdirSync } from 'fs';
7
+ import { existsSync, cpSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
+ import { execSync } from 'child_process';
8
9
  import { Server as McpServer } from '@modelcontextprotocol/sdk/server/index.js';
9
10
  import { ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
10
11
  import { isDevelopment as checkIsDevelopment } from '@magic-ingredients/tiny-brain-core';
@@ -275,12 +276,17 @@ export class MCPServer {
275
276
  hasClientSecret: !!this.config.account?.clientSecret,
276
277
  configKeys: Object.keys(this.config)
277
278
  });
279
+ // Create credential service to check for credentials and LLM API key
280
+ const credentialService = new CredentialStorageService();
281
+ // Check LLM API key availability (for dashboard to disable/enable skill invocation buttons)
282
+ const hasLlmApiKey = await credentialService.hasLlmApiKey();
283
+ // Create getter function for the actual API key (for skill invocation)
284
+ const getLlmApiKey = () => credentialService.getLlmApiKey();
278
285
  // Check for remote auth credentials
279
286
  if (!this.config.account?.clientId || !this.config.account?.clientSecret) {
280
287
  this.logger.info('No remote credentials configured in MCP config, checking tiny-brain CLI config...');
281
288
  // Fallback to tiny-brain CLI config (like what CLI status command uses)
282
289
  try {
283
- const credentialService = new CredentialStorageService();
284
290
  const credentials = await credentialService.getCredentials();
285
291
  if (credentials && credentials.clientId && credentials.clientSecret) {
286
292
  this.logger.info('Found credentials in CLI config, using for authentication');
@@ -292,12 +298,28 @@ export class MCPServer {
292
298
  }
293
299
  else {
294
300
  this.logger.info('No credentials found in CLI config either, running in local-only mode');
301
+ // Still set libraryAuth with hasLlmApiKey for dashboard
302
+ this.baseContext.libraryAuth = {
303
+ clientId: undefined,
304
+ hasStoredSecret: false,
305
+ hasLlmApiKey,
306
+ token: undefined,
307
+ getLlmApiKey
308
+ };
295
309
  return;
296
310
  }
297
311
  }
298
312
  catch (error) {
299
313
  this.logger.warn('Error reading CLI config:', error);
300
314
  this.logger.info('Running in local-only mode');
315
+ // Still set libraryAuth with hasLlmApiKey for dashboard
316
+ this.baseContext.libraryAuth = {
317
+ clientId: undefined,
318
+ hasStoredSecret: false,
319
+ hasLlmApiKey,
320
+ token: undefined,
321
+ getLlmApiKey
322
+ };
301
323
  return;
302
324
  }
303
325
  }
@@ -321,7 +343,9 @@ export class MCPServer {
321
343
  this.baseContext.libraryAuth = {
322
344
  clientId: this.config.account?.clientId,
323
345
  hasStoredSecret: true,
324
- token: token.token
346
+ hasLlmApiKey,
347
+ token: token.token,
348
+ getLlmApiKey
325
349
  };
326
350
  }
327
351
  else {
@@ -329,18 +353,26 @@ export class MCPServer {
329
353
  this.logger.info('Continuing in local-only mode - authentication returned null');
330
354
  this.authToken = undefined;
331
355
  // Still populate libraryAuth with credentials (but no token)
332
- if (this.config.account?.clientId) {
333
- this.baseContext.libraryAuth = {
334
- clientId: this.config.account.clientId,
335
- hasStoredSecret: !!this.config.account.clientSecret,
336
- token: undefined
337
- };
338
- }
356
+ this.baseContext.libraryAuth = {
357
+ clientId: this.config.account?.clientId,
358
+ hasStoredSecret: !!this.config.account?.clientSecret,
359
+ hasLlmApiKey,
360
+ token: undefined,
361
+ getLlmApiKey
362
+ };
339
363
  }
340
364
  }
341
365
  catch (error) {
342
366
  this.logger.error('Unexpected error during remote authentication', error);
343
367
  // Continue in local mode - don't fail the entire initialization
368
+ // Still set libraryAuth with hasLlmApiKey for dashboard
369
+ this.baseContext.libraryAuth = {
370
+ clientId: this.config.account?.clientId,
371
+ hasStoredSecret: !!this.config.account?.clientSecret,
372
+ hasLlmApiKey,
373
+ token: undefined,
374
+ getLlmApiKey
375
+ };
344
376
  }
345
377
  }
346
378
  /**
@@ -530,6 +562,8 @@ export class MCPServer {
530
562
  const newPersonaId = persona?.id;
531
563
  this.activePersona = newPersonaId;
532
564
  this.logger.info(`[${this.instanceId}] Active persona updated to: ${newPersonaId || 'none'}, notifying ${this.personaChangeListeners.length} listeners`);
565
+ // Update session tracking for statusline
566
+ this.updatePersonaSession(newPersonaId || null);
533
567
  // Notify all registered listeners
534
568
  for (const listener of this.personaChangeListeners) {
535
569
  try {
@@ -623,6 +657,8 @@ export class MCPServer {
623
657
  const newPersonaId = persona?.id;
624
658
  this.activePersona = newPersonaId;
625
659
  this.logger.info(`[${this.instanceId}] Active persona updated to: ${newPersonaId || 'none'}, notifying ${this.personaChangeListeners.length} listeners`);
660
+ // Update session tracking for statusline
661
+ this.updatePersonaSession(newPersonaId || null);
626
662
  // Notify all registered listeners
627
663
  for (const listener of this.personaChangeListeners) {
628
664
  try {
@@ -667,4 +703,66 @@ export class MCPServer {
667
703
  this.logger.info(`Log level set to: ${level}`);
668
704
  return {};
669
705
  }
706
+ /**
707
+ * Get the TTY by walking up the process tree
708
+ * Child processes don't inherit TTY directly, but we can find it from parent processes
709
+ */
710
+ getTtyFromProcessTree() {
711
+ try {
712
+ let pid = process.pid;
713
+ for (let i = 0; i < 15; i++) {
714
+ const info = execSync(`ps -p ${pid} -o ppid=,tty=`, { encoding: 'utf-8' }).trim();
715
+ const [ppid, tty] = info.split(/\s+/);
716
+ if (tty && tty !== '??' && tty !== '-') {
717
+ return '/dev/' + tty;
718
+ }
719
+ pid = parseInt(ppid);
720
+ if (pid <= 1)
721
+ break;
722
+ }
723
+ return null;
724
+ }
725
+ catch {
726
+ return null;
727
+ }
728
+ }
729
+ /**
730
+ * Update sessions.json with the active persona for the current TTY
731
+ */
732
+ updatePersonaSession(personaId) {
733
+ const tty = this.getTtyFromProcessTree();
734
+ if (!tty) {
735
+ this.logger.debug('No TTY available for persona session tracking');
736
+ return;
737
+ }
738
+ try {
739
+ const basePath = process.cwd();
740
+ const sessionsPath = path.join(basePath, '.tiny-brain', 'sessions.json');
741
+ let sessions = {};
742
+ try {
743
+ const content = readFileSync(sessionsPath, 'utf-8');
744
+ sessions = JSON.parse(content);
745
+ }
746
+ catch {
747
+ // File doesn't exist or is invalid, start fresh
748
+ sessions = {};
749
+ }
750
+ // Update this TTY's entry, preserving PRD/Fix
751
+ const existingEntry = sessions[tty];
752
+ sessions[tty] = {
753
+ activePrdId: existingEntry?.activePrdId ?? null,
754
+ activeFixId: existingEntry?.activeFixId ?? null,
755
+ activePersona: personaId,
756
+ updatedAt: new Date().toISOString(),
757
+ };
758
+ // Ensure directory exists
759
+ mkdirSync(path.dirname(sessionsPath), { recursive: true });
760
+ // Write sessions file
761
+ writeFileSync(sessionsPath, JSON.stringify(sessions, null, 2), 'utf-8');
762
+ this.logger.debug(`Updated persona session: ${personaId} for TTY ${tty}`);
763
+ }
764
+ catch (err) {
765
+ this.logger.error('Failed to update persona session:', err);
766
+ }
767
+ }
670
768
  }
@@ -5,11 +5,36 @@
5
5
  * - Fetching full agent data from TBR
6
6
  * - Installing/updating agents via AgentService
7
7
  * - Removing deprecated agents via AgentService
8
- * - Updating repository context via RepoService
8
+ *
9
+ * Note: Repository context (tech stack) is now managed by TechContextService
10
+ * via .tiny-brain/analysis.json - CLAUDE.md is no longer modified.
9
11
  */
10
12
  import type { RequestContext } from '../types/request-context.js';
11
13
  import type { RepoAnalysis } from '@magic-ingredients/tiny-brain-core';
12
- import type { UserSelections } from './analyse-service.js';
14
+ /** Agent recommendation for installation */
15
+ export interface AgentRecommendation {
16
+ name: string;
17
+ version: string;
18
+ description: string;
19
+ }
20
+ /** Agent update recommendation */
21
+ export interface AgentUpdateRecommendation {
22
+ name: string;
23
+ from: string;
24
+ to: string;
25
+ description?: string;
26
+ }
27
+ /** Agent removal recommendation */
28
+ export interface AgentRemovalRecommendation {
29
+ name: string;
30
+ description?: string;
31
+ }
32
+ /** User selections for agent operations */
33
+ export interface UserSelections {
34
+ install: AgentRecommendation[];
35
+ update: AgentUpdateRecommendation[];
36
+ remove: AgentRemovalRecommendation[];
37
+ }
13
38
  export interface ExecutionResult {
14
39
  installed: string[];
15
40
  updated: string[];
@@ -26,7 +51,6 @@ export interface ExecutionResult {
26
51
  export declare class AgentManager {
27
52
  private context;
28
53
  private agentService;
29
- private repoService;
30
54
  private libraryClient;
31
55
  constructor(context: RequestContext);
32
56
  /**
@@ -37,9 +61,5 @@ export declare class AgentManager {
37
61
  * Fetch full agent data from TBR
38
62
  */
39
63
  private fetchAgentData;
40
- /**
41
- * Update repository context with current agent state
42
- */
43
- private updateRepositoryContext;
44
64
  }
45
65
  //# sourceMappingURL=agent-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-manager.d.ts","sourceRoot":"","sources":["../../src/services/agent-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAKlE,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,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AAE,mBAAmB,EAAE,CAAC;IAC/B,MAAM,EAAE,yBAAyB,EAAE,CAAC;IACpC,MAAM,EAAE,0BAA0B,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAgB;gBAEjB,OAAO,EAAE,cAAc;IAK3C;;OAEG;IACG,sBAAsB,CAC1B,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,eAAe,CAAC;IAoE3B;;OAEG;YACW,cAAc;CAyD7B"}
@@ -5,24 +5,22 @@
5
5
  * - Fetching full agent data from TBR
6
6
  * - Installing/updating agents via AgentService
7
7
  * - Removing deprecated agents via AgentService
8
- * - Updating repository context via RepoService
8
+ *
9
+ * Note: Repository context (tech stack) is now managed by TechContextService
10
+ * via .tiny-brain/analysis.json - CLAUDE.md is no longer modified.
9
11
  */
10
12
  import { AgentService } from './agent-service.js';
11
- import { RepoService } from './repo-service.js';
12
13
  import { LibraryClient } from '@magic-ingredients/tiny-brain-core';
13
- import { getPackageVersion } from '../utils/package-version.js';
14
14
  /**
15
15
  * Orchestrates agent recommendation execution
16
16
  */
17
17
  export class AgentManager {
18
18
  context;
19
19
  agentService;
20
- repoService;
21
20
  libraryClient;
22
21
  constructor(context) {
23
22
  this.context = context;
24
23
  this.agentService = new AgentService(context);
25
- this.repoService = new RepoService(context);
26
24
  this.libraryClient = new LibraryClient();
27
25
  }
28
26
  /**
@@ -69,9 +67,8 @@ export class AgentManager {
69
67
  });
70
68
  });
71
69
  }
72
- // Step 4: Update repository context with current state
73
- const installedAgents = await this.agentService.getInstalledAgents();
74
- await this.updateRepositoryContext(repoAnalysis, installedAgents);
70
+ // Note: Repository context is now managed by TechContextService
71
+ // via .tiny-brain/analysis.json - no CLAUDE.md update needed
75
72
  }
76
73
  catch (error) {
77
74
  const message = error instanceof Error ? error.message : 'Unknown error';
@@ -128,29 +125,4 @@ export class AgentManager {
128
125
  }
129
126
  return agentsToProcess;
130
127
  }
131
- /**
132
- * Update repository context with current agent state
133
- */
134
- async updateRepositoryContext(repoAnalysis, installedAgents) {
135
- try {
136
- // Convert to AgentInfo format expected by RepoService
137
- const agentInfos = installedAgents.map(agent => ({
138
- name: agent.name,
139
- description: `Agent ${agent.name}`,
140
- details: {
141
- version: agent.version,
142
- description: `Agent ${agent.name}`
143
- }
144
- }));
145
- // Get current package version to include in context block
146
- const currentVersion = getPackageVersion();
147
- // Update context file via RepoService with version
148
- await this.repoService.writeRepoBlockToContextFile(repoAnalysis, agentInfos, 'CLAUDE.md', currentVersion);
149
- this.context.logger.info('Updated repository context with installed agents');
150
- }
151
- catch (error) {
152
- // Log but don't fail the operation
153
- this.context.logger.warn('Failed to update repository context:', error);
154
- }
155
- }
156
128
  }
@@ -10,62 +10,25 @@ export interface AnalyseOptions {
10
10
  dryRun?: boolean;
11
11
  contextPath?: string;
12
12
  }
13
- export interface AgentRecommendation {
14
- name: string;
15
- version: string;
16
- description: string;
17
- }
18
- export interface AgentUpdateRecommendation {
19
- name: string;
20
- from: string;
21
- to: string;
22
- description?: string;
23
- }
24
- export interface AgentRemovalRecommendation {
25
- name: string;
26
- description?: string;
27
- }
28
- export interface SkillInfo {
29
- name: string;
30
- version: string;
31
- }
32
- export interface AgentRecommendations {
33
- install: AgentRecommendation[];
34
- update: AgentUpdateRecommendation[];
35
- remove: AgentRemovalRecommendation[];
36
- }
37
13
  export interface AnalyseResult {
38
14
  analysis: RepoAnalysis;
39
15
  isFirstAnalysis: boolean;
40
16
  dryRun?: boolean;
41
17
  contextPath: string;
42
- currentAgents?: string[];
43
- installedSkills?: SkillInfo[];
44
- recommendations?: AgentRecommendations | null;
18
+ enableAgenticCoding?: boolean;
45
19
  prdInitialized?: boolean;
46
20
  adrInitialized?: boolean;
47
21
  qualityInitialized?: boolean;
22
+ fixesInitialized?: boolean;
48
23
  gitHooksInstalled?: boolean;
49
24
  contextBlockVersion?: string;
50
25
  contextBlockUpdated?: boolean;
51
26
  changes?: {
52
27
  techStackAdded: string[];
53
28
  techStackRemoved: string[];
54
- agentsSuggestedNew: string[];
55
- agentsSuggestedRemove: string[];
56
29
  };
57
30
  skillPermissionsAdded?: string[];
58
- }
59
- export interface AppliedRecommendationsSummary {
60
- installed: string[];
61
- updated: string[];
62
- removed: string[];
63
- errors: string[];
64
- }
65
- export interface UserSelections {
66
- install: AgentRecommendation[];
67
- update: AgentUpdateRecommendation[];
68
- remove: AgentRemovalRecommendation[];
31
+ writtenTechContexts?: string[];
69
32
  }
70
33
  /**
71
34
  * Service for managing repository analysis
@@ -76,27 +39,12 @@ export declare class AnalyseService {
76
39
  private repoService;
77
40
  private libraryClient;
78
41
  private configService;
42
+ private techContextService;
79
43
  constructor(context: RequestContext);
80
44
  /**
81
45
  * Perform repository analysis with unified behavior for initialized/uninitialized repos
82
46
  */
83
47
  performAnalysis(options?: AnalyseOptions): Promise<AnalyseResult>;
84
- /**
85
- * Extract version from SKILL.md frontmatter
86
- * @param skillPath - Path to SKILL.md file
87
- * @returns Version string or null if not found
88
- */
89
- private extractSkillVersion;
90
- /**
91
- * Install a single skill with its templates
92
- * @param skillName - Name of the skill (e.g., 'plan', 'feature', 'fix')
93
- * @param templates - Array of template files to copy
94
- * @param skillsDir - Target skills directory
95
- * @param srcSkillsDir - Source skills directory
96
- * @param srcTemplatesDir - Source templates directory
97
- * @returns true if skill was installed/updated
98
- */
99
- private installSkill;
100
48
  /**
101
49
  * Register repository in dashboard for visibility
102
50
  * Called after successful analysis regardless of invocation method
@@ -107,20 +55,25 @@ export declare class AnalyseService {
107
55
  */
108
56
  private countPrdsInRepo;
109
57
  /**
110
- * Initialize SDD skills (plan, feature, fix) in .claude/skills/
111
- * @returns true if any skills were installed or updated
58
+ * Initialize PRD directory structure for SDD workflow
59
+ * @returns true if directory was created
112
60
  */
113
- private initializeSDDSkills;
61
+ private initializePrdDirectory;
114
62
  /**
115
- * Initialize ADR skill in .claude/skills/
116
- * @returns true if skill was installed or updated
63
+ * Initialize ADR directory structure
64
+ * @returns true if directory was created
117
65
  */
118
- private initializeADRSkill;
66
+ private initializeAdrDirectory;
119
67
  /**
120
- * Initialize Quality skill in .claude/skills/
121
- * @returns true if skill was installed or updated
68
+ * Initialize Quality directory structure
69
+ * @returns true if directory was created
122
70
  */
123
- private initializeQualitySkill;
71
+ private initializeQualityDirectory;
72
+ /**
73
+ * Initialize fixes tracking directory
74
+ * @returns true if directory was created
75
+ */
76
+ private initializeFixesDirectory;
124
77
  /**
125
78
  * Initialize git hooks for TDD workflow
126
79
  * Copies hook templates to .git/hooks/ if not already present
@@ -134,39 +87,19 @@ export declare class AnalyseService {
134
87
  */
135
88
  private injectSkillPermissions;
136
89
  /**
137
- * Get installed skills with their versions from .claude/skills/
138
- * @returns Array of installed skills with name and version
90
+ * Fetch tech contexts from TBR and write them to .tiny-brain/tech/
91
+ * Only called when enableAgenticCoding=false
139
92
  */
140
- private getInstalledSkills;
141
- /**
142
- * Fetch agent recommendations from TBR based on repo analysis and current agents
143
- */
144
- private fetchRecommendationsFromTBR;
93
+ private fetchAndWriteTechContexts;
145
94
  /**
146
95
  * Format analysis output for display
147
96
  */
148
97
  formatAnalysisOutput(result: AnalyseResult): string;
149
- /**
150
- * Format recommendations section for output
151
- */
152
- private formatRecommendations;
153
- /**
154
- * Format skills help text explaining model-invoked behavior
155
- */
156
- private formatSkillsHelpText;
157
98
  /**
158
99
  * Compare two tech stacks and return differences
159
100
  * Handles null previous analysis (first run)
160
101
  */
161
102
  compareTechStacks(previousAnalysis: RepoAnalysis | null, currentAnalysis: RepoAnalysis): TechStackDiff;
162
- /**
163
- * Prompt user for selection of recommendations to apply
164
- * Always requires user confirmation - defaults to 'all' but user must confirm
165
- */
166
- promptForSelection(recommendations: AgentRecommendations, promptFn?: (question: string, options?: {
167
- default?: string;
168
- choices?: string[];
169
- }) => Promise<string>): Promise<UserSelections>;
170
103
  /**
171
104
  * Check if tiny-brain block needs updating based on version
172
105
  * @param existingContent - Content containing existing tiny-brain block
@@ -1 +1 @@
1
- {"version":3,"file":"analyse-service.d.ts","sourceRoot":"","sources":["../../src/services/analyse-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,aAAa,EAInB,MAAM,oCAAoC,CAAC;AAW5C,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,MAAM,EAAE,yBAAyB,EAAE,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