@nueldotdev/amnesiac 1.0.0 → 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/.npmignore CHANGED
@@ -6,6 +6,7 @@
6
6
  !lib/
7
7
  !package.json
8
8
  !README.md
9
+ !CHANGELOG.md
9
10
  !LICENSE
10
11
 
11
12
  # Ignore config, test, and local files
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 nueldotdev:
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -23,6 +23,7 @@ Amnesiac is a CLI tool for keeping track of what’s changed in your code. It lo
23
23
  - [Getting Your API Key](#getting-your-api-key)
24
24
  - [Keeping Your API Key Secure](#keeping-your-api-key-secure)
25
25
  - [Understanding Gemini Models](#understanding-gemini-models)
26
+ - [Changelog](#changelog)
26
27
 
27
28
  ## Features
28
29
 
@@ -40,7 +41,7 @@ To install Amnesiac, you will first need to have [Node.js](https://nodejs.org/)
40
41
  Then, you can install Amnesiac globally via npm:
41
42
 
42
43
  ```bash
43
- npm install -g amnesiac
44
+ npm install -g @nueldotdev/amnesiac
44
45
  ```
45
46
 
46
47
  This will make the `amnesiac` command available from any directory in your terminal.
@@ -50,7 +51,7 @@ This will make the `amnesiac` command available from any directory in your termi
50
51
  To update your globally installed Amnesiac to the latest version, simply run:
51
52
 
52
53
  ```bash
53
- npm update -g amnesiac
54
+ npm update -g @nueldotdev/amnesiac
54
55
  ```
55
56
 
56
57
  ## Getting Started
@@ -79,6 +80,29 @@ npm update -g amnesiac
79
80
  - Receive a concise changelog entry.
80
81
  - Prepend the new entry to your `CHANGELOG.md` file (or the file specified in your config).
81
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
+
82
106
  ## Configuration & Profiles
83
107
 
84
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.
@@ -100,7 +124,7 @@ You can create an `amnesiac.config.js` file in the root of your project to defin
100
124
  ```javascript
101
125
  export default {
102
126
  apiKey: process.env.GEMINI_API_KEY, // Can be sourced from environment variables
103
- model: "gemini-1.5-pro",
127
+ model: "gemini-2.5-flash",
104
128
  outputFile: "PROJECT_CHANGELOG.md",
105
129
  prompt: `
106
130
  Generate a comprehensive changelog entry focusing on new features and bug fixes for this project.
@@ -121,8 +145,20 @@ The main command to generate a changelog entry. It uses the configuration determ
121
145
  ```bash
122
146
  amnesiac
123
147
  amnesiac -p "Custom prompt for this run" # Override prompt for a single run
124
- amnesiac -m "gemini-pro" # Override model for a single run
148
+ amnesiac -m "gemini-2.5-flash" # Override model for a single run
125
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
126
162
  ```
127
163
 
128
164
  ### `amnesiac init`
@@ -220,9 +256,13 @@ Your API key is a sensitive credential. Treat it like a password:
220
256
 
221
257
  ### Understanding Gemini Models
222
258
 
223
- The `model` parameter (e.g., `gemini-1.5-flash`, `gemini-1.5-pro`) determines which Gemini model Amnesiac uses for content generation.
259
+ The `model` parameter (e.g., `gemini-2.5-flash`, `gemini-2.5-pro`) determines which Gemini model Amnesiac uses for content generation.
224
260
 
225
- - **`gemini-1.5-flash`:** A faster, more cost-effective model, suitable for many common tasks. This is the default.
226
- - **`gemini-1.5-pro`:** A more capable model for complex tasks, offering higher quality but potentially at a higher latency or cost.
261
+ - **`gemini-2.5-flash`:** A faster, more cost-effective model, suitable for many common tasks. This is the default.
262
+ - **`gemini-2.5-pro`:** A more capable model for complex tasks, offering higher quality but potentially at a higher latency or cost.
227
263
 
228
264
  You can specify the model in your global or local configurations, or override it for a single run using `amnesiac -m <model_name>`. Refer to the [Gemini API documentation](https://ai.google.dev/models/gemini) for the latest information on available models and their capabilities.
265
+
266
+ ## Changelog
267
+
268
+ See full history in [CHANGELOG.md](./CHANGELOG.md).
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();
@@ -26,7 +27,7 @@ program
26
27
  const localConfigPath = path.resolve(process.cwd(), "amnesiac.config.js");
27
28
  const defaultConfigContent = `export default {
28
29
  apiKey: process.env.GEMINI_API_KEY || "", // Consider adding a placeholder for API key
29
- model: "gemini-1.5-flash",
30
+ model: "gemini-2.5-flash",
30
31
  outputFile: "CHANGELOG.md",
31
32
  prompt: \`
32
33
  You are an assistant that generates clean, developer-friendly changelog entries.
@@ -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")
@@ -200,7 +236,7 @@ program
200
236
  type: "input",
201
237
  name: "model",
202
238
  message: "Enter model name:",
203
- default: existingConfig.model || "gemini-1.5-flash",
239
+ default: existingConfig.model || "gemini-2.5-flash",
204
240
  },
205
241
  {
206
242
  type: "input",
@@ -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.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
- "simple-git": "^3.28.0"
37
+ "open": "^11.0.0",
38
+ "simple-git": "^3.28.0",
39
+ "update-notifier": "^7.3.1"
38
40
  }
39
- }
41
+ }