gaslighting-engine 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -89,6 +89,32 @@ gaslighting-engine skill
89
89
  gaslighting-engine agents
90
90
  ```
91
91
 
92
+ ## Update Notice
93
+
94
+ Gaslighting-engine checks npm for a newer version when you run normal commands.
95
+
96
+ If an update exists, it prints a short notice like:
97
+
98
+ ```txt
99
+ Gaslighting-engine update available:
100
+ - current: 0.1.0
101
+ - latest: 0.1.1
102
+ - update: npm install -g gaslighting-engine@latest
103
+ - npx: npx gaslighting-engine@latest
104
+ ```
105
+
106
+ The update check is best-effort and never blocks the command. Disable it with:
107
+
108
+ ```bash
109
+ GASLIGHTING_ENGINE_NO_UPDATE_CHECK=1 gaslighting-engine doctor
110
+ ```
111
+
112
+ PowerShell:
113
+
114
+ ```powershell
115
+ $env:GASLIGHTING_ENGINE_NO_UPDATE_CHECK="1"; gaslighting-engine doctor; Remove-Item Env:GASLIGHTING_ENGINE_NO_UPDATE_CHECK
116
+ ```
117
+
92
118
  ## Useful Options
93
119
 
94
120
  Options are escape hatches. The strict behavior is already the default.
package/dist/cli.js CHANGED
@@ -6,6 +6,7 @@ import { runGenerate } from "./commands/generate.js";
6
6
  import { runInit } from "./commands/init.js";
7
7
  import { runSkill } from "./commands/skill.js";
8
8
  import { runUpdate } from "./commands/update.js";
9
+ import { packageVersion } from "./version.js";
9
10
  const projectTypes = [
10
11
  "hospital_homepage",
11
12
  "ecommerce",
@@ -48,7 +49,7 @@ export function buildCli() {
48
49
  program
49
50
  .name("gaslighting-engine")
50
51
  .description("LUDGI Gaslighting-engine: a hardcore project-discipline generator for AI coding agents.")
51
- .version("0.1.0")
52
+ .version(packageVersion)
52
53
  .showHelpAfterError()
53
54
  .addHelpText("after", `
54
55
  Examples:
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { buildCli, normalizeDefaultInitArgv } from "./cli.js";
3
+ import { notifyIfUpdateAvailable } from "./utils/updateCheck.js";
4
+ await notifyIfUpdateAvailable(process.argv);
3
5
  buildCli().parse(normalizeDefaultInitArgv(process.argv));
@@ -0,0 +1,61 @@
1
+ import { packageName, packageVersion } from "../version.js";
2
+ const updateCheckTimeoutMs = 900;
3
+ export async function notifyIfUpdateAvailable(argv) {
4
+ if (shouldSkipUpdateCheck(argv))
5
+ return;
6
+ try {
7
+ const latestVersion = process.env.GASLIGHTING_ENGINE_LATEST_VERSION ?? (await fetchLatestVersion());
8
+ if (!latestVersion || !isNewerVersion(latestVersion, packageVersion))
9
+ return;
10
+ console.error("");
11
+ console.error("Gaslighting-engine update available:");
12
+ console.error(`- current: ${packageVersion}`);
13
+ console.error(`- latest: ${latestVersion}`);
14
+ console.error(`- update: npm install -g ${packageName}@latest`);
15
+ console.error(`- npx: npx ${packageName}@latest`);
16
+ console.error("");
17
+ }
18
+ catch {
19
+ // Update checks must never block the user's actual command.
20
+ }
21
+ }
22
+ async function fetchLatestVersion() {
23
+ const controller = new AbortController();
24
+ const timeout = setTimeout(() => controller.abort(), updateCheckTimeoutMs);
25
+ try {
26
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
27
+ signal: controller.signal,
28
+ headers: { accept: "application/json" },
29
+ });
30
+ if (!response.ok)
31
+ return undefined;
32
+ const data = (await response.json());
33
+ return data.version;
34
+ }
35
+ finally {
36
+ clearTimeout(timeout);
37
+ }
38
+ }
39
+ function shouldSkipUpdateCheck(argv) {
40
+ if (process.env.GASLIGHTING_ENGINE_NO_UPDATE_CHECK === "1")
41
+ return true;
42
+ if (process.env.NO_UPDATE_NOTIFIER === "1")
43
+ return true;
44
+ return argv.some((arg) => ["--help", "-h", "--version", "-V"].includes(arg));
45
+ }
46
+ export function isNewerVersion(candidate, current) {
47
+ const candidateParts = parseVersion(candidate);
48
+ const currentParts = parseVersion(current);
49
+ for (let index = 0; index < 3; index += 1) {
50
+ if (candidateParts[index] > currentParts[index])
51
+ return true;
52
+ if (candidateParts[index] < currentParts[index])
53
+ return false;
54
+ }
55
+ return false;
56
+ }
57
+ function parseVersion(version) {
58
+ const clean = version.split("-")[0] ?? version;
59
+ const parts = clean.split(".").map((part) => Number.parseInt(part, 10));
60
+ return [parts[0] || 0, parts[1] || 0, parts[2] || 0];
61
+ }
@@ -0,0 +1,2 @@
1
+ export const packageName = "gaslighting-engine";
2
+ export const packageVersion = "0.1.1";
package/docs/examples.md CHANGED
@@ -20,3 +20,9 @@ Published usage:
20
20
  ```bash
21
21
  npx gaslighting-engine "I want to build a hospital website."
22
22
  ```
23
+
24
+ Update check test:
25
+
26
+ ```bash
27
+ GASLIGHTING_ENGINE_LATEST_VERSION=9.9.9 node dist/index.js doctor --path examples/hospital-homepage
28
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaslighting-engine",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "LUDGI Gaslighting-engine: a hardcore project-discipline generator for AI coding agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",