explorbot 0.0.1 → 0.0.5
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 +679 -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 +19 -98
- 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 +0 -1
- 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 +0 -1
- package/dist/src/ai/planner.js +0 -1
- package/dist/src/ai/provider.js +0 -1
- package/dist/src/ai/quartermaster.js +0 -1
- package/dist/src/ai/researcher/cache.js +0 -1
- package/dist/src/ai/researcher/coordinates.js +0 -1
- package/dist/src/ai/researcher/deep-analysis.js +0 -1
- 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 +0 -1
- package/dist/src/ai/researcher/mixin.js +0 -1
- package/dist/src/ai/researcher/parser.js +0 -1
- package/dist/src/ai/researcher/research-result.js +0 -1
- package/dist/src/ai/researcher.js +0 -1
- 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 +0 -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 +0 -1
- 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 +2 -2
- 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 +115 -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 +0 -1
- 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 +0 -1
- package/dist/src/explorer.js +0 -1
- 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 +0 -1
- package/dist/src/utils/xpath.js +0 -1
- package/package.json +27 -3
- package/src/action-result.ts +694 -0
- package/src/action.ts +445 -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 +141 -0
- package/src/ai/planner.ts +536 -0
- package/src/ai/provider.ts +613 -0
- package/src/ai/quartermaster.ts +286 -0
- package/src/ai/researcher/cache.ts +103 -0
- package/src/ai/researcher/coordinates.ts +238 -0
- package/src/ai/researcher/deep-analysis.ts +415 -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 +115 -0
- package/src/ai/researcher.ts +857 -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 +1117 -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 +128 -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 +41 -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 +490 -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 +713 -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 +145 -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
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
import type { ActionResult } from './action-result.js';
|
|
5
|
+
import { ConfigParser } from './config.js';
|
|
6
|
+
import { KnowledgeTracker } from './knowledge-tracker.js';
|
|
7
|
+
import type { WebPageState } from './state-manager.js';
|
|
8
|
+
import { createDebug, tag } from './utils/logger.js';
|
|
9
|
+
import { mdq } from './utils/markdown-query.js';
|
|
10
|
+
import { extractStatePath } from './utils/url-matcher.js';
|
|
11
|
+
|
|
12
|
+
const debugLog = createDebug('explorbot:experience');
|
|
13
|
+
const DEFAULT_MAX_EXPERIENCE_LINES = 100;
|
|
14
|
+
|
|
15
|
+
export class ExperienceTracker {
|
|
16
|
+
private experienceDir: string;
|
|
17
|
+
private disabled: boolean;
|
|
18
|
+
private knowledgeTracker: KnowledgeTracker;
|
|
19
|
+
|
|
20
|
+
constructor(options: { disabled?: boolean } = {}) {
|
|
21
|
+
const configParser = ConfigParser.getInstance();
|
|
22
|
+
const config = configParser.getConfig();
|
|
23
|
+
const configPath = configParser.getConfigPath();
|
|
24
|
+
this.disabled = options.disabled ?? false;
|
|
25
|
+
this.knowledgeTracker = new KnowledgeTracker();
|
|
26
|
+
|
|
27
|
+
// Resolve experience directory relative to the config file location (project root)
|
|
28
|
+
if (configPath) {
|
|
29
|
+
const projectRoot = dirname(configPath);
|
|
30
|
+
this.experienceDir = join(projectRoot, config.dirs?.experience || 'experience');
|
|
31
|
+
} else {
|
|
32
|
+
this.experienceDir = config.dirs?.experience || 'experience';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!this.disabled) {
|
|
36
|
+
this.ensureDirectory(this.experienceDir);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private getExperienceDirectories(): string[] {
|
|
41
|
+
const directories = [this.experienceDir];
|
|
42
|
+
|
|
43
|
+
// Also check for experience directory in current working directory
|
|
44
|
+
const cwdExperienceDir = join(process.cwd(), 'experience');
|
|
45
|
+
debugLog('Checking for experience directory in CWD:', cwdExperienceDir);
|
|
46
|
+
debugLog('CWD experience dir exists:', existsSync(cwdExperienceDir));
|
|
47
|
+
debugLog('CWD experience dir different from main:', cwdExperienceDir !== this.experienceDir);
|
|
48
|
+
|
|
49
|
+
if (existsSync(cwdExperienceDir) && cwdExperienceDir !== this.experienceDir) {
|
|
50
|
+
directories.push(cwdExperienceDir);
|
|
51
|
+
debugLog('Added CWD experience directory:', cwdExperienceDir);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Also check for experience directory in the directory where the script was run from
|
|
55
|
+
// This is useful when running from subdirectories like 'example'
|
|
56
|
+
const scriptCwd = process.env.INITIAL_CWD || process.cwd();
|
|
57
|
+
const scriptExperienceDir = join(scriptCwd, 'experience');
|
|
58
|
+
debugLog('Checking for experience directory in script CWD:', scriptExperienceDir);
|
|
59
|
+
debugLog('Script CWD experience dir exists:', existsSync(scriptExperienceDir));
|
|
60
|
+
|
|
61
|
+
if (existsSync(scriptExperienceDir) && scriptExperienceDir !== this.experienceDir && !directories.includes(scriptExperienceDir)) {
|
|
62
|
+
directories.push(scriptExperienceDir);
|
|
63
|
+
debugLog('Added script CWD experience directory:', scriptExperienceDir);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
debugLog('Final experience directories:', directories);
|
|
67
|
+
return directories;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private ensureDirectory(dir: string): void {
|
|
71
|
+
if (this.disabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!existsSync(dir)) {
|
|
75
|
+
mkdirSync(dir, { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
readExperienceFile(stateHash: string): { content: string; data: any } {
|
|
80
|
+
const filePath = this.getExperienceFilePath(stateHash);
|
|
81
|
+
const fileContent = readFileSync(filePath, 'utf8');
|
|
82
|
+
const { content, data } = matter(fileContent);
|
|
83
|
+
return { content, data };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
writeExperienceFile(stateHash: string, content: string, frontmatter?: any): void {
|
|
87
|
+
if (this.disabled) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const filePath = this.getExperienceFilePath(stateHash);
|
|
91
|
+
const fileContent = matter.stringify(content, frontmatter || {});
|
|
92
|
+
writeFileSync(filePath, fileContent, 'utf8');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
hasRecentExperience(stateHash: string, prefix = ''): boolean {
|
|
96
|
+
if (this.disabled) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (prefix) {
|
|
100
|
+
stateHash = `${prefix}_${stateHash}`;
|
|
101
|
+
}
|
|
102
|
+
const filePath = this.getExperienceFilePath(stateHash);
|
|
103
|
+
if (!existsSync(filePath)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const stats = statSync(filePath);
|
|
107
|
+
return stats.mtime.getTime() > Date.now() - 1000 * 60 * 60 * 24;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private getExperienceFilePath(stateHash: string): string {
|
|
111
|
+
return join(this.experienceDir, `${stateHash}.md`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private ensureExperienceFile(state: ActionResult): string {
|
|
115
|
+
if (this.disabled) {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
const stateHash = state.getStateHash();
|
|
119
|
+
const filePath = this.getExperienceFilePath(stateHash);
|
|
120
|
+
|
|
121
|
+
if (!existsSync(filePath)) {
|
|
122
|
+
const frontmatter = {
|
|
123
|
+
url: state.url ? extractStatePath(state.url) : '',
|
|
124
|
+
title: state.title,
|
|
125
|
+
};
|
|
126
|
+
this.writeExperienceFile(stateHash, '', frontmatter);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return filePath;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
updateSummary(state: ActionResult, summary: string): void {
|
|
133
|
+
if (this.disabled) return;
|
|
134
|
+
const stateHash = state.getStateHash();
|
|
135
|
+
this.ensureExperienceFile(state);
|
|
136
|
+
const { content, data } = this.readExperienceFile(stateHash);
|
|
137
|
+
data.summary = summary;
|
|
138
|
+
this.writeExperienceFile(stateHash, content, data);
|
|
139
|
+
debugLog(`Updated summary for ${stateHash}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private isWritingDisabled(state: ActionResult): boolean {
|
|
143
|
+
return this.knowledgeTracker.getRelevantKnowledge(state).some((k) => k.noExperienceWriting === true || k.noExperienceWriting === 'true');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async saveSuccessfulResolution(state: ActionResult, originalMessage: string, code: string, explanation?: string): Promise<void> {
|
|
147
|
+
if (this.disabled || this.isWritingDisabled(state)) return;
|
|
148
|
+
|
|
149
|
+
this.ensureExperienceFile(state);
|
|
150
|
+
const stateHash = state.getStateHash();
|
|
151
|
+
const { content, data } = this.readExperienceFile(stateHash);
|
|
152
|
+
if (content.includes(code)) {
|
|
153
|
+
debugLog('Skipping duplicate successful resolution', code);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const filteredCode = code.replace(/I\.amOnPage\s*\([^)]*\)/gs, '');
|
|
158
|
+
const newEntryContent = `### SUCCEEDED: ${originalMessage.split('\n')[0]}
|
|
159
|
+
|
|
160
|
+
${explanation ? `Solution: ${explanation}` : ''}
|
|
161
|
+
|
|
162
|
+
\`\`\`javascript
|
|
163
|
+
${filteredCode}
|
|
164
|
+
\`\`\`
|
|
165
|
+
`;
|
|
166
|
+
|
|
167
|
+
const updatedContent = `${newEntryContent}\n\n${content}`;
|
|
168
|
+
this.writeExperienceFile(stateHash, updatedContent, data);
|
|
169
|
+
|
|
170
|
+
tag('substep').log(` Added successful resolution to: ${stateHash}.md`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getAllExperience(): { filePath: string; data: any; content: string }[] {
|
|
174
|
+
const allFiles: { filePath: string; data: any; content: string }[] = [];
|
|
175
|
+
|
|
176
|
+
for (const experienceDir of this.getExperienceDirectories()) {
|
|
177
|
+
if (!existsSync(experienceDir)) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const files = readdirSync(experienceDir)
|
|
183
|
+
.filter((file: string) => file.endsWith('.md'))
|
|
184
|
+
.map((file: string) => join(experienceDir, file));
|
|
185
|
+
|
|
186
|
+
for (const file of files) {
|
|
187
|
+
try {
|
|
188
|
+
const content = readFileSync(file, 'utf8');
|
|
189
|
+
const parsed = matter(content);
|
|
190
|
+
allFiles.push({
|
|
191
|
+
filePath: file,
|
|
192
|
+
data: parsed.data,
|
|
193
|
+
content: parsed.content,
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
debugLog(`Failed to read experience file ${file}:`, error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} catch (error) {
|
|
200
|
+
debugLog(`Failed to read experience directory ${experienceDir}:`, error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return allFiles;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
getRelevantExperience(state: ActionResult, options?: { includeDescendantExperience?: boolean }): { filePath: string; data: any; content: string }[] {
|
|
208
|
+
const relevantKnowledge = this.knowledgeTracker.getRelevantKnowledge(state);
|
|
209
|
+
const readingDisabled = relevantKnowledge.some((knowledge) => knowledge.noExperienceReading === true || knowledge.noExperienceReading === 'true');
|
|
210
|
+
if (readingDisabled) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
const config = ConfigParser.getInstance().getConfig();
|
|
214
|
+
const maxLines = config.experience?.maxReadLines ?? DEFAULT_MAX_EXPERIENCE_LINES;
|
|
215
|
+
|
|
216
|
+
return this.getAllExperience()
|
|
217
|
+
.filter((experience) => {
|
|
218
|
+
const experienceState = experience.data as WebPageState;
|
|
219
|
+
return state.isRelevantExperienceRecord(experienceState, {
|
|
220
|
+
includeDescendantExperience: options?.includeDescendantExperience,
|
|
221
|
+
});
|
|
222
|
+
})
|
|
223
|
+
.map((experience) => {
|
|
224
|
+
const lines = experience.content.split('\n');
|
|
225
|
+
if (lines.length <= maxLines) return experience;
|
|
226
|
+
return { ...experience, content: lines.slice(0, maxLines).join('\n') };
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Clean up experience tracker (for testing)
|
|
232
|
+
*/
|
|
233
|
+
cleanup(): void {
|
|
234
|
+
// Clear any in-memory state if needed
|
|
235
|
+
// The actual files will be cleaned up by test cleanup
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
saveSessionExperience(state: ActionResult, entry: SessionExperienceEntry): void {
|
|
239
|
+
if (this.disabled || this.isWritingDisabled(state)) return;
|
|
240
|
+
|
|
241
|
+
this.ensureExperienceFile(state);
|
|
242
|
+
const stateHash = state.getStateHash();
|
|
243
|
+
const { content, data } = this.readExperienceFile(stateHash);
|
|
244
|
+
|
|
245
|
+
if (entry.relatedUrls?.length) {
|
|
246
|
+
const currentPath = extractStatePath(state.url || '');
|
|
247
|
+
const existingRelated = Array.isArray(data.related) ? data.related : [];
|
|
248
|
+
const allRelated = [...new Set([...existingRelated, ...entry.relatedUrls])];
|
|
249
|
+
data.related = allRelated.filter((url) => url !== currentPath);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const sessionContent = this.trimSessionContent(this.generateSessionContent(entry));
|
|
253
|
+
if (!sessionContent) return;
|
|
254
|
+
const updatedContent = `${sessionContent}\n${content}`;
|
|
255
|
+
this.writeExperienceFile(stateHash, updatedContent, data);
|
|
256
|
+
|
|
257
|
+
tag('substep').log(`Added session experience to: ${stateHash}.md`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private generateSessionContent(entry: SessionExperienceEntry): string {
|
|
261
|
+
let content = `## Successful Flow: ${entry.scenario}\n\n`;
|
|
262
|
+
|
|
263
|
+
for (const step of entry.steps) {
|
|
264
|
+
content += `* ${step.message}\n\n`;
|
|
265
|
+
if (step.code) {
|
|
266
|
+
content += '```js\n';
|
|
267
|
+
content += `${step.code}\n`;
|
|
268
|
+
content += '```\n\n';
|
|
269
|
+
}
|
|
270
|
+
if (step.discovery) {
|
|
271
|
+
const discoveries = step.discovery.split('\n').filter((d) => d.trim());
|
|
272
|
+
for (const discovery of discoveries) {
|
|
273
|
+
content += `> ${discovery.trim()}\n\n`;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
content += '---\n';
|
|
279
|
+
return content;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private trimSessionContent(content: string): string | null {
|
|
283
|
+
const q = mdq(content);
|
|
284
|
+
if (q.query('heading').count() === 0) return null;
|
|
285
|
+
if (q.query('code').count() === 0) return null;
|
|
286
|
+
|
|
287
|
+
let result = content;
|
|
288
|
+
const codeBlocks = q.query('code').each();
|
|
289
|
+
if (codeBlocks.length > 2) {
|
|
290
|
+
for (const block of codeBlocks.slice(2)) {
|
|
291
|
+
result = result.replace(block.text(), '');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const blockquotes = mdq(result).query('blockquote').each();
|
|
296
|
+
if (blockquotes.length > 5) {
|
|
297
|
+
for (const bq of blockquotes.slice(5)) {
|
|
298
|
+
result = result.replace(bq.text(), '');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const lines = result.split('\n');
|
|
303
|
+
if (lines.length > 40) {
|
|
304
|
+
result = lines.slice(0, 40).join('\n');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (!result.trim()) return null;
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
getSuccessfulExperience(state: ActionResult, options?: { includeDescendants?: boolean; stripCode?: boolean }): string[] {
|
|
312
|
+
const records = this.getRelevantExperience(state, {
|
|
313
|
+
includeDescendantExperience: options?.includeDescendants,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const results: string[] = [];
|
|
317
|
+
for (const record of records) {
|
|
318
|
+
if (!record.content) continue;
|
|
319
|
+
|
|
320
|
+
const successFlows = mdq(record.content).query('section(~"Successful Flow")').text();
|
|
321
|
+
const succeeded = mdq(record.content).query('section(~"SUCCEEDED")').text();
|
|
322
|
+
let combined = [successFlows, succeeded].filter(Boolean).join('\n\n');
|
|
323
|
+
|
|
324
|
+
if (!combined.trim()) continue;
|
|
325
|
+
|
|
326
|
+
if (options?.stripCode) {
|
|
327
|
+
combined = mdq(combined).query('code').replace('');
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (combined.trim()) results.push(combined.trim());
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return results;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface SessionStep {
|
|
338
|
+
message: string;
|
|
339
|
+
status: 'passed' | 'failed' | 'neutral';
|
|
340
|
+
tool?: string;
|
|
341
|
+
code?: string;
|
|
342
|
+
discovery?: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface SessionExperienceEntry {
|
|
346
|
+
scenario: string;
|
|
347
|
+
result: 'success' | 'partial' | 'failed';
|
|
348
|
+
steps: SessionStep[];
|
|
349
|
+
relatedUrls?: string[];
|
|
350
|
+
}
|