neuralbrain 0.0.2 → 0.1.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/.env.example +2 -2
- package/README.md +19 -4
- package/dist/ai/chat.d.ts +1 -2
- package/dist/ai/chat.d.ts.map +1 -1
- package/dist/ai/chat.js +1 -2
- package/dist/ai/chat.js.map +1 -1
- package/dist/ai/config.d.ts +1 -1
- package/dist/ai/config.js +2 -2
- package/dist/ai/config.js.map +1 -1
- package/dist/app.d.ts +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +417 -50
- package/dist/app.js.map +1 -1
- package/dist/cli.d.ts +53 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +437 -37
- package/dist/cli.js.map +1 -1
- package/dist/consolidation/candidates.d.ts.map +1 -1
- package/dist/consolidation/candidates.js +19 -4
- package/dist/consolidation/candidates.js.map +1 -1
- package/dist/consolidation/fixtures.js +1 -1
- package/dist/consolidation/fixtures.js.map +1 -1
- package/dist/consolidation/gate.d.ts.map +1 -1
- package/dist/consolidation/gate.js +145 -109
- package/dist/consolidation/gate.js.map +1 -1
- package/dist/consolidation/runner.d.ts +6 -0
- package/dist/consolidation/runner.d.ts.map +1 -1
- package/dist/consolidation/runner.js +22 -2
- package/dist/consolidation/runner.js.map +1 -1
- package/dist/dashboard/clientScript.d.ts +1 -1
- package/dist/dashboard/clientScript.d.ts.map +1 -1
- package/dist/dashboard/clientScript.js +3774 -905
- package/dist/dashboard/clientScript.js.map +1 -1
- package/dist/dashboard/html.d.ts.map +1 -1
- package/dist/dashboard/html.js +605 -101
- package/dist/dashboard/html.js.map +1 -1
- package/dist/dashboard/styles.d.ts +1 -1
- package/dist/dashboard/styles.d.ts.map +1 -1
- package/dist/dashboard/styles.js +1591 -359
- package/dist/dashboard/styles.js.map +1 -1
- package/dist/learning/embedWorker.d.ts +13 -0
- package/dist/learning/embedWorker.d.ts.map +1 -1
- package/dist/learning/embedWorker.js +329 -59
- package/dist/learning/embedWorker.js.map +1 -1
- package/dist/learning/embedding.d.ts +1 -0
- package/dist/learning/embedding.d.ts.map +1 -1
- package/dist/learning/embedding.js +101 -26
- package/dist/learning/embedding.js.map +1 -1
- package/dist/learning/engine.js +1 -1
- package/dist/learning/engine.js.map +1 -1
- package/dist/learning/search.d.ts +17 -1
- package/dist/learning/search.d.ts.map +1 -1
- package/dist/learning/search.js +2094 -354
- package/dist/learning/search.js.map +1 -1
- package/dist/learning/storeMeta.d.ts +9 -0
- package/dist/learning/storeMeta.d.ts.map +1 -1
- package/dist/learning/storeMeta.js +30 -24
- package/dist/learning/storeMeta.js.map +1 -1
- package/dist/learning/types.d.ts +57 -8
- package/dist/learning/types.d.ts.map +1 -1
- package/dist/lib/condenser.d.ts +112 -0
- package/dist/lib/condenser.d.ts.map +1 -0
- package/dist/lib/condenser.js +1337 -0
- package/dist/lib/condenser.js.map +1 -0
- package/dist/lib/db.d.ts +10 -0
- package/dist/lib/db.d.ts.map +1 -1
- package/dist/lib/db.js +654 -167
- package/dist/lib/db.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +3 -2
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/projectSlug.d.ts +12 -5
- package/dist/lib/projectSlug.d.ts.map +1 -1
- package/dist/lib/projectSlug.js +62 -23
- package/dist/lib/projectSlug.js.map +1 -1
- package/dist/lib/recurrence.d.ts +16 -0
- package/dist/lib/recurrence.d.ts.map +1 -0
- package/dist/lib/recurrence.js +293 -0
- package/dist/lib/recurrence.js.map +1 -0
- package/dist/lib/scope.d.ts +36 -1
- package/dist/lib/scope.d.ts.map +1 -1
- package/dist/lib/scope.js +183 -19
- package/dist/lib/scope.js.map +1 -1
- package/dist/lib/signalTags.d.ts +39 -0
- package/dist/lib/signalTags.d.ts.map +1 -0
- package/dist/lib/signalTags.js +203 -0
- package/dist/lib/signalTags.js.map +1 -0
- package/dist/lib/spool.d.ts +2 -0
- package/dist/lib/spool.d.ts.map +1 -1
- package/dist/lib/spool.js +176 -65
- package/dist/lib/spool.js.map +1 -1
- package/dist/lib/storeDiagnostics.d.ts +41 -0
- package/dist/lib/storeDiagnostics.d.ts.map +1 -0
- package/dist/lib/storeDiagnostics.js +148 -0
- package/dist/lib/storeDiagnostics.js.map +1 -0
- package/dist/lib/temporal.d.ts +44 -0
- package/dist/lib/temporal.d.ts.map +1 -0
- package/dist/lib/temporal.js +1063 -0
- package/dist/lib/temporal.js.map +1 -0
- package/dist/mcp/server.d.ts +93 -3
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +499 -68
- package/dist/mcp/server.js.map +1 -1
- package/dist/memory/actionStore.d.ts +94 -3
- package/dist/memory/actionStore.d.ts.map +1 -1
- package/dist/memory/actionStore.js +412 -124
- package/dist/memory/actionStore.js.map +1 -1
- package/dist/memory/deadLetterStore.d.ts.map +1 -1
- package/dist/memory/deadLetterStore.js +4 -2
- package/dist/memory/deadLetterStore.js.map +1 -1
- package/dist/memory/embedQueueStore.d.ts +19 -8
- package/dist/memory/embedQueueStore.d.ts.map +1 -1
- package/dist/memory/embedQueueStore.js +55 -25
- package/dist/memory/embedQueueStore.js.map +1 -1
- package/dist/memory/failurePatternStore.d.ts +17 -1
- package/dist/memory/failurePatternStore.d.ts.map +1 -1
- package/dist/memory/failurePatternStore.js +54 -31
- package/dist/memory/failurePatternStore.js.map +1 -1
- package/dist/memory/graphStore.d.ts +133 -3
- package/dist/memory/graphStore.d.ts.map +1 -1
- package/dist/memory/graphStore.js +980 -155
- package/dist/memory/graphStore.js.map +1 -1
- package/dist/memory/noteStore.d.ts +27 -2
- package/dist/memory/noteStore.d.ts.map +1 -1
- package/dist/memory/noteStore.js +89 -26
- package/dist/memory/noteStore.js.map +1 -1
- package/dist/memory/observationStore.d.ts +11 -1
- package/dist/memory/observationStore.d.ts.map +1 -1
- package/dist/memory/observationStore.js +90 -15
- package/dist/memory/observationStore.js.map +1 -1
- package/dist/memory/projectRename.d.ts.map +1 -1
- package/dist/memory/projectRename.js +5 -1
- package/dist/memory/projectRename.js.map +1 -1
- package/dist/memory/rollupSweeper.d.ts.map +1 -1
- package/dist/memory/rollupSweeper.js +43 -23
- package/dist/memory/rollupSweeper.js.map +1 -1
- package/dist/memory/sessionStore.d.ts +25 -7
- package/dist/memory/sessionStore.d.ts.map +1 -1
- package/dist/memory/sessionStore.js +145 -33
- package/dist/memory/sessionStore.js.map +1 -1
- package/dist/memory/trajectoryStore.d.ts +8 -0
- package/dist/memory/trajectoryStore.d.ts.map +1 -1
- package/dist/memory/trajectoryStore.js +196 -130
- package/dist/memory/trajectoryStore.js.map +1 -1
- package/dist/middleware/rateLimiter.d.ts.map +1 -1
- package/dist/middleware/rateLimiter.js +24 -1
- package/dist/middleware/rateLimiter.js.map +1 -1
- package/dist/routes/dashboard.d.ts.map +1 -1
- package/dist/routes/dashboard.js +181 -8
- package/dist/routes/dashboard.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +173 -21
- package/dist/routes/mcp.js.map +1 -1
- package/dist/routes/memories.js +9 -1
- package/dist/routes/memories.js.map +1 -1
- package/dist/scripts/doctor.d.ts +26 -2
- package/dist/scripts/doctor.d.ts.map +1 -1
- package/dist/scripts/doctor.js +371 -259
- package/dist/scripts/doctor.js.map +1 -1
- package/dist/scripts/installAgent.d.ts.map +1 -1
- package/dist/scripts/installAgent.js +101 -19
- package/dist/scripts/installAgent.js.map +1 -1
- package/dist/scripts/migrateAgentMemory.js +2 -2
- package/dist/scripts/smokeTest.js +1 -1
- package/dist/scripts/smokeTest.js.map +1 -1
- package/docker-compose.yml +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugin/hooks/postToolUse.js +155 -50
- package/plugin/hooks/sessionStart.js +179 -27
- package/plugin/hooks/sessionStop.js +152 -37
- package/plugin/plugin.json +1 -1
- package/plugin/rules/AGENTS.md +10 -8
- package/plugin/skills/brain-memory/REFERENCE.md +15 -14
- package/plugin/skills/brain-memory/SKILL.md +2 -2
- package/plugin/skills/digest/SKILL.md +1 -1
- package/plugin/skills/handoff/SKILL.md +1 -1
- package/plugin/skills/save/SKILL.md +2 -2
- package/plugin/skills/search/SKILL.md +2 -2
- package/src/ai/chat.ts +1 -2
- package/src/ai/config.ts +2 -2
- package/src/app.ts +475 -54
- package/src/cli.ts +500 -38
- package/src/consolidation/candidates.ts +22 -4
- package/src/consolidation/fixtures.ts +1 -1
- package/src/consolidation/gate.ts +177 -140
- package/src/consolidation/runner.ts +26 -2
- package/src/dashboard/clientScript.ts +3774 -905
- package/src/dashboard/html.ts +605 -101
- package/src/dashboard/styles.ts +1591 -359
- package/src/learning/embedWorker.ts +350 -70
- package/src/learning/embedding.ts +141 -28
- package/src/learning/engine.ts +1 -1
- package/src/learning/search.ts +2533 -397
- package/src/learning/storeMeta.ts +36 -29
- package/src/learning/types.ts +66 -8
- package/src/lib/condenser.ts +1515 -0
- package/src/lib/db.ts +690 -171
- package/src/lib/logger.ts +4 -2
- package/src/lib/projectSlug.ts +77 -23
- package/src/lib/recurrence.ts +382 -0
- package/src/lib/scope.ts +220 -22
- package/src/lib/signalTags.ts +257 -0
- package/src/lib/spool.ts +181 -71
- package/src/lib/storeDiagnostics.ts +181 -0
- package/src/lib/temporal.ts +1250 -0
- package/src/mcp/server.ts +559 -88
- package/src/memory/actionStore.ts +642 -171
- package/src/memory/deadLetterStore.ts +4 -2
- package/src/memory/embedQueueStore.ts +63 -27
- package/src/memory/failurePatternStore.ts +84 -31
- package/src/memory/graphStore.ts +1396 -215
- package/src/memory/noteStore.ts +151 -30
- package/src/memory/observationStore.ts +117 -17
- package/src/memory/projectRename.ts +6 -2
- package/src/memory/rollupSweeper.ts +46 -23
- package/src/memory/sessionStore.ts +197 -38
- package/src/memory/trajectoryStore.ts +260 -140
- package/src/middleware/rateLimiter.ts +24 -1
- package/src/routes/dashboard.ts +194 -9
- package/src/routes/mcp.ts +185 -26
- package/src/routes/memories.ts +8 -1
- package/src/scripts/doctor.ts +461 -262
- package/src/scripts/installAgent.ts +106 -19
- package/src/scripts/migrateAgentMemory.ts +2 -2
- package/src/scripts/smokeTest.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -12,9 +12,13 @@ exports.hostNeedsLocalEmbedder = hostNeedsLocalEmbedder;
|
|
|
12
12
|
exports.ensureLocalEmbedder = ensureLocalEmbedder;
|
|
13
13
|
exports.isNpxCacheCopy = isNpxCacheCopy;
|
|
14
14
|
exports.isInstalledCopy = isInstalledCopy;
|
|
15
|
+
exports.locateInstalledCopy = locateInstalledCopy;
|
|
15
16
|
exports.installGlobalPackage = installGlobalPackage;
|
|
16
17
|
exports.modeUsesCompose = modeUsesCompose;
|
|
18
|
+
exports.waitForShutdown = waitForShutdown;
|
|
17
19
|
exports.runInit = runInit;
|
|
20
|
+
exports.parseRemindersArgs = parseRemindersArgs;
|
|
21
|
+
exports.runRemindersCheck = runRemindersCheck;
|
|
18
22
|
const crypto_1 = __importDefault(require("crypto"));
|
|
19
23
|
const fs_1 = __importDefault(require("fs"));
|
|
20
24
|
const https_1 = __importDefault(require("https"));
|
|
@@ -26,6 +30,7 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
26
30
|
const brainHome_1 = require("./lib/brainHome");
|
|
27
31
|
const tls_1 = require("./lib/tls");
|
|
28
32
|
const projectSlug_1 = require("./lib/projectSlug");
|
|
33
|
+
const recurrence_1 = require("./lib/recurrence");
|
|
29
34
|
const scope_1 = require("./lib/scope");
|
|
30
35
|
const installAgent_1 = require("./scripts/installAgent");
|
|
31
36
|
const COMPOSE_PROJECT_NAME = 'neuralbrain';
|
|
@@ -158,6 +163,9 @@ function parseInstallArgs(argv) {
|
|
|
158
163
|
}
|
|
159
164
|
else if (arg === '--mode') {
|
|
160
165
|
const val = argv[++i];
|
|
166
|
+
if (!val || val.startsWith('--')) {
|
|
167
|
+
throw new Error('Missing value for --mode. Expected: docker | qdrant-docker | local-only');
|
|
168
|
+
}
|
|
161
169
|
if (val === 'docker' || val === 'qdrant-docker' || val === 'local-only') {
|
|
162
170
|
opts.mode = val;
|
|
163
171
|
}
|
|
@@ -178,7 +186,11 @@ function parseInstallArgs(argv) {
|
|
|
178
186
|
opts.agents = true;
|
|
179
187
|
}
|
|
180
188
|
else if (arg === '--port') {
|
|
181
|
-
const
|
|
189
|
+
const rawPort = argv[++i];
|
|
190
|
+
if (!rawPort || rawPort.startsWith('--')) {
|
|
191
|
+
throw new Error('Missing value for --port');
|
|
192
|
+
}
|
|
193
|
+
const p = parseInt(rawPort, 10);
|
|
182
194
|
if (Number.isNaN(p) || p <= 0) {
|
|
183
195
|
throw new Error(`Invalid --port value`);
|
|
184
196
|
}
|
|
@@ -229,7 +241,13 @@ function startHostDaemon(packageRoot, envPath) {
|
|
|
229
241
|
}
|
|
230
242
|
}
|
|
231
243
|
const logPath = getLogFilePath();
|
|
232
|
-
const out = fs_1.default.openSync(logPath, 'a');
|
|
244
|
+
const out = fs_1.default.openSync(logPath, 'a', 0o600);
|
|
245
|
+
try {
|
|
246
|
+
fs_1.default.chmodSync(logPath, 0o600);
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// ignore chmod errors on unsupported platforms
|
|
250
|
+
}
|
|
233
251
|
const entryJs = path_1.default.join(packageRoot, 'dist', 'index.js');
|
|
234
252
|
const parsedEnv = dotenv_1.default.parse(fs_1.default.readFileSync(envPath, 'utf8'));
|
|
235
253
|
const child = (0, child_process_1.spawn)(process.execPath, [entryJs], {
|
|
@@ -237,14 +255,14 @@ function startHostDaemon(packageRoot, envPath) {
|
|
|
237
255
|
detached: true,
|
|
238
256
|
stdio: ['ignore', out, out],
|
|
239
257
|
env: {
|
|
240
|
-
...process.env,
|
|
241
258
|
...parsedEnv,
|
|
242
|
-
|
|
259
|
+
...process.env,
|
|
260
|
+
NODE_ENV: process.env.NODE_ENV || parsedEnv.NODE_ENV || 'production',
|
|
243
261
|
},
|
|
244
262
|
});
|
|
245
263
|
child.unref();
|
|
246
264
|
if (child.pid) {
|
|
247
|
-
fs_1.default.writeFileSync(pidFile, `${child.pid}\n`, 'utf8');
|
|
265
|
+
fs_1.default.writeFileSync(pidFile, `${child.pid}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
248
266
|
}
|
|
249
267
|
return child.pid ?? 0;
|
|
250
268
|
}
|
|
@@ -253,17 +271,21 @@ function stopHostDaemon() {
|
|
|
253
271
|
if (!fs_1.default.existsSync(pidFile))
|
|
254
272
|
return false;
|
|
255
273
|
const pid = parseInt(fs_1.default.readFileSync(pidFile, 'utf8').trim(), 10);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
274
|
+
if (Number.isNaN(pid) || pid <= 0) {
|
|
275
|
+
fs_1.default.rmSync(pidFile, { force: true });
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
process.kill(pid, 'SIGTERM');
|
|
280
|
+
fs_1.default.rmSync(pidFile, { force: true });
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (err?.code === 'ESRCH') {
|
|
285
|
+
fs_1.default.rmSync(pidFile, { force: true });
|
|
264
286
|
}
|
|
287
|
+
return false;
|
|
265
288
|
}
|
|
266
|
-
return false;
|
|
267
289
|
}
|
|
268
290
|
function isHttpsEnabled() {
|
|
269
291
|
return (process.env.BRAIN_HTTPS === '1' ||
|
|
@@ -502,16 +524,51 @@ function readPackageVersion(packageRoot) {
|
|
|
502
524
|
return null;
|
|
503
525
|
}
|
|
504
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* Finds the globally installed copy on disk.
|
|
529
|
+
*
|
|
530
|
+
* `npm root -g` alone is not trusted: npm masks anything that looks like a
|
|
531
|
+
* UUID in its output (legacy npm tokens were UUIDs), so a global folder whose
|
|
532
|
+
* path contains one is printed with `***` and points nowhere. Candidates, first
|
|
533
|
+
* existing one wins: npm's answer (unless masked), the configured global
|
|
534
|
+
* prefix, then the folder next to the running node binary (nvm and standard
|
|
535
|
+
* installs).
|
|
536
|
+
*/
|
|
537
|
+
function locateInstalledCopy(reportedRoot, exists = fs_1.default.existsSync) {
|
|
538
|
+
const roots = [];
|
|
539
|
+
if (reportedRoot && !reportedRoot.includes('***'))
|
|
540
|
+
roots.push(reportedRoot);
|
|
541
|
+
const prefix = process.env.npm_config_prefix || process.env.NPM_CONFIG_PREFIX;
|
|
542
|
+
if (prefix) {
|
|
543
|
+
roots.push(process.platform === 'win32' ? path_1.default.join(prefix, 'node_modules') : path_1.default.join(prefix, 'lib', 'node_modules'));
|
|
544
|
+
}
|
|
545
|
+
const binDir = path_1.default.dirname(process.execPath);
|
|
546
|
+
roots.push(process.platform === 'win32' ? path_1.default.join(binDir, 'node_modules') : path_1.default.join(path_1.default.dirname(binDir), 'lib', 'node_modules'));
|
|
547
|
+
for (const root of roots) {
|
|
548
|
+
const candidate = path_1.default.join(root, 'neuralbrain');
|
|
549
|
+
if (exists(path_1.default.join(candidate, 'package.json')))
|
|
550
|
+
return candidate;
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
505
554
|
function installGlobalPackage(packageRoot, run = child_process_1.spawnSync) {
|
|
506
555
|
if (isInstalledCopy(packageRoot)) {
|
|
507
556
|
return { ok: true, installedRoot: packageRoot, alreadyInstalled: true };
|
|
508
557
|
}
|
|
509
558
|
const rootRes = run('npm', ['root', '-g'], { encoding: 'utf8', stdio: 'pipe' });
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
559
|
+
const reportedRoot = rootRes.status === 0 ? String(rootRes.stdout || '').trim() : '';
|
|
560
|
+
// The real location is confirmed on disk after installing (see locateInstalledCopy).
|
|
561
|
+
const located = () => {
|
|
562
|
+
const root = locateInstalledCopy(reportedRoot);
|
|
563
|
+
return root
|
|
564
|
+
? { ok: true, installedRoot: root, alreadyInstalled: false }
|
|
565
|
+
: {
|
|
566
|
+
ok: false,
|
|
567
|
+
installedRoot: null,
|
|
568
|
+
alreadyInstalled: false,
|
|
569
|
+
error: 'installed, but could not find the global copy (check `npm root -g`)',
|
|
570
|
+
};
|
|
571
|
+
};
|
|
515
572
|
// onnxruntime-node's script only fetches the CUDA add-on, which the host never
|
|
516
573
|
// uses; with CUDA present it can 404 and fail the whole install. Skip it in
|
|
517
574
|
// case npm runs the script anyway (npm 10 and older run every script).
|
|
@@ -528,7 +585,7 @@ function installGlobalPackage(packageRoot, run = child_process_1.spawnSync) {
|
|
|
528
585
|
if (installRes.status !== 0) {
|
|
529
586
|
return { ok: false, installedRoot: null, alreadyInstalled: false, error: '`npm install -g` failed' };
|
|
530
587
|
}
|
|
531
|
-
return
|
|
588
|
+
return located();
|
|
532
589
|
}
|
|
533
590
|
const packDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'neuralbrain-pack-'));
|
|
534
591
|
try {
|
|
@@ -561,7 +618,7 @@ function installGlobalPackage(packageRoot, run = child_process_1.spawnSync) {
|
|
|
561
618
|
if (installRes.status !== 0) {
|
|
562
619
|
return { ok: false, installedRoot: null, alreadyInstalled: false, error: '`npm install -g` failed' };
|
|
563
620
|
}
|
|
564
|
-
return
|
|
621
|
+
return located();
|
|
565
622
|
}
|
|
566
623
|
finally {
|
|
567
624
|
fs_1.default.rmSync(packDir, { recursive: true, force: true });
|
|
@@ -650,7 +707,9 @@ async function cmdStart() {
|
|
|
650
707
|
const protocol = useHttps ? 'https' : 'http';
|
|
651
708
|
console.log(`Starting neuralbrain (mode: ${mode})...`);
|
|
652
709
|
startForMode(mode, envPath, packageRoot);
|
|
653
|
-
|
|
710
|
+
// Docker mode builds the image first (`up --build`), so give it the same
|
|
711
|
+
// headroom install does.
|
|
712
|
+
const healthy = await waitForHealth(port, mode === 'docker' ? 90000 : 30000, useHttps);
|
|
654
713
|
console.log(healthy ? `Ready at ${protocol}://127.0.0.1:${port}` : 'Started, waiting for health check...');
|
|
655
714
|
}
|
|
656
715
|
/**
|
|
@@ -678,6 +737,42 @@ function cmdStop() {
|
|
|
678
737
|
console.log('Nothing running.');
|
|
679
738
|
}
|
|
680
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* Polls `isUp` until it reports false (the old service has let go of its port)
|
|
742
|
+
* or `timeoutMs` passes. Returns true once the service is down.
|
|
743
|
+
*
|
|
744
|
+
* `stop` returns as soon as SIGTERM is sent to a host daemon, which then takes
|
|
745
|
+
* a moment to drain and exit. Starting before it has gone would either fail on
|
|
746
|
+
* the port or, worse, let the new start's health wait be answered by the old
|
|
747
|
+
* process.
|
|
748
|
+
*/
|
|
749
|
+
async function waitForShutdown(isUp, timeoutMs = 15000, intervalMs = 250) {
|
|
750
|
+
const deadline = Date.now() + timeoutMs;
|
|
751
|
+
while (true) {
|
|
752
|
+
if (!(await isUp()))
|
|
753
|
+
return true;
|
|
754
|
+
if (Date.now() >= deadline)
|
|
755
|
+
return false;
|
|
756
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
async function cmdRestart() {
|
|
760
|
+
(0, brainHome_1.loadBrainEnv)();
|
|
761
|
+
const envPath = (0, brainHome_1.getBrainEnvPath)();
|
|
762
|
+
if (!fs_1.default.existsSync(envPath)) {
|
|
763
|
+
throw new Error(`Not initialized. Run \`neuralbrain install\` first (missing ${envPath}).`);
|
|
764
|
+
}
|
|
765
|
+
const port = parseInt(process.env.PORT || '3737', 10);
|
|
766
|
+
const useHttps = isHttpsEnabled();
|
|
767
|
+
console.log('Stopping neuralbrain...');
|
|
768
|
+
cmdStop();
|
|
769
|
+
const down = await waitForShutdown(async () => (await checkHealth(port, useHttps)) !== null);
|
|
770
|
+
if (!down) {
|
|
771
|
+
throw new Error(`Something is still answering on port ${port} after stopping. ` +
|
|
772
|
+
'Not starting a second copy; check `neuralbrain status`.');
|
|
773
|
+
}
|
|
774
|
+
await cmdStart();
|
|
775
|
+
}
|
|
681
776
|
async function cmdStatus() {
|
|
682
777
|
(0, brainHome_1.loadBrainEnv)();
|
|
683
778
|
const brainHome = (0, brainHome_1.getBrainHomeDir)();
|
|
@@ -722,8 +817,8 @@ function cmdLogs() {
|
|
|
722
817
|
(0, child_process_1.spawnSync)('tail', ['-n', '100', '-f', logPath], { stdio: 'inherit' });
|
|
723
818
|
}
|
|
724
819
|
/**
|
|
725
|
-
* `neuralbrain init [project-id] [--force]
|
|
726
|
-
* agent working anywhere below it records the same project_id.
|
|
820
|
+
* `neuralbrain init [project-id] [--force] [--auto-subproject] [--max-depth <n>]`:
|
|
821
|
+
* writes .brainrc in `cwd` so every agent working anywhere below it records the same project_id.
|
|
727
822
|
*
|
|
728
823
|
* Defaults to the folder's own name. An existing .brainrc is kept unless
|
|
729
824
|
* `force` is set. An explicit id that is not a valid project_id is an error,
|
|
@@ -732,14 +827,13 @@ function cmdLogs() {
|
|
|
732
827
|
function runInit(options) {
|
|
733
828
|
const cwd = path_1.default.resolve(options.cwd);
|
|
734
829
|
const filePath = path_1.default.join(cwd, '.brainrc');
|
|
830
|
+
if (options.maxDepth !== undefined &&
|
|
831
|
+
(!Number.isInteger(options.maxDepth) || options.maxDepth <= 0)) {
|
|
832
|
+
throw new Error('--max-depth must be a positive integer');
|
|
833
|
+
}
|
|
735
834
|
let explicit;
|
|
736
835
|
if (options.projectId !== undefined) {
|
|
737
|
-
const
|
|
738
|
-
.trim()
|
|
739
|
-
.toLowerCase()
|
|
740
|
-
.replace(/[^a-z0-9._-]+/g, '-')
|
|
741
|
-
.replace(/^-+|-+$/g, '');
|
|
742
|
-
const norm = (0, scope_1.normalizeProjectId)(sanitized);
|
|
836
|
+
const norm = (0, scope_1.normalizeProjectId)(options.projectId);
|
|
743
837
|
if (!norm.ok) {
|
|
744
838
|
throw new Error(`'${options.projectId}' is not a valid project id: ${norm.error}`);
|
|
745
839
|
}
|
|
@@ -753,20 +847,60 @@ function runInit(options) {
|
|
|
753
847
|
const existing = (0, projectSlug_1.resolveCanonicalProjectId)({ cwd, fallbackToDirname: false });
|
|
754
848
|
return { filePath, projectId: existing ?? '', written: false, enclosingProjectId: null };
|
|
755
849
|
}
|
|
756
|
-
const written = (0, projectSlug_1.writeBrainRc)(cwd, explicit
|
|
850
|
+
const written = (0, projectSlug_1.writeBrainRc)(cwd, explicit, {
|
|
851
|
+
autoSubproject: options.autoSubproject,
|
|
852
|
+
maxDepth: options.maxDepth,
|
|
853
|
+
});
|
|
757
854
|
const enclosingProjectId = gitOrParent && gitOrParent !== written.projectId ? gitOrParent : null;
|
|
758
855
|
return { filePath: written.filePath, projectId: written.projectId, written: true, enclosingProjectId };
|
|
759
856
|
}
|
|
760
857
|
function cmdInit(argv) {
|
|
761
|
-
|
|
762
|
-
|
|
858
|
+
let force = false;
|
|
859
|
+
let autoSubproject = false;
|
|
860
|
+
let maxDepth;
|
|
861
|
+
const positional = [];
|
|
862
|
+
for (let i = 0; i < argv.length; i++) {
|
|
863
|
+
const arg = argv[i];
|
|
864
|
+
if (arg === '--force' || arg === '-f') {
|
|
865
|
+
force = true;
|
|
866
|
+
}
|
|
867
|
+
else if (arg === '--auto-subproject') {
|
|
868
|
+
autoSubproject = true;
|
|
869
|
+
}
|
|
870
|
+
else if (arg === '--max-depth' || arg.startsWith('--max-depth=')) {
|
|
871
|
+
const raw = arg.startsWith('--max-depth=') ? arg.slice('--max-depth='.length) : argv[++i];
|
|
872
|
+
if (!raw || raw.startsWith('-')) {
|
|
873
|
+
console.error('Missing value for --max-depth');
|
|
874
|
+
process.exit(1);
|
|
875
|
+
}
|
|
876
|
+
const parsed = Number(raw);
|
|
877
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
878
|
+
console.error(`Invalid --max-depth '${raw}': must be a positive integer`);
|
|
879
|
+
process.exit(1);
|
|
880
|
+
}
|
|
881
|
+
maxDepth = parsed;
|
|
882
|
+
}
|
|
883
|
+
else if (arg.startsWith('-')) {
|
|
884
|
+
console.error(`Unknown option for init: ${arg}`);
|
|
885
|
+
process.exit(1);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
positional.push(arg);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
763
891
|
if (positional.length > 1) {
|
|
764
|
-
console.error('Usage: neuralbrain init [project-id] [--force]');
|
|
892
|
+
console.error('Usage: neuralbrain init [project-id] [--force] [--auto-subproject] [--max-depth <n>]');
|
|
765
893
|
process.exit(1);
|
|
766
894
|
}
|
|
767
895
|
let result;
|
|
768
896
|
try {
|
|
769
|
-
result = runInit({
|
|
897
|
+
result = runInit({
|
|
898
|
+
cwd: process.cwd(),
|
|
899
|
+
projectId: positional[0],
|
|
900
|
+
force,
|
|
901
|
+
autoSubproject,
|
|
902
|
+
maxDepth,
|
|
903
|
+
});
|
|
770
904
|
}
|
|
771
905
|
catch (err) {
|
|
772
906
|
console.error(err instanceof Error ? err.message : String(err));
|
|
@@ -779,12 +913,256 @@ function cmdInit(argv) {
|
|
|
779
913
|
}
|
|
780
914
|
console.log(`Wrote ${result.filePath}`);
|
|
781
915
|
console.log(`project_id: ${result.projectId}`);
|
|
916
|
+
if (autoSubproject) {
|
|
917
|
+
console.log(`auto_subproject: true${maxDepth !== undefined ? ` (max_depth: ${maxDepth})` : ''}`);
|
|
918
|
+
}
|
|
782
919
|
if (result.enclosingProjectId) {
|
|
783
920
|
console.log(`Note: this folder was part of project "${result.enclosingProjectId}". ` +
|
|
784
921
|
`Work here will now be recorded as "${result.projectId}". ` +
|
|
785
922
|
'If that was not intended, delete the file or run init in the project root.');
|
|
786
923
|
}
|
|
787
924
|
}
|
|
925
|
+
function validateWebhookUrl(raw) {
|
|
926
|
+
const val = raw.trim();
|
|
927
|
+
if (!/^https?:\/\//i.test(val)) {
|
|
928
|
+
throw new Error(`Invalid --webhook URL '${val}': must start with http:// or https://`);
|
|
929
|
+
}
|
|
930
|
+
try {
|
|
931
|
+
new URL(val);
|
|
932
|
+
}
|
|
933
|
+
catch {
|
|
934
|
+
throw new Error(`Invalid --webhook URL '${val}'`);
|
|
935
|
+
}
|
|
936
|
+
return val;
|
|
937
|
+
}
|
|
938
|
+
function parseRemindersArgs(argv) {
|
|
939
|
+
const opts = {
|
|
940
|
+
json: false,
|
|
941
|
+
includeAncestors: true,
|
|
942
|
+
includeChildren: false,
|
|
943
|
+
includeGlobal: true,
|
|
944
|
+
dryRun: false,
|
|
945
|
+
};
|
|
946
|
+
for (let i = 0; i < argv.length; i++) {
|
|
947
|
+
const arg = argv[i];
|
|
948
|
+
const eqIdx = arg.indexOf('=');
|
|
949
|
+
const flag = eqIdx !== -1 ? arg.slice(0, eqIdx) : arg;
|
|
950
|
+
const inlineVal = eqIdx !== -1 ? arg.slice(eqIdx + 1) : undefined;
|
|
951
|
+
const takeValue = (name) => {
|
|
952
|
+
if (inlineVal !== undefined) {
|
|
953
|
+
if (!inlineVal)
|
|
954
|
+
throw new Error(`Missing value for ${name}`);
|
|
955
|
+
return inlineVal;
|
|
956
|
+
}
|
|
957
|
+
const next = argv[++i];
|
|
958
|
+
if (!next || next.startsWith('--')) {
|
|
959
|
+
throw new Error(`Missing value for ${name}`);
|
|
960
|
+
}
|
|
961
|
+
return next;
|
|
962
|
+
};
|
|
963
|
+
if (flag === '--json') {
|
|
964
|
+
opts.json = true;
|
|
965
|
+
}
|
|
966
|
+
else if (flag === '--include-children') {
|
|
967
|
+
opts.includeChildren = true;
|
|
968
|
+
}
|
|
969
|
+
else if (flag === '--no-ancestors') {
|
|
970
|
+
opts.includeAncestors = false;
|
|
971
|
+
}
|
|
972
|
+
else if (flag === '--no-global') {
|
|
973
|
+
opts.includeGlobal = false;
|
|
974
|
+
}
|
|
975
|
+
else if (flag === '--dry-run') {
|
|
976
|
+
opts.dryRun = true;
|
|
977
|
+
}
|
|
978
|
+
else if (flag === '--webhook') {
|
|
979
|
+
opts.webhookUrl = validateWebhookUrl(takeValue('--webhook'));
|
|
980
|
+
}
|
|
981
|
+
else if (flag === '--project') {
|
|
982
|
+
const val = takeValue('--project').trim();
|
|
983
|
+
const norm = (0, scope_1.normalizeProjectId)(val);
|
|
984
|
+
if (!norm.ok) {
|
|
985
|
+
throw new Error(`Invalid --project '${val}': ${norm.error}`);
|
|
986
|
+
}
|
|
987
|
+
opts.projectId = norm.projectId;
|
|
988
|
+
}
|
|
989
|
+
else if (flag === '--cooldown') {
|
|
990
|
+
const val = takeValue('--cooldown').trim();
|
|
991
|
+
const ms = (0, recurrence_1.parseDurationMs)(val);
|
|
992
|
+
if (ms === null) {
|
|
993
|
+
throw new Error(`Invalid --cooldown duration '${val}' (examples: 30m, 2h, 1d, PT15M)`);
|
|
994
|
+
}
|
|
995
|
+
opts.cooldownMs = ms;
|
|
996
|
+
opts.cooldown = val;
|
|
997
|
+
}
|
|
998
|
+
else if (flag === '--limit') {
|
|
999
|
+
const val = takeValue('--limit').trim();
|
|
1000
|
+
const parsed = Number(val);
|
|
1001
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
1002
|
+
throw new Error(`Invalid --limit '${val}': must be a positive integer`);
|
|
1003
|
+
}
|
|
1004
|
+
opts.limit = parsed;
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
return opts;
|
|
1011
|
+
}
|
|
1012
|
+
function formatRemindersHuman(result) {
|
|
1013
|
+
if (result.reminders.length === 0) {
|
|
1014
|
+
return `No due reminders (checked at ${result.checked_at}).`;
|
|
1015
|
+
}
|
|
1016
|
+
const lines = [`Due reminders (${result.reminders.length}, checked at ${result.checked_at}):`];
|
|
1017
|
+
for (const r of result.reminders) {
|
|
1018
|
+
const overdueTag = r.overdue ? '[OVERDUE] ' : '';
|
|
1019
|
+
const prio = r.priority ? `[${String(r.priority).toUpperCase()}] ` : '';
|
|
1020
|
+
const when = r.due_at ? `due ${r.due_at}` : r.remind_at ? `remind ${r.remind_at}` : '';
|
|
1021
|
+
const loc = r.project_id ? `${r.scope}:${r.project_id}` : r.scope;
|
|
1022
|
+
const tier = r.match_tier ? ` [${r.match_tier}]` : '';
|
|
1023
|
+
lines.push(`- ${overdueTag}${prio}${r.title} (${r.id}, ${loc}${tier}${when ? `, ${when}` : ''})`);
|
|
1024
|
+
}
|
|
1025
|
+
const statusBits = [`marked=${result.marked_count}`];
|
|
1026
|
+
if (result.webhook_delivered !== undefined) {
|
|
1027
|
+
statusBits.push(`webhook_delivered=${result.webhook_delivered}`);
|
|
1028
|
+
}
|
|
1029
|
+
if (result.acked_count !== undefined) {
|
|
1030
|
+
statusBits.push(`acked=${result.acked_count}`);
|
|
1031
|
+
}
|
|
1032
|
+
lines.push(`Summary: ${statusBits.join(', ')}`);
|
|
1033
|
+
return lines.join('\n');
|
|
1034
|
+
}
|
|
1035
|
+
async function runRemindersCheck(options = {}) {
|
|
1036
|
+
const rawWebhook = options.webhookUrl !== undefined ? options.webhookUrl : options.webhook;
|
|
1037
|
+
const webhookUrl = rawWebhook !== undefined && rawWebhook !== null ? validateWebhookUrl(rawWebhook) : undefined;
|
|
1038
|
+
let projectId;
|
|
1039
|
+
const rawProject = options.projectId !== undefined ? options.projectId : options.project;
|
|
1040
|
+
if (rawProject !== undefined && rawProject !== null && rawProject.trim() !== '') {
|
|
1041
|
+
const norm = (0, scope_1.normalizeProjectId)(rawProject.trim());
|
|
1042
|
+
if (!norm.ok) {
|
|
1043
|
+
throw new Error(`Invalid project_id '${rawProject}': ${norm.error}`);
|
|
1044
|
+
}
|
|
1045
|
+
projectId = norm.projectId;
|
|
1046
|
+
}
|
|
1047
|
+
let cooldownMs = options.cooldownMs;
|
|
1048
|
+
if (cooldownMs !== undefined) {
|
|
1049
|
+
if (typeof cooldownMs !== 'number' || !Number.isFinite(cooldownMs) || cooldownMs < 0) {
|
|
1050
|
+
throw new Error('cooldownMs must be a non-negative finite number');
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
else if (options.cooldown !== undefined) {
|
|
1054
|
+
const parsed = (0, recurrence_1.parseDurationMs)(options.cooldown);
|
|
1055
|
+
if (parsed === null) {
|
|
1056
|
+
throw new Error(`Invalid --cooldown duration '${options.cooldown}'`);
|
|
1057
|
+
}
|
|
1058
|
+
cooldownMs = parsed;
|
|
1059
|
+
}
|
|
1060
|
+
if (options.limit !== undefined && (!Number.isInteger(options.limit) || options.limit <= 0)) {
|
|
1061
|
+
throw new Error('limit must be a positive integer');
|
|
1062
|
+
}
|
|
1063
|
+
const packageRoot = getPackageRoot();
|
|
1064
|
+
const apiUrl = (options.apiUrl || (0, installAgent_1.resolveApiUrl)({}, packageRoot, process.cwd(), os_1.default.homedir())).replace(/\/+$/, '');
|
|
1065
|
+
const apiKey = options.apiKey !== undefined
|
|
1066
|
+
? options.apiKey
|
|
1067
|
+
: (0, installAgent_1.resolveApiKey)({}, packageRoot, process.cwd(), os_1.default.homedir());
|
|
1068
|
+
const fetchFn = options.fetchFn || (0, tls_1.createLocalTlsFetch)();
|
|
1069
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
1070
|
+
if (apiKey) {
|
|
1071
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
1072
|
+
}
|
|
1073
|
+
const dryRun = Boolean(options.dryRun);
|
|
1074
|
+
const checkPayload = {
|
|
1075
|
+
include_ancestors: options.includeAncestors ?? true,
|
|
1076
|
+
include_children: options.includeChildren ?? false,
|
|
1077
|
+
include_global: options.includeGlobal ?? true,
|
|
1078
|
+
dry_run: webhookUrl ? true : dryRun,
|
|
1079
|
+
};
|
|
1080
|
+
if (projectId)
|
|
1081
|
+
checkPayload.project_id = projectId;
|
|
1082
|
+
if (cooldownMs !== undefined)
|
|
1083
|
+
checkPayload.cooldown_ms = cooldownMs;
|
|
1084
|
+
if (options.limit !== undefined)
|
|
1085
|
+
checkPayload.limit = options.limit;
|
|
1086
|
+
const checkRes = await fetchFn(`${apiUrl}/actions/reminders/check`, {
|
|
1087
|
+
method: 'POST',
|
|
1088
|
+
headers,
|
|
1089
|
+
body: JSON.stringify(checkPayload),
|
|
1090
|
+
});
|
|
1091
|
+
const checkData = (await checkRes.json().catch(() => ({})));
|
|
1092
|
+
if (!checkRes.ok) {
|
|
1093
|
+
throw new Error(`Reminders check failed (${checkRes.status}): ${checkData?.error?.message || JSON.stringify(checkData)}`);
|
|
1094
|
+
}
|
|
1095
|
+
const checkedAt = typeof checkData.checked_at === 'string' ? checkData.checked_at : new Date().toISOString();
|
|
1096
|
+
const reminders = Array.isArray(checkData.reminders) ? checkData.reminders : [];
|
|
1097
|
+
let markedCount = typeof checkData.marked_count === 'number' ? checkData.marked_count : 0;
|
|
1098
|
+
let ackedCount;
|
|
1099
|
+
let webhookDelivered;
|
|
1100
|
+
let webhookStatus;
|
|
1101
|
+
if (webhookUrl && reminders.length > 0) {
|
|
1102
|
+
const webhookRes = await fetchFn(webhookUrl, {
|
|
1103
|
+
method: 'POST',
|
|
1104
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1105
|
+
body: JSON.stringify({
|
|
1106
|
+
event: 'neuralbrain.reminders.due',
|
|
1107
|
+
checked_at: checkedAt,
|
|
1108
|
+
count: reminders.length,
|
|
1109
|
+
reminders,
|
|
1110
|
+
}),
|
|
1111
|
+
signal: AbortSignal.timeout(10_000),
|
|
1112
|
+
});
|
|
1113
|
+
webhookStatus = webhookRes.status;
|
|
1114
|
+
if (!webhookRes.ok) {
|
|
1115
|
+
throw new Error(`Webhook delivery failed with status ${webhookRes.status}`);
|
|
1116
|
+
}
|
|
1117
|
+
webhookDelivered = true;
|
|
1118
|
+
if (!dryRun) {
|
|
1119
|
+
const ackRes = await fetchFn(`${apiUrl}/actions/reminders/ack`, {
|
|
1120
|
+
method: 'POST',
|
|
1121
|
+
headers,
|
|
1122
|
+
body: JSON.stringify({ ids: reminders.map((r) => r.id) }),
|
|
1123
|
+
});
|
|
1124
|
+
const ackData = (await ackRes.json().catch(() => ({})));
|
|
1125
|
+
if (!ackRes.ok) {
|
|
1126
|
+
throw new Error(`Reminders ack failed (${ackRes.status}): ${ackData?.error?.message || JSON.stringify(ackData)}`);
|
|
1127
|
+
}
|
|
1128
|
+
ackedCount = typeof ackData.updated === 'number' ? ackData.updated : reminders.length;
|
|
1129
|
+
markedCount = ackedCount ?? reminders.length;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
else if (webhookUrl) {
|
|
1133
|
+
webhookDelivered = false;
|
|
1134
|
+
}
|
|
1135
|
+
const summaryData = {
|
|
1136
|
+
checked_at: checkedAt,
|
|
1137
|
+
reminders,
|
|
1138
|
+
marked_count: markedCount,
|
|
1139
|
+
...(ackedCount !== undefined ? { acked_count: ackedCount } : {}),
|
|
1140
|
+
...(webhookDelivered !== undefined ? { webhook_delivered: webhookDelivered } : {}),
|
|
1141
|
+
...(webhookStatus !== undefined ? { webhook_status: webhookStatus } : {}),
|
|
1142
|
+
};
|
|
1143
|
+
const output = options.json
|
|
1144
|
+
? JSON.stringify(summaryData, null, 2)
|
|
1145
|
+
: formatRemindersHuman(summaryData);
|
|
1146
|
+
return {
|
|
1147
|
+
...summaryData,
|
|
1148
|
+
output,
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
async function cmdReminders(argv) {
|
|
1152
|
+
const action = argv[0];
|
|
1153
|
+
if (!action || action === '-h' || action === '--help' || action === 'help') {
|
|
1154
|
+
printHelp();
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
if (action !== 'check') {
|
|
1158
|
+
console.error(`Unknown reminders subcommand '${action}'. Expected: check`);
|
|
1159
|
+
process.exit(1);
|
|
1160
|
+
}
|
|
1161
|
+
(0, brainHome_1.loadBrainEnv)();
|
|
1162
|
+
const opts = parseRemindersArgs(argv.slice(1));
|
|
1163
|
+
const result = await runRemindersCheck(opts);
|
|
1164
|
+
console.log(result.output);
|
|
1165
|
+
}
|
|
788
1166
|
function printHelp() {
|
|
789
1167
|
console.log(`
|
|
790
1168
|
Usage: neuralbrain <command> [options]
|
|
@@ -800,13 +1178,26 @@ Commands:
|
|
|
800
1178
|
--no-agents Skip configuring coding agents
|
|
801
1179
|
start Start the configured Brain service
|
|
802
1180
|
stop Stop running Brain / Docker containers
|
|
1181
|
+
restart Stop, wait for the port to free, then start (docker mode rebuilds the image)
|
|
803
1182
|
status Show service and health status
|
|
804
1183
|
logs Tail Brain service logs
|
|
805
1184
|
doctor Run health and AI conformance diagnostics
|
|
806
1185
|
install-agent Configure Antigravity, Claude Code, Cursor, or project rules
|
|
807
1186
|
init Write .brainrc here so agents use one project_id for this folder
|
|
808
|
-
[project-id] Defaults to this folder's name
|
|
1187
|
+
[project-id] Defaults to this folder's name (supports hierarchical a/b/c)
|
|
809
1188
|
--force, -f Replace an existing .brainrc
|
|
1189
|
+
--auto-subproject Derive subproject segments from subfolder path below .brainrc
|
|
1190
|
+
--max-depth <n> Limit auto-subproject depth below .brainrc
|
|
1191
|
+
reminders check Check due/overdue action reminders via Brain HTTP API
|
|
1192
|
+
--json Print machine-readable JSON output
|
|
1193
|
+
--webhook <url> POST due reminders payload to http(s) webhook before acking
|
|
1194
|
+
--project <id> Filter reminders to project_id
|
|
1195
|
+
--include-children Include child subprojects under --project
|
|
1196
|
+
--no-ancestors Exclude ancestor projects when --project is set
|
|
1197
|
+
--no-global Exclude global-scoped actions
|
|
1198
|
+
--cooldown <d> Minimum interval before re-notifying (e.g. 30m, 2h, PT15M)
|
|
1199
|
+
--dry-run Evaluate without stamping last_reminded_at
|
|
1200
|
+
--limit <n> Max reminders to return
|
|
810
1201
|
rename-project Rename a project_id across SQLite and Qdrant (<from> <to>)
|
|
811
1202
|
mcp Start the stdio MCP server
|
|
812
1203
|
`);
|
|
@@ -830,6 +1221,10 @@ async function main() {
|
|
|
830
1221
|
cmdStop();
|
|
831
1222
|
return;
|
|
832
1223
|
}
|
|
1224
|
+
if (sub === 'restart') {
|
|
1225
|
+
await cmdRestart();
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
833
1228
|
if (sub === 'status') {
|
|
834
1229
|
await cmdStatus();
|
|
835
1230
|
return;
|
|
@@ -858,6 +1253,10 @@ async function main() {
|
|
|
858
1253
|
cmdInit(args.slice(1));
|
|
859
1254
|
return;
|
|
860
1255
|
}
|
|
1256
|
+
if (sub === 'reminders') {
|
|
1257
|
+
await cmdReminders(args.slice(1));
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
861
1260
|
if (sub === 'rename-project') {
|
|
862
1261
|
(0, brainHome_1.loadBrainEnv)();
|
|
863
1262
|
const [fromId, toId] = args.slice(1);
|
|
@@ -870,7 +1269,8 @@ async function main() {
|
|
|
870
1269
|
const headers = { 'Content-Type': 'application/json' };
|
|
871
1270
|
if (apiKey)
|
|
872
1271
|
headers.Authorization = `Bearer ${apiKey}`;
|
|
873
|
-
const
|
|
1272
|
+
const tlsFetch = (0, tls_1.createLocalTlsFetch)();
|
|
1273
|
+
const res = await tlsFetch(`${apiUrl}/maintenance/rename-project`, {
|
|
874
1274
|
method: 'POST',
|
|
875
1275
|
headers,
|
|
876
1276
|
body: JSON.stringify({ from_project_id: fromId, to_project_id: toId }),
|