Skip to content

feat: auto-detect default config file#913

Closed
112-stack wants to merge 1 commit into
nodejs:mainfrom
112-stack:agent/auto-detect-config
Closed

feat: auto-detect default config file#913
112-stack wants to merge 1 commit into
nodejs:mainfrom
112-stack:agent/auto-detect-config

Conversation

@112-stack

Copy link
Copy Markdown

Description

Automatically discover doc-kit.config.mjs in the current working directory when --config-file is omitted. An explicitly supplied config path still takes precedence.

The previous loader returned an empty configuration whenever the CLI option was absent, so the conventional filename could not be used without repeating the flag. This change adds dependency-free discovery, focused coverage for discovery/absence/explicit precedence, user-facing documentation, and a minor changeset.

Validation

  • node --test --experimental-test-module-mocks src/utils/configuration/__tests__/index.test.mjs — 16/16 pass
  • node --run lint — 0 errors (2 existing warnings in useOrama.mjs)
  • node --run format:check — pass
  • Full Windows run: 520/523 pass. The three failures are existing path-separator assumptions in src/generators/ast/__tests__/generate.test.mjs and src/generators/web/utils/__tests__/copying.test.mjs; none touch configuration loading.

Related Issues

Fixes #897

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed. (See the Windows-only baseline failures documented above.)
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 18, 2026 5:03am

Request Review

@112-stack
112-stack marked this pull request as ready for review July 18, 2026 05:04
@112-stack
112-stack requested a review from a team as a code owner July 18, 2026 05:04
@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small, localized change to config loading with clear precedence rules and unit tests; no auth, security, or data-path changes.

Overview
When --config-file is not passed, loadConfigFile now looks for doc-kit.config.mjs in the current working directory (existsSync + resolve) and imports it if present; otherwise behavior stays the same (empty config). An explicit config path still bypasses discovery and loads only that file.

README generate usage is updated to describe this default. Unit tests cover explicit paths, cwd discovery, and missing/falsy config (with existsSync mocked). Minor changeset for @node-core/doc-kit.

Reviewed by Cursor Bugbot for commit 265cc22. Bugbot is set up for automated code reviews on this repo. Configure here.

@avivkeller

Copy link
Copy Markdown
Member

Please look at the feedback given on #901 before sending an AI agent to rush in and complete the work incorrectly

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking, see above

@112-stack

112-stack commented Jul 18, 2026

Copy link
Copy Markdown
Author

Thanks for pointing this out, You're right, I should have reviewed #901 and its discussion before opening this PR.

#913 duplicates that active work and only handles doc-kit.config.mjs inside loadConfigFile, while the feedback on #901 calls for resolving the full supported set (.js, .cjs, .mjs, .ts, .cts, and .mts) in a defined order before calling the loader.

I'm closing this PR rather than competing with the existing contributor's work. Sorry for the noise.

@112-stack 112-stack closed this Jul 18, 2026
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.

Consideration: detect doc-kit.config.mjs automatically

2 participants