Skip to content

feat: migrate config from JSON to YAML (GIT-89)#63

Merged
TonyCasey merged 1 commit intomainfrom
git-89
Feb 14, 2026
Merged

feat: migrate config from JSON to YAML (GIT-89)#63
TonyCasey merged 1 commit intomainfrom
git-89

Conversation

@TonyCasey
Copy link
Copy Markdown
Owner

@TonyCasey TonyCasey commented Feb 14, 2026

Summary

  • Update config.ts to read from .git-mem/.git-mem.yaml instead of .git-mem.json
  • Add YAML parsing using the yaml package
  • Export getConfigPath(), getConfigDir(), CONFIG_DIR, CONFIG_FILE for reuse
  • Update integration test helpers to write YAML config
  • Update all tests for new config format

This also completes GIT-93 (update integration test helpers).

Closes GIT-89
Closes GIT-93

Test plan

  • All 529 tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Configuration system upgraded from JSON to YAML format for improved readability and maintainability.
    • Configuration file location updated: now stored in dedicated .git-mem/ subdirectory instead of project root for better organization.
    • Enhanced configuration path resolution utilities for more robust handling.

- Update config.ts to read from .git-mem/.git-mem.yaml
- Export getConfigPath() and getConfigDir() helpers
- Export CONFIG_DIR and CONFIG_FILE constants
- Update integration test helpers to write YAML config
- Update all unit and integration tests

This also completes GIT-93 (update integration test helpers).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AI-Agent: Claude-Code/2.1.42
AI-Model: claude-opus-4-5-20251101
AI-Decision: migrate config from JSON to YAML (GIT-89). - Update config.ts to read from .git-mem/.git-mem.yaml
AI-Confidence: medium
AI-Tags: hooks, utils, tests, integration, unit
AI-Lifecycle: project
AI-Memory-Id: ea93b196
AI-Source: heuristic
Copilot AI review requested due to automatic review settings February 14, 2026 22:42
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@TonyCasey TonyCasey merged commit 6d1e0c0 into main Feb 14, 2026
4 of 5 checks passed
@TonyCasey TonyCasey deleted the git-89 branch February 14, 2026 22:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR migrates the git-mem configuration system from JSON format (.git-mem.json in root) to YAML format (.git-mem.yaml in a dedicated .git-mem directory). It introduces public helper functions for config path resolution and updates all related test files accordingly.

Changes

Cohort / File(s) Summary
Configuration Module
src/hooks/utils/config.ts
Introduces CONFIG_DIR and CONFIG_FILE constants, adds getConfigPath() and getConfigDir() helper functions, and migrates config parsing from JSON.parse to YAML parsing via parseYaml().
Test Helpers and Integration Tests
tests/integration/hooks/helpers.ts, tests/integration/hooks/hook-commit-msg.test.ts
Updates config writing to use the new .git-mem/.git-mem.yaml path structure, switches from JSON serialization to YAML (stringifyYaml), and ensures directory creation before file writes.
Unit Tests
tests/unit/hooks/utils/config.test.ts
Refactors test suite to validate YAML-based config flow; adds tests for new getConfigPath() and getConfigDir() helpers; introduces writeConfig() test helper; expands loadHookConfig test coverage for defaults, merging, invalid YAML, and new commitMsg settings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch git-89

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates hook configuration from a root-level JSON file to a YAML file under a dedicated .git-mem/ directory, updating config loading utilities and test helpers accordingly.

Changes:

  • Switch loadHookConfig() to read .git-mem/.git-mem.yaml and parse with the yaml package.
  • Export config path utilities/constants (getConfigPath(), getConfigDir(), CONFIG_DIR, CONFIG_FILE) for reuse.
  • Update unit/integration tests and helpers to write YAML config files in the new location.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/hooks/utils/config.ts Introduces YAML-based config loading and exports config path helpers/constants.
tests/unit/hooks/utils/config.test.ts Updates unit tests to cover new config helpers and YAML config reading/merging.
tests/integration/hooks/helpers.ts Updates integration helper to write YAML config under .git-mem/.
tests/integration/hooks/hook-commit-msg.test.ts Updates commit-msg integration test setup to write YAML config under .git-mem/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/utils/config.ts
Comment on lines 59 to 68
export function loadHookConfig(cwd?: string): IHookConfig {
const dir = cwd ?? process.cwd();
const configPath = join(dir, '.git-mem.json');
const configPath = getConfigPath(cwd);

if (!existsSync(configPath)) {
return DEFAULTS;
}

try {
const raw = JSON.parse(readFileSync(configPath, 'utf8')) as Record<string, unknown>;
const raw = parseYaml(readFileSync(configPath, 'utf8')) as Record<string, unknown>;
const rawHooks = (raw.hooks ?? {}) as Partial<IHooksConfig>;
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

loadHookConfig() now only looks for .git-mem/.git-mem.yaml. However, the CLI init flows in this repo still create and deep-merge .git-mem.json (e.g., src/commands/init.ts, src/commands/init-hooks.ts), meaning user config written by init will be silently ignored by hooks. Either update the init commands to write the YAML file in the new location, or add a backward-compatible fallback here that reads legacy .git-mem.json if the YAML file is missing.

Copilot uses AI. Check for mistakes.
Comment thread src/hooks/utils/config.ts
Comment on lines +20 to +37
/**
* Get the full path to the config file.
* @param cwd - Working directory (defaults to process.cwd())
* @returns Absolute path to .git-mem/.git-mem.yaml
*/
export function getConfigPath(cwd?: string): string {
const dir = cwd ?? process.cwd();
return join(dir, CONFIG_DIR, CONFIG_FILE);
}

/**
* Get the path to the config directory.
* @param cwd - Working directory (defaults to process.cwd())
* @returns Absolute path to .git-mem/
*/
export function getConfigDir(cwd?: string): string {
const dir = cwd ?? process.cwd();
return join(dir, CONFIG_DIR);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The JSDoc for getConfigPath() / getConfigDir() says the returned path is absolute, but join(cwd, ...) will return a relative path if the caller passes a relative cwd. Consider either resolving cwd (e.g., via resolve()) or adjusting the docs to say the path is relative when cwd is relative.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +50
it('should return path to .git-mem/.git-mem.yaml', () => {
const testDir = '/some/dir';
const result = getConfigPath(testDir);
assert.equal(result, '/some/dir/.git-mem/.git-mem.yaml');
});

it('should use process.cwd() when no cwd provided', () => {
const result = getConfigPath();
assert.ok(result.endsWith('.git-mem/.git-mem.yaml'));
});
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

These assertions hard-code POSIX separators (/some/dir/... and .endsWith('.git-mem/.git-mem.yaml')). Since getConfigPath() uses path.join(), the output is platform-dependent and these tests will fail on Windows. Consider asserting using join(testDir, CONFIG_DIR, CONFIG_FILE) and using path.sep-safe checks for the process.cwd() cases.

Copilot uses AI. Check for mistakes.
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