Skip to content

COPSPA-489#15

Draft
Bullitt300 wants to merge 29 commits intomainfrom
copspa-489
Draft

COPSPA-489#15
Bullitt300 wants to merge 29 commits intomainfrom
copspa-489

Conversation

@Bullitt300
Copy link
Copy Markdown

No description provided.

@Bullitt300 Bullitt300 marked this pull request as ready for review April 21, 2026 12:31
@Bullitt300 Bullitt300 marked this pull request as draft April 21, 2026 12:31
@Bullitt300 Bullitt300 changed the base branch from develop to main April 21, 2026 12:36
- Entfernen: TitleGenerator, DescriptionGenerator, CsvWriter, WebhookSender, ProviderAdapter, MessageExtractor
- Hinzufügen: SessionDataMapper für Konvertierung zu Lib-Interface
- Hinzufügen: OpenCodeSessionManager in Lib (generisch, wiederverwendbar)
- Refactor: EventHook nutzt TimeTrackingFacade mit Lazy Loading (Marketplace-Pattern)
- Refactor: SessionManager wird zu Wrapper um Lib's OpenCodeSessionManager
- Result: ~870 Zeilen Duplikation eliminiert, Single Source of Truth

Implementiert:
- Workspace Dependency: @techdivision/lib-ts-time-tracking
- Inline ConversationContextProvider mit SDK Integration
- Graceful Degradation für Fehlerbehandlung
- Activity-Summary Fallback wenn LLM fehlschlägt
- Unit Tests für SessionDataMapper und SessionManager
- Integration Tests für EventHook mit TimeTrackingFacade

Fixes COPSPA-489
Use GitHub repository directly with prepare script for automatic build.
Commit: 3ee597d (chore: Use prepare script instead of postinstall)
Document the GitHub dependency and provide troubleshooting steps
for manual build if needed.
For development and testing in .opencode directories, use local file path
instead of GitHub URL to avoid network issues and ensure consistent builds.
- Delete CsvFormatter.ts (84 lines): Functionality now in lib-ts-time-tracking
- Delete WriterService.ts (54 lines): Replaced by lib's WriteResultInterface
- Delete TitleGenerationConfig.ts (96 lines): Title generation now in lib
- Remove title_generation field from TimeTrackingConfig.ts
- Update EventHook.ts to use lib's WriteResultInterface
- Remove unused writers parameter from createEventHook()
- Update track-time.ts tool to use lib's WriteResultInterface
- Update CsvEntryData.ts comment to remove WriterService reference

Total cleanup: 234 lines removed
TypeScript compilation: ✅ No errors
…tion

- Add SessionSummaryConfigInterface import to TimeTrackingConfig.ts
- Add 'summary' field (new, preferred) to TimeTrackingJsonConfig
- Keep 'title_generation' field (deprecated, for backward compatibility)
- Create ConfigMigration.ts utility with resolveSummaryConfig()
- Update EventHook.ts to use resolveSummaryConfig() for config migration
- Priority: summary > title_generation > undefined
- Both old and new configs work seamlessly

Migration strategy:
- Old configs with 'title_generation' continue to work
- New configs can use 'summary' field
- If both present, 'summary' takes precedence
- No breaking changes for existing users

TypeScript compilation: ✅ No errors
- Add .npmrc configuration for GitHub Packages registry
- Update package.json: file:../lib-ts-time-tracking → ^4.2.0
- Add .npmrc.example for developer reference
- Update .gitignore to exclude .npmrc (but keep .npmrc.example)
- Update GitHub Actions workflow to install dependencies with GitHub token
- Add scope: @techdivision to setup-node action

This enables:
- ✅ Production-ready dependency management
- ✅ CI/CD compatibility
- ✅ Multi-developer support
- ✅ Automatic updates when lib is published

Developers need to:
1. Generate GitHub token with read:packages scope
2. Configure npm with: npm login --scope=@techdivision --registry=https://npm.pkg.github.com
3. Run: npm install

TypeScript compilation: ✅ No errors
…ption

Problem:
- CSV entries showed 'Ticket unbekannt:' in description even though issue_key was correct
- Root cause: resolved ticket was not passed to SessionDataMapper
- LLM couldn't see the ticket and generated 'Ticket unbekannt:' when ticket wasn't in conversation

Solution:
- Pass resolved.ticket from TicketResolver to SessionDataMapper.build()
- Update SessionDataMapper to accept ticket parameter
- Use config.ticket as priority over session.ticket

Impact:
- CSV descriptions now always include correct ticket key
- 'Ticket unbekannt:' only appears if ticket is truly unknown
- LLM has explicit ticket info for summary generation

Example:
Before: 'Ticket unbekannt: Überprüfung des Installationsstatus...'
After:  'COPSPA-489: Überprüfung des Installationsstatus...'

TypeScript compilation: ✅ No errors
1. ConfigMigration.ts: Enhanced resolveSummaryConfig()
   - Add enabled-check: return undefined if enabled: false
   - Add validation: require model and api_url for LLM
   - Add logging: warn if config incomplete
   - Prevents invalid LLM calls with incomplete config

2. EventHook.ts: Use pricing from opencode-project.json
   - Read pricing from config instead of hardcoding
   - Keep defaults as fallback if not configured
   - Allows users to customize pricing per environment

3. EventHook.ts: Add null-checks for totalTokens
   - Use ?? 0 for input, output, reasoning fields
   - Prevents NaN in toast message if fields missing
   - Handles Claude 3.5 reasoning token field gracefully

4. Remove deprecated tools/track-time.ts
   - Tool was deprecated and had dead code
   - CsvEntryData built but never used
   - WriteResultInterface only for error message
   - No equivalent in lib-ts-time-tracking
   - Users should use automatic time tracking plugin instead

Impact:
- Summary generation now validates config properly
- Pricing can be customized per environment
- Toast messages always show valid token counts
- Cleaner codebase without deprecated tool

TypeScript compilation: ✅ No errors
Updated to use the local lib-ts-time-tracking which includes the fix for
returning actual summary generator availability status instead of hardcoded false.

This resolves the 'title generation NOT available' toast message issue.
Add EnvResolver utility to resolve {env:VAR_NAME} placeholders in config values.
This ensures that environment variables like TT_AGENT_API_KEY are properly
resolved before being passed to the TimeTrackingFacade.

Changes:
- Create EnvResolver.ts with resolveEnvVar() and resolveEnvVarsInObject()
- Update ConfigLoader to resolve env vars in loaded config
- Recursively resolves nested objects and arrays

This fixes the issue where api_key was still {env:TT_AGENT_API_KEY} instead
of the actual API key value, causing LLM summary generation to fail.
Synchronize local ConfigMigration.ts with node_modules version to ensure
consistent behavior. The simpler ?? (nullish coalescing) operator is more
reliable than hasOwnProperty checks.

This ensures 'summary' field is properly resolved just like 'title_generation'.
Add console logs to show:
- Which config keys are present
- Whether 'summary' field is found
- Whether 'title_generation' field is found
- Whether summaryConfig was resolved

This helps verify that 'summary' field is being properly resolved.
…o lib

Add EnvResolver utility to resolve {env:VAR_NAME} placeholders in config values.
This ensures that environment variables like TT_AGENT_API_KEY are properly
resolved before being passed to the TimeTrackingFacade.

Changes:
- Create EnvResolver.ts with resolveEnvVar() and resolveEnvVarsInObject()
- Update EventHook to resolve env vars in summaryConfig after migration
- Add debug logging to show before/after env resolution

This fixes the issue where api_key was still {env:TT_AGENT_API_KEY} instead
of the actual API key value, causing LLM summary generation to fail.
Remove the plugin's resolveSummaryConfig() call and instead pass both
'summary' and 'title_generation' fields to the lib. The lib's ConfigMapper
will handle the migration and normalization.

Changes:
- Remove resolveSummaryConfig() call from EventHook
- Pass both config.summary and config.title_generation to lib
- Let lib handle the mapping via ConfigMapper

This ensures the lib's mapping logic is used instead of duplicating
the migration logic in the plugin.
Add EnvResolver utility to resolve {env:VAR_NAME} placeholders in config values.
This ensures that environment variables like TT_AGENT_API_KEY are properly
resolved before being passed to the TimeTrackingFacade.

Changes:
- Create EnvResolver.ts with resolveEnvVar() and resolveEnvVarsInObject()
- EventHook: Resolve env vars in summary and title_generation config
- Recursively resolves nested objects and arrays

This fixes the issue where api_key was still {env:TT_AGENT_API_KEY} instead
of the actual API key value, causing LLM summary generation to fail.
Add console logs to show:
- libConfig.summary and libConfig.title_generation (after env resolution)
- trackResult.summary (what the lib returns)

This helps debug the flow and identify where the issue is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant