@zibby/core 0.1.21 → 0.1.23

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 (167) hide show
  1. package/dist/agents/base.js +17 -0
  2. package/dist/backend-client.js +1 -0
  3. package/dist/constants/tool-names.js +1 -0
  4. package/dist/constants/zibby-scratch.js +1 -0
  5. package/dist/constants.js +1 -0
  6. package/dist/enrichment/base.js +1 -0
  7. package/dist/enrichment/enrichers/accessibility-enricher.js +1 -0
  8. package/dist/enrichment/enrichers/dom-enricher.js +1 -0
  9. package/dist/enrichment/enrichers/page-state-enricher.js +1 -0
  10. package/dist/enrichment/enrichers/position-enricher.js +1 -0
  11. package/dist/enrichment/index.js +1 -0
  12. package/dist/enrichment/mcp-integration.js +1 -0
  13. package/dist/enrichment/mcp-ref-enricher.js +1 -0
  14. package/dist/enrichment/pipeline.js +3 -0
  15. package/dist/enrichment/trace-text-enricher.js +1 -0
  16. package/dist/framework/agents/assistant-strategy.js +5 -0
  17. package/dist/framework/agents/base.js +1 -0
  18. package/dist/framework/agents/claude-strategy.js +4 -0
  19. package/dist/framework/agents/codex-strategy.js +4 -0
  20. package/dist/framework/agents/cursor-strategy.js +32 -0
  21. package/dist/framework/agents/gemini-strategy.js +11 -0
  22. package/dist/framework/agents/index.js +13 -0
  23. package/dist/framework/agents/middleware/assistant-round-pipeline.js +3 -0
  24. package/dist/framework/agents/providers/base.js +1 -0
  25. package/dist/framework/agents/providers/index.js +1 -0
  26. package/dist/framework/agents/providers/openai-transport.js +2 -0
  27. package/dist/framework/agents/providers/openai.js +1 -0
  28. package/dist/framework/agents/providers/transport-base.js +1 -0
  29. package/dist/framework/agents/utils/auth-resolver.js +1 -0
  30. package/dist/framework/agents/utils/cursor-output-formatter.js +1 -0
  31. package/dist/framework/agents/utils/openai-proxy-formatter.js +9 -0
  32. package/dist/framework/agents/utils/payload-budget.js +3 -0
  33. package/dist/framework/agents/utils/structured-output-formatter.js +21 -0
  34. package/dist/framework/code-generator.js +10 -0
  35. package/dist/framework/constants.js +1 -0
  36. package/dist/framework/context-loader.js +5 -0
  37. package/dist/framework/function-bridge.js +2 -0
  38. package/dist/framework/function-skill-registry.js +1 -0
  39. package/dist/framework/graph-compiler.js +1 -0
  40. package/dist/framework/graph.js +5 -0
  41. package/dist/framework/index.js +1 -0
  42. package/dist/framework/mcp-client.js +2 -0
  43. package/dist/framework/node-registry.js +9 -0
  44. package/dist/framework/node.js +5 -0
  45. package/dist/framework/output-parser.js +3 -0
  46. package/dist/framework/skill-registry.js +1 -0
  47. package/dist/framework/state-utils.js +1 -0
  48. package/dist/framework/state.js +1 -0
  49. package/dist/framework/tool-resolver.js +1 -0
  50. package/dist/index.js +8 -0
  51. package/dist/runtime/generation/base.js +1 -0
  52. package/dist/runtime/generation/index.js +3 -0
  53. package/dist/runtime/generation/mcp-ref-strategy.js +41 -0
  54. package/dist/runtime/generation/stable-id-strategy.js +16 -0
  55. package/dist/runtime/stable-id-runtime.js +1 -0
  56. package/dist/runtime/verification/base.js +1 -0
  57. package/dist/runtime/verification/index.js +3 -0
  58. package/dist/runtime/verification/playwright-json-strategy.js +1 -0
  59. package/dist/runtime/zibby-runtime.js +1 -0
  60. package/dist/sync/index.js +1 -0
  61. package/dist/sync/uploader.js +1 -0
  62. package/dist/tools/run-playwright-test.js +5 -0
  63. package/dist/utils/adf-converter.js +7 -0
  64. package/dist/utils/ast-utils.js +1 -0
  65. package/dist/utils/ci-setup.js +5 -0
  66. package/dist/utils/cursor-mcp-isolated-home.js +1 -0
  67. package/dist/utils/cursor-utils.js +18 -0
  68. package/dist/utils/live-frame-discovery.js +1 -0
  69. package/dist/utils/logger.js +1 -0
  70. package/dist/utils/mcp-config-writer.js +10 -0
  71. package/dist/utils/mission-control-from-run-states.js +1 -0
  72. package/dist/utils/node-schema-parser.js +1 -0
  73. package/dist/utils/parallel-config.js +1 -0
  74. package/dist/utils/post-process-events.js +1 -0
  75. package/dist/utils/result-handler.js +1 -0
  76. package/{src → dist}/utils/ripple-effect.js +3 -12
  77. package/dist/utils/run-capacity-coordinator.js +1 -0
  78. package/dist/utils/run-capacity-queue.js +2 -0
  79. package/dist/utils/run-index-merge.js +1 -0
  80. package/dist/utils/run-index-post-cli.js +1 -0
  81. package/dist/utils/run-registry.js +3 -0
  82. package/dist/utils/run-state-session.js +2 -0
  83. package/dist/utils/selector-generator.js +4 -0
  84. package/dist/utils/session-state-constants.js +1 -0
  85. package/dist/utils/session-state-live-runs.js +1 -0
  86. package/dist/utils/streaming-parser.js +4 -0
  87. package/dist/utils/test-post-processor.js +18 -0
  88. package/dist/utils/timeline.js +14 -0
  89. package/dist/utils/trace-parser.js +2 -0
  90. package/dist/utils/video-organizer.js +3 -0
  91. package/package.json +49 -35
  92. package/templates/browser-test-automation/README.md +29 -7
  93. package/templates/browser-test-automation/chat.mjs +36 -0
  94. package/templates/browser-test-automation/graph.mjs +5 -9
  95. package/templates/browser-test-automation/nodes/execute-live.mjs +30 -58
  96. package/templates/browser-test-automation/nodes/generate-script.mjs +32 -12
  97. package/templates/browser-test-automation/nodes/utils.mjs +153 -10
  98. package/templates/browser-test-automation/pipeline-ids.js +12 -0
  99. package/templates/browser-test-automation/result-handler.mjs +78 -2
  100. package/templates/browser-test-automation/run-index.mjs +418 -0
  101. package/scripts/export-default-workflows.js +0 -51
  102. package/scripts/patch-cursor-mcp.js +0 -174
  103. package/scripts/setup-ci.sh +0 -115
  104. package/scripts/setup-official-playwright-mcp.sh +0 -226
  105. package/scripts/test-with-video.sh +0 -49
  106. package/src/agents/base.js +0 -361
  107. package/src/constants.js +0 -47
  108. package/src/enrichment/base.js +0 -49
  109. package/src/enrichment/enrichers/accessibility-enricher.js +0 -197
  110. package/src/enrichment/enrichers/dom-enricher.js +0 -171
  111. package/src/enrichment/enrichers/page-state-enricher.js +0 -129
  112. package/src/enrichment/enrichers/position-enricher.js +0 -67
  113. package/src/enrichment/index.js +0 -96
  114. package/src/enrichment/mcp-integration.js +0 -149
  115. package/src/enrichment/mcp-ref-enricher.js +0 -78
  116. package/src/enrichment/pipeline.js +0 -192
  117. package/src/enrichment/trace-text-enricher.js +0 -115
  118. package/src/framework/AGENTS.md +0 -98
  119. package/src/framework/agents/base.js +0 -72
  120. package/src/framework/agents/claude-strategy.js +0 -278
  121. package/src/framework/agents/cursor-strategy.js +0 -544
  122. package/src/framework/agents/index.js +0 -105
  123. package/src/framework/agents/utils/cursor-output-formatter.js +0 -67
  124. package/src/framework/agents/utils/openai-proxy-formatter.js +0 -249
  125. package/src/framework/code-generator.js +0 -301
  126. package/src/framework/constants.js +0 -33
  127. package/src/framework/context-loader.js +0 -101
  128. package/src/framework/function-bridge.js +0 -78
  129. package/src/framework/function-skill-registry.js +0 -20
  130. package/src/framework/graph-compiler.js +0 -342
  131. package/src/framework/graph.js +0 -610
  132. package/src/framework/index.js +0 -28
  133. package/src/framework/node-registry.js +0 -163
  134. package/src/framework/node.js +0 -259
  135. package/src/framework/output-parser.js +0 -71
  136. package/src/framework/skill-registry.js +0 -55
  137. package/src/framework/state-utils.js +0 -52
  138. package/src/framework/state.js +0 -67
  139. package/src/framework/tool-resolver.js +0 -65
  140. package/src/index.js +0 -345
  141. package/src/runtime/generation/base.js +0 -46
  142. package/src/runtime/generation/index.js +0 -70
  143. package/src/runtime/generation/mcp-ref-strategy.js +0 -197
  144. package/src/runtime/generation/stable-id-strategy.js +0 -170
  145. package/src/runtime/stable-id-runtime.js +0 -248
  146. package/src/runtime/verification/base.js +0 -44
  147. package/src/runtime/verification/index.js +0 -67
  148. package/src/runtime/verification/playwright-json-strategy.js +0 -119
  149. package/src/runtime/zibby-runtime.js +0 -299
  150. package/src/sync/index.js +0 -2
  151. package/src/sync/uploader.js +0 -29
  152. package/src/tools/run-playwright-test.js +0 -158
  153. package/src/utils/adf-converter.js +0 -68
  154. package/src/utils/ast-utils.js +0 -37
  155. package/src/utils/ci-setup.js +0 -124
  156. package/src/utils/cursor-utils.js +0 -71
  157. package/src/utils/logger.js +0 -144
  158. package/src/utils/mcp-config-writer.js +0 -115
  159. package/src/utils/node-schema-parser.js +0 -522
  160. package/src/utils/post-process-events.js +0 -55
  161. package/src/utils/result-handler.js +0 -102
  162. package/src/utils/selector-generator.js +0 -239
  163. package/src/utils/streaming-parser.js +0 -387
  164. package/src/utils/test-post-processor.js +0 -211
  165. package/src/utils/timeline.js +0 -217
  166. package/src/utils/trace-parser.js +0 -325
  167. package/src/utils/video-organizer.js +0 -91
@@ -1,65 +0,0 @@
1
- import { getSkill } from './skill-registry.js';
2
-
3
- const NODE_DEFAULT_TOOLS = {};
4
-
5
- export function resolveNodeTools(nodeType, userToolIds) {
6
- if (Array.isArray(userToolIds)) {
7
- return getResolvedToolDefinitions(userToolIds);
8
- }
9
- const defaults = NODE_DEFAULT_TOOLS[nodeType];
10
- if (!defaults || defaults.length === 0) return null;
11
- return getResolvedToolDefinitions(defaults);
12
- }
13
-
14
- export function getResolvedToolDefinitions(toolIds) {
15
- if (!Array.isArray(toolIds) || toolIds.length === 0) return null;
16
-
17
- const claudeTools = [];
18
- const mcpServers = {};
19
- const validIds = [];
20
-
21
- for (const toolId of toolIds) {
22
- const skill = getSkill(toolId);
23
- if (!skill) {
24
- console.warn(`[ToolResolver] Unknown skill "${toolId}" — skipping`);
25
- continue;
26
- }
27
-
28
- validIds.push(toolId);
29
-
30
- for (const tool of (skill.tools || [])) {
31
- claudeTools.push({
32
- name: tool.name,
33
- description: tool.description,
34
- input_schema: tool.input_schema || { type: 'object', properties: {} }
35
- });
36
- }
37
-
38
- if (!mcpServers[skill.serverName]) {
39
- if (typeof skill.resolve === 'function') {
40
- const resolved = skill.resolve();
41
- if (resolved) {
42
- mcpServers[skill.serverName] = { ...resolved, toolPrefix: toolId };
43
- }
44
- } else {
45
- const env = {};
46
- for (const key of (skill.envKeys || [])) {
47
- const value = process.env[key];
48
- if (value) env[key] = value;
49
- }
50
- mcpServers[skill.serverName] = {
51
- command: skill.command,
52
- args: [...(skill.args || [])],
53
- env,
54
- toolPrefix: toolId,
55
- };
56
- }
57
- }
58
- }
59
-
60
- if (validIds.length === 0) return null;
61
-
62
- return { toolIds: validIds, claudeTools, mcpServers };
63
- }
64
-
65
- export { NODE_DEFAULT_TOOLS };
package/src/index.js DELETED
@@ -1,345 +0,0 @@
1
- import { readFileSync, existsSync } from 'fs';
2
- import { join } from 'path';
3
- import { DEFAULT_OUTPUT_BASE, SESSIONS_DIR, RESULT_FILE } from './framework/constants.js';
4
-
5
- import { WorkflowAgent, workflow } from './agents/base.js';
6
- export { WorkflowAgent, workflow };
7
- export { WorkflowGraph } from './framework/graph.js';
8
- export { ResultHandler } from './utils/result-handler.js';
9
- export { z } from 'zod';
10
-
11
- export {
12
- invokeAgent,
13
- getAgentStrategy,
14
- CursorAgentStrategy,
15
- ClaudeAgentStrategy,
16
- AgentStrategy
17
- } from './framework/agents/index.js';
18
-
19
- export { SKILLS } from './framework/constants.js';
20
- export { registerSkill, getSkill, hasSkill, getAllSkills, listSkillIds } from './framework/skill-registry.js';
21
-
22
- export { organizeVideos } from './utils/video-organizer.js';
23
- export { ZibbyUploader, createUploader } from './sync/index.js';
24
- export { patchCursorAgentForCI, checkCursorAgentPatched, getApprovalKeys, saveApprovalKeys } from './utils/ci-setup.js';
25
- export { DEFAULT_MODELS, AGENT_TYPES, LOG_LEVELS as CORE_LOG_LEVELS } from './constants.js';
26
- export {
27
- DEFAULT_OUTPUT_BASE,
28
- SESSIONS_DIR,
29
- SESSION_INFO_FILE,
30
- RESULT_FILE,
31
- RAW_OUTPUT_FILE,
32
- EVENTS_FILE,
33
- CI_ENV_VARS
34
- } from './framework/constants.js';
35
- export { RIPPLE_EFFECT_SCRIPT, injectRippleEffect, generateRippleHelperCode } from './utils/ripple-effect.js';
36
- export { checkCursorAgentInstalled, getCursorAgentInstallInstructions } from './utils/cursor-utils.js';
37
- export { SelectorGenerator } from './utils/selector-generator.js';
38
- export { TestPostProcessor } from './utils/test-post-processor.js';
39
- export { TraceParser } from './utils/trace-parser.js';
40
- export { StreamingParser } from './utils/streaming-parser.js';
41
- export { ZibbyRuntime } from './runtime/zibby-runtime.js';
42
- export { StableIdRuntime } from './runtime/stable-id-runtime.js';
43
- export { logger, Logger, LOG_LEVELS } from './utils/logger.js';
44
- export { timeline } from './utils/timeline.js';
45
- export { postProcessEvents } from './utils/post-process-events.js';
46
- export { runPlaywrightTestTool, resetExecutionCount } from './tools/run-playwright-test.js';
47
-
48
- export {
49
- testGenerationManager,
50
- TestGenerationStrategy,
51
- MCPRefStrategy,
52
- StableIdStrategy
53
- } from './runtime/generation/index.js';
54
-
55
- export {
56
- testVerificationManager,
57
- TestVerificationStrategy,
58
- PlaywrightJsonVerificationStrategy
59
- } from './runtime/verification/index.js';
60
-
61
- export {
62
- EventEnricher,
63
- EnrichmentPipeline,
64
- PositionEnricher,
65
- AccessibilityEnricher,
66
- PageStateEnricher,
67
- DOMEnricher,
68
- createDefaultPipeline,
69
- createMinimalPipeline,
70
- createCustomPipeline
71
- } from './enrichment/index.js';
72
-
73
- export {
74
- enrichRecordedEvents,
75
- LiveEnrichmentRecorder
76
- } from './enrichment/mcp-integration.js';
77
-
78
- const mcpErrorHandler = (error) => {
79
- if (error?.message?.includes('Connection closed') ||
80
- error?.message?.includes('MCP error -32000') ||
81
- error?.code === -32000) {
82
- return;
83
- }
84
- console.error('Unhandled rejection:', error);
85
- };
86
-
87
- if (!process.listeners('unhandledRejection').includes(mcpErrorHandler)) {
88
- process.on('unhandledRejection', mcpErrorHandler);
89
- }
90
-
91
- export async function runTest(specPath, config = {}) {
92
- const {
93
- agent: _agent,
94
- mcp: _mcp,
95
- headless: _headless,
96
- cwd = process.cwd(),
97
- specPath: relativeSpecPath,
98
- ...agentConfig
99
- } = config;
100
-
101
- const testSpec = readFileSync(specPath, 'utf-8');
102
-
103
- const adapter = null;
104
- const { agent: localAgent, error: localAgentError } = await loadLocalAgent(cwd, agentConfig);
105
- let agent = localAgent;
106
-
107
- if (!agent && config.fallbackAgentModule) {
108
- const mod = config.fallbackAgentModule;
109
- const AgentClass = mod.BrowserTestAutomationAgent || mod.default;
110
- if (AgentClass) {
111
- agent = new AgentClass(agentConfig);
112
- }
113
- }
114
-
115
- if (!agent && localAgentError) {
116
- console.warn(`⚠️ Failed to load local agent: ${localAgentError}`);
117
- }
118
-
119
- if (!agent) {
120
- throw new Error(
121
- `No agent found. Please run:\n` +
122
- ` zibby init\n\n` +
123
- `This will create .zibby/graph.mjs with your workflow definition.`
124
- );
125
- }
126
-
127
- await agent.initialize(adapter);
128
-
129
- try {
130
- if (config.singleNode) {
131
- console.log(`\n🎯 Running Single Node: ${config.singleNode} (Framework Mode)\n`);
132
-
133
- const outputPath = agent.calculateOutputPath(relativeSpecPath || specPath);
134
-
135
- const graph = agent.buildGraph();
136
- const nodeMap = {};
137
- for (const [name, node] of graph.nodes.entries()) {
138
- nodeMap[name] = node.config || node;
139
- }
140
-
141
- let sessionData = {};
142
- if (config.sessionId) {
143
- let sessionId = config.sessionId;
144
-
145
- // Get output base path from config (use new default)
146
- const outputBase = config.paths?.output || DEFAULT_OUTPUT_BASE;
147
-
148
- if (sessionId === 'last') {
149
- const sessionsDir = join(cwd, outputBase, SESSIONS_DIR);
150
- if (existsSync(sessionsDir)) {
151
- const { readdirSync, statSync } = await import('fs');
152
- const sessions = readdirSync(sessionsDir)
153
- .filter(f => statSync(join(sessionsDir, f)).isDirectory())
154
- .map(f => ({ name: f, time: statSync(join(sessionsDir, f)).mtimeMs }))
155
- .sort((a, b) => b.time - a.time);
156
-
157
- if (sessions.length > 0) {
158
- sessionId = sessions[0].name;
159
- console.log(`📂 Using latest session: ${sessionId}`);
160
- } else {
161
- console.log(`⚠️ No sessions found in ${sessionsDir}`);
162
- }
163
- }
164
- }
165
-
166
- const sessionPath = join(cwd, outputBase, SESSIONS_DIR, sessionId);
167
- const executeLiveFolder = join(sessionPath, 'execute_live');
168
- const resultPath = join(executeLiveFolder, RESULT_FILE);
169
-
170
- if (existsSync(resultPath)) {
171
- console.log(`📂 Loading session: ${sessionId}`);
172
- sessionData = {
173
- sessionPath,
174
- execute_live_output: JSON.parse(readFileSync(resultPath, 'utf-8'))
175
- };
176
- } else {
177
- console.log(`⚠️ Session not found: ${sessionPath}`);
178
- }
179
- }
180
-
181
- const result = await agent.runSingleNode(
182
- config.singleNode,
183
- nodeMap,
184
- {
185
- testSpec,
186
- outputPath,
187
- cwd: cwd || process.cwd(),
188
- contextConfig: config.contextConfig,
189
- specPath: relativeSpecPath || specPath,
190
- config,
191
- ...sessionData
192
- }
193
- );
194
-
195
- if (typeof agent.onComplete === 'function') {
196
- await agent.onComplete(result);
197
- }
198
-
199
- return result;
200
- }
201
-
202
- const result = await agent.run(testSpec, {
203
- testSpec,
204
- specPath: relativeSpecPath || specPath,
205
- cwd: cwd || process.cwd(),
206
- config
207
- });
208
-
209
- return result;
210
- } finally {
211
- await agent.cleanup();
212
- }
213
- }
214
-
215
- function kebabToPascal(str) {
216
- return str
217
- .split('-')
218
- .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
219
- .join('');
220
- }
221
-
222
- function findWorkflow(agentModule, workflowName) {
223
- if (agentModule[workflowName]) {
224
- return agentModule[workflowName];
225
- }
226
-
227
- const pascalCase = kebabToPascal(workflowName);
228
- if (agentModule[pascalCase]) {
229
- return agentModule[pascalCase];
230
- }
231
-
232
- const withSuffix = `${pascalCase}Workflow`;
233
- if (agentModule[withSuffix]) {
234
- return agentModule[withSuffix];
235
- }
236
-
237
- return null;
238
- }
239
-
240
- export async function listWorkflows(cwd = process.cwd()) {
241
- try {
242
- const { join: pathJoin } = await import('path');
243
- const { existsSync: fsExistsSync } = await import('fs');
244
- const { pathToFileURL } = await import('url');
245
-
246
- const localAgentPath = pathJoin(cwd, '.zibby/graph.mjs');
247
-
248
- if (!fsExistsSync(localAgentPath)) {
249
- return { available: [], default: null, error: 'No .zibby/graph.mjs found' };
250
- }
251
-
252
- const agentModule = await import(pathToFileURL(localAgentPath).href);
253
- const available = Object.keys(agentModule).filter(k =>
254
- k !== 'default' &&
255
- typeof agentModule[k] === 'function' &&
256
- agentModule[k].prototype instanceof WorkflowAgent
257
- );
258
-
259
- const defaultWorkflow = agentModule.BrowserTestAutomationAgent ? 'BrowserTestAutomationAgent' :
260
- agentModule.CursorAgent ? 'CursorAgent' :
261
- agentModule.default ? 'default' :
262
- available[0] || null;
263
-
264
- return { available, default: defaultWorkflow, error: null };
265
- } catch (error) {
266
- return { available: [], default: null, error: error.message };
267
- }
268
- }
269
-
270
- async function loadLocalAgent(cwd, config) {
271
- try {
272
- const { join: pathJoin } = await import('path');
273
- const { existsSync: fsExistsSync } = await import('fs');
274
- const { pathToFileURL } = await import('url');
275
-
276
- const localAgentPath = pathJoin(cwd, '.zibby/graph.mjs');
277
-
278
- if (!fsExistsSync(localAgentPath)) {
279
- return { agent: null, error: null };
280
- }
281
-
282
- const agentModule = await import(pathToFileURL(localAgentPath).href);
283
-
284
- const workflowName = config.workflow;
285
- let AgentClass;
286
-
287
- if (workflowName) {
288
- AgentClass = findWorkflow(agentModule, workflowName);
289
- if (!AgentClass) {
290
- const available = Object.keys(agentModule).filter(k => k !== 'default' && typeof agentModule[k] === 'function');
291
- throw new Error(
292
- `Workflow "${workflowName}" not found.\n` +
293
- `Available workflows: ${available.join(', ')}\n` +
294
- `Supported formats: QuickSmokeWorkflow, QuickSmoke, quick-smoke`
295
- );
296
- }
297
- const actualName = Object.keys(agentModule).find(k => agentModule[k] === AgentClass);
298
- console.log(`✓ Using workflow: ${actualName} (from --workflow ${workflowName})`);
299
- } else {
300
- // Try multiple fallbacks for default workflow
301
- AgentClass = agentModule.BrowserTestAutomationAgent ||
302
- agentModule.CursorAgent ||
303
- agentModule.default;
304
-
305
- // If still not found, try to find any workflow class
306
- if (!AgentClass) {
307
- const availableClasses = Object.keys(agentModule).filter(k =>
308
- k !== 'default' &&
309
- typeof agentModule[k] === 'function' &&
310
- agentModule[k].prototype instanceof WorkflowAgent
311
- );
312
- if (availableClasses.length > 0) {
313
- AgentClass = agentModule[availableClasses[0]];
314
- console.log(`✓ Using workflow: ${availableClasses[0]} (auto-detected)`);
315
- }
316
- }
317
-
318
- if (!AgentClass) {
319
- return { agent: null, error: 'Could not find any WorkflowAgent export in local graph.js' };
320
- }
321
-
322
- if (!AgentClass.name?.includes('auto-detected')) {
323
- console.log('✓ Using local agent from .zibby/graph.mjs');
324
- }
325
- }
326
-
327
- return { agent: new AgentClass(config), error: null };
328
- } catch (error) {
329
- return { agent: null, error: error.message };
330
- }
331
- }
332
-
333
- export class TestAutomation {
334
- constructor(config = {}) {
335
- this.config = config;
336
- }
337
-
338
- async run(options) {
339
- return runTest(options.spec || options.specPath, {
340
- ...this.config,
341
- ...options,
342
- });
343
- }
344
- }
345
-
@@ -1,46 +0,0 @@
1
- /**
2
- * Base class for test generation strategies
3
- * Defines the interface that all generation strategies must implement
4
- */
5
- export class TestGenerationStrategy {
6
- /**
7
- * Generate a test file from execution data
8
- * @param {Object} context - Generation context
9
- * @param {string} context.testFilePath - Where to write the test
10
- * @param {string} context.sessionPath - Session data path
11
- * @param {string} context.outputPath - Output file path
12
- * @param {Object} context.state - Workflow state
13
- * @param {Object} context.executionData - Data from execute_live node
14
- * @returns {Promise<Object>} - { success: boolean, testPath: string, method: string }
15
- */
16
- async generate(_context) {
17
- throw new Error('TestGenerationStrategy.generate() must be implemented');
18
- }
19
-
20
- /**
21
- * Check if this strategy can be used with available data
22
- * @param {Object} context - Same context as generate()
23
- * @returns {boolean}
24
- */
25
- canGenerate(_context) {
26
- throw new Error('TestGenerationStrategy.canGenerate() must be implemented');
27
- }
28
-
29
- /**
30
- * Get strategy name for logging
31
- * @returns {string}
32
- */
33
- getName() {
34
- throw new Error('TestGenerationStrategy.getName() must be implemented');
35
- }
36
-
37
- /**
38
- * Get strategy priority (higher = try first)
39
- * @returns {number}
40
- */
41
- getPriority() {
42
- return 0;
43
- }
44
- }
45
-
46
- export default TestGenerationStrategy;
@@ -1,70 +0,0 @@
1
- /**
2
- * Test Generation Strategy Manager
3
- * Automatically selects and runs the best available generation strategy
4
- */
5
- import { MCPRefStrategy } from './mcp-ref-strategy.js';
6
- import { StableIdStrategy } from './stable-id-strategy.js';
7
-
8
- export class TestGenerationStrategyManager {
9
- constructor() {
10
- // Register all available strategies (auto-sorted by priority)
11
- this.strategies = [
12
- new StableIdStrategy(), // Priority 300 - Highest (stable ID injection)
13
- new MCPRefStrategy(), // Priority 200 - Fallback (MCP descriptions)
14
- ];
15
-
16
- // Sort by priority (highest first)
17
- this.strategies.sort((a, b) => b.getPriority() - a.getPriority());
18
- }
19
-
20
- /**
21
- * Add a custom strategy
22
- * @param {TestGenerationStrategy} strategy
23
- */
24
- registerStrategy(strategy) {
25
- this.strategies.push(strategy);
26
- this.strategies.sort((a, b) => b.getPriority() - a.getPriority());
27
- }
28
-
29
- /**
30
- * Generate test using the best available strategy
31
- * @param {Object} context - Generation context
32
- * @returns {Promise<Object>} - Generation result
33
- */
34
- async generate(context) {
35
- console.log(`\n📋 Available generation strategies (${this.strategies.length}):`);
36
- this.strategies.forEach(s => {
37
- const canUse = s.canGenerate(context);
38
- console.log(` ${canUse ? '✓' : '✗'} ${s.getName()} (priority: ${s.getPriority()})`);
39
- });
40
-
41
- // Find first strategy that can generate
42
- for (const strategy of this.strategies) {
43
- if (strategy.canGenerate(context)) {
44
- console.log(`\n🎯 Selected: ${strategy.getName()}`);
45
- return strategy.generate(context);
46
- }
47
- }
48
-
49
- throw new Error('No generation strategy available for this context');
50
- }
51
-
52
- /**
53
- * Get strategy by name
54
- * @param {string} name - Strategy name
55
- * @returns {TestGenerationStrategy|null}
56
- */
57
- getStrategy(name) {
58
- return this.strategies.find(s => s.getName().includes(name)) || null;
59
- }
60
- }
61
-
62
- // Export strategy classes for custom implementations
63
- export { MCPRefStrategy } from './mcp-ref-strategy.js';
64
- export { StableIdStrategy } from './stable-id-strategy.js';
65
- export { TestGenerationStrategy } from './base.js';
66
-
67
- // Export singleton instance
68
- export const testGenerationManager = new TestGenerationStrategyManager();
69
-
70
- export default testGenerationManager;