@persistmemory/cli 0.3.3 → 0.4.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/bin.js +29 -17
- package/dist/bin.js.map +3 -3
- package/dist/index.js +29 -17
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1402,7 +1402,7 @@ function shortDate(iso) {
|
|
|
1402
1402
|
}
|
|
1403
1403
|
|
|
1404
1404
|
// src/help.ts
|
|
1405
|
-
var VERSION = true ? "0.
|
|
1405
|
+
var VERSION = true ? "0.4.0" : versionFromManifest();
|
|
1406
1406
|
var PACKAGE = "@persistmemory/cli";
|
|
1407
1407
|
var HELP = `
|
|
1408
1408
|
pm \u2014 PersistMemory from your terminal
|
|
@@ -1444,12 +1444,14 @@ var HELP = `
|
|
|
1444
1444
|
remember - capture whatever is piped in
|
|
1445
1445
|
remember --file <path> capture a file's contents
|
|
1446
1446
|
|
|
1447
|
-
agent
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1447
|
+
agent answer file requests from this machine.
|
|
1448
|
+
Reads ~/Desktop, ~/Documents and
|
|
1449
|
+
~/Downloads by default, and nothing
|
|
1450
|
+
outside them. It stays in the foreground.
|
|
1451
|
+
Background it, and stop it later, with:
|
|
1452
|
+
nohup pm agent > ~/agent.log 2>&1 &
|
|
1452
1453
|
pkill -f "pm agent"
|
|
1454
|
+
agent --root <dir> [--root ...] choose the folders yourself instead
|
|
1453
1455
|
|
|
1454
1456
|
search <query> search your memory
|
|
1455
1457
|
list memories the most recent memories
|
|
@@ -2318,6 +2320,15 @@ async function upload(apiUrl, token, filename, bytes) {
|
|
|
2318
2320
|
if (!stored.attachToken) return { ok: false, error: "the upload returned no reference" };
|
|
2319
2321
|
return { ok: true, attachToken: stored.attachToken, bytes: bytes.length };
|
|
2320
2322
|
}
|
|
2323
|
+
function defaultRoots(home = homedir2(), isDirectory = (path) => {
|
|
2324
|
+
try {
|
|
2325
|
+
return statSync2(path).isDirectory();
|
|
2326
|
+
} catch {
|
|
2327
|
+
return false;
|
|
2328
|
+
}
|
|
2329
|
+
}) {
|
|
2330
|
+
return ["Desktop", "Documents", "Downloads"].map((name) => join4(home, name)).filter(isDirectory);
|
|
2331
|
+
}
|
|
2321
2332
|
var MAX_LISTED = 200;
|
|
2322
2333
|
function sizeOf(path) {
|
|
2323
2334
|
const size = statSync2(path).size;
|
|
@@ -2335,18 +2346,19 @@ async function agentCommand(context) {
|
|
|
2335
2346
|
(one) => resolve3(one.startsWith("~") ? resolve3(homedir2(), one.slice(1).replace(/^[/\\]/, "")) : one)
|
|
2336
2347
|
);
|
|
2337
2348
|
if (roots.length === 0) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2349
|
+
const usual = defaultRoots();
|
|
2350
|
+
if (usual.length === 0) {
|
|
2351
|
+
context.error(
|
|
2352
|
+
"This machine has no Desktop, Documents or Downloads folder, so there is nothing to offer by default. Say which folders it may read from:"
|
|
2353
|
+
);
|
|
2354
|
+
context.error("");
|
|
2355
|
+
context.error(" pm agent --root ~/projects");
|
|
2356
|
+
return 1;
|
|
2357
|
+
}
|
|
2358
|
+
roots.push(...usual);
|
|
2359
|
+
context.print(
|
|
2360
|
+
`Reading from ${usual.map((path) => path.replace(homedir2(), "~")).join(", ")} \u2014 nothing outside them. Use --root to choose your own.`
|
|
2340
2361
|
);
|
|
2341
|
-
context.error("");
|
|
2342
|
-
context.error(" pm agent --root ~/Desktop --root ~/Documents");
|
|
2343
|
-
context.error("");
|
|
2344
|
-
context.error("It stays in the foreground. To leave it running:");
|
|
2345
|
-
context.error("");
|
|
2346
|
-
context.error(" nohup pm agent --root ~/Desktop > ~/agent.log 2>&1 &");
|
|
2347
|
-
context.error("");
|
|
2348
|
-
context.error('And to stop it later: pkill -f "pm agent"');
|
|
2349
|
-
return 1;
|
|
2350
2362
|
}
|
|
2351
2363
|
for (const root of roots) {
|
|
2352
2364
|
try {
|