Improve devlog init so it is safe to run multiple times and fully prepares the local DevLog workspace.
Context:
README.md says devlog init is safe to run multiple times and will not overwrite existing data
- Current implementation uses
viper.SafeWriteConfig(), which can fail when the config already exists
- Current implementation creates only the base
~/.devlog/ directory and writes config, but does not ensure subdirectories exist
Expected behavior:
devlog init can be run repeatedly without failing in normal already-initialized cases
- Existing config should not be overwritten
- Missing directories should be created automatically
- The command should report what was created versus what already existed
- Directories that should be ensured:
~/.devlog/
~/.devlog/entries/
~/.devlog/summaries/
~/.devlog/templates/
Implementation notes:
- Preserve existing user config if
config.json is already present
- Create config only when it does not already exist
- If some directories are missing, create only the missing ones
- Return real errors only for actual failure cases such as permission issues or invalid paths
- Consider printing a friendly summary such as:
- config already exists
- created entries/
- created summaries/
Acceptance criteria:
- Running
devlog init on a fresh machine creates config and required directories
- Running
devlog init again succeeds without overwriting existing config
- If one or more subdirectories are missing, they are recreated
- The command output clearly indicates what happened
- Behavior matches the README claim that init is safe to run multiple times
Improve
devlog initso it is safe to run multiple times and fully prepares the local DevLog workspace.Context:
README.mdsaysdevlog initis safe to run multiple times and will not overwrite existing dataviper.SafeWriteConfig(), which can fail when the config already exists~/.devlog/directory and writes config, but does not ensure subdirectories existExpected behavior:
devlog initcan be run repeatedly without failing in normal already-initialized cases~/.devlog/~/.devlog/entries/~/.devlog/summaries/~/.devlog/templates/Implementation notes:
config.jsonis already presentAcceptance criteria:
devlog initon a fresh machine creates config and required directoriesdevlog initagain succeeds without overwriting existing config