testchimp-runner-core 0.0.26 β†’ 0.0.29

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.
Files changed (43) hide show
  1. package/CREDIT_CALLBACK_ARCHITECTURE.md +253 -0
  2. package/INTEGRATION_COMPLETE.md +322 -0
  3. package/RELEASE_0.0.26.md +165 -0
  4. package/RELEASE_0.0.27.md +236 -0
  5. package/RELEASE_0.0.28.md +286 -0
  6. package/dist/credit-usage-service.d.ts +28 -2
  7. package/dist/credit-usage-service.d.ts.map +1 -1
  8. package/dist/credit-usage-service.js +60 -24
  9. package/dist/credit-usage-service.js.map +1 -1
  10. package/dist/execution-service.d.ts.map +1 -1
  11. package/dist/execution-service.js +134 -10
  12. package/dist/execution-service.js.map +1 -1
  13. package/dist/index.d.ts +13 -6
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +19 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/progress-reporter.d.ts +30 -0
  18. package/dist/progress-reporter.d.ts.map +1 -1
  19. package/dist/prompts.d.ts.map +1 -1
  20. package/dist/prompts.js +5 -4
  21. package/dist/prompts.js.map +1 -1
  22. package/dist/scenario-service.d.ts +1 -1
  23. package/dist/scenario-service.d.ts.map +1 -1
  24. package/dist/scenario-service.js +7 -4
  25. package/dist/scenario-service.js.map +1 -1
  26. package/dist/scenario-worker-class.d.ts +2 -10
  27. package/dist/scenario-worker-class.d.ts.map +1 -1
  28. package/dist/scenario-worker-class.js +88 -26
  29. package/dist/scenario-worker-class.js.map +1 -1
  30. package/dist/types.d.ts +9 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/types.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/credit-usage-service.ts +81 -26
  35. package/src/execution-service.ts +158 -11
  36. package/src/index.ts +42 -10
  37. package/src/progress-reporter.ts +35 -0
  38. package/src/prompts.ts +5 -4
  39. package/src/scenario-service.ts +16 -4
  40. package/src/scenario-worker-class.ts +102 -28
  41. package/src/types.ts +16 -0
  42. package/testchimp-runner-core-0.0.27.tgz +0 -0
  43. package/testchimp-runner-core-0.0.26.tgz +0 -0
@@ -0,0 +1,165 @@
1
+ # Release 0.0.26 - Fix Orchestrator Reasoning Logs
2
+
3
+ ## Summary
4
+ Fixed bug where orchestrator reasoning logs (πŸ’­ REASONING, 🧠 SELF-REFLECTION, etc.) were not appearing in VS Code output channel due to outputChannel being lost during service recreation.
5
+
6
+ ## Bug Fixed
7
+
8
+ ### The Problem
9
+ Orchestrator reasoning logs were only showing in `console.log()` (debug console), not in:
10
+ - ❌ VS Code "TestChimp Agent" output channel
11
+ - ❌ Log files
12
+
13
+ Users couldn't see what the agent was thinking!
14
+
15
+ **Root Cause:**
16
+ When `setAuthConfig()` was called, it recreated `ScenarioService`, which lost the `outputChannel` reference. Workers were then created without access to the output channel, causing all orchestrator logs to fall back to `console.log()` only.
17
+
18
+ **Call sequence that caused the bug:**
19
+ 1. `embeddedService.initialize()` β†’ calls `service.setOutputChannel()` βœ…
20
+ 2. Then calls `service.setAuthConfig()` which:
21
+ - Recreates `ScenarioService` ❌ outputChannel lost!
22
+ - Calls `scenarioService.initialize()` β†’ creates workers without outputChannel
23
+ 3. Orchestrator logs β†’ `console.log()` only (not visible in output channel)
24
+
25
+ ## Solution
26
+
27
+ ### Changes in runner-core
28
+
29
+ **TestChimpService (`index.ts`):**
30
+
31
+ 1. **Store outputChannel** in private field:
32
+ ```typescript
33
+ private outputChannel?: any; // Store outputChannel to preserve it across service recreations
34
+ ```
35
+
36
+ 2. **Preserve it in setOutputChannel()**:
37
+ ```typescript
38
+ setOutputChannel(outputChannel: any): void {
39
+ this.outputChannel = outputChannel; // Store for future use
40
+ if (typeof this.scenarioService?.setOutputChannel === 'function') {
41
+ this.scenarioService.setOutputChannel(outputChannel);
42
+ }
43
+ }
44
+ ```
45
+
46
+ 3. **Reapply after service recreation** (in both `setAuthConfig()` and `setBackendUrl()`):
47
+ ```typescript
48
+ // Reapply outputChannel if we have one (critical for orchestrator logs)
49
+ if (this.outputChannel) {
50
+ this.scenarioService.setOutputChannel(this.outputChannel);
51
+ }
52
+ ```
53
+
54
+ ### Result
55
+
56
+ Now orchestrator logs flow correctly:
57
+ ```
58
+ Orchestrator (runner-core)
59
+ ↓ this.logger?.()
60
+ ScenarioWorker.log()
61
+ ↓ outputChannel.appendLine()
62
+ VS Code Output Channel βœ…
63
+ ↓ dual-write
64
+ Log File βœ…
65
+ ```
66
+
67
+ ## What Now Appears in Output Channel
68
+
69
+ **All Environments:**
70
+ - βœ… `πŸ’­ REASONING: [agent's reasoning]`
71
+ - βœ… `🧠 SELF-REFLECTION: [guidance for next iteration]`
72
+ - βœ… `πŸ’‘ Why: [command reasoning]`
73
+ - βœ… `πŸ”§ TOOLS: [tool usage]`
74
+ - βœ… `🚧 BLOCKER: [blocker detection]`
75
+ - βœ… `πŸ“ COMMANDS: [commands to execute]`
76
+ - βœ… `βœ“ [success messages]`
77
+ - βœ… `βœ— [failure messages]`
78
+
79
+ **Development Only:**
80
+ - βœ… `πŸ’° Reporting token usage: X + Y`
81
+
82
+ **Staging/Production (Suppressed from channel, but in file):**
83
+ - ❌ Token usage logs (still tracked, just not displayed)
84
+
85
+ ## Testing the Fix
86
+
87
+ To verify reasoning logs appear:
88
+ 1. Run test generation in VS Code
89
+ 2. Check "TestChimp Agent" output channel
90
+ 3. Look for `πŸ’­ REASONING`, `🧠 SELF-REFLECTION`, etc.
91
+ 4. Check log file has complete information
92
+
93
+ ## Files Modified
94
+
95
+ **runner-core:**
96
+ - `/src/index.ts` - Store and reapply outputChannel across service recreations
97
+
98
+ **vs-extension:**
99
+ - `/package.json` - Updated to use `^0.0.26`
100
+
101
+ **github-action:**
102
+ - `/package.json` - Updated to use `^0.0.26`
103
+
104
+ ## Published to npm
105
+
106
+ ```
107
+ βœ… Published: testchimp-runner-core@0.0.26
108
+ πŸ“¦ Package Size: 245.9 kB
109
+ πŸ“‹ Registry: https://registry.npmjs.org/
110
+ πŸ”’ Files: 166
111
+ ```
112
+
113
+ ## Verification
114
+
115
+ **vs-extension:**
116
+ ```
117
+ testchimp-vs-extension@0.0.8
118
+ └── testchimp-runner-core@0.0.26 βœ…
119
+ ```
120
+
121
+ **github-action:**
122
+ ```
123
+ testchimp-runner-action@1.0.18
124
+ └── testchimp-runner-core@0.0.26 βœ…
125
+ ```
126
+
127
+ ## Build Status
128
+
129
+ βœ… **runner-core** - Published to npm
130
+ βœ… **vs-extension** - Updated and built (492 KiB)
131
+ βœ… **github-action** - Updated and built (1151 KiB)
132
+
133
+ ## Backward Compatibility
134
+
135
+ βœ… Fully backward compatible
136
+ - No API changes
137
+ - Only fixes a bug in log routing
138
+ - All functionality preserved
139
+
140
+ ## Complete Feature Set in 0.0.26
141
+
142
+ This version includes all improvements made today:
143
+ 1. βœ… Semantic selector preference (getByRole, getByLabel, etc.)
144
+ 2. βœ… Playwright expect() assertions instead of manual checks
145
+ 3. βœ… Script cleanup feature (removes redundancies)
146
+ 4. βœ… Fixed comment placement in generated scripts
147
+ 5. βœ… Focused step execution (no extra assertions)
148
+ 6. βœ… Environment-aware log filtering (in vs-extension)
149
+ 7. βœ… **Orchestrator reasoning logs in output channel** (NEW in 0.0.26)
150
+
151
+ ## Next Steps
152
+
153
+ For future service recreations, the pattern to follow:
154
+ ```typescript
155
+ // When recreating a service, reapply stored configuration:
156
+ if (this.logger) {
157
+ this.newService.setLogger(this.logger);
158
+ }
159
+ if (this.outputChannel) {
160
+ this.newService.setOutputChannel(this.outputChannel);
161
+ }
162
+ ```
163
+
164
+ This ensures configuration persists across service lifecycles.
165
+
@@ -0,0 +1,236 @@
1
+ # Release 0.0.27 - Clean Logs and Credit Callback Architecture
2
+
3
+ ## Summary
4
+ Major cleanup of logging architecture with timestamps moved to consumers, minimal initialization logs, credit callback support for server-side integration, and version read from package.json.
5
+
6
+ ## Changes in 0.0.27
7
+
8
+ ### 1. Timestamps at Consumer Level
9
+ **Architecture Fix:**
10
+ - ❌ Before: runner-core added timestamps
11
+ - βœ… After: Consumer adds timestamps in their timezone
12
+
13
+ **runner-core:**
14
+ - Removed all timestamp formatting
15
+ - Reports raw messages via callbacks
16
+
17
+ **vs-extension:**
18
+ - Added `formatLocalTimestamp()` utility function
19
+ - Wraps outputChannel to add timestamps automatically
20
+ - Format: `HH:MM:SS.mmm` in local timezone
21
+
22
+ ### 2. Minimal Initialization Logs
23
+ **Before:**
24
+ ```
25
+ πŸ€– Initializing Orchestrator Mode
26
+ βœ“ Orchestrator initialized with 5 tools (DEBUG MODE)
27
+ ═══════════════════════════════════════════════════════
28
+ πŸš€ RUNNER-CORE VERSION: v1.5.0-vision-preserve-values
29
+ ═══════════════════════════════════════════════════════
30
+ Initializing Scenario worker...
31
+ Scenario worker initialized with session: scenario_worker_XXX
32
+ Scenario worker initialized (Orchestrator Mode) with session...
33
+ Scenario service initialized
34
+ ```
35
+
36
+ **After:**
37
+ ```
38
+ testchimp-runner-core v0.0.27
39
+ πŸ“‹ Processing scenario: [scenario description]
40
+ ```
41
+
42
+ **Changes:**
43
+ - Single version log (reads from package.json)
44
+ - No internal initialization details
45
+ - Clean, minimal output
46
+
47
+ ### 3. Credit Callback Architecture
48
+ **Purpose:** Allow server-side integration to update DB directly without axios calls
49
+
50
+ **Implementation:**
51
+ ```typescript
52
+ export interface CreditUsage {
53
+ credits: number;
54
+ usageReason: CreditUsageReason;
55
+ jobId?: string;
56
+ timestamp: number;
57
+ }
58
+
59
+ export type CreditUsageCallback = (usage: CreditUsage) => void | Promise<void>;
60
+ ```
61
+
62
+ **Behavior:**
63
+ 1. **If callback provided** (server-side):
64
+ - βœ… Call callback β†’ Direct DB update
65
+ - ❌ NO axios calls made
66
+
67
+ 2. **If NO callback but auth configured** (client-side):
68
+ - ❌ No callback
69
+ - βœ… Makes axios call to backend API
70
+
71
+ 3. **If neither** (development):
72
+ - Logs warning
73
+ - Continues without tracking
74
+
75
+ **Usage:**
76
+ ```typescript
77
+ // Server-side
78
+ const service = new TestChimpService(
79
+ fileHandler, undefined, backendUrl, maxWorkers,
80
+ llmProvider, progressReporter, orchestratorOptions,
81
+ async (creditUsage) => {
82
+ await db.insertCreditUsage(creditUsage); // Direct DB
83
+ }
84
+ );
85
+
86
+ // Client-side (vs-ext, github-action)
87
+ const service = new TestChimpService(
88
+ fileHandler, authConfig, backendUrl
89
+ // No callback - uses axios
90
+ );
91
+ ```
92
+
93
+ ### 4. Wrapped OutputChannel
94
+ **Problem:** runner-core wrote directly to outputChannel without timestamps
95
+
96
+ **Solution:** vs-extension wraps the outputChannel:
97
+ ```typescript
98
+ const wrappedChannel = {
99
+ appendLine: (message) => {
100
+ const timestamp = formatLocalTimestamp();
101
+ const shouldLog = isDev || !isVerboseDebugLog;
102
+ if (shouldLog) {
103
+ this.outputChannel?.appendLine(`[${timestamp}] ${message}`);
104
+ }
105
+ }
106
+ };
107
+ service.setOutputChannel(wrappedChannel);
108
+ ```
109
+
110
+ **Result:**
111
+ - βœ… All logs get timestamps
112
+ - βœ… Filtering applied
113
+ - βœ… Consumer controls presentation
114
+
115
+ ### 5. Dynamic Version in build_local.sh
116
+ **Before:**
117
+ ```bash
118
+ cp testchimp-runner-core-0.0.22.tgz . # Hardcoded!
119
+ ```
120
+
121
+ **After:**
122
+ ```bash
123
+ RUNNER_VERSION=$(node -p "require('./package.json').version")
124
+ TARBALL_NAME="testchimp-runner-core-${RUNNER_VERSION}.tgz"
125
+ cp "$PARENT_DIR/runner-core/${TARBALL_NAME}" .
126
+ ```
127
+
128
+ **Benefit:** Always uses correct version, no manual updates needed
129
+
130
+ ## New Exports
131
+
132
+ ```typescript
133
+ export {
134
+ // Credit usage types
135
+ CreditUsageCallback,
136
+ CreditUsage,
137
+ CreditUsageReason,
138
+
139
+ // Existing exports...
140
+ TestChimpService,
141
+ // ...
142
+ }
143
+ ```
144
+
145
+ ## Files Modified
146
+
147
+ ### runner-core
148
+ 1. `/src/scenario-worker-class.ts` - Removed timestamps, minimal logs, version from package.json
149
+ 2. `/src/scenario-service.ts` - Removed initialization logs
150
+ 3. `/src/credit-usage-service.ts` - Added callback architecture, callback-first logic
151
+ 4. `/src/index.ts` - Credit callback support, preserve across recreations
152
+
153
+ ### vs-extension
154
+ 1. `/src/embedded-service.ts` - `formatLocalTimestamp()` utility, wrapped outputChannel, consistent filtering
155
+ 2. `/build_local.sh` - Dynamic version detection
156
+ 3. `/package.json` - Updated to `^0.0.27`
157
+
158
+ ### github-action
159
+ 1. `/package.json` - Updated to `^0.0.27`
160
+
161
+ ## Published to npm
162
+
163
+ ```
164
+ βœ… Published: testchimp-runner-core@0.0.27
165
+ πŸ“¦ Package Size: ~245 kB
166
+ πŸ“‹ Registry: https://registry.npmjs.org/
167
+ ```
168
+
169
+ ## Benefits
170
+
171
+ ### Logging
172
+ 1. **Local Timezone** - Timestamps match user's clock
173
+ 2. **Clean Output** - Only essential information
174
+ 3. **Consumer Control** - Consumer decides format and filtering
175
+ 4. **No Verbose Init** - Single version log instead of 10+ lines
176
+
177
+ ### Credit Tracking
178
+ 1. **Server-Side** - Direct DB updates, no HTTP overhead
179
+ 2. **Client-Side** - Existing axios behavior preserved
180
+ 3. **Flexible** - Each consumer decides how to track
181
+ 4. **Observable** - Callback provides visibility
182
+
183
+ ### Architecture
184
+ 1. **Separation of Concerns** - Library reports, consumer presents
185
+ 2. **Environment Agnostic** - Library doesn't assume timezone/environment
186
+ 3. **Testable** - Easy to mock callbacks
187
+ 4. **Maintainable** - Clear boundaries
188
+
189
+ ## Migration
190
+
191
+ ### For All Consumers
192
+ Update package.json:
193
+ ```json
194
+ {
195
+ "dependencies": {
196
+ "testchimp-runner-core": "^0.0.27"
197
+ }
198
+ }
199
+ ```
200
+
201
+ ### For Server-Side (Optional)
202
+ Add credit callback:
203
+ ```typescript
204
+ const service = new TestChimpService(
205
+ fileHandler, undefined, backendUrl, maxWorkers,
206
+ llmProvider, progressReporter, orchestratorOptions,
207
+ async (creditUsage) => {
208
+ await creditRepository.insert(creditUsage);
209
+ }
210
+ );
211
+ ```
212
+
213
+ ## Backward Compatibility
214
+
215
+ βœ… Fully backward compatible
216
+ - All parameters optional
217
+ - Existing behavior preserved
218
+ - No breaking changes
219
+
220
+ ## Complete Feature Set
221
+
222
+ All improvements from today are now in 0.0.27:
223
+ 1. βœ… Semantic selector preference
224
+ 2. βœ… Playwright expect() assertions
225
+ 3. βœ… Script cleanup feature
226
+ 4. βœ… Fixed comment placement
227
+ 5. βœ… Focused step execution
228
+ 6. βœ… Orchestrator reasoning logs in output channel
229
+ 7. βœ… Environment-aware log filtering (consumer-side)
230
+ 8. βœ… Local timezone timestamps
231
+ 9. βœ… Clean initialization logs
232
+ 10. βœ… Credit callback architecture
233
+ 11. βœ… Version from package.json
234
+
235
+ Ready for production! πŸš€
236
+
@@ -0,0 +1,286 @@
1
+ # Runner-Core 0.0.28 Release - Scriptservice Integration
2
+
3
+ ## Overview
4
+
5
+ Extended runner-core with lifecycle callbacks and created SmartTestRunnerCoreV2 wrapper to enable scriptservice integration. This release makes runner-core a drop-in replacement for scriptservice's duplicated SmartTestRunnerCore.
6
+
7
+ ## Changes
8
+
9
+ ### 1. Extended ProgressReporter with Lifecycle Callbacks
10
+
11
+ **File:** `src/progress-reporter.ts`
12
+
13
+ Added optional lifecycle callbacks to ProgressReporter interface:
14
+
15
+ ```typescript
16
+ export interface StepInfo {
17
+ stepId?: string;
18
+ stepNumber: number;
19
+ description: string;
20
+ code?: string;
21
+ }
22
+
23
+ export interface ProgressReporter {
24
+ // ... existing callbacks ...
25
+
26
+ // NEW: Lifecycle callbacks (used by scriptservice, ignored by local clients)
27
+ beforeStartTest?(page: any, browser: any, context: any): Promise<void>;
28
+ beforeStepStart?(step: StepInfo, page: any): Promise<void>;
29
+ afterEndTest?(status: 'passed' | 'failed', error?: string, page?: any): Promise<void>;
30
+ }
31
+ ```
32
+
33
+ **Purpose:**
34
+ - `beforeStartTest`: Initialize browser context, set up DB records (scriptservice only)
35
+ - `beforeStepStart`: Update step status to IN_PROGRESS in DB (scriptservice only)
36
+ - `afterEndTest`: Write final status to DB, cleanup resources (scriptservice only)
37
+ - Local clients (vs-ext, github-action) can ignore these - they use return values
38
+
39
+ ### 2. Integrated Lifecycle Callbacks
40
+
41
+ **Files:**
42
+ - `src/execution-service.ts` - RUN_EXACTLY and AI_REPAIR modes
43
+ - `src/scenario-worker-class.ts` - Orchestrator mode
44
+
45
+ **Integration Points:**
46
+
47
+ **ExecutionService (RUN_EXACTLY):**
48
+ ```typescript
49
+ // Before script execution
50
+ if (this.progressReporter?.beforeStartTest) {
51
+ await this.progressReporter.beforeStartTest(page, browser, context);
52
+ }
53
+
54
+ // After execution (success or failure)
55
+ if (this.progressReporter?.afterEndTest) {
56
+ await this.progressReporter.afterEndTest(
57
+ success ? 'passed' : 'failed',
58
+ error,
59
+ page
60
+ );
61
+ }
62
+ ```
63
+
64
+ **ExecutionService (AI_REPAIR):**
65
+ ```typescript
66
+ // Before each step
67
+ if (this.progressReporter?.beforeStepStart) {
68
+ await this.progressReporter.beforeStepStart(
69
+ { stepNumber, description, code },
70
+ page
71
+ );
72
+ }
73
+ ```
74
+
75
+ **ScenarioWorker (Orchestrator):**
76
+ ```typescript
77
+ // After browser initialization
78
+ if (this.progressReporter?.beforeStartTest) {
79
+ await this.progressReporter.beforeStartTest(page, browser, context);
80
+ }
81
+
82
+ // Before each orchestrator step
83
+ if (this.progressReporter?.beforeStepStart) {
84
+ await this.progressReporter.beforeStepStart({ stepNumber, description }, page);
85
+ }
86
+
87
+ // In finally block (before browser close)
88
+ if (this.progressReporter?.afterEndTest) {
89
+ await this.progressReporter.afterEndTest(
90
+ overallSuccess ? 'passed' : 'failed',
91
+ error,
92
+ page
93
+ );
94
+ }
95
+ ```
96
+
97
+ ### 3. Version Bump
98
+
99
+ **File:** `package.json`
100
+
101
+ Updated version from `0.0.27` to `0.0.28`
102
+
103
+ ## Scriptservice Integration
104
+
105
+ ### 1. Created ScriptserviceLLMProvider
106
+
107
+ **File:** `services/scriptservice/providers/scriptservice-llm-provider.ts` (NEW)
108
+
109
+ Implements `LLMProvider` interface for scriptservice:
110
+ - Wraps scriptservice's existing OpenAI client
111
+ - Supports both text and vision prompts
112
+ - Uses scriptservice's OpenAI API key from ConfigService
113
+ - No backend proxy - all calls are local
114
+ - No token tracking needed (scriptservice doesn't use this interface for tracking)
115
+
116
+ ### 2. Created SmartTestRunnerCoreV2
117
+
118
+ **File:** `services/scriptservice/smart-test-runner-core-v2.ts` (NEW)
119
+
120
+ Drop-in replacement for SmartTestRunnerCore:
121
+ - **Same Interface:** Maintains exact same constructor and methods (runExactly, runWithRepair)
122
+ - **Uses runner-core:** Delegates to TestChimpService internally
123
+ - **Callback Mapping:** Maps scriptservice callbacks to runner-core ProgressReporter
124
+ - **Lifecycle Support:** Properly calls beforeStartTest, beforeStepStart, afterEndTest
125
+ - **No Breaking Changes:** Can replace SmartTestRunnerCore with zero code changes
126
+
127
+ **Key Features:**
128
+ ```typescript
129
+ export class SmartTestRunnerCoreV2 {
130
+ constructor(config: RunnerConfig) {
131
+ // Create local LLM provider (no backend)
132
+ const llmProvider = new ScriptserviceLLMProvider();
133
+
134
+ // Map callbacks to progress reporter
135
+ const progressReporter: ProgressReporter = {
136
+ onStepProgress: async (stepProgress) => {
137
+ // Call scriptservice's onStepComplete
138
+ },
139
+ beforeStartTest: config.callbacks?.beforeStartTest,
140
+ beforeStepStart: config.callbacks?.beforeStepStart,
141
+ afterEndTest: config.callbacks?.afterEndTest
142
+ };
143
+
144
+ // Initialize runner-core (no auth, no backend)
145
+ this.runnerCore = new TestChimpService(
146
+ undefined, // No file handler
147
+ undefined, // No auth
148
+ undefined, // No backend URL
149
+ 1, // Single worker
150
+ llmProvider,
151
+ progressReporter
152
+ );
153
+ }
154
+
155
+ async runExactly(script: string): Promise<RunExactlyResult> { /* ... */ }
156
+ async runWithRepair(steps: TestStepWithId[]): Promise<RunWithRepairResult> { /* ... */ }
157
+ }
158
+ ```
159
+
160
+ ### 3. Updated Scriptservice Consumers
161
+
162
+ **Files Updated:**
163
+ - `services/scriptservice/smart-test-execution-handler.ts`
164
+ - `services/scriptservice/workers/test-based-explorer.ts`
165
+ - `services/scriptservice/package.json` - Added `testchimp-runner-core: ^0.0.28`
166
+
167
+ **Migration Strategy:**
168
+ ```typescript
169
+ // Environment flag for gradual rollout
170
+ const useV2 = process.env.USE_RUNNER_CORE_V2 !== 'false'; // Default: true
171
+ const runner = useV2
172
+ ? new SmartTestRunnerCoreV2(runnerConfig)
173
+ : new SmartTestRunnerCore(runnerConfig);
174
+ ```
175
+
176
+ **Rollout Plan:**
177
+ 1. Deploy with `USE_RUNNER_CORE_V2=true` (default)
178
+ 2. Monitor scriptservice execution logs
179
+ 3. If issues occur, set `USE_RUNNER_CORE_V2=false` to rollback
180
+ 4. Once validated, remove flag and delete old SmartTestRunnerCore
181
+
182
+ ## Benefits
183
+
184
+ ### For Scriptservice:
185
+ 1. **Zero Axios Calls:** All LLM calls local, all DB writes via callbacks
186
+ 2. **Auto-Updates:** Automatically get runner-core improvements (better prompts, vision, orchestrator)
187
+ 3. **Code Deduplication:** Remove ~600 lines of duplicated execution/repair logic
188
+ 4. **Consistency:** Same prompts and logic as vs-extension and github-action
189
+
190
+ ### For Runner-Core:
191
+ 1. **Universal Library:** Works for both client-side (vs-ext) and server-side (scriptservice)
192
+ 2. **Flexible Architecture:** Callbacks allow different execution patterns
193
+ 3. **Backward Compatible:** Existing consumers unaffected (callbacks are optional)
194
+
195
+ ## Testing
196
+
197
+ ### Scriptservice Testing:
198
+ ```bash
199
+ # Test with V2 (default)
200
+ USE_RUNNER_CORE_V2=true npm start
201
+
202
+ # Test with V1 (legacy fallback)
203
+ USE_RUNNER_CORE_V2=false npm start
204
+ ```
205
+
206
+ ### Expected Behavior:
207
+ - V2: Logs show "using SmartTestRunnerCoreV2 (runner-core)"
208
+ - V1: Logs show "using SmartTestRunnerCore (legacy)"
209
+ - All callbacks (beforeStartTest, beforeStepStart, afterEndTest, onStepComplete) should fire
210
+ - DB writes should happen via callbacks
211
+ - Screenshots should upload to GCS
212
+ - Journey reporting should work
213
+
214
+ ## Publishing
215
+
216
+ ### Prerequisites:
217
+ 1. βœ… Build runner-core: `npm run build`
218
+ 2. βœ… No lint errors
219
+ 3. βœ… Version bumped to 0.0.28
220
+ 4. ⏸️ **Awaiting user permission to publish to npm**
221
+
222
+ ### Publish Command (when approved):
223
+ ```bash
224
+ cd /Users/nuwansam/IdeaProjects/AwareRepo/local/runner-core
225
+ npm publish
226
+ ```
227
+
228
+ ### Post-Publish:
229
+ 1. Install in scriptservice: `npm install testchimp-runner-core@0.0.28`
230
+ 2. Install in vs-ext: Update to 0.0.28
231
+ 3. Install in github-action: Update to 0.0.28
232
+
233
+ ## Migration Checklist
234
+
235
+ ### Phase 1: Deploy with V2 (Default)
236
+ - [x] Add lifecycle callbacks to ProgressReporter
237
+ - [x] Integrate callbacks in ExecutionService and ScenarioService
238
+ - [x] Create ScriptserviceLLMProvider
239
+ - [x] Create SmartTestRunnerCoreV2
240
+ - [x] Update scriptservice consumers with environment flag
241
+ - [ ] Publish runner-core 0.0.28 (needs user permission)
242
+ - [ ] Install 0.0.28 in scriptservice
243
+ - [ ] Deploy scriptservice with USE_RUNNER_CORE_V2=true
244
+ - [ ] Monitor logs and execution results
245
+
246
+ ### Phase 2: Validate (1-2 weeks)
247
+ - [ ] Verify all smart test executions work
248
+ - [ ] Verify explorer mode works
249
+ - [ ] Verify script generation works
250
+ - [ ] Check DB writes happen correctly
251
+ - [ ] Check screenshot uploads work
252
+ - [ ] Monitor for any errors or regressions
253
+
254
+ ### Phase 3: Full Migration
255
+ - [ ] Remove environment flag check
256
+ - [ ] Replace all `new SmartTestRunnerCore` with `new SmartTestRunnerCoreV2`
257
+ - [ ] Delete old `smart-test-runner-core.ts` file
258
+ - [ ] Optional: Rename V2 to just `SmartTestRunnerCore`
259
+
260
+ ## Breaking Changes
261
+
262
+ None. All changes are backward compatible.
263
+
264
+ ## Files Changed
265
+
266
+ ### Runner-Core:
267
+ - `src/progress-reporter.ts` - Added lifecycle callbacks
268
+ - `src/execution-service.ts` - Integrated callbacks
269
+ - `src/scenario-worker-class.ts` - Integrated callbacks
270
+ - `package.json` - Version bump to 0.0.28
271
+
272
+ ### Scriptservice:
273
+ - `providers/scriptservice-llm-provider.ts` - NEW
274
+ - `smart-test-runner-core-v2.ts` - NEW
275
+ - `smart-test-execution-handler.ts` - Added V2 usage with flag
276
+ - `workers/test-based-explorer.ts` - Added V2 usage with flag
277
+ - `package.json` - Added testchimp-runner-core dependency
278
+
279
+ ## Notes
280
+
281
+ - Lifecycle callbacks are **optional** - local clients (vs-ext, github-action) don't need them
282
+ - Scriptservice uses callbacks for DB writes and resource management
283
+ - V2 wrapper uses existing page/browser/context (doesn't create new ones)
284
+ - LLM calls in V2 are all local (no backend proxy)
285
+ - No authentication needed for scriptservice (already authenticated at service level)
286
+