fix(fs-watcher): load agentmemory env file
Summary
- load
~/.agentmemory/.envand$XDG_CONFIG_HOME/agentmemory/.envin@agentmemory/fs-watcher - keep explicit process environment values higher priority than file values
- document the fallback and add tests for file loading and env override behavior
This addresses the filesystem watcher part of #298, where a watcher running under a process manager/container could fall back to localhost even though the shared server URL lives in agentmemory's documented env file.
Conflict check
- Current open PRs do not touch
integrations/filesystem-watcher/*ortest/fs-watcher.test.ts.
Tests
npm test -- test/fs-watcher.test.tsnode --check integrations/filesystem-watcher/watcher.mjsgit diff --checknpm run buildnpm test
Summary by CodeRabbit
-
Documentation
- Clarified how configuration is loaded from .env files for the filesystem watcher.
-
New Features
- Filesystem watcher can load configuration from .env files in user config locations, with explicit process environment variables taking precedence.
-
Tests
- Added tests covering .env parsing, quoting/comments handling, XDG_HOME support, and environment-variable precedence.
@Zavianx is attempting to deploy a commit to the rohitg00's projects Team on Vercel.
A member of the Team first needs to authorize it.
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 41950be1-89d3-4423-bee4-bca786a9e2b7
π₯ Commits
Reviewing files that changed from the base of the PR and between b8ca80a93010a3e760f57fc438a0956cc3d2d8d3 and 1a1f409968f88cd9306f15a6358f9b702769a346.
π Files selected for processing (2)
integrations/filesystem-watcher/README.mdtest/fs-watcher.test.ts
β Files skipped from review due to trivial changes (1)
- integrations/filesystem-watcher/README.md
π Walkthrough
Walkthrough
Adds support for loading watcher configuration from ~/.agentmemory/.env and $XDG_CONFIG_HOME/agentmemory/.env; implements parsing/loading helpers, merges file-sourced values with process env in configFromEnv (process env wins), expands tests, and updates README.
Changes
Environment file configuration loading
| Layer / File(s) | Summary |
|---|---|
Env-file parsing and loading helpers integrations/filesystem-watcher/watcher.mjs |
parseEnvFile parses key/value pairs (comments, blank lines, basic quoting), loadAgentMemoryEnv best-effort loads .env from ~/.agentmemory/.env and $XDG_CONFIG_HOME/agentmemory/.env. fs import reformatted. |
ConfigFromEnv env merging integrations/filesystem-watcher/watcher.mjs |
configFromEnv merges file-loaded env values with the provided env (file first, explicit env overrides) and derives roots, baseUrl, secret, project, sessionId, ignorePatterns, and allowBinary. |
Test coverage for env file loading test/fs-watcher.test.ts |
Adds Vitest cases to verify loading from ~/.agentmemory/.env, parsing edge cases (quoting, inline comments, open quotes, empty/malformed lines), XDG_CONFIG_HOME precedence, and explicit AGENTMEMORY_* overrides. Temporary HOME/XDG dirs are used and cleaned up. |
Documentation of env file loading integrations/filesystem-watcher/README.md |
README documents the .env loading order and that process environment variables override file values. |
Possibly related PRs
- rohitg00/agentmemory#163: Related changes to env-parsing /
configFromEnvlogic in the filesystem watcher.
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~20 minutes
Poem
π° In burrows of code I softly comb,
I read.envfrom home and XDG home,
I stitch their keys with process light,
so watcher wakes configured right,
and hops along the filesystem loam.
π₯ Pre-merge checks | β 4 | β 1
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'fix(fs-watcher): load agentmemory env file' accurately summarizes the main change: enabling the filesystem watcher to load environment configuration from agentmemory env files, which directly addresses the PR's primary objective. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.