agendex-cli 0.4.0 → 0.5.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 +32 -8
- package/dist/cli.js +58 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,15 +14,39 @@ bun install -g agendex-cli
|
|
|
14
14
|
## Commands
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
agendex login
|
|
18
|
-
agendex login --url
|
|
19
|
-
agendex
|
|
20
|
-
agendex
|
|
21
|
-
agendex
|
|
22
|
-
agendex
|
|
23
|
-
agendex
|
|
24
|
-
agendex
|
|
17
|
+
agendex login # Authenticate via browser OAuth (agendex.dev)
|
|
18
|
+
agendex login --url <url> # Login to a self-hosted instance
|
|
19
|
+
agendex logout # Clear stored cloud token
|
|
20
|
+
agendex configure # Select which agents/adapters to index
|
|
21
|
+
agendex start # Start daemon (backgrounds itself)
|
|
22
|
+
agendex stop # Stop the running daemon
|
|
23
|
+
agendex sync # One-shot scan + sync to cloud
|
|
24
|
+
agendex status # Show config state, daemon status, uptime & hostname
|
|
25
|
+
agendex help # Show help message
|
|
26
|
+
agendex --version / -v # Print CLI version
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Status Output
|
|
30
|
+
|
|
31
|
+
`agendex status` prints a rich overview:
|
|
32
|
+
|
|
33
|
+
- Config version, local/cloud token state, Convex URL
|
|
34
|
+
- Enabled adapters
|
|
35
|
+
- Daemon running state with PID
|
|
36
|
+
- **Uptime** — how long the daemon has been running
|
|
37
|
+
- **Hostname** — machine the daemon is running on
|
|
38
|
+
- CLI version
|
|
39
|
+
|
|
40
|
+
## Auto-Update Check
|
|
41
|
+
|
|
42
|
+
Before running `start`, `configure`, or `sync`, the CLI checks for a newer published version. If an update is required the command is blocked and you are prompted to upgrade:
|
|
43
|
+
|
|
25
44
|
```
|
|
45
|
+
[agendex] update required: v0.1.0 → v0.2.0
|
|
46
|
+
[agendex] run: npm i -g agendex-cli
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The check is skipped for `stop`, `status`, `login`, `logout`, and `help`.
|
|
26
50
|
|
|
27
51
|
## Supported Runtime
|
|
28
52
|
|
package/dist/cli.js
CHANGED
|
@@ -2800,19 +2800,35 @@ function requestText(urlString, options) {
|
|
|
2800
2800
|
|
|
2801
2801
|
// src/pid.ts
|
|
2802
2802
|
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2803
|
-
import { homedir as homedir9 } from "node:os";
|
|
2803
|
+
import { homedir as homedir9, hostname } from "node:os";
|
|
2804
2804
|
import { dirname, join as join10 } from "node:path";
|
|
2805
2805
|
var pidPath = join10(homedir9(), ".agendex", "daemon.pid");
|
|
2806
2806
|
function writePid() {
|
|
2807
2807
|
mkdirSync2(dirname(pidPath), { recursive: true });
|
|
2808
|
-
|
|
2808
|
+
const info = {
|
|
2809
|
+
pid: process.pid,
|
|
2810
|
+
startedAtMs: Date.now(),
|
|
2811
|
+
hostname: hostname()
|
|
2812
|
+
};
|
|
2813
|
+
writeFileSync2(pidPath, JSON.stringify(info));
|
|
2809
2814
|
}
|
|
2810
|
-
function
|
|
2815
|
+
function readPidInfo() {
|
|
2811
2816
|
if (!existsSync6(pidPath))
|
|
2812
2817
|
return null;
|
|
2813
2818
|
const raw = readFileSync3(pidPath, "utf-8").trim();
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2819
|
+
const asNumber = Number(raw);
|
|
2820
|
+
if (Number.isFinite(asNumber) && asNumber > 0 && !raw.startsWith("{")) {
|
|
2821
|
+
return { pid: asNumber };
|
|
2822
|
+
}
|
|
2823
|
+
try {
|
|
2824
|
+
const parsed = JSON.parse(raw);
|
|
2825
|
+
if (Number.isFinite(parsed.pid) && parsed.pid > 0)
|
|
2826
|
+
return parsed;
|
|
2827
|
+
} catch {}
|
|
2828
|
+
return null;
|
|
2829
|
+
}
|
|
2830
|
+
function readPid() {
|
|
2831
|
+
return readPidInfo()?.pid ?? null;
|
|
2816
2832
|
}
|
|
2817
2833
|
function removePid() {
|
|
2818
2834
|
try {
|
|
@@ -3013,7 +3029,7 @@ import { join as join11 } from "node:path";
|
|
|
3013
3029
|
// package.json
|
|
3014
3030
|
var package_default = {
|
|
3015
3031
|
name: "agendex-cli",
|
|
3016
|
-
version: "0.
|
|
3032
|
+
version: "0.5.0",
|
|
3017
3033
|
description: "Agendex CLI for login, sync, and daemon workflows",
|
|
3018
3034
|
homepage: "https://github.com/Tyru5/Agendex#readme",
|
|
3019
3035
|
repository: {
|
|
@@ -3119,6 +3135,10 @@ var command = args[0] ?? "start";
|
|
|
3119
3135
|
var cliEntry = resolve5(process.argv[1] ?? fileURLToPath2(import.meta.url));
|
|
3120
3136
|
async function main() {
|
|
3121
3137
|
const isInternal = args.includes("--daemon") || args.includes("--worker");
|
|
3138
|
+
if (command === "--version" || command === "-v") {
|
|
3139
|
+
writeStdout(CLI_VERSION);
|
|
3140
|
+
return 0;
|
|
3141
|
+
}
|
|
3122
3142
|
const isPassthrough = ["stop", "status", "login", "logout", "help", "--help", "-h"].includes(command);
|
|
3123
3143
|
if (!isInternal && !isPassthrough) {
|
|
3124
3144
|
const { updateAvailable, current, latest } = await checkForUpdate();
|
|
@@ -3196,7 +3216,8 @@ async function main() {
|
|
|
3196
3216
|
}
|
|
3197
3217
|
case "status": {
|
|
3198
3218
|
const config = loadConfig();
|
|
3199
|
-
const
|
|
3219
|
+
const pidInfo = readPidInfo();
|
|
3220
|
+
const pid = pidInfo?.pid ?? null;
|
|
3200
3221
|
const running = pid ? isRunning(pid) : false;
|
|
3201
3222
|
writeStdout(`[agendex] Config version: ${config?.configVersion ?? "none"}`);
|
|
3202
3223
|
writeStdout(`[agendex] Local token: ${config?.token ? "set" : "not set"}`);
|
|
@@ -3204,6 +3225,20 @@ async function main() {
|
|
|
3204
3225
|
writeStdout(`[agendex] Convex URL: ${config?.convexUrl ?? "not set"}`);
|
|
3205
3226
|
writeStdout(`[agendex] Enabled adapters: ${config?.enabledAdapters.join(", ") || "none"}`);
|
|
3206
3227
|
writeStdout(`[agendex] Daemon: ${running ? `running (PID ${pid})` : "not running"}`);
|
|
3228
|
+
if (running && pidInfo?.startedAtMs) {
|
|
3229
|
+
writeStdout(`[agendex] Uptime: ${formatDuration(Date.now() - pidInfo.startedAtMs)}`);
|
|
3230
|
+
} else if (running) {
|
|
3231
|
+
writeStdout(`[agendex] Uptime: unknown (restart daemon to populate)`);
|
|
3232
|
+
} else {
|
|
3233
|
+
writeStdout(`[agendex] Uptime: n/a`);
|
|
3234
|
+
}
|
|
3235
|
+
if (running && pidInfo?.hostname) {
|
|
3236
|
+
writeStdout(`[agendex] Hostname: ${pidInfo.hostname}`);
|
|
3237
|
+
} else if (running) {
|
|
3238
|
+
writeStdout(`[agendex] Hostname: unknown (restart daemon to populate)`);
|
|
3239
|
+
} else {
|
|
3240
|
+
writeStdout(`[agendex] Hostname: n/a`);
|
|
3241
|
+
}
|
|
3207
3242
|
writeStdout(`[agendex] CLI version: ${CLI_VERSION}`);
|
|
3208
3243
|
return 0;
|
|
3209
3244
|
}
|
|
@@ -3224,6 +3259,8 @@ Usage:
|
|
|
3224
3259
|
agendex sync One-shot scan + sync to cloud
|
|
3225
3260
|
agendex status Show current config state + daemon status
|
|
3226
3261
|
agendex help Show this help message
|
|
3262
|
+
agendex --version Print CLI version
|
|
3263
|
+
agendex -v Print CLI version
|
|
3227
3264
|
`.trim());
|
|
3228
3265
|
return 0;
|
|
3229
3266
|
}
|
|
@@ -3264,3 +3301,17 @@ function writeStderr(message) {
|
|
|
3264
3301
|
writeSync(process.stderr.fd, `${message}
|
|
3265
3302
|
`);
|
|
3266
3303
|
}
|
|
3304
|
+
function formatDuration(ms) {
|
|
3305
|
+
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
|
|
3306
|
+
const days = Math.floor(totalSeconds / 86400);
|
|
3307
|
+
const hours = Math.floor(totalSeconds % 86400 / 3600);
|
|
3308
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
3309
|
+
const seconds = totalSeconds % 60;
|
|
3310
|
+
if (days > 0)
|
|
3311
|
+
return `${days}d ${hours}h ${minutes}m ${seconds}s`;
|
|
3312
|
+
if (hours > 0)
|
|
3313
|
+
return `${hours}h ${minutes}m ${seconds}s`;
|
|
3314
|
+
if (minutes > 0)
|
|
3315
|
+
return `${minutes}m ${seconds}s`;
|
|
3316
|
+
return `${seconds}s`;
|
|
3317
|
+
}
|