Skip to content

Phase 1: Extract browser-compatible test detection to Common, move resolution to Core#79

Draft
Copilot wants to merge 26 commits intomainfrom
copilot/update-common-library-architecture
Draft

Phase 1: Extract browser-compatible test detection to Common, move resolution to Core#79
Copilot wants to merge 26 commits intomainfrom
copilot/update-common-library-architecture

Conversation

Copy link

Copilot AI commented Feb 4, 2026

Consolidating resolver functionality into Common and Core to simplify architecture. Common becomes browser-compatible; resolver will be deprecated.

Changes

Common: Browser-Compatible Test Detection

  • New detectTests.ts: Extracted pure parsing logic (parseContent) from resolver
    • No fs/path/os dependencies - works on string content
    • Helpers: parseXmlAttributes, parseObject, replaceNumericVariables
  • Browser-compatible crypto: Shimmed randomUUID with Web Crypto API + Node.js fallbacks
  • Exports updated: Added detectTests() (temporary: kept files.ts and resolvePaths.ts for backwards compatibility)
// New browser-compatible API
import { detectTests } from 'doc-detective-common';

const tests = await detectTests({
  content: markdownString,
  filePath: 'docs/test.md',
  fileType: { extensions: ['md'], markup: [...] }
});

Core: Test Resolution Logic

  • New resolveTests.js: Complete resolution pipeline from resolver
    • resolveDetectedTests, resolveSpec, resolveTest, resolveContext
    • Context/platform/browser matrix resolution
    • OpenAPI document fetching
  • Exports: Added resolveTests() to public API

Status

✅ Common: 441/441 tests passing
⚠️ Still depends on resolver (breaking change deferred to Phase 2)

Next Steps

  1. Port file I/O layer (qualifyFiles, parseTests) to Core
  2. Remove files.ts/resolvePaths.ts from Common exports
  3. Update Core to stop importing from resolver
  4. Update VSCode extension to use new APIs
Original prompt

We're going to make substantial updates to the common, resolver, and core libraries. Overall goal: Achieve a simpler architecture to ease development and contributions.

Method: Consolidate down to two primary repos:
Common (doc-detective/common): Browser-compatible library for most intrinsic primitives
Doc Detective (doc-detective/doc-detective): Everything else, including CLI, runner, etc.

As part of this process, multiple some repos will be turned down:

  • Resolver

Phase 1
Goal: Achieve a browser-compatible Common library.

Tasks:

  • Common moves all browser-incompatible functionality (like node imports) into Core and CLI
  • Common pulls in test detection logic in from Resolver
  • Core pulls test resolution logic in from Resolver
  • Common exposes three exports total
    • schemas object
    • validate() function
    • detectTests() function
  • Core exposes current exports plus
    • resolveTests() function
  • Update VSCode extension to use new Common exports

The user has attached the following file paths as relevant context:

  • .github\copilot-instructions.md

Created from VS Code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 4, 2026 04:00
Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
- Created new detectTests.ts with browser-compatible parseContent function
- Extracted pure parsing logic (no fs, path dependencies)
- Added helper functions: parseXmlAttributes, parseObject, replaceNumericVariables
- Updated common exports to include detectTests functionality
- Successfully compiles with TypeScript strict mode

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
- Made crypto.randomUUID browser-compatible with fallbacks
- Added detectTests() function as main entry point for test detection
- Removed duplicate interface declarations
- All 441 tests passing
- Module compiles successfully with TypeScript strict mode

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
- Created resolveTests.js in core/src/
- Ported resolveDetectedTests, resolveSpec, resolveTest, resolveContext from resolver
- Added resolveContexts and isDriverRequired helper functions
- Updated Core's index.js to export resolveTests()
- Module compiles and loads successfully

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
Copilot AI changed the title [WIP] Update common library for simpler architecture Phase 1: Extract browser-compatible test detection to Common, move resolution to Core Feb 4, 2026
Copilot AI requested a review from hawkeyexl February 4, 2026 04:17
- Add unit tests to verify the export of functions from the CommonJS and ESM modules.
- Implement tests to ensure the `detectTests` function works correctly with both import styles.
- Confirm that the results from `detectTests` are identical when using CJS and ESM.
- Check for type definitions related to `detectTests` in the generated TypeScript declaration files.
- Remove obsolete test files: `temp-element-timeout-test.json` and `temp-network-timeout-test.json`.
53c0ab09b update ignore
ec3ad2154 Remove deprecated files and functions: - Delete `files.js`, `index.js`, `resolvePaths.js`, `schemas/index.js`, and `validate.js` as they are no longer needed.
49636115d Refactor code and improve logging functionality
2a41c1ebe Add tests for module exports and remove unused test files
5c75d1844 feat: make Common module browser-compatible
a873eefd3 feat: add browser-compatible detectTests module to common
bac81c1ee Initial exploration of Phase 1 consolidation task

git-subtree-dir: common
git-subtree-split: 53c0ab09ba1963fc8db19234252c4036b5a1297f
…dencies

- Remove the `readFile` function and its associated tests from the codebase.
- Delete the `resolvePaths` function and its related tests.
- Update `package.json` to remove `axios` from dependencies and add `@apidevtools/json-schema-ref-parser` to devDependencies.
- Adjust exports in `index.ts` to remove deprecated functions.
- Update tests to reflect changes in exports and remove tests for deleted functions.
- Upgrade dependencies in package.json for improved functionality and security.
- Add a deepMerge function to handle configuration overrides more effectively.
- Introduce resolveConcurrentRunners to manage concurrent execution settings.
- Implement detectTests function to identify and parse test specifications from files.
- Create files.js to handle reading and parsing of JSON and YAML files.
- Enhance error handling and logging throughout the configuration and test detection processes.
- Add support for DITA file types and improve path resolution for configuration properties.
- Refactor index.js to include new detectTests and readFile functionalities.
- Clamp rectangle values to ensure they stay within image bounds in saveScreenshot function.
- Improve cleanup logic by checking if temporary files exist before deletion.
- Update server start logic to handle cases where the server is already running.
- Set maxVariation to 0 for more precise screenshot comparisons.
- Add assertions to verify the creation of initial screenshot files.
- Change dependencies for `doc-detective-common` and `doc-detective-core` to local file paths.
- Update the `saveScreenshot` function to await the `sharp` processing for cropping images.
- Remove the retry logic for checking if the cropped image file exists after processing.
- Ensure the output of the `sharp` processing is in PNG format for both images being resized.
- Add tests to normalize logLevel configurations in the log function
- Implement tests to ensure messages are not logged when logLevel is set to silent
- Add tests to skip detected steps inside ignore blocks in markdown content
- Use structuredClone for test input in integration tests to prevent mutation
- Upgrade axios to version 1.13.5
- Update doc-detective-common to version 4.0.0-beta.0
- Upgrade body-parser to version 2.2.2
- Upgrade chai to version 6.2.2
- Update posthog-node to version 5.24.15
- Change version of doc-detective-core to 4.0.0-beta.0
- Create a test suite for the upload module, including tests for collecting changed files, integration configuration retrieval, and uploader functionality.
- Implement a drag-and-drop test HTML file to demonstrate widget dragging and dropping into designated zones.
- Add an enhanced elements test HTML file to showcase various button and input elements with different attributes and accessibility features.
- Create multiple HTML files to test DOM mutations, including scenarios for immediate and delayed mutations, as well as continuous network requests.
- Include a static HTML page to serve as a baseline for testing static content loading.
…r CJS format - Add a banner to set importMetaUrl for compatibility
…- Change version from 3.6.3 to 4.0.0-beta.0 - Modify postinstall script to disable warning DEP0190 - Update import statements in postinstall.js to use namespace imports
… import path for testsModule in getRunner() function to use the dist directory - Delete temp-screenshot-regression-test.json as it is no longer needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants