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 +26 -0
- package/dist/cli.js +2 -1
- package/dist/index.js +2 -0
- package/dist/utils/updateCheck.js +61 -0
- package/dist/version.js +2 -0
- package/docs/examples.md +6 -0
- package/package.json +1 -1
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(
|
|
52
|
+
.version(packageVersion)
|
|
52
53
|
.showHelpAfterError()
|
|
53
54
|
.addHelpText("after", `
|
|
54
55
|
Examples:
|
package/dist/index.js
CHANGED
|
@@ -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
|
+
}
|
package/dist/version.js
ADDED
package/docs/examples.md
CHANGED