explorbot 0.0.1 → 0.1.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.
- package/README.md +80 -26
- package/bin/explorbot-cli.ts +680 -0
- package/boat/api-tester/src/ai/chief/styles.ts +15 -0
- package/boat/api-tester/src/ai/chief.ts +335 -0
- package/boat/api-tester/src/ai/curler-tools.ts +278 -0
- package/boat/api-tester/src/ai/curler.ts +306 -0
- package/boat/api-tester/src/api-client.ts +28 -0
- package/boat/api-tester/src/apibot.ts +203 -0
- package/boat/api-tester/src/cli.ts +301 -0
- package/boat/api-tester/src/config.ts +190 -0
- package/dist/bin/explorbot-cli.js +23 -101
- package/dist/boat/api-tester/bin/apibot-cli.js +0 -1
- package/dist/boat/api-tester/src/ai/chief/styles.js +0 -1
- package/dist/boat/api-tester/src/ai/chief.js +0 -1
- package/dist/boat/api-tester/src/ai/curler-tools.js +0 -1
- package/dist/boat/api-tester/src/ai/curler.js +0 -1
- package/dist/boat/api-tester/src/api-client.js +0 -1
- package/dist/boat/api-tester/src/apibot.js +0 -1
- package/dist/boat/api-tester/src/cli.js +0 -1
- package/dist/boat/api-tester/src/config.js +0 -1
- package/dist/src/action-result.js +0 -1
- package/dist/src/action.js +14 -12
- package/dist/src/activity.js +0 -1
- package/dist/src/ai/agent.js +0 -1
- package/dist/src/ai/bosun.js +0 -1
- package/dist/src/ai/captain/idle-mode.js +0 -1
- package/dist/src/ai/captain/mixin.js +0 -1
- package/dist/src/ai/captain/test-mode.js +0 -1
- package/dist/src/ai/captain/web-mode.js +0 -1
- package/dist/src/ai/captain.js +0 -1
- package/dist/src/ai/conversation.js +0 -1
- package/dist/src/ai/experience-compactor.js +0 -1
- package/dist/src/ai/fisherman-tools.js +0 -1
- package/dist/src/ai/fisherman.js +0 -1
- package/dist/src/ai/historian.js +0 -1
- package/dist/src/ai/navigator.js +0 -1
- package/dist/src/ai/pilot.js +0 -1
- package/dist/src/ai/planner/session-dedup.js +0 -1
- package/dist/src/ai/planner/styles.js +0 -1
- package/dist/src/ai/planner/subpages.js +42 -7
- package/dist/src/ai/planner.js +15 -4
- package/dist/src/ai/provider.js +0 -1
- package/dist/src/ai/quartermaster.js +0 -1
- package/dist/src/ai/researcher/cache.js +13 -9
- package/dist/src/ai/researcher/coordinates.js +4 -3
- package/dist/src/ai/researcher/deep-analysis.js +16 -20
- package/dist/src/ai/researcher/fingerprint-worker.js +0 -1
- package/dist/src/ai/researcher/focus.js +0 -1
- package/dist/src/ai/researcher/locators.js +1 -2
- package/dist/src/ai/researcher/mixin.js +0 -1
- package/dist/src/ai/researcher/parser.js +4 -4
- package/dist/src/ai/researcher/research-result.js +2 -1
- package/dist/src/ai/researcher.js +6 -6
- package/dist/src/ai/rules.js +0 -1
- package/dist/src/ai/task-agent.js +0 -1
- package/dist/src/ai/tester.js +0 -1
- package/dist/src/ai/tools.js +4 -1
- package/dist/src/api/api-client.js +0 -1
- package/dist/src/api/request-result.js +0 -1
- package/dist/src/api/request-store.js +0 -1
- package/dist/src/api/spec-reader.js +0 -1
- package/dist/src/api/xhr-capture.js +0 -1
- package/dist/src/browser-server.js +0 -1
- package/dist/src/command-handler.js +0 -1
- package/dist/src/commands/add-rule-command.js +0 -1
- package/dist/src/commands/base-command.js +0 -1
- package/dist/src/commands/clean-command.js +0 -1
- package/dist/src/commands/context-aria-command.js +0 -1
- package/dist/src/commands/context-command.js +2 -3
- package/dist/src/commands/context-data-command.js +0 -1
- package/dist/src/commands/context-experience-command.js +0 -1
- package/dist/src/commands/context-html-command.js +0 -1
- package/dist/src/commands/context-knowledge-command.js +0 -1
- package/dist/src/commands/debug-command.js +0 -1
- package/dist/src/commands/drill-command.js +0 -1
- package/dist/src/commands/exit-command.js +0 -1
- package/dist/src/commands/explore-command.js +3 -3
- package/dist/src/commands/freesail-command.js +0 -1
- package/dist/src/commands/help-command.js +0 -1
- package/dist/src/commands/index.js +0 -1
- package/dist/src/commands/init-command.js +117 -0
- package/dist/src/commands/knows-command.js +0 -1
- package/dist/src/commands/learn-command.js +0 -1
- package/dist/src/commands/navigate-command.js +0 -1
- package/dist/src/commands/path-command.js +0 -1
- package/dist/src/commands/plan-clear-command.js +0 -1
- package/dist/src/commands/plan-command.js +6 -2
- package/dist/src/commands/plan-edit-command.js +0 -1
- package/dist/src/commands/plan-load-command.js +0 -1
- package/dist/src/commands/plan-reload-command.js +0 -1
- package/dist/src/commands/plan-save-command.js +0 -1
- package/dist/src/commands/research-command.js +0 -1
- package/dist/src/commands/start-command.js +0 -1
- package/dist/src/commands/status-command.js +0 -1
- package/dist/src/commands/test-command.js +0 -1
- package/dist/src/components/ActivityPane.js +0 -1
- package/dist/src/components/AddKnowledge.js +0 -1
- package/dist/src/components/AddRule.js +0 -1
- package/dist/src/components/App.js +0 -1
- package/dist/src/components/Autocomplete.js +0 -1
- package/dist/src/components/InputPane.js +0 -1
- package/dist/src/components/InputReadline.js +0 -1
- package/dist/src/components/LogPane.js +0 -1
- package/dist/src/components/PlanEditor.js +0 -1
- package/dist/src/components/PlanPane.js +0 -1
- package/dist/src/components/SessionTimer.js +0 -1
- package/dist/src/components/StateTransitionPane.js +0 -1
- package/dist/src/components/StatusPane.js +0 -1
- package/dist/src/components/TaskPane.js +0 -1
- package/dist/src/components/Welcome.js +0 -1
- package/dist/src/components/WelcomeChecklist.js +0 -1
- package/dist/src/components/WelcomeCommands.js +0 -1
- package/dist/src/components/autocomplete-store.js +0 -1
- package/dist/src/components/parse-keypress.js +0 -1
- package/dist/src/config.js +0 -1
- package/dist/src/execution-controller.js +0 -1
- package/dist/src/experience-tracker.js +0 -1
- package/dist/src/explorbot.js +1 -2
- package/dist/src/explorer.js +58 -17
- package/dist/src/index.js +0 -1
- package/dist/src/knowledge-tracker.js +2 -2
- package/dist/src/observability.js +0 -1
- package/dist/src/reporter.js +0 -1
- package/dist/src/state-manager.js +0 -1
- package/dist/src/stats.js +0 -1
- package/dist/src/test-plan.js +0 -1
- package/dist/src/utils/aria.js +0 -1
- package/dist/src/utils/cli-name.js +16 -0
- package/dist/src/utils/code-extractor.js +0 -1
- package/dist/src/utils/context-formatter.js +0 -1
- package/dist/src/utils/error-page.js +0 -1
- package/dist/src/utils/expandable.js +0 -1
- package/dist/src/utils/hooks-runner.js +0 -1
- package/dist/src/utils/html-diff.js +0 -1
- package/dist/src/utils/html.js +0 -1
- package/dist/src/utils/logger.js +0 -1
- package/dist/src/utils/loop.js +0 -1
- package/dist/src/utils/markdown-parser.js +0 -1
- package/dist/src/utils/markdown-query.js +0 -1
- package/dist/src/utils/markdown-terminal.js +0 -1
- package/dist/src/utils/research-parser.js +0 -1
- package/dist/src/utils/retry.js +0 -1
- package/dist/src/utils/rules-loader.js +0 -1
- package/dist/src/utils/strings.js +0 -1
- package/dist/src/utils/test-plan-markdown.js +0 -1
- package/dist/src/utils/throttle.js +0 -1
- package/dist/src/utils/unique-names.js +0 -1
- package/dist/src/utils/url-matcher.js +0 -1
- package/dist/src/utils/web-element.js +6 -5
- package/dist/src/utils/xpath.js +0 -1
- package/package.json +28 -4
- package/src/action-result.ts +694 -0
- package/src/action.ts +449 -0
- package/src/activity.ts +111 -0
- package/src/ai/agent.ts +3 -0
- package/src/ai/bosun.ts +557 -0
- package/src/ai/captain/idle-mode.ts +116 -0
- package/src/ai/captain/mixin.ts +22 -0
- package/src/ai/captain/test-mode.ts +262 -0
- package/src/ai/captain/web-mode.ts +136 -0
- package/src/ai/captain.ts +504 -0
- package/src/ai/conversation.ts +205 -0
- package/src/ai/experience-compactor.ts +284 -0
- package/src/ai/fisherman-tools.ts +181 -0
- package/src/ai/fisherman.ts +223 -0
- package/src/ai/historian.ts +457 -0
- package/src/ai/navigator.ts +572 -0
- package/src/ai/pilot.ts +776 -0
- package/src/ai/planner/session-dedup.ts +35 -0
- package/src/ai/planner/styles.ts +17 -0
- package/src/ai/planner/subpages.ts +171 -0
- package/src/ai/planner.ts +549 -0
- package/src/ai/provider.ts +613 -0
- package/src/ai/quartermaster.ts +286 -0
- package/src/ai/researcher/cache.ts +109 -0
- package/src/ai/researcher/coordinates.ts +239 -0
- package/src/ai/researcher/deep-analysis.ts +412 -0
- package/src/ai/researcher/fingerprint-worker.ts +59 -0
- package/src/ai/researcher/focus.ts +42 -0
- package/src/ai/researcher/locators.ts +282 -0
- package/src/ai/researcher/mixin.ts +4 -0
- package/src/ai/researcher/parser.ts +186 -0
- package/src/ai/researcher/research-result.ts +116 -0
- package/src/ai/researcher.ts +858 -0
- package/src/ai/rules.ts +376 -0
- package/src/ai/task-agent.ts +141 -0
- package/src/ai/tester.ts +939 -0
- package/src/ai/tools.ts +1122 -0
- package/src/api/api-client.ts +109 -0
- package/src/api/request-result.ts +212 -0
- package/src/api/request-store.ts +130 -0
- package/src/api/spec-reader.ts +174 -0
- package/src/api/xhr-capture.ts +100 -0
- package/src/browser-server.ts +74 -0
- package/src/command-handler.ts +454 -0
- package/src/commands/add-rule-command.ts +63 -0
- package/src/commands/base-command.ts +27 -0
- package/src/commands/clean-command.ts +73 -0
- package/src/commands/context-aria-command.ts +22 -0
- package/src/commands/context-command.ts +67 -0
- package/src/commands/context-data-command.ts +30 -0
- package/src/commands/context-experience-command.ts +48 -0
- package/src/commands/context-html-command.ts +33 -0
- package/src/commands/context-knowledge-command.ts +43 -0
- package/src/commands/debug-command.ts +13 -0
- package/src/commands/drill-command.ts +34 -0
- package/src/commands/exit-command.ts +32 -0
- package/src/commands/explore-command.ts +129 -0
- package/src/commands/freesail-command.ts +95 -0
- package/src/commands/help-command.ts +8 -0
- package/src/commands/index.ts +69 -0
- package/src/commands/init-command.ts +131 -0
- package/src/commands/knows-command.ts +68 -0
- package/src/commands/learn-command.ts +44 -0
- package/src/commands/navigate-command.ts +18 -0
- package/src/commands/path-command.ts +83 -0
- package/src/commands/plan-clear-command.ts +14 -0
- package/src/commands/plan-command.ts +46 -0
- package/src/commands/plan-edit-command.ts +9 -0
- package/src/commands/plan-load-command.ts +18 -0
- package/src/commands/plan-reload-command.ts +28 -0
- package/src/commands/plan-save-command.ts +25 -0
- package/src/commands/research-command.ts +45 -0
- package/src/commands/start-command.ts +13 -0
- package/src/commands/status-command.tsx +23 -0
- package/src/commands/test-command.ts +84 -0
- package/src/components/ActivityPane.tsx +80 -0
- package/src/components/AddKnowledge.tsx +169 -0
- package/src/components/AddRule.tsx +174 -0
- package/src/components/App.tsx +377 -0
- package/src/components/Autocomplete.tsx +63 -0
- package/src/components/InputPane.tsx +259 -0
- package/src/components/InputReadline.tsx +704 -0
- package/src/components/LogPane.tsx +187 -0
- package/src/components/PlanEditor.tsx +150 -0
- package/src/components/PlanPane.tsx +71 -0
- package/src/components/SessionTimer.tsx +35 -0
- package/src/components/StateTransitionPane.tsx +149 -0
- package/src/components/StatusPane.tsx +62 -0
- package/src/components/TaskPane.tsx +119 -0
- package/src/components/Welcome.tsx +83 -0
- package/src/components/WelcomeChecklist.tsx +118 -0
- package/src/components/WelcomeCommands.tsx +102 -0
- package/src/components/autocomplete-store.ts +35 -0
- package/src/components/parse-keypress.ts +170 -0
- package/src/config.ts +491 -0
- package/src/execution-controller.ts +109 -0
- package/src/experience-tracker.ts +350 -0
- package/src/explorbot.ts +405 -0
- package/src/explorer.ts +760 -0
- package/src/index.tsx +62 -0
- package/src/knowledge-tracker.ts +230 -0
- package/src/observability.ts +150 -0
- package/src/reporter.ts +224 -0
- package/src/state-manager.ts +556 -0
- package/src/stats.ts +53 -0
- package/src/test-plan.ts +432 -0
- package/src/utils/aria.ts +629 -0
- package/src/utils/cli-name.ts +13 -0
- package/src/utils/code-extractor.ts +22 -0
- package/src/utils/context-formatter.ts +239 -0
- package/src/utils/error-page.ts +23 -0
- package/src/utils/expandable.ts +38 -0
- package/src/utils/hooks-runner.ts +79 -0
- package/src/utils/html-diff.ts +918 -0
- package/src/utils/html.ts +1316 -0
- package/src/utils/logger.ts +534 -0
- package/src/utils/loop.ts +176 -0
- package/src/utils/markdown-parser.ts +127 -0
- package/src/utils/markdown-query.ts +466 -0
- package/src/utils/markdown-terminal.ts +43 -0
- package/src/utils/research-parser.ts +11 -0
- package/src/utils/retry.ts +73 -0
- package/src/utils/rules-loader.ts +118 -0
- package/src/utils/strings.ts +13 -0
- package/src/utils/test-plan-markdown.ts +332 -0
- package/src/utils/throttle.ts +18 -0
- package/src/utils/unique-names.ts +14 -0
- package/src/utils/url-matcher.ts +45 -0
- package/src/utils/web-element.ts +147 -0
- package/src/utils/xpath.ts +129 -0
- package/dist/bin/explorbot-cli.js.map +0 -1
- package/dist/boat/api-tester/bin/apibot-cli.js.map +0 -1
- package/dist/boat/api-tester/example/apibot.config.js +0 -31
- package/dist/boat/api-tester/example/apibot.config.js.map +0 -1
- package/dist/boat/api-tester/src/ai/chief/styles.js.map +0 -1
- package/dist/boat/api-tester/src/ai/chief.js.map +0 -1
- package/dist/boat/api-tester/src/ai/curler-tools.js.map +0 -1
- package/dist/boat/api-tester/src/ai/curler.js.map +0 -1
- package/dist/boat/api-tester/src/api-client.js.map +0 -1
- package/dist/boat/api-tester/src/apibot.js.map +0 -1
- package/dist/boat/api-tester/src/cli.js.map +0 -1
- package/dist/boat/api-tester/src/config.js.map +0 -1
- package/dist/prompts/audit-rules.md +0 -124
- package/dist/src/action-result.js.map +0 -1
- package/dist/src/action.js.map +0 -1
- package/dist/src/activity.js.map +0 -1
- package/dist/src/ai/agent.js.map +0 -1
- package/dist/src/ai/bosun.js.map +0 -1
- package/dist/src/ai/captain/idle-mode.js.map +0 -1
- package/dist/src/ai/captain/mixin.js.map +0 -1
- package/dist/src/ai/captain/test-mode.js.map +0 -1
- package/dist/src/ai/captain/web-mode.js.map +0 -1
- package/dist/src/ai/captain.js.map +0 -1
- package/dist/src/ai/conversation.js.map +0 -1
- package/dist/src/ai/experience-compactor.js.map +0 -1
- package/dist/src/ai/fisherman-tools.js.map +0 -1
- package/dist/src/ai/fisherman.js.map +0 -1
- package/dist/src/ai/historian.js.map +0 -1
- package/dist/src/ai/navigator.js.map +0 -1
- package/dist/src/ai/pilot.js.map +0 -1
- package/dist/src/ai/planner/session-dedup.js.map +0 -1
- package/dist/src/ai/planner/styles.js.map +0 -1
- package/dist/src/ai/planner/subpages.js.map +0 -1
- package/dist/src/ai/planner.js.map +0 -1
- package/dist/src/ai/provider.js.map +0 -1
- package/dist/src/ai/quartermaster.js.map +0 -1
- package/dist/src/ai/researcher/cache.js.map +0 -1
- package/dist/src/ai/researcher/coordinates.js.map +0 -1
- package/dist/src/ai/researcher/deep-analysis.js.map +0 -1
- package/dist/src/ai/researcher/fingerprint-worker.js.map +0 -1
- package/dist/src/ai/researcher/focus.js.map +0 -1
- package/dist/src/ai/researcher/locators.js.map +0 -1
- package/dist/src/ai/researcher/mixin.js.map +0 -1
- package/dist/src/ai/researcher/parser.js.map +0 -1
- package/dist/src/ai/researcher/research-result.js.map +0 -1
- package/dist/src/ai/researcher.js.map +0 -1
- package/dist/src/ai/rules.js.map +0 -1
- package/dist/src/ai/task-agent.js.map +0 -1
- package/dist/src/ai/tester.js.map +0 -1
- package/dist/src/ai/tools.js.map +0 -1
- package/dist/src/api/api-client.js.map +0 -1
- package/dist/src/api/request-result.js.map +0 -1
- package/dist/src/api/request-store.js.map +0 -1
- package/dist/src/api/spec-reader.js.map +0 -1
- package/dist/src/api/xhr-capture.js.map +0 -1
- package/dist/src/browser-server.js.map +0 -1
- package/dist/src/command-handler.js.map +0 -1
- package/dist/src/commands/add-rule-command.js.map +0 -1
- package/dist/src/commands/base-command.js.map +0 -1
- package/dist/src/commands/clean-command.js.map +0 -1
- package/dist/src/commands/context-aria-command.js.map +0 -1
- package/dist/src/commands/context-command.js.map +0 -1
- package/dist/src/commands/context-data-command.js.map +0 -1
- package/dist/src/commands/context-experience-command.js.map +0 -1
- package/dist/src/commands/context-html-command.js.map +0 -1
- package/dist/src/commands/context-knowledge-command.js.map +0 -1
- package/dist/src/commands/debug-command.js.map +0 -1
- package/dist/src/commands/drill-command.js.map +0 -1
- package/dist/src/commands/exit-command.js.map +0 -1
- package/dist/src/commands/explore-command.js.map +0 -1
- package/dist/src/commands/freesail-command.js.map +0 -1
- package/dist/src/commands/help-command.js.map +0 -1
- package/dist/src/commands/index.js.map +0 -1
- package/dist/src/commands/knows-command.js.map +0 -1
- package/dist/src/commands/learn-command.js.map +0 -1
- package/dist/src/commands/navigate-command.js.map +0 -1
- package/dist/src/commands/path-command.js.map +0 -1
- package/dist/src/commands/plan-clear-command.js.map +0 -1
- package/dist/src/commands/plan-command.js.map +0 -1
- package/dist/src/commands/plan-edit-command.js.map +0 -1
- package/dist/src/commands/plan-load-command.js.map +0 -1
- package/dist/src/commands/plan-reload-command.js.map +0 -1
- package/dist/src/commands/plan-save-command.js.map +0 -1
- package/dist/src/commands/research-command.js.map +0 -1
- package/dist/src/commands/start-command.js.map +0 -1
- package/dist/src/commands/status-command.js.map +0 -1
- package/dist/src/commands/test-command.js.map +0 -1
- package/dist/src/components/ActivityPane.js.map +0 -1
- package/dist/src/components/AddKnowledge.js.map +0 -1
- package/dist/src/components/AddRule.js.map +0 -1
- package/dist/src/components/App.js.map +0 -1
- package/dist/src/components/Autocomplete.js.map +0 -1
- package/dist/src/components/InputPane.js.map +0 -1
- package/dist/src/components/InputReadline.js.map +0 -1
- package/dist/src/components/LogPane.js.map +0 -1
- package/dist/src/components/PlanEditor.js.map +0 -1
- package/dist/src/components/PlanPane.js.map +0 -1
- package/dist/src/components/SessionTimer.js.map +0 -1
- package/dist/src/components/StateTransitionPane.js.map +0 -1
- package/dist/src/components/StatusPane.js.map +0 -1
- package/dist/src/components/TaskPane.js.map +0 -1
- package/dist/src/components/Welcome.js.map +0 -1
- package/dist/src/components/WelcomeChecklist.js.map +0 -1
- package/dist/src/components/WelcomeCommands.js.map +0 -1
- package/dist/src/components/autocomplete-store.js.map +0 -1
- package/dist/src/components/parse-keypress.js.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/execution-controller.js.map +0 -1
- package/dist/src/experience-tracker.js.map +0 -1
- package/dist/src/explorbot.js.map +0 -1
- package/dist/src/explorer.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/knowledge-tracker.js.map +0 -1
- package/dist/src/observability.js.map +0 -1
- package/dist/src/reporter.js.map +0 -1
- package/dist/src/state-manager.js.map +0 -1
- package/dist/src/stats.js.map +0 -1
- package/dist/src/test-plan.js.map +0 -1
- package/dist/src/utils/aria.js.map +0 -1
- package/dist/src/utils/code-extractor.js.map +0 -1
- package/dist/src/utils/context-formatter.js.map +0 -1
- package/dist/src/utils/error-page.js.map +0 -1
- package/dist/src/utils/expandable.js.map +0 -1
- package/dist/src/utils/hooks-runner.js.map +0 -1
- package/dist/src/utils/html-diff.js.map +0 -1
- package/dist/src/utils/html.js.map +0 -1
- package/dist/src/utils/logger.js.map +0 -1
- package/dist/src/utils/loop.js.map +0 -1
- package/dist/src/utils/markdown-parser.js.map +0 -1
- package/dist/src/utils/markdown-query.js.map +0 -1
- package/dist/src/utils/markdown-terminal.js.map +0 -1
- package/dist/src/utils/research-parser.js.map +0 -1
- package/dist/src/utils/retry.js.map +0 -1
- package/dist/src/utils/rules-loader.js.map +0 -1
- package/dist/src/utils/strings.js.map +0 -1
- package/dist/src/utils/test-plan-markdown.js.map +0 -1
- package/dist/src/utils/throttle.js.map +0 -1
- package/dist/src/utils/unique-names.js.map +0 -1
- package/dist/src/utils/url-matcher.js.map +0 -1
- package/dist/src/utils/web-element.js.map +0 -1
- package/dist/src/utils/xpath.js.map +0 -1
- package/prompts/audit-rules.md +0 -124
package/src/index.tsx
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { addKnowledgeCommand } from './commands/add-knowledge.js';
|
|
4
|
+
import { cleanCommand } from './commands/clean.js';
|
|
5
|
+
import { exploreCommand } from './commands/explore.js';
|
|
6
|
+
import { initCommand } from './commands/init.js';
|
|
7
|
+
|
|
8
|
+
const program = new Command();
|
|
9
|
+
|
|
10
|
+
program
|
|
11
|
+
.name('explorbot')
|
|
12
|
+
.description('AI-powered web exploration tool')
|
|
13
|
+
.option('-f, --from <url>', 'Start exploration from a specific URL')
|
|
14
|
+
.option('-v, --verbose', 'Enable verbose logging')
|
|
15
|
+
.option('--debug', 'Enable debug logging (same as --verbose)')
|
|
16
|
+
.option('-c, --config <path>', 'Path to configuration file')
|
|
17
|
+
.option('-p, --path <path>', 'Working directory path')
|
|
18
|
+
.helpOption('-h, --help', 'Show this help message');
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command('clean')
|
|
22
|
+
.description('Clean up artifacts or experience folders')
|
|
23
|
+
.option('-t, --type <type>', 'Type of cleanup (artifacts|experience|all)', 'artifacts')
|
|
24
|
+
.option('-p, --path <path>', 'Custom path to clean')
|
|
25
|
+
.action(async (options, command) => {
|
|
26
|
+
const globalOptions = command.parent.opts();
|
|
27
|
+
const allOptions = { ...globalOptions, ...options };
|
|
28
|
+
await cleanCommand(allOptions);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.command('init')
|
|
33
|
+
.description('Initialize a new project with configuration')
|
|
34
|
+
.option('-c, --config-path <path>', 'Path for the config file', './explorbot.config.js')
|
|
35
|
+
.option('-f, --force', 'Overwrite existing config file', false)
|
|
36
|
+
.option('-p, --path <path>', 'Working directory for initialization')
|
|
37
|
+
.action(async (options, command) => {
|
|
38
|
+
const globalOptions = command.parent.opts();
|
|
39
|
+
const allOptions = { ...globalOptions, ...options };
|
|
40
|
+
await initCommand(allOptions);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
program
|
|
44
|
+
.command('add-knowledge')
|
|
45
|
+
.alias('learn')
|
|
46
|
+
.description('Add knowledge for specific URLs')
|
|
47
|
+
.option('-p, --path <path>', 'Knowledge directory path')
|
|
48
|
+
.action(async (options) => {
|
|
49
|
+
await addKnowledgeCommand(options);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
program.parse();
|
|
53
|
+
|
|
54
|
+
const options = program.opts();
|
|
55
|
+
const command = program.args[0];
|
|
56
|
+
|
|
57
|
+
if (command === 'clean' || command === 'init' || command === 'add-knowledge' || command === 'learn') {
|
|
58
|
+
// These commands are handled by their respective actions
|
|
59
|
+
} else {
|
|
60
|
+
// Default to explore command
|
|
61
|
+
exploreCommand(options);
|
|
62
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
import { ActionResult } from './action-result.js';
|
|
5
|
+
import { ConfigParser } from './config.js';
|
|
6
|
+
import { getCliName } from './utils/cli-name.ts';
|
|
7
|
+
import { createDebug } from './utils/logger.js';
|
|
8
|
+
|
|
9
|
+
const debugLog = createDebug('explorbot:knowledge-tracker');
|
|
10
|
+
|
|
11
|
+
interface Knowledge {
|
|
12
|
+
filePath: string;
|
|
13
|
+
url: string;
|
|
14
|
+
content: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class KnowledgeTracker {
|
|
19
|
+
private knowledgeDir: string;
|
|
20
|
+
private knowledgeFiles: Knowledge[] = [];
|
|
21
|
+
private isLoaded = false;
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
const configParser = ConfigParser.getInstance();
|
|
25
|
+
const config = configParser.getConfig();
|
|
26
|
+
const configPath = configParser.getConfigPath();
|
|
27
|
+
|
|
28
|
+
if (configPath) {
|
|
29
|
+
const projectRoot = dirname(configPath);
|
|
30
|
+
this.knowledgeDir = join(projectRoot, config.dirs?.knowledge || 'knowledge');
|
|
31
|
+
} else {
|
|
32
|
+
this.knowledgeDir = config.dirs?.knowledge || 'knowledge';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!existsSync(this.knowledgeDir)) {
|
|
36
|
+
mkdirSync(this.knowledgeDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private loadKnowledgeFiles(): void {
|
|
41
|
+
if (this.isLoaded) return;
|
|
42
|
+
|
|
43
|
+
this.knowledgeFiles = [];
|
|
44
|
+
|
|
45
|
+
if (!existsSync(this.knowledgeDir)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const files = readdirSync(this.knowledgeDir)
|
|
50
|
+
.filter((file) => file.endsWith('.md'))
|
|
51
|
+
.map((file) => join(this.knowledgeDir, file));
|
|
52
|
+
|
|
53
|
+
for (const filePath of files) {
|
|
54
|
+
try {
|
|
55
|
+
const fileContent = readFileSync(filePath, 'utf8');
|
|
56
|
+
const parsed = matter(fileContent);
|
|
57
|
+
const urlPattern = parsed.data.url || parsed.data.path || '*';
|
|
58
|
+
|
|
59
|
+
this.knowledgeFiles.push({
|
|
60
|
+
filePath,
|
|
61
|
+
url: urlPattern,
|
|
62
|
+
content: this.interpolateVars(parsed.content),
|
|
63
|
+
...parsed.data,
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
// Skip invalid files
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.isLoaded = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getRelevantKnowledge(state: ActionResult): Knowledge[] {
|
|
74
|
+
this.loadKnowledgeFiles();
|
|
75
|
+
|
|
76
|
+
return this.knowledgeFiles.filter((knowledge) => {
|
|
77
|
+
return state.isMatchedBy(knowledge);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
addKnowledge(urlPattern: string, description: string): { filename: string; filePath: string; isNewFile: boolean } {
|
|
82
|
+
const configParser = ConfigParser.getInstance();
|
|
83
|
+
const config = configParser.getConfig();
|
|
84
|
+
const configPath = configParser.getConfigPath();
|
|
85
|
+
|
|
86
|
+
if (!configPath) {
|
|
87
|
+
throw new Error(`No explorbot configuration found. Please run "${getCliName()} init" first.`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const projectRoot = dirname(configPath);
|
|
91
|
+
const knowledgeDir = join(projectRoot, config.dirs?.knowledge || 'knowledge');
|
|
92
|
+
|
|
93
|
+
if (!existsSync(knowledgeDir)) {
|
|
94
|
+
mkdirSync(knowledgeDir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const normalizedUrl = this.normalizeUrl(urlPattern);
|
|
98
|
+
const filename = this.generateFilename(normalizedUrl);
|
|
99
|
+
const filePath = join(knowledgeDir, filename);
|
|
100
|
+
|
|
101
|
+
const isNewFile = !existsSync(filePath);
|
|
102
|
+
|
|
103
|
+
if (isNewFile) {
|
|
104
|
+
const frontmatter = {
|
|
105
|
+
url: normalizedUrl,
|
|
106
|
+
title: '', // Can be populated later
|
|
107
|
+
};
|
|
108
|
+
const fileContent = matter.stringify(description, frontmatter);
|
|
109
|
+
writeFileSync(filePath, fileContent, 'utf8');
|
|
110
|
+
} else {
|
|
111
|
+
const existingContent = readFileSync(filePath, 'utf8');
|
|
112
|
+
const parsed = matter(existingContent);
|
|
113
|
+
|
|
114
|
+
// Update URL in frontmatter if different
|
|
115
|
+
const frontmatter = { ...parsed.data, url: normalizedUrl };
|
|
116
|
+
const existingDescription = parsed.content.trim();
|
|
117
|
+
|
|
118
|
+
// Append new knowledge with separator
|
|
119
|
+
let newContent;
|
|
120
|
+
if (existingDescription) {
|
|
121
|
+
newContent = `${existingDescription}\n\n---\n\n${description}`;
|
|
122
|
+
} else {
|
|
123
|
+
newContent = description;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const fileContent = matter.stringify(newContent, frontmatter);
|
|
127
|
+
writeFileSync(filePath, fileContent, 'utf8');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { filename, filePath, isNewFile };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private interpolateVars(content: string): string {
|
|
134
|
+
return content.replace(/\$\{([^}]+)\}/g, (match, expr: string) => {
|
|
135
|
+
const dotIndex = expr.indexOf('.');
|
|
136
|
+
if (dotIndex === -1) return match;
|
|
137
|
+
|
|
138
|
+
const namespace = expr.slice(0, dotIndex);
|
|
139
|
+
const key = expr.slice(dotIndex + 1);
|
|
140
|
+
|
|
141
|
+
if (namespace === 'env') return process.env[key] ?? '';
|
|
142
|
+
|
|
143
|
+
if (namespace === 'config') {
|
|
144
|
+
const config = ConfigParser.getInstance().getConfig();
|
|
145
|
+
const value = key.split('.').reduce((obj: any, k) => obj?.[k], config);
|
|
146
|
+
if (value !== undefined && typeof value !== 'object') return String(value);
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return match;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private generateFilename(url: string): string {
|
|
155
|
+
let filename = url
|
|
156
|
+
.replace(/https?:\/\//g, '')
|
|
157
|
+
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
158
|
+
.replace(/_+/g, '_')
|
|
159
|
+
.replace(/^_|_$/g, '')
|
|
160
|
+
.toLowerCase();
|
|
161
|
+
|
|
162
|
+
if (!filename || filename === '*') {
|
|
163
|
+
filename = 'general';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!filename.endsWith('.md')) {
|
|
167
|
+
filename += '.md';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return filename;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getExistingUrls(): string[] {
|
|
174
|
+
this.loadKnowledgeFiles();
|
|
175
|
+
|
|
176
|
+
return this.knowledgeFiles.map((knowledge) => knowledge.url).filter((url) => url && url !== '*');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
getKnowledgeForUrl(urlPattern: string): string[] {
|
|
180
|
+
this.loadKnowledgeFiles();
|
|
181
|
+
const normalizedUrl = this.normalizeUrl(urlPattern);
|
|
182
|
+
|
|
183
|
+
return this.knowledgeFiles.filter((knowledge) => knowledge.url === normalizedUrl).map((knowledge) => knowledge.content.trim());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
listAllKnowledge(): Array<{ url: string; firstLine: string; filePath: string }> {
|
|
187
|
+
this.loadKnowledgeFiles();
|
|
188
|
+
|
|
189
|
+
return this.knowledgeFiles.map((knowledge) => {
|
|
190
|
+
const content = knowledge.content.trim();
|
|
191
|
+
const firstLine = content.split('\n')[0]?.trim() || '';
|
|
192
|
+
return {
|
|
193
|
+
url: knowledge.url,
|
|
194
|
+
firstLine,
|
|
195
|
+
filePath: knowledge.filePath,
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
getMatchingKnowledge(url: string): Knowledge[] {
|
|
201
|
+
this.loadKnowledgeFiles();
|
|
202
|
+
const state = new ActionResult({ url });
|
|
203
|
+
return this.getRelevantKnowledge(state);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
normalizeUrl(url: string): string {
|
|
207
|
+
const trimmed = url.trim();
|
|
208
|
+
|
|
209
|
+
if (!trimmed) {
|
|
210
|
+
throw new Error('URL pattern cannot be empty');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return trimmed;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
getStateParameters(state: ActionResult, keys: string[]) {
|
|
217
|
+
const relevantKnowledge = this.getRelevantKnowledge(state);
|
|
218
|
+
const result: Record<string, any> = {};
|
|
219
|
+
|
|
220
|
+
for (const key of keys) {
|
|
221
|
+
for (const knowledge of relevantKnowledge) {
|
|
222
|
+
if (knowledge[key] !== undefined && result[key] === undefined) {
|
|
223
|
+
result[key] = knowledge[key];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { type Span, context, trace } from '@opentelemetry/api';
|
|
3
|
+
|
|
4
|
+
type TelemetryMetadata = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
type TelemetryState = {
|
|
7
|
+
metadata: TelemetryMetadata;
|
|
8
|
+
traceId: string;
|
|
9
|
+
updateParent: boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
span?: Span;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let current: TelemetryState | null = null;
|
|
15
|
+
let depth = 0;
|
|
16
|
+
|
|
17
|
+
export const Observability = {
|
|
18
|
+
async run<T>(name: string, metadata: TelemetryMetadata, fn: () => Promise<T>): Promise<T> {
|
|
19
|
+
const started = Observability.startTrace(name, metadata);
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
if (!started) {
|
|
23
|
+
const parentSpan = current?.span;
|
|
24
|
+
if (!parentSpan || !current) return await fn();
|
|
25
|
+
|
|
26
|
+
const tracer = trace.getTracer('ai');
|
|
27
|
+
const childSpan = tracer.startSpan(name, undefined, trace.setSpan(context.active(), parentSpan));
|
|
28
|
+
const savedSpan = current.span;
|
|
29
|
+
const savedName = current.name;
|
|
30
|
+
current.span = childSpan;
|
|
31
|
+
current.name = name;
|
|
32
|
+
return await context.with(trace.setSpan(context.active(), childSpan), async () => {
|
|
33
|
+
try {
|
|
34
|
+
return await fn();
|
|
35
|
+
} finally {
|
|
36
|
+
childSpan.end();
|
|
37
|
+
current!.span = savedSpan;
|
|
38
|
+
current!.name = savedName;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const tracer = trace.getTracer('ai');
|
|
44
|
+
const spanContext = {
|
|
45
|
+
traceId: current?.traceId || randomBytes(16).toString('hex'),
|
|
46
|
+
spanId: randomBytes(8).toString('hex'),
|
|
47
|
+
traceFlags: 1,
|
|
48
|
+
};
|
|
49
|
+
const rootContext = trace.setSpanContext(context.active(), spanContext);
|
|
50
|
+
|
|
51
|
+
const initSpan = tracer.startSpan(name, undefined, rootContext);
|
|
52
|
+
initSpan.setAttribute('langfuse.trace.name', name);
|
|
53
|
+
initSpan.setAttribute('langfuse.trace.id', current?.traceId || '');
|
|
54
|
+
if (current?.metadata?.sessionId) {
|
|
55
|
+
initSpan.setAttribute('langfuse.trace.session_id', String(current.metadata.sessionId));
|
|
56
|
+
}
|
|
57
|
+
if (current?.metadata?.userId) {
|
|
58
|
+
initSpan.setAttribute('langfuse.trace.user_id', String(current.metadata.userId));
|
|
59
|
+
}
|
|
60
|
+
if (current?.metadata?.tags && Array.isArray(current.metadata.tags)) {
|
|
61
|
+
initSpan.setAttribute('langfuse.trace.tags', current.metadata.tags);
|
|
62
|
+
}
|
|
63
|
+
if (current?.metadata?.input) {
|
|
64
|
+
initSpan.setAttribute('langfuse.trace.input', JSON.stringify(current.metadata.input));
|
|
65
|
+
}
|
|
66
|
+
initSpan.end();
|
|
67
|
+
|
|
68
|
+
const span = tracer.startSpan(name, undefined, rootContext);
|
|
69
|
+
current.span = span;
|
|
70
|
+
|
|
71
|
+
return await context.with(trace.setSpan(rootContext, span), async () => {
|
|
72
|
+
try {
|
|
73
|
+
return await fn();
|
|
74
|
+
} finally {
|
|
75
|
+
span.end();
|
|
76
|
+
current.span = undefined;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} finally {
|
|
80
|
+
Observability.endTrace(started);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
startTrace(name: string, metadata: TelemetryMetadata) {
|
|
85
|
+
if (current) {
|
|
86
|
+
depth += 1;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const langfuseTraceId = metadata.langfuseTraceId || randomBytes(16).toString('hex');
|
|
91
|
+
current = {
|
|
92
|
+
metadata: {
|
|
93
|
+
...metadata,
|
|
94
|
+
langfuseTraceId,
|
|
95
|
+
},
|
|
96
|
+
traceId: langfuseTraceId,
|
|
97
|
+
updateParent: true,
|
|
98
|
+
name,
|
|
99
|
+
};
|
|
100
|
+
depth = 1;
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
endTrace(started: boolean) {
|
|
105
|
+
if (!current) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!started) {
|
|
110
|
+
depth -= 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
depth -= 1;
|
|
115
|
+
if (depth <= 0) {
|
|
116
|
+
current = null;
|
|
117
|
+
depth = 0;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
getTelemetry() {
|
|
122
|
+
if (!current) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const telemetry = {
|
|
127
|
+
isEnabled: true,
|
|
128
|
+
functionId: current.name,
|
|
129
|
+
metadata: {
|
|
130
|
+
...current.metadata,
|
|
131
|
+
langfuseTraceId: current.traceId,
|
|
132
|
+
langfuseUpdateParent: current.updateParent,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (current.updateParent) {
|
|
137
|
+
current.updateParent = false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return telemetry;
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
isTracing() {
|
|
144
|
+
return Boolean(current);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
getSpan() {
|
|
148
|
+
return current?.span;
|
|
149
|
+
},
|
|
150
|
+
};
|
package/src/reporter.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { Client } from '@testomatio/reporter';
|
|
3
|
+
import type { Step } from '@testomatio/reporter/types/types.js';
|
|
4
|
+
import { ConfigParser, outputPath } from './config.js';
|
|
5
|
+
import type { ReporterConfig } from './config.js';
|
|
6
|
+
import { Test } from './test-plan.js';
|
|
7
|
+
import { createDebug } from './utils/logger.js';
|
|
8
|
+
|
|
9
|
+
export type ReporterMeta = Record<string, string | undefined>;
|
|
10
|
+
|
|
11
|
+
const debugLog = createDebug('explorbot:reporter');
|
|
12
|
+
|
|
13
|
+
export interface ReporterStep {
|
|
14
|
+
title: string;
|
|
15
|
+
status: 'passed' | 'failed';
|
|
16
|
+
code: string[];
|
|
17
|
+
discovery?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class Reporter {
|
|
21
|
+
private client: Client;
|
|
22
|
+
private isRunStarted = false;
|
|
23
|
+
private reporterEnabled: boolean;
|
|
24
|
+
|
|
25
|
+
constructor(config?: ReporterConfig) {
|
|
26
|
+
this.reporterEnabled = Reporter.resolveEnabled(config);
|
|
27
|
+
|
|
28
|
+
if (this.reporterEnabled && (!process.env.TESTOMATIO || config?.html)) {
|
|
29
|
+
this.configureHtmlPipe();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.client = new Client({ apiKey: process.env.TESTOMATIO || '' });
|
|
33
|
+
const pipe = process.env.TESTOMATIO && config?.html ? 'both' : process.env.TESTOMATIO ? 'testomatio' : 'html';
|
|
34
|
+
debugLog('Reporter initialized', { enabled: this.reporterEnabled, pipe });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static resolveEnabled(config?: ReporterConfig): boolean {
|
|
38
|
+
if (config?.enabled === true) return true;
|
|
39
|
+
if (config?.enabled === false) return false;
|
|
40
|
+
return Boolean(process.env.TESTOMATIO);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private configureHtmlPipe(): void {
|
|
44
|
+
process.env.TESTOMATIO_HTML_REPORT_SAVE = '1';
|
|
45
|
+
process.env.TESTOMATIO_HTML_REPORT_FOLDER = outputPath('reports');
|
|
46
|
+
debugLog('HTML report pipe configured', { folder: process.env.TESTOMATIO_HTML_REPORT_FOLDER });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async startRun(): Promise<void> {
|
|
50
|
+
if (this.isRunStarted) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!this.reporterEnabled) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const timeoutMs = Number(process.env.TESTOMATIO_TIMEOUT_MS || '15000');
|
|
60
|
+
const timeoutPromise = new Promise<'timeout'>((resolve) => setTimeout(() => resolve('timeout'), timeoutMs));
|
|
61
|
+
|
|
62
|
+
const result = await Promise.race([this.client.createRun().then(() => 'success' as const), timeoutPromise]);
|
|
63
|
+
|
|
64
|
+
if (result === 'timeout') {
|
|
65
|
+
debugLog('Reporter run creation timed out');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (process.env.TESTOMATIO && !this.client.runId) {
|
|
70
|
+
debugLog('Testomat.io run creation failed - no runId received');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.isRunStarted = true;
|
|
75
|
+
debugLog('Reporter run started', { runId: this.client.runId || 'html-only' });
|
|
76
|
+
} catch (error) {
|
|
77
|
+
debugLog('Failed to start reporter:', error);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
process.env.TESTOMATIO_STACK_PASSED = 'true';
|
|
82
|
+
process.env.TESTOMATIO_STEPS_PASSED = 'true';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async reportTestStart(test: Test): Promise<void> {
|
|
86
|
+
await this.startRun();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected combineStepsAndNotes(test: Test, lastScreenshotFile?: string): Step[] {
|
|
90
|
+
const noteEntries = Object.entries(test.notes)
|
|
91
|
+
.map(([timestampKey, note]) => ({
|
|
92
|
+
startTime: note.startTime,
|
|
93
|
+
message: note.message,
|
|
94
|
+
status: note.status,
|
|
95
|
+
screenshot: note.screenshot,
|
|
96
|
+
}))
|
|
97
|
+
.sort((a, b) => a.startTime - b.startTime);
|
|
98
|
+
|
|
99
|
+
const stepEntries = Object.entries(test.steps)
|
|
100
|
+
.map(([timestampKey, stepData]) => ({
|
|
101
|
+
noteStartTime: stepData.noteStartTime,
|
|
102
|
+
text: stepData.text,
|
|
103
|
+
duration: stepData.duration,
|
|
104
|
+
error: stepData.error,
|
|
105
|
+
log: stepData.log,
|
|
106
|
+
}))
|
|
107
|
+
.filter((step) => step.noteStartTime !== undefined);
|
|
108
|
+
|
|
109
|
+
const steps: Step[] = [];
|
|
110
|
+
|
|
111
|
+
for (const noteEntry of noteEntries) {
|
|
112
|
+
const noteSteps = stepEntries
|
|
113
|
+
.filter((step) => step.noteStartTime === noteEntry.startTime)
|
|
114
|
+
.map((entry) => ({
|
|
115
|
+
category: 'framework',
|
|
116
|
+
title: entry.text,
|
|
117
|
+
duration: entry.duration ?? 0,
|
|
118
|
+
...Object.fromEntries(Object.entries(entry).filter(([k]) => k !== 'noteStartTime' && k !== 'text' && k !== 'duration')),
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
const step: Step = {
|
|
122
|
+
category: 'user',
|
|
123
|
+
title: noteEntry.message,
|
|
124
|
+
duration: 0,
|
|
125
|
+
status: noteEntry.status || 'none',
|
|
126
|
+
steps: noteSteps.length > 0 ? noteSteps : undefined,
|
|
127
|
+
};
|
|
128
|
+
if (noteEntry.screenshot) {
|
|
129
|
+
step.artifacts = [outputPath('states', noteEntry.screenshot)];
|
|
130
|
+
}
|
|
131
|
+
steps.push(step);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (lastScreenshotFile && steps.length > 0) {
|
|
135
|
+
const lastStep = steps[steps.length - 1];
|
|
136
|
+
const screenshotPath = outputPath('states', lastScreenshotFile);
|
|
137
|
+
if (lastStep.artifacts) {
|
|
138
|
+
lastStep.artifacts.push(screenshotPath);
|
|
139
|
+
} else {
|
|
140
|
+
lastStep.artifacts = [screenshotPath];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return steps;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async reportTest(test: Test, meta?: ReporterMeta): Promise<void> {
|
|
148
|
+
await this.startRun();
|
|
149
|
+
|
|
150
|
+
if (!this.isRunStarted) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
let status = null;
|
|
156
|
+
if (test.isSuccessful) {
|
|
157
|
+
status = 'passed';
|
|
158
|
+
} else if (test.isSkipped) {
|
|
159
|
+
status = 'skipped';
|
|
160
|
+
} else if (test.hasFailed) {
|
|
161
|
+
status = 'failed';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const screenshotFile = meta?.screenshotFile;
|
|
165
|
+
if (meta) {
|
|
166
|
+
meta.screenshotFile = undefined;
|
|
167
|
+
meta = Object.fromEntries(Object.entries(meta).filter(([, v]) => v));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const steps = this.combineStepsAndNotes(test, screenshotFile);
|
|
171
|
+
|
|
172
|
+
const testData = {
|
|
173
|
+
rid: test.id,
|
|
174
|
+
title: test.scenario,
|
|
175
|
+
suite_title: test.plan?.title || 'Auto-Exploratory Testing',
|
|
176
|
+
file: '<note>',
|
|
177
|
+
description: test.description,
|
|
178
|
+
code: test.generatedCode || '',
|
|
179
|
+
steps,
|
|
180
|
+
logs: Object.values(test.steps)
|
|
181
|
+
.map((stepData) => stepData.text)
|
|
182
|
+
.join('\n'),
|
|
183
|
+
files: Object.values(test.artifacts) || [],
|
|
184
|
+
message: test.summary || this.extractLastNoteMessage(test) || '',
|
|
185
|
+
meta,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
debugLog(testData);
|
|
189
|
+
|
|
190
|
+
await this.client.addTestRun(status, testData);
|
|
191
|
+
debugLog(`Test reported: ${test.scenario} - ${status}`);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
debugLog('Failed to report test:', error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async finishRun(): Promise<void> {
|
|
198
|
+
if (!this.isRunStarted) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
await this.client.updateRunStatus('finished');
|
|
204
|
+
this.isRunStarted = false;
|
|
205
|
+
debugLog('Testomat.io run finished');
|
|
206
|
+
} catch (error) {
|
|
207
|
+
debugLog('Failed to finish Testomat.io run:', error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
isEnabled(): boolean {
|
|
212
|
+
return this.isRunStarted;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private extractLastNoteMessage(test: Test): string {
|
|
216
|
+
const notes = Object.values(test.notes);
|
|
217
|
+
if (notes.length === 0) return '';
|
|
218
|
+
return notes[notes.length - 1].message;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async reportSteps(test: Test, steps: ReporterStep[]): Promise<void> {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}
|