feat: add iris init / config check / config path (v0.1.16)#22
Conversation
Config experience: generate, validate, and locate the config from the CLI, instead of hand-writing ~/.iris-slack/config.toml. - `iris init` — write a commented starter config (embedded string so it works from the SEA binary too); never overwrites; created 0600 (holds tokens) - `iris config check` — validate via loadConfig() without starting; prints a per-project summary; ConfigError reported with path + non-zero exit - `iris config path` — print which config file would be used main()'s switch is now a dispatch table to keep complexity flat. README (en/ja) setup updated. Ported from upstream (GitLab) v0.1.17; the OSS-specific execFileSync hardening and resolveConfigPath(cwd/home) test seam are preserved (cli.ts changes are additive only). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThree new CLI subcommands ( Changesiris init & config subcommands
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli.ts`:
- Around line 210-214: The logic in the config path resolution needs to
explicitly reject the --config flag when it lacks a value argument instead of
silently falling back to auto-resolution. Modify the condition to check if
--config is present but either is the last argument or the next element is
undefined or another flag, and in that case throw or return an error with a
usage message. Only proceed with resolveConfigPath() as a fallback when --config
is not present at all.
- Around line 186-196: The code has a race condition where a file could be
created between the existsSync check and the writeFileSync call, causing the
non-overwrite guarantee to be broken. Replace the current check-then-write
pattern with an atomic file creation operation. Use the writeFileSync call with
a flag option set to 'wx' (write exclusive) instead of the default behavior,
which will throw an error if the file already exists, eliminating the race
condition. Remove the existsSync check since the exclusive write flag will
handle the collision detection atomically. Ensure the mkdirSync call is still
executed before attempting the atomic write to create the necessary directory
structure.
🪄 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 Plus
Run ID: 496debbb-2939-4f57-bfb3-43179c2d5582
📒 Files selected for processing (4)
README.ja.mdREADME.mdpackage.jsonsrc/cli.ts
Addresses CodeRabbit review on PR #22. - init: replace the existsSync-then-write (TOCTOU) with an exclusive create (writeFileSync flag 'wx'), so the never-overwrite guarantee holds even against a concurrent creator. EEXIST → the same friendly notice. - resolveConfigForInspect: when --config is present but has no value (or the next token is a flag), fail fast with a usage error instead of silently auto-resolving. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
@coderabbitai Addressed both:
|
|
Tip For best results, initiate chat on the files or code changes.
Thanks for the thorough follow-through on both points! 🐇✨ |
Summary
Adds a config experience so users can generate, validate, and locate their config from the CLI instead of hand-writing
~/.iris-slack/config.toml.iris init— writes a commented starter config (embedded as a string so it works from the SEA binary, which doesn't bundle the example file). Never overwrites an existing file; created0600since it holds Slack tokens.iris config check— runsloadConfig()on the resolved path without starting the bridge; prints a per-project summary (name / mode / workDir / channel & user counts; no tokens).ConfigErroris reported with the file path and a non-zero exit.iris config path— prints which config file would be used (or reports none and suggestsiris init).Both inspect commands honor
--config; otherwise they use the sameresolveConfigPath()search the bridge uses.Implementation
main()'s switch is now a dispatch table to keep complexity flat as commands are added.iris init→ fill tokens →iris config check.execFileSync(no-shell) calls from the CodeQL fix and theresolveConfigPath(cwd/home)test seam are untouched — cli.ts changes are additive only, config.ts is unchanged.Checks
pnpm verify— 99 tests pass🤖 Generated with Claude Code
Summary by CodeRabbit
iris initto generate a commented starter config template (created with secure permissions and without overwriting existing files)iris config checkto validate the effective configuration and display a summaryiris config pathto show where the config is resolved from0.1.16