@nueldotdev/amnesiac 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -5
- package/README.md +35 -0
- package/bin/cli.js +83 -4
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
##
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
## 2026-01-21 — v1.0.2
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
* **Changelog Preview & Edit:** Introduced a new `--dry-run` option allowing users to preview and edit generated changelog entries before saving them.
|
|
6
|
+
* **Changelog Save Recovery:** Implemented a recovery mechanism to persist generated changelog content locally if saving fails.
|
|
7
|
+
* **Git Status & Diff Command:** Added a new `show-git` command with `--status` and `--diff` options to display the current Git repository status or changes directly from the CLI.
|
|
8
|
+
* **New Dependencies:** Added `open` and `update-notifier` for future enhancements and version notifications.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
* **Refactored Changelog Generation:** The `generateDocs` function now returns the generated changelog entry instead of directly writing it to a file, providing more control over the saving process.
|
|
13
|
+
* **Improved Configuration Loading:** Enhanced `loadConfig` to better manage active profiles and ensure CLI options correctly override existing configurations.
|
|
14
|
+
* **Git Status JSDoc:** Added detailed JSDoc comments to the `getStatus` function in `lib/git.js` for improved code clarity.
|
|
15
|
+
|
|
16
|
+
## 2025-10-03 — v1.0.1
|
|
17
|
+
|
|
18
|
+
- Default model updated: Now uses `gemini-2.5-flash` by default to align with the latest Gemini API.
|
|
19
|
+
|
|
20
|
+
|
package/README.md
CHANGED
|
@@ -80,6 +80,29 @@ npm update -g @nueldotdev/amnesiac
|
|
|
80
80
|
- Receive a concise changelog entry.
|
|
81
81
|
- Prepend the new entry to your `CHANGELOG.md` file (or the file specified in your config).
|
|
82
82
|
|
|
83
|
+
### Preview/edit workflow (recommended)
|
|
84
|
+
|
|
85
|
+
If you want to review and tweak the generated entry before it is written to your changelog, use `--dry-run`:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
amnesiac --dry-run
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This flow will:
|
|
92
|
+
|
|
93
|
+
- Open a temporary `.md` file containing the generated entry in your default editor
|
|
94
|
+
- Let you edit it
|
|
95
|
+
- Ask you to confirm before saving it to your changelog
|
|
96
|
+
|
|
97
|
+
**Important (Windows/editor note):** some editors don't allow the CLI to reliably detect when the file is closed. After you edit the temp file, **save it in your editor (Ctrl+S)**, then return to the terminal and press Enter when prompted.
|
|
98
|
+
|
|
99
|
+
### Safety: backups and recovery
|
|
100
|
+
|
|
101
|
+
When saving to your changelog file, Amnesiac writes safely:
|
|
102
|
+
|
|
103
|
+
- If a changelog file already exists, it may create a best-effort backup alongside it (e.g. `CHANGELOG.md.bak.<timestamp>`).
|
|
104
|
+
- If saving fails (permissions/locked file/etc.), Amnesiac will write a **recovery copy** to your OS temp directory and print the path so you don't lose the generated/edited entry.
|
|
105
|
+
|
|
83
106
|
## Configuration & Profiles
|
|
84
107
|
|
|
85
108
|
Amnesiac offers a flexible configuration system that allows you to manage settings at different levels: per-project, globally, or as a one-off CLI override.
|
|
@@ -124,6 +147,18 @@ amnesiac
|
|
|
124
147
|
amnesiac -p "Custom prompt for this run" # Override prompt for a single run
|
|
125
148
|
amnesiac -m "gemini-2.5-flash" # Override model for a single run
|
|
126
149
|
amnesiac -u work # Use 'work' profile for a single run
|
|
150
|
+
amnesiac -d # Preview/edit in your editor before saving
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `amnesiac show-git`
|
|
154
|
+
|
|
155
|
+
Display the current Git status or diff for the repository you are currently in.
|
|
156
|
+
|
|
157
|
+
**Usage:**
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
amnesiac show-git --status
|
|
161
|
+
amnesiac show-git --diff
|
|
127
162
|
```
|
|
128
163
|
|
|
129
164
|
### `amnesiac init`
|
package/bin/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import os from "os";
|
|
|
6
6
|
import inquirer from "inquirer";
|
|
7
7
|
import { generateDocs } from "../lib/doc_generator.js";
|
|
8
8
|
import { loadConfig } from "../lib/config.js";
|
|
9
|
+
import { previewAndEditChangelog, saveChangelogEntry, persistRecoveryCopy } from "../lib/display.js";
|
|
9
10
|
import { readFileSync } from 'fs';
|
|
10
11
|
|
|
11
12
|
const program = new Command();
|
|
@@ -113,6 +114,41 @@ program
|
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
|
|
117
|
+
|
|
118
|
+
program
|
|
119
|
+
.command("show-git")
|
|
120
|
+
.option("-s, --status", "Display the status of the files within the repository")
|
|
121
|
+
.option("-d, --diff", "Display the changes within the files of the repository")
|
|
122
|
+
.description("Display the current status or changes in your Git repository")
|
|
123
|
+
.action(async (options) => {
|
|
124
|
+
// Only allow one of --status or --diff at a time
|
|
125
|
+
if (options.status && options.diff) {
|
|
126
|
+
console.error("\n❌ You can only use one of --status or --diff at a time.\n");
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
if (!options.status && !options.diff) {
|
|
130
|
+
console.error("\n❌ Please specify either --status or --diff.\n");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
if (options.status) {
|
|
136
|
+
const { getStatus } = await import('../lib/git.js');
|
|
137
|
+
const statusStr = await getStatus();
|
|
138
|
+
console.log("\n--- Git Status ---\n" + statusStr + "\n");
|
|
139
|
+
} else if (options.diff) {
|
|
140
|
+
const { getDiff } = await import('../lib/git.js');
|
|
141
|
+
const { displayChanges } = await import('../lib/display.js');
|
|
142
|
+
const diffStr = await getDiff();
|
|
143
|
+
await displayChanges(diffStr);
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error(`\n❌ An error occurred while displaying git info: ${error.message}`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
|
|
116
152
|
program
|
|
117
153
|
.command("config")
|
|
118
154
|
.description("Set up or edit Amnesiac config")
|
|
@@ -258,19 +294,62 @@ program
|
|
|
258
294
|
}
|
|
259
295
|
});
|
|
260
296
|
|
|
261
|
-
program
|
|
297
|
+
program
|
|
298
|
+
.option("-d, --dry-run", "Preview and edit before saving")
|
|
262
299
|
.option("-u, --use <profile>", "Use a specific profile for this run")
|
|
263
300
|
.option("-p, --prompt <text>", "Override prompt")
|
|
264
301
|
.option("-m, --model <name>", "Override model")
|
|
265
|
-
// Future: .option("-u, --use <profile>", "Use specific profile")
|
|
266
302
|
.action(async (opts) => {
|
|
267
303
|
try {
|
|
268
304
|
const config = await loadConfig(opts);
|
|
269
|
-
await generateDocs(config);
|
|
305
|
+
const changelogEntry = await generateDocs(config);
|
|
306
|
+
|
|
307
|
+
if (!changelogEntry) {
|
|
308
|
+
return; // No changes detected
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (opts.dryRun) {
|
|
312
|
+
// Preview and let user edit/confirm
|
|
313
|
+
console.log("\n🔄 Previewing changelog entry. \nYou can review and edit before saving");
|
|
314
|
+
const { content, shouldSave, wasModified } = await previewAndEditChangelog(changelogEntry);
|
|
315
|
+
|
|
316
|
+
if (shouldSave) {
|
|
317
|
+
let savedPath;
|
|
318
|
+
try {
|
|
319
|
+
savedPath = saveChangelogEntry(config, content);
|
|
320
|
+
} catch (e) {
|
|
321
|
+
const recoveryPath = persistRecoveryCopy(content, "save_failed");
|
|
322
|
+
console.error(`\n❌ Failed to save changelog: ${e.message}`);
|
|
323
|
+
console.error(`✅ Your generated entry was saved for recovery at: ${recoveryPath}\n`);
|
|
324
|
+
process.exit(1);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (wasModified) {
|
|
328
|
+
console.log(`✅ Your edited changelog has been saved to ${savedPath}`);
|
|
329
|
+
} else {
|
|
330
|
+
console.log(`✅ Changelog updated at ${savedPath}`);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
console.log("❌ Changelog not saved.");
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
// No preview, just save
|
|
337
|
+
console.log("🔄 Saving changelog entry...");
|
|
338
|
+
let savedPath;
|
|
339
|
+
try {
|
|
340
|
+
savedPath = saveChangelogEntry(config, changelogEntry);
|
|
341
|
+
} catch (e) {
|
|
342
|
+
const recoveryPath = persistRecoveryCopy(changelogEntry, "save_failed");
|
|
343
|
+
console.error(`\n❌ Failed to save changelog: ${e.message}`);
|
|
344
|
+
console.error(`✅ Your generated entry was saved for recovery at: ${recoveryPath}\n`);
|
|
345
|
+
process.exit(1);
|
|
346
|
+
}
|
|
347
|
+
console.log(`✅ Changelog updated at ${savedPath}`);
|
|
348
|
+
}
|
|
270
349
|
} catch (error) {
|
|
271
350
|
console.error(`\n❌ An error occurred: ${error.message}`);
|
|
272
351
|
process.exit(1);
|
|
273
352
|
}
|
|
274
353
|
});
|
|
275
354
|
|
|
276
|
-
program.parse(process.argv);
|
|
355
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nueldotdev/amnesiac",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A command-line tool to automatically generate documentation for recent codebase changes using the Gemini API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli-tool",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"@google/generative-ai": "^0.24.1",
|
|
35
35
|
"commander": "^14.0.1",
|
|
36
36
|
"inquirer": "^12.9.6",
|
|
37
|
-
"
|
|
37
|
+
"open": "^11.0.0",
|
|
38
|
+
"simple-git": "^3.28.0",
|
|
39
|
+
"update-notifier": "^7.3.1"
|
|
38
40
|
}
|
|
39
41
|
}
|