agendex-cli 0.12.0 → 0.13.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/dist/cli.js +63 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
@@ -44,6 +45,7 @@ var __export = (target, all) => {
|
|
|
44
45
|
});
|
|
45
46
|
};
|
|
46
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
48
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
47
49
|
|
|
48
50
|
// ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
49
51
|
var require_picocolors = __commonJS((exports, module) => {
|
|
@@ -2552,7 +2554,7 @@ async function parseGenericMarkdownPlan(filePath, extraMetadata) {
|
|
|
2552
2554
|
try {
|
|
2553
2555
|
const content = await readFile6(filePath, "utf-8");
|
|
2554
2556
|
const stats = await stat6(filePath);
|
|
2555
|
-
let agent = "unknown";
|
|
2557
|
+
let agent = (typeof extraMetadata.agentHint === "string" ? extraMetadata.agentHint : "") || "unknown";
|
|
2556
2558
|
const fmMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n/);
|
|
2557
2559
|
if (fmMatch) {
|
|
2558
2560
|
const agentLine = fmMatch[1]?.match(/^agent:\s*(.+)$/m);
|
|
@@ -2630,13 +2632,15 @@ async function scanCustomPlanDirs(coveredPaths, into) {
|
|
|
2630
2632
|
continue;
|
|
2631
2633
|
}
|
|
2632
2634
|
const files = await walkDir(dir);
|
|
2635
|
+
const dirBasename = dir.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? "custom";
|
|
2633
2636
|
let count = 0;
|
|
2634
2637
|
for (const file of files) {
|
|
2635
2638
|
if (!file.endsWith(".md"))
|
|
2636
2639
|
continue;
|
|
2637
2640
|
const plan = await parseGenericMarkdownPlan(file, {
|
|
2638
2641
|
source: "custom-dir",
|
|
2639
|
-
customDir: dir
|
|
2642
|
+
customDir: dir,
|
|
2643
|
+
agentHint: dirBasename
|
|
2640
2644
|
});
|
|
2641
2645
|
if (plan) {
|
|
2642
2646
|
into.set(plan.id, plan);
|
|
@@ -3590,7 +3594,7 @@ import { join as join12 } from "node:path";
|
|
|
3590
3594
|
// package.json
|
|
3591
3595
|
var package_default = {
|
|
3592
3596
|
name: "agendex-cli",
|
|
3593
|
-
version: "0.
|
|
3597
|
+
version: "0.13.0",
|
|
3594
3598
|
description: "Agendex CLI for login, sync, and daemon workflows",
|
|
3595
3599
|
homepage: "https://github.com/Tyru5/Agendex#readme",
|
|
3596
3600
|
repository: {
|
|
@@ -3945,15 +3949,61 @@ async function main() {
|
|
|
3945
3949
|
writeStderr(`[agendex] path is not a directory: ${resolved}`);
|
|
3946
3950
|
return 1;
|
|
3947
3951
|
}
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3952
|
+
if (args.includes("--live")) {
|
|
3953
|
+
const cfg = loadConfig();
|
|
3954
|
+
const token = cfg?.token;
|
|
3955
|
+
if (!token) {
|
|
3956
|
+
writeStderr("[agendex] no local token found in config — is the server running?");
|
|
3957
|
+
return 1;
|
|
3958
|
+
}
|
|
3959
|
+
const port = process.env.PORT ?? "4890";
|
|
3960
|
+
const { request } = await import("node:http");
|
|
3961
|
+
const body = JSON.stringify({ path: resolved });
|
|
3962
|
+
try {
|
|
3963
|
+
const res = await new Promise((resolve7, reject) => {
|
|
3964
|
+
const req = request(`http://localhost:${port}/api/v1/plan-sources`, {
|
|
3965
|
+
method: "POST",
|
|
3966
|
+
headers: {
|
|
3967
|
+
Authorization: `Bearer ${token}`,
|
|
3968
|
+
"Content-Type": "application/json",
|
|
3969
|
+
"Content-Length": String(Buffer.byteLength(body))
|
|
3970
|
+
}
|
|
3971
|
+
}, (res2) => {
|
|
3972
|
+
let data = "";
|
|
3973
|
+
res2.setEncoding("utf8");
|
|
3974
|
+
res2.on("data", (chunk) => {
|
|
3975
|
+
data += chunk;
|
|
3976
|
+
});
|
|
3977
|
+
res2.on("end", () => resolve7({ status: res2.statusCode ?? 0, body: data }));
|
|
3978
|
+
res2.on("error", reject);
|
|
3979
|
+
});
|
|
3980
|
+
req.on("error", reject);
|
|
3981
|
+
req.write(body);
|
|
3982
|
+
req.end();
|
|
3983
|
+
});
|
|
3984
|
+
if (res.status >= 200 && res.status < 300) {
|
|
3985
|
+
writeStdout(`[agendex] added custom plan dir: ${resolved}`);
|
|
3986
|
+
writeStdout(`[agendex] server notified — scanning + watching now`);
|
|
3987
|
+
} else {
|
|
3988
|
+
writeStderr(`[agendex] server returned ${res.status}: ${res.body}`);
|
|
3989
|
+
return 1;
|
|
3990
|
+
}
|
|
3991
|
+
} catch (err) {
|
|
3992
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
3993
|
+
writeStderr(`[agendex] could not reach local server on port ${port}: ${msg}`);
|
|
3994
|
+
return 1;
|
|
3995
|
+
}
|
|
3996
|
+
} else {
|
|
3997
|
+
const cfg = loadConfig();
|
|
3998
|
+
const currentDirs = cfg?.customPlanDirs ?? [];
|
|
3999
|
+
const updated = normalizeCustomPlanDirs([...currentDirs, resolved]);
|
|
4000
|
+
saveConfig({
|
|
4001
|
+
...cfg ?? { configVersion: 3, enabledAdapters: [] },
|
|
4002
|
+
customPlanDirs: updated
|
|
4003
|
+
});
|
|
4004
|
+
writeStdout(`[agendex] added custom plan dir: ${resolved}`);
|
|
4005
|
+
writeStdout(`[agendex] daemon will pick up the change automatically`);
|
|
4006
|
+
}
|
|
3957
4007
|
return 0;
|
|
3958
4008
|
}
|
|
3959
4009
|
case "remove-dir": {
|
|
@@ -4070,6 +4120,7 @@ Usage:
|
|
|
4070
4120
|
agendex logout Clear stored cloud token
|
|
4071
4121
|
agendex configure Select which agents/adapters to index
|
|
4072
4122
|
agendex add-dir <path> Add a custom directory to scan for plans
|
|
4123
|
+
agendex add-dir <path> --live Add dir and notify running server immediately
|
|
4073
4124
|
agendex remove-dir <path> Remove a custom directory
|
|
4074
4125
|
agendex list-dirs List custom plan directories
|
|
4075
4126
|
agendex sync One-shot scan + sync to cloud (skips unchanged plans)
|