Skip to content

fix: resolve scanAgents omitted path against active project cwd - #1631

Merged
avoidwork merged 3 commits into
mainfrom
fix/scan-agents-active-project-cwd
Nov 1, 2026
Merged

avoidwork merged 3 commits into
mainfrom
fix/scan-agents-active-project-cwd

Conversation

@avoidwork

@avoidwork avoidwork commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Description

The scanAgents tool ignored the active project context: it captured the root
cwd once at module load (const cwd = loadConfig().cwd) and, when no path
argument was supplied, always fell back to that frozen root — never consulting the
active project. When a user selected a project via the /projects panel,
scanAgents still scanned the madz root instead of the active project, returning
the wrong AGENTS.md (or none at all).

This change makes scanAgents resolve an omitted path against the live active
project cwd via getProjectCwd() || config.cwd || process.cwd(), mirroring the
sibling file and discovery tools. The frozen module-load capture is removed
and the resolution is evaluated at call time. The scan-agents spec is updated to
reflect the new default-path behavior, and a regression test asserts
active-project-cwd resolution.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)
  • Performance improvement
  • CI / build / tooling

Testing

Added a regression test in tests/unit/tools_scanAgents.test.js that calls
setProjectCwd(<projectDir>) and asserts an omitted path resolves to the
project directory (reading that project's AGENTS.md), replacing the prior
"uses process.cwd()" test. The full suite passes via npm run test and
npm run coverage.

Coverage

  • Line coverage maintained

src/tools/scanAgents/index.js is at 100% line coverage; overall 91.52%.

Checklist

  • npm run lint passes
  • Tests pass with maintained line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

Closes #1630

Add proposal, design, spec delta, and tasks for resolving the scanAgents
omitted-path default against the active project cwd (getProjectCwd) instead
of a frozen module-load cwd. Closes #1630.
@avoidwork avoidwork added the bug Something isn't working label Nov 1, 2026
@avoidwork avoidwork self-assigned this Nov 1, 2026
Import getProjectCwd and resolve an omitted path as
getProjectCwd() || config.cwd || process.cwd() at call time, mirroring the
file and discovery tools. Remove the frozen module-load cwd capture and
update the regression test to assert active-project-cwd resolution.

Closes #1630
Sync the scan-agents spec delta to openspec/specs/scan-agents/spec.md and
move the change to openspec/changes/archive/.
@avoidwork avoidwork changed the title docs: add openspec change for scan-agents active project cwd fix: resolve scanAgents omitted path against active project cwd Nov 1, 2026
@avoidwork

Copy link
Copy Markdown
Owner Author

Implementation Audit — scan-agents-active-project-cwd

Goal fulfillment

  • Goal 1 (resolve omitted path against active project cwd): satisfied.
    scanAgentsImpl now resolves input.path || getProjectCwd() || config.cwd || process.cwd() at call time.

Spec compliance

  • Matches the MODIFIED "Tool discovers AGENTS.md in specified path" requirement:
    active-project default, config.cwd fallback, process.cwd fallback.
  • Explicit-path behavior unchanged; validatePath/sandbox allowlist unchanged
    (no new traversal surface).

Task completion

  • 1.1 import getProjectCwd — done.
  • 1.2 removed frozen const cwd = loadConfig().cwd — done.
  • 1.3 call-time fallback chain — done.
  • 2.1 regression test via setProjectCwd — done.
  • 2.2 full suite + coverage — done.

Quality

  • npm run lint: 0 warnings, 0 errors.
  • npm run coverage: full suite passes; scanAgents/index.js at 100% line
    coverage; overall 91.52%.
  • No forbidden patterns introduced.

Result

No errors. Proceed to archive.

@avoidwork
avoidwork merged commit cd5452d into main Nov 1, 2026
2 checks passed
@avoidwork
avoidwork deleted the fix/scan-agents-active-project-cwd branch November 1, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: scanAgents ignores active project context when no path is supplied

1 participant