Skip to content

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

Closed
TonyCasey wants to merge 1 commit intogit-88from
git-89
Closed

feat: migrate config from JSON to YAML (GIT-89)#60
TonyCasey wants to merge 1 commit intogit-88from
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

  • npm run pre-commit passes (type-check + lint)
  • All 529 tests pass (438 unit + 91 integration)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Configuration management switched from JSON format to YAML format
    • Configuration files now organized in dedicated .git-mem directory structure
    • Enhanced configuration utilities with improved path resolution capabilities
  • Tests

    • Test infrastructure updated to validate new YAML-based configuration layout and directory organization

- 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
@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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

Configuration loading migrated from JSON file (.git-mem.json) to YAML format (.git-mem/.git-mem.yaml) in a dedicated directory. New utility exports added for path resolution: getConfigPath() and getConfigDir(). Tests updated to use YAML parsing and new config constants throughout.

Changes

Cohort / File(s) Summary
Configuration Module
src/hooks/utils/config.ts
Switched config loading from JSON to YAML, added constants (CONFIG_DIR, CONFIG_FILE) and helper functions (getConfigPath, getConfigDir) for cwd-aware path resolution. Updated parser to use parseYaml instead of JSON.parse.
Test Helpers and Integration Tests
tests/integration/hooks/helpers.ts, tests/integration/hooks/hook-commit-msg.test.ts
Updated config writing logic to create .git-mem directory, write YAML files instead of JSON, and use new CONFIG_DIR/CONFIG_FILE constants. Applies stringifyYaml for serialization.
Config Unit Tests
tests/unit/hooks/utils/config.test.ts
Expanded test suite to validate new getConfigPath() and getConfigDir() APIs, updated fixtures to use YAML format under .git-mem directory, added tests for cwd-aware path resolution and YAML parsing edge cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: migrating configuration format from JSON to YAML, which is reflected across all modified files.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into git-88

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/utils/config.ts (1)

59-99: ⚠️ Potential issue | 🟠 Major

Add legacy .git-mem.json fallback (avoid silent behavior change).

Existing repos initialized with .git-mem.json (at root) will silently fall back to defaults when hooks try to load config, since loadHookConfig() now only looks for .git-mem/.git-mem.yaml. This is a breaking change because init commands (src/commands/init.ts, src/commands/init-hooks.ts) still create .git-mem.json at the root.

Consider a backward-compat fallback to check .git-mem.json (legacy, root-level) after checking .git-mem/.git-mem.yaml (new location).

Suggested backward-compat fallback
 export function loadHookConfig(cwd?: string): IHookConfig {
+  const dir = cwd ?? process.cwd();
   const configPath = getConfigPath(cwd);
+  const legacyPath = join(dir, '.git-mem.json');

-  if (!existsSync(configPath)) {
-    return DEFAULTS;
-  }
+  const hasYaml = existsSync(configPath);
+  const hasLegacy = existsSync(legacyPath);
+  if (!hasYaml && !hasLegacy) {
+    return DEFAULTS;
+  }

   try {
-    const raw = parseYaml(readFileSync(configPath, 'utf8')) as Record<string, unknown>;
+    const contents = readFileSync(hasYaml ? configPath : legacyPath, 'utf8');
+    const raw = (hasYaml ? parseYaml(contents) : JSON.parse(contents)) as Record<string, unknown>;
     const rawHooks = (raw.hooks ?? {}) as Partial<IHooksConfig>;

@TonyCasey TonyCasey deleted the branch git-88 February 14, 2026 22:42
@TonyCasey TonyCasey closed this Feb 14, 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.

1 participant