@paxnax/berliner 0.9.0 → 0.10.0
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 +1 -0
- package/dist/args.js +1 -0
- package/dist/commands/version.js +40 -0
- package/dist/index.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,7 @@ Other commands:
|
|
|
127
127
|
- `berliner delete <session-id>`: delete a session, or one item with `--evidence <id>`. Asks to confirm unless `--yes`.
|
|
128
128
|
- `berliner evidence public <id>`: let anyone with the link view one file, and print its public URL and Markdown line. `berliner evidence private <id>` makes it private again. `berliner session` shows the ids, and the URL of each public file.
|
|
129
129
|
- `berliner skill`: print the agent skill (`SKILL.md`) to install in your agent.
|
|
130
|
+
- `berliner version [--json]`, or `berliner --version`: print this CLI's version and whether it is the latest release, with `berliner upgrade` to run when it is not. It looks the latest release up at most every 5 minutes; when the registry can't be reached it still prints the version and says so.
|
|
130
131
|
- `berliner upgrade [--yes] [--no-skill] [--no-hooks]`: install the latest CLI and skill. It shows its plan (the versions, the exact install command, each skill file and each Berliner hook it updates) and asks before changing anything; a second question, or `--no-skill`, leaves your skill as it is, and `--no-hooks` leaves your hooks as they are. It brings a Berliner hook an older setup installed up to date, but never adds one; your token and config are never touched. When it updated a skill or hook, its last line names the tools to start a new session in so they load it.
|
|
131
132
|
- `berliner hook <tool>`: run by the hooks setup installs, with the tool's payload on stdin. It never fails and never makes the agent wait, and prints only the reminder when a session starts; errors go to `${XDG_STATE_HOME:-~/.local/state}/berliner/hook.log`.
|
|
132
133
|
|
package/dist/args.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { cacheDir } from "../config.js";
|
|
4
|
+
import { print } from "../output.js";
|
|
5
|
+
import { currentVersion, latestVersion, newer, registryOf } from "../version.js";
|
|
6
|
+
// Short, unlike the daily notice's day: someone asking for the version wants to see a release within minutes of it.
|
|
7
|
+
const CACHE_MS = 5 * 60_000;
|
|
8
|
+
const LOOKUP_TIMEOUT_MS = 3000;
|
|
9
|
+
// The latest release, from the cache file while it is fresh (its mtime is when it was looked up); null when the registry
|
|
10
|
+
// can't be reached.
|
|
11
|
+
async function latest(env) {
|
|
12
|
+
const file = join(cacheDir(env), "latest-version");
|
|
13
|
+
try {
|
|
14
|
+
if (Date.now() - statSync(file).mtimeMs < CACHE_MS)
|
|
15
|
+
return readFileSync(file, "utf8").trim();
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Not looked up yet on this machine.
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const version = await latestVersion(env, LOOKUP_TIMEOUT_MS);
|
|
22
|
+
mkdirSync(cacheDir(env), { recursive: true, mode: 0o700 });
|
|
23
|
+
writeFileSync(file, version);
|
|
24
|
+
return version;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function version(env, values) {
|
|
31
|
+
const version = currentVersion();
|
|
32
|
+
const last = await latest(env);
|
|
33
|
+
const upToDate = last === null ? null : !newer(last, version);
|
|
34
|
+
const text = last === null
|
|
35
|
+
? `berliner ${version} (couldn't reach ${registryOf(env)} to check for a newer release)`
|
|
36
|
+
: upToDate
|
|
37
|
+
? `berliner ${version} (latest)`
|
|
38
|
+
: `berliner ${version}, ${last} is out: run berliner upgrade`;
|
|
39
|
+
print({ data: { version, latest: last, up_to_date: upToDate }, text }, values.json === true);
|
|
40
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { team } from "./commands/team.js";
|
|
|
17
17
|
import { summary } from "./commands/summary.js";
|
|
18
18
|
import { update } from "./commands/update.js";
|
|
19
19
|
import { upgrade } from "./commands/upgrade.js";
|
|
20
|
+
import { version } from "./commands/version.js";
|
|
20
21
|
import { readConfig } from "./config.js";
|
|
21
22
|
import { warn } from "./output.js";
|
|
22
23
|
import { upgradeNotice } from "./version.js";
|
|
@@ -47,6 +48,7 @@ Commands:
|
|
|
47
48
|
evidence private <id> make it viewable only by you again [--json]
|
|
48
49
|
upgrade install the latest CLI, skill and hooks [--yes --no-skill --no-hooks]
|
|
49
50
|
skill print the bundled SKILL.md
|
|
51
|
+
version print this version and whether it is the latest release [--json] (also --version)
|
|
50
52
|
hook <tool> run by the hooks of claude-code, codex or opencode; reads the payload on stdin
|
|
51
53
|
|
|
52
54
|
Environment: BERLINER_TOKEN, BERLINER_URL, BERLINER_VENDOR_SUBSCRIPTION_SLUG (the subscription of new sessions),
|
|
@@ -70,6 +72,7 @@ const handled = new Set([
|
|
|
70
72
|
"skill",
|
|
71
73
|
"hook",
|
|
72
74
|
"upgrade",
|
|
75
|
+
"version",
|
|
73
76
|
]);
|
|
74
77
|
const cfg = () => readConfig(process.env);
|
|
75
78
|
try {
|
|
@@ -80,6 +83,8 @@ try {
|
|
|
80
83
|
await hook(process.env, args.positionals, args.values);
|
|
81
84
|
else if (args.error)
|
|
82
85
|
throw new CliError(args.error, "usage");
|
|
86
|
+
else if (args.command === "version" || args.values.version)
|
|
87
|
+
await version(process.env, args.values);
|
|
83
88
|
else if (args.command === "setup")
|
|
84
89
|
await setup(process.env, args.values);
|
|
85
90
|
else if (args.command === "report")
|
|
@@ -117,8 +122,8 @@ catch (err) {
|
|
|
117
122
|
console.error(usage);
|
|
118
123
|
process.exitCode = softFail ? 0 : 1;
|
|
119
124
|
}
|
|
120
|
-
// The hook carries it in the session-start reminder instead, and upgrade
|
|
121
|
-
if (args.command !== "hook" && args.command !== "upgrade") {
|
|
125
|
+
// The hook carries it in the session-start reminder instead, and upgrade and version look for themselves.
|
|
126
|
+
if (args.command !== "hook" && args.command !== "upgrade" && args.command !== "version" && !args.values.version) {
|
|
122
127
|
const notice = await upgradeNotice(process.env);
|
|
123
128
|
if (notice)
|
|
124
129
|
console.error(notice);
|