Skip to content

feat: add --config flag for chronicle.yaml path#26

Open
rsbh wants to merge 6 commits intomainfrom
feat_config_file_arg
Open

feat: add --config flag for chronicle.yaml path#26
rsbh wants to merge 6 commits intomainfrom
feat_config_file_arg

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented Mar 31, 2026

Summary

  • Add --config <path> flag to dev, build, and serve commands to specify chronicle.yaml location
  • Remove -c short arg from --content across all commands to avoid future conflicts
  • Config resolution: --config flag takes priority over cwd lookup; removed content dir fallback

Test plan

  • Build CLI successfully
  • Verified --help shows --config option
  • Tested --config flag from different cwd — dev server starts with correct config

🤖 Generated with Claude Code

rsbh and others added 2 commits March 31, 2026 08:39
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a --config option to build, dev, and serve to specify a chronicle.yaml path.
  • Breaking Changes

    • Removed the -c shorthand for --content across CLI commands (use --content).
    • Config resolution changed: when --config is provided that exact file is used; otherwise the tool no longer falls back to the content directory and checks the project/CWD location only.

Walkthrough

CLI commands remove the -c shorthand for --content, add a new --config <path> option, and pass a resolved configPath into Vite config creation; config resolution now prefers an explicit config flag and no longer falls back to the content directory.

Changes

Cohort / File(s) Summary
CLI Commands
packages/chronicle/src/cli/commands/build.ts, packages/chronicle/src/cli/commands/dev.ts, packages/chronicle/src/cli/commands/serve.ts, packages/chronicle/src/cli/commands/start.ts
Removed -c short alias for --content (long-only); added --config <path> to build/dev/serve; actions resolve configPath and pass it into createViteConfig when applicable.
Config Utilities
packages/chronicle/src/cli/utils/config.ts
Exported and changed `resolveConfigPath(configPath?: string): string
Vite Configuration
packages/chronicle/src/server/vite-config.ts
Added optional configPath?: string to ViteConfigOptions; createViteConfig/config reading now uses configPath (reads exact file when provided) and otherwise checks projectRoot only (removed contentDir fallback).

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI Command
  participant Resolver as resolveConfigPath
  participant Loader as loadCLIConfig
  participant Vite as createViteConfig
  participant FS as Filesystem

  CLI->>Resolver: provide options.config (optional)
  Resolver->>FS: read provided config path (if any) or return undefined
  Resolver-->>CLI: return configPath or undefined
  CLI->>Loader: call loadCLIConfig(contentDir, configPath)
  Loader->>FS: read/parse resolved chronicle.yaml (configPath or CWD/chronicle.yaml)
  Loader-->>CLI: return CLIConfig
  CLI->>Vite: call createViteConfig(..., configPath)
  Vite->>FS: read chronicle.yaml using configPath or projectRoot
  Vite-->>CLI: return resolved Vite config
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • rohilsurana
  • rohanchkrabrty
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a --config flag for specifying the chronicle.yaml path.
Description check ✅ Passed The description is directly related to the changeset, detailing the new --config flag addition and removal of -c shorthand across commands.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat_config_file_arg

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.

❤️ Share

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/chronicle/src/server/vite-config.ts`:
- Around line 26-33: The readChronicleConfig function currently swallows read
errors when a user supplies a configPath; change the behavior so that when
configPath is provided and fs.readFile fails you do not return null but instead
surface the error (either rethrow the caught error or throw a new Error that
includes the provided configPath and the original error message) so callers know
the explicit config is unreadable; update the try/catch around fs.readFile in
readChronicleConfig to include the configPath in the error context and propagate
the failure rather than silently returning null.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ef651e45-ab60-45d5-a7e2-de5ae51da3dc

📥 Commits

Reviewing files that changed from the base of the PR and between 8c3b2b6 and f0d6038.

📒 Files selected for processing (6)
  • packages/chronicle/src/cli/commands/build.ts
  • packages/chronicle/src/cli/commands/dev.ts
  • packages/chronicle/src/cli/commands/serve.ts
  • packages/chronicle/src/cli/commands/start.ts
  • packages/chronicle/src/cli/utils/config.ts
  • packages/chronicle/src/server/vite-config.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…null

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/chronicle/src/cli/utils/config.ts`:
- Around line 18-23: The function resolveConfigPath currently returns
path.resolve(configPath) even if that file does not exist; update
resolveConfigPath (and its usage in loadCLIConfig) to validate existence: when
configPath is provided, resolve it, check fs.existsSync(resolvedPath) and only
return the resolvedPath if the file exists, otherwise return undefined (so
loadCLIConfig can emit the friendly error). Ensure you reference
resolveConfigPath and any direct callers like loadCLIConfig to handle the
undefined return properly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d292239b-0d11-4036-834c-801ae15e2f45

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9d126 and 1e146a7.

📒 Files selected for processing (4)
  • packages/chronicle/src/cli/commands/build.ts
  • packages/chronicle/src/cli/commands/dev.ts
  • packages/chronicle/src/cli/commands/serve.ts
  • packages/chronicle/src/cli/utils/config.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/chronicle/src/cli/commands/build.ts
  • packages/chronicle/src/cli/commands/dev.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/chronicle/src/cli/utils/config.ts`:
- Around line 27-37: The catch block around reading/parsing the config masks
YAML parse errors by always claiming the file is missing; update the error
handling around fs.readFile(resolvedConfigPath, 'utf-8') and parse(raw) so you
inspect the caught error (e.g., catch (err)): if err.code === 'ENOENT' log the
existing "not found" message, otherwise treat it as a parse/other error and log
a clear message that includes the parse failure details (err.message and
optionally err.stack) and mention the config file (resolvedConfigPath) so users
know their ChronicleConfig YAML is malformed and can fix it before
process.exit(1).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 03916522-ad4f-4b50-8d75-4fa7ded3a7a6

📥 Commits

Reviewing files that changed from the base of the PR and between 1e146a7 and 09d2628.

📒 Files selected for processing (1)
  • packages/chronicle/src/cli/utils/config.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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