@rigstate/cli 0.7.38 → 0.7.39
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/.rigstate/memories/2585b51e-f576-4c0c-b69d-2daaaa427bf4.json +18 -0
- package/.rigstate/memories/739c72cd-d1a7-49a7-901c-8f2a9db9e4ca.json +17 -0
- package/.rigstate/memories/bd30d910-dd03-42d7-8eee-8306a5536ca1.json +18 -0
- package/dist/index.cjs +342 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +342 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/ask.ts +100 -0
- package/src/commands/remember.ts +67 -0
- package/src/index.ts +4 -0
- package/src/utils/memory-store.ts +183 -0
package/dist/index.js
CHANGED
|
@@ -390,19 +390,19 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false, versi
|
|
|
390
390
|
}
|
|
391
391
|
const files = syncResponse.data.data.files;
|
|
392
392
|
if (files && Array.isArray(files)) {
|
|
393
|
-
const
|
|
394
|
-
const
|
|
393
|
+
const fs27 = await import("fs/promises");
|
|
394
|
+
const path30 = await import("path");
|
|
395
395
|
for (const file of files) {
|
|
396
|
-
const filePath =
|
|
397
|
-
await
|
|
398
|
-
await
|
|
396
|
+
const filePath = path30.join(process.cwd(), file.path);
|
|
397
|
+
await fs27.mkdir(path30.dirname(filePath), { recursive: true });
|
|
398
|
+
await fs27.writeFile(filePath, file.content, "utf-8");
|
|
399
399
|
}
|
|
400
400
|
console.log(chalk4.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
|
|
401
401
|
try {
|
|
402
|
-
const masterPath =
|
|
402
|
+
const masterPath = path30.join(process.cwd(), ".cursorrules");
|
|
403
403
|
let masterContent = "";
|
|
404
404
|
try {
|
|
405
|
-
masterContent = await
|
|
405
|
+
masterContent = await fs27.readFile(masterPath, "utf-8");
|
|
406
406
|
} catch {
|
|
407
407
|
masterContent = "";
|
|
408
408
|
}
|
|
@@ -431,7 +431,7 @@ ${END_MARKER}`;
|
|
|
431
431
|
|
|
432
432
|
${governanceBlock}` : governanceBlock;
|
|
433
433
|
}
|
|
434
|
-
await
|
|
434
|
+
await fs27.writeFile(masterPath, newContent, "utf-8");
|
|
435
435
|
console.log(chalk4.dim(" \u{1F4DC} Updated master .cursorrules (Constitution enforced)"));
|
|
436
436
|
} catch (e) {
|
|
437
437
|
console.warn(chalk4.yellow(` \u26A0\uFE0F Could not update .cursorrules: ${e.message}`));
|
|
@@ -1188,8 +1188,8 @@ var require_package = __commonJS({
|
|
|
1188
1188
|
|
|
1189
1189
|
// src/index.ts
|
|
1190
1190
|
init_esm_shims();
|
|
1191
|
-
import { Command as
|
|
1192
|
-
import
|
|
1191
|
+
import { Command as Command27 } from "commander";
|
|
1192
|
+
import chalk39 from "chalk";
|
|
1193
1193
|
|
|
1194
1194
|
// src/commands/login.ts
|
|
1195
1195
|
init_esm_shims();
|
|
@@ -1357,9 +1357,9 @@ function createLinkCommand() {
|
|
|
1357
1357
|
});
|
|
1358
1358
|
}
|
|
1359
1359
|
async function hardenGitIgnore(cwd) {
|
|
1360
|
-
const
|
|
1361
|
-
const
|
|
1362
|
-
const ignorePath =
|
|
1360
|
+
const fs27 = await import("fs/promises");
|
|
1361
|
+
const path30 = await import("path");
|
|
1362
|
+
const ignorePath = path30.join(cwd, ".gitignore");
|
|
1363
1363
|
const REQUIRED_IGNORES = [
|
|
1364
1364
|
"# Rigstate - Runtime Artifacts (Do not commit)",
|
|
1365
1365
|
".rigstate/ACTIVE_VIOLATIONS.md",
|
|
@@ -1374,7 +1374,7 @@ async function hardenGitIgnore(cwd) {
|
|
|
1374
1374
|
try {
|
|
1375
1375
|
let content = "";
|
|
1376
1376
|
try {
|
|
1377
|
-
content = await
|
|
1377
|
+
content = await fs27.readFile(ignorePath, "utf-8");
|
|
1378
1378
|
} catch {
|
|
1379
1379
|
content = "";
|
|
1380
1380
|
}
|
|
@@ -1382,7 +1382,7 @@ async function hardenGitIgnore(cwd) {
|
|
|
1382
1382
|
if (missing.length > 0) {
|
|
1383
1383
|
console.log(chalk7.dim(" Configuring .gitignore for Rigstate safety..."));
|
|
1384
1384
|
const toAppend = "\n\n" + REQUIRED_IGNORES.join("\n") + "\n";
|
|
1385
|
-
await
|
|
1385
|
+
await fs27.writeFile(ignorePath, content + toAppend, "utf-8");
|
|
1386
1386
|
console.log(chalk7.green(" \u2714 .gitignore updated (Artifacts protected)"));
|
|
1387
1387
|
} else {
|
|
1388
1388
|
console.log(chalk7.green(" \u2714 .gitignore already hardened"));
|
|
@@ -1392,21 +1392,21 @@ async function hardenGitIgnore(cwd) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
1394
|
async function installHooks(cwd) {
|
|
1395
|
-
const
|
|
1396
|
-
const
|
|
1395
|
+
const fs27 = await import("fs/promises");
|
|
1396
|
+
const path30 = await import("path");
|
|
1397
1397
|
try {
|
|
1398
|
-
await
|
|
1398
|
+
await fs27.access(path30.join(cwd, ".git"));
|
|
1399
1399
|
} catch {
|
|
1400
1400
|
console.log(chalk7.dim(" (Not a git repository, skipping hooks)"));
|
|
1401
1401
|
return;
|
|
1402
1402
|
}
|
|
1403
|
-
const hooksDir =
|
|
1403
|
+
const hooksDir = path30.join(cwd, ".husky");
|
|
1404
1404
|
try {
|
|
1405
|
-
const preCommitPath =
|
|
1405
|
+
const preCommitPath = path30.join(cwd, ".git/hooks/pre-commit");
|
|
1406
1406
|
let shouldInstall = false;
|
|
1407
1407
|
try {
|
|
1408
|
-
await
|
|
1409
|
-
const content = await
|
|
1408
|
+
await fs27.access(preCommitPath);
|
|
1409
|
+
const content = await fs27.readFile(preCommitPath, "utf-8");
|
|
1410
1410
|
if (content.includes("rigstate")) {
|
|
1411
1411
|
console.log(chalk7.green(" \u2714 Git hooks already active"));
|
|
1412
1412
|
} else {
|
|
@@ -1430,12 +1430,12 @@ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
|
|
|
1430
1430
|
rigstate check --staged --strict=critical
|
|
1431
1431
|
exit $?
|
|
1432
1432
|
`;
|
|
1433
|
-
await
|
|
1433
|
+
await fs27.mkdir(path30.dirname(preCommitPath), { recursive: true });
|
|
1434
1434
|
if (await fileExists(preCommitPath)) {
|
|
1435
|
-
const existing = await
|
|
1436
|
-
await
|
|
1435
|
+
const existing = await fs27.readFile(preCommitPath, "utf-8");
|
|
1436
|
+
await fs27.writeFile(preCommitPath, existing + "\n\n" + PRE_COMMIT_SCRIPT2.replace("#!/bin/sh\n", ""), { mode: 493 });
|
|
1437
1437
|
} else {
|
|
1438
|
-
await
|
|
1438
|
+
await fs27.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
|
|
1439
1439
|
}
|
|
1440
1440
|
console.log(chalk7.green(" \u2714 Applied Guardian protection (git-hooks)"));
|
|
1441
1441
|
}
|
|
@@ -1443,10 +1443,10 @@ exit $?
|
|
|
1443
1443
|
console.log(chalk7.dim(" (Skipped hooks: " + e.message + ")"));
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
async function fileExists(
|
|
1447
|
-
const
|
|
1446
|
+
async function fileExists(path30) {
|
|
1447
|
+
const fs27 = await import("fs/promises");
|
|
1448
1448
|
try {
|
|
1449
|
-
await
|
|
1449
|
+
await fs27.access(path30);
|
|
1450
1450
|
return true;
|
|
1451
1451
|
} catch {
|
|
1452
1452
|
return false;
|
|
@@ -3496,7 +3496,7 @@ var KnowledgeHarvester = class extends EventEmitter3 {
|
|
|
3496
3496
|
pollInterval: 100
|
|
3497
3497
|
}
|
|
3498
3498
|
});
|
|
3499
|
-
this.watcher.on("add", (
|
|
3499
|
+
this.watcher.on("add", (path30) => this.handleFileEvent(path30, "add")).on("change", (path30) => this.handleFileEvent(path30, "change"));
|
|
3500
3500
|
this.isReady = true;
|
|
3501
3501
|
}
|
|
3502
3502
|
async stop() {
|
|
@@ -3688,7 +3688,7 @@ var GuardianDaemon = class extends EventEmitter4 {
|
|
|
3688
3688
|
setupFileWatcher() {
|
|
3689
3689
|
Logger.info("Starting file watcher...");
|
|
3690
3690
|
this.fileWatcher = createFileWatcher(this.config.watchPath);
|
|
3691
|
-
this.fileWatcher.on("change", (
|
|
3691
|
+
this.fileWatcher.on("change", (path30) => this.handleFileChange(path30));
|
|
3692
3692
|
this.fileWatcher.start();
|
|
3693
3693
|
Logger.info("File watcher active");
|
|
3694
3694
|
}
|
|
@@ -5391,16 +5391,310 @@ Council session aborted: ${e.message}`));
|
|
|
5391
5391
|
});
|
|
5392
5392
|
}
|
|
5393
5393
|
function sleep(ms) {
|
|
5394
|
-
return new Promise((
|
|
5394
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5395
5395
|
}
|
|
5396
5396
|
|
|
5397
5397
|
// src/index.ts
|
|
5398
5398
|
init_genesis();
|
|
5399
|
+
|
|
5400
|
+
// src/commands/remember.ts
|
|
5401
|
+
init_esm_shims();
|
|
5402
|
+
import { Command as Command25 } from "commander";
|
|
5403
|
+
import chalk37 from "chalk";
|
|
5404
|
+
|
|
5405
|
+
// src/utils/memory-store.ts
|
|
5406
|
+
init_esm_shims();
|
|
5407
|
+
import * as fs26 from "fs";
|
|
5408
|
+
import * as path29 from "path";
|
|
5409
|
+
import { randomUUID } from "crypto";
|
|
5410
|
+
var MEMORIES_DIR = ".rigstate/memories";
|
|
5411
|
+
function getMemoriesDir() {
|
|
5412
|
+
const dir = path29.resolve(process.cwd(), MEMORIES_DIR);
|
|
5413
|
+
if (!fs26.existsSync(dir)) {
|
|
5414
|
+
fs26.mkdirSync(dir, { recursive: true });
|
|
5415
|
+
}
|
|
5416
|
+
return dir;
|
|
5417
|
+
}
|
|
5418
|
+
function saveMemory(input) {
|
|
5419
|
+
const dir = getMemoriesDir();
|
|
5420
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5421
|
+
const memory = {
|
|
5422
|
+
id: randomUUID(),
|
|
5423
|
+
...input,
|
|
5424
|
+
title: input.title,
|
|
5425
|
+
content: input.content,
|
|
5426
|
+
category: input.category || "CONTEXT",
|
|
5427
|
+
source: input.source || "USER",
|
|
5428
|
+
tags: input.tags || [],
|
|
5429
|
+
importance: input.importance || 5,
|
|
5430
|
+
confidence: input.confidence || 1,
|
|
5431
|
+
created_at: now,
|
|
5432
|
+
updated_at: now,
|
|
5433
|
+
expires_at: input.expires_at || null
|
|
5434
|
+
};
|
|
5435
|
+
const filename = `${memory.id}.json`;
|
|
5436
|
+
const filepath = path29.join(dir, filename);
|
|
5437
|
+
fs26.writeFileSync(filepath, JSON.stringify(memory, null, 2), "utf-8");
|
|
5438
|
+
return memory;
|
|
5439
|
+
}
|
|
5440
|
+
function loadAllMemories() {
|
|
5441
|
+
const dir = getMemoriesDir();
|
|
5442
|
+
const files = fs26.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
5443
|
+
const memories = [];
|
|
5444
|
+
for (const file of files) {
|
|
5445
|
+
try {
|
|
5446
|
+
const raw = fs26.readFileSync(path29.join(dir, file), "utf-8");
|
|
5447
|
+
memories.push(JSON.parse(raw));
|
|
5448
|
+
} catch {
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
return memories;
|
|
5452
|
+
}
|
|
5453
|
+
function searchMemories(query, limit = 5) {
|
|
5454
|
+
const memories = loadAllMemories();
|
|
5455
|
+
const tokens = tokenize(query);
|
|
5456
|
+
if (tokens.length === 0) return [];
|
|
5457
|
+
const results = [];
|
|
5458
|
+
for (const memory of memories) {
|
|
5459
|
+
if (memory.expires_at && new Date(memory.expires_at) < /* @__PURE__ */ new Date()) {
|
|
5460
|
+
continue;
|
|
5461
|
+
}
|
|
5462
|
+
let score = 0;
|
|
5463
|
+
const matchedFields = [];
|
|
5464
|
+
const titleTokens = tokenize(memory.title);
|
|
5465
|
+
const titleMatches = tokens.filter((t) => titleTokens.includes(t)).length;
|
|
5466
|
+
if (titleMatches > 0) {
|
|
5467
|
+
score += titleMatches * 3;
|
|
5468
|
+
matchedFields.push("title");
|
|
5469
|
+
}
|
|
5470
|
+
const contentLower = memory.content.toLowerCase();
|
|
5471
|
+
const contentMatches = tokens.filter((t) => contentLower.includes(t)).length;
|
|
5472
|
+
if (contentMatches > 0) {
|
|
5473
|
+
score += contentMatches * 1;
|
|
5474
|
+
matchedFields.push("content");
|
|
5475
|
+
}
|
|
5476
|
+
const tagLower = memory.tags.map((t) => t.toLowerCase());
|
|
5477
|
+
const tagMatches = tokens.filter((t) => tagLower.includes(t)).length;
|
|
5478
|
+
if (tagMatches > 0) {
|
|
5479
|
+
score += tagMatches * 4;
|
|
5480
|
+
matchedFields.push("tags");
|
|
5481
|
+
}
|
|
5482
|
+
if (tokens.includes(memory.category.toLowerCase())) {
|
|
5483
|
+
score += 2;
|
|
5484
|
+
matchedFields.push("category");
|
|
5485
|
+
}
|
|
5486
|
+
score *= memory.importance / 5;
|
|
5487
|
+
if (score > 0) {
|
|
5488
|
+
results.push({ memory, score, matchedFields });
|
|
5489
|
+
}
|
|
5490
|
+
}
|
|
5491
|
+
return results.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
5492
|
+
}
|
|
5493
|
+
function getMemoryStats() {
|
|
5494
|
+
const memories = loadAllMemories();
|
|
5495
|
+
const byCategory = {};
|
|
5496
|
+
for (const m of memories) {
|
|
5497
|
+
byCategory[m.category] = (byCategory[m.category] || 0) + 1;
|
|
5498
|
+
}
|
|
5499
|
+
return { total: memories.length, byCategory };
|
|
5500
|
+
}
|
|
5501
|
+
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
5502
|
+
"the",
|
|
5503
|
+
"a",
|
|
5504
|
+
"an",
|
|
5505
|
+
"is",
|
|
5506
|
+
"are",
|
|
5507
|
+
"was",
|
|
5508
|
+
"were",
|
|
5509
|
+
"in",
|
|
5510
|
+
"on",
|
|
5511
|
+
"at",
|
|
5512
|
+
"to",
|
|
5513
|
+
"for",
|
|
5514
|
+
"of",
|
|
5515
|
+
"with",
|
|
5516
|
+
"by",
|
|
5517
|
+
"from",
|
|
5518
|
+
"and",
|
|
5519
|
+
"or",
|
|
5520
|
+
"not",
|
|
5521
|
+
"this",
|
|
5522
|
+
"that",
|
|
5523
|
+
"it",
|
|
5524
|
+
"we",
|
|
5525
|
+
"you",
|
|
5526
|
+
"they",
|
|
5527
|
+
"my",
|
|
5528
|
+
"our",
|
|
5529
|
+
"your",
|
|
5530
|
+
"its",
|
|
5531
|
+
"his",
|
|
5532
|
+
"her",
|
|
5533
|
+
"how",
|
|
5534
|
+
"what",
|
|
5535
|
+
"why",
|
|
5536
|
+
"when",
|
|
5537
|
+
"where",
|
|
5538
|
+
"which",
|
|
5539
|
+
"who",
|
|
5540
|
+
"do",
|
|
5541
|
+
"does",
|
|
5542
|
+
"did",
|
|
5543
|
+
"has",
|
|
5544
|
+
"have",
|
|
5545
|
+
"had",
|
|
5546
|
+
"be",
|
|
5547
|
+
"been",
|
|
5548
|
+
"being",
|
|
5549
|
+
"will",
|
|
5550
|
+
"would",
|
|
5551
|
+
"can",
|
|
5552
|
+
"could",
|
|
5553
|
+
"should",
|
|
5554
|
+
"shall",
|
|
5555
|
+
"may",
|
|
5556
|
+
"might",
|
|
5557
|
+
"must",
|
|
5558
|
+
"vi",
|
|
5559
|
+
"er",
|
|
5560
|
+
"var",
|
|
5561
|
+
"har",
|
|
5562
|
+
"den",
|
|
5563
|
+
"det",
|
|
5564
|
+
"en",
|
|
5565
|
+
"et",
|
|
5566
|
+
"og",
|
|
5567
|
+
"i",
|
|
5568
|
+
"p\xE5",
|
|
5569
|
+
"til",
|
|
5570
|
+
"fra",
|
|
5571
|
+
"med",
|
|
5572
|
+
"som",
|
|
5573
|
+
"om",
|
|
5574
|
+
"for",
|
|
5575
|
+
"av",
|
|
5576
|
+
"ikke",
|
|
5577
|
+
"hvorfor",
|
|
5578
|
+
"hvordan",
|
|
5579
|
+
"hva",
|
|
5580
|
+
"n\xE5r",
|
|
5581
|
+
"hvor"
|
|
5582
|
+
]);
|
|
5583
|
+
function tokenize(text) {
|
|
5584
|
+
return text.toLowerCase().replace(/[^a-zA-Z0-9æøåÆØÅ\s]/g, " ").split(/\s+/).filter((t) => t.length > 1 && !STOP_WORDS.has(t));
|
|
5585
|
+
}
|
|
5586
|
+
|
|
5587
|
+
// src/commands/remember.ts
|
|
5588
|
+
init_config();
|
|
5589
|
+
function createRememberCommand() {
|
|
5590
|
+
return new Command25("remember").description("Save a memory to the local knowledge base (.rigstate/memories/)").argument("<text>", "The memory content to save").option("-t, --title <title>", "Title for the memory (defaults to first 60 chars of text)").option("-c, --category <category>", "Category: ADR, DECISION, LESSON, CONTEXT, INSTRUCTION, PATTERN, GOTCHA", "CONTEXT").option("--tags <tags>", 'Comma-separated tags (e.g. "supabase,architecture")').option("-i, --importance <n>", "Importance 1-10 (default: 5)", "5").option("--source <source>", "Source: USER, AGENT, COUNCIL, GOVERNANCE, HARVEST, IMPORT", "USER").action(async (text, options) => {
|
|
5591
|
+
try {
|
|
5592
|
+
const projectId = getProjectId();
|
|
5593
|
+
const title = options.title || text.substring(0, 60) + (text.length > 60 ? "..." : "");
|
|
5594
|
+
const tags = options.tags ? options.tags.split(",").map((t) => t.trim()) : [];
|
|
5595
|
+
const importance = Math.min(10, Math.max(1, parseInt(options.importance, 10) || 5));
|
|
5596
|
+
const memory = saveMemory({
|
|
5597
|
+
title,
|
|
5598
|
+
content: text,
|
|
5599
|
+
category: options.category || "CONTEXT",
|
|
5600
|
+
source: options.source || "USER",
|
|
5601
|
+
tags,
|
|
5602
|
+
importance,
|
|
5603
|
+
project_id: projectId || void 0
|
|
5604
|
+
});
|
|
5605
|
+
console.log("");
|
|
5606
|
+
console.log(chalk37.bold.green("\u{1F9E0} Memory Saved"));
|
|
5607
|
+
console.log(chalk37.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
5608
|
+
console.log(`${chalk37.bold("ID:")} ${chalk37.dim(memory.id)}`);
|
|
5609
|
+
console.log(`${chalk37.bold("Title:")} ${chalk37.cyan(memory.title)}`);
|
|
5610
|
+
console.log(`${chalk37.bold("Category:")} ${chalk37.magenta(memory.category)}`);
|
|
5611
|
+
console.log(`${chalk37.bold("Importance:")} ${"\u2B50".repeat(Math.min(5, Math.ceil(importance / 2)))} (${importance}/10)`);
|
|
5612
|
+
if (tags.length > 0) {
|
|
5613
|
+
console.log(`${chalk37.bold("Tags:")} ${tags.map((t) => chalk37.yellow(`#${t}`)).join(" ")}`);
|
|
5614
|
+
}
|
|
5615
|
+
console.log(chalk37.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
5616
|
+
const stats = getMemoryStats();
|
|
5617
|
+
console.log(chalk37.dim(`Total memories: ${stats.total}`));
|
|
5618
|
+
console.log("");
|
|
5619
|
+
} catch (err) {
|
|
5620
|
+
console.error(chalk37.red(`\u274C Failed to save memory: ${err.message}`));
|
|
5621
|
+
process.exit(1);
|
|
5622
|
+
}
|
|
5623
|
+
});
|
|
5624
|
+
}
|
|
5625
|
+
|
|
5626
|
+
// src/commands/ask.ts
|
|
5627
|
+
init_esm_shims();
|
|
5628
|
+
import { Command as Command26 } from "commander";
|
|
5629
|
+
import chalk38 from "chalk";
|
|
5630
|
+
function createAskCommand() {
|
|
5631
|
+
return new Command26("ask").description("Search local memories instantly (<10ms, offline)").argument("<query>", "Natural language query to search memories").option("-n, --limit <n>", "Maximum results to return", "5").action(async (query, options) => {
|
|
5632
|
+
const limit = parseInt(options.limit, 10) || 5;
|
|
5633
|
+
const startTime = performance.now();
|
|
5634
|
+
const results = searchMemories(query, limit);
|
|
5635
|
+
const elapsed = (performance.now() - startTime).toFixed(1);
|
|
5636
|
+
console.log("");
|
|
5637
|
+
if (results.length === 0) {
|
|
5638
|
+
const stats2 = getMemoryStats();
|
|
5639
|
+
console.log(chalk38.yellow(`\u{1F50D} No memories found for: "${query}"`));
|
|
5640
|
+
console.log(chalk38.dim(` Searched ${stats2.total} memories in ${elapsed}ms.`));
|
|
5641
|
+
if (stats2.total === 0) {
|
|
5642
|
+
console.log("");
|
|
5643
|
+
console.log(chalk38.dim(" No memories yet. Start with:"));
|
|
5644
|
+
console.log(chalk38.white(' rigstate remember "We chose Supabase for real-time and RLS"'));
|
|
5645
|
+
}
|
|
5646
|
+
console.log("");
|
|
5647
|
+
return;
|
|
5648
|
+
}
|
|
5649
|
+
console.log(chalk38.bold(`\u{1F9E0} ${results.length} memor${results.length === 1 ? "y" : "ies"} found`) + chalk38.dim(` (${elapsed}ms)`));
|
|
5650
|
+
console.log(chalk38.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
5651
|
+
for (const { memory, score, matchedFields } of results) {
|
|
5652
|
+
const categoryColor = getCategoryColor(memory.category);
|
|
5653
|
+
const stars = "\u2B50".repeat(Math.min(5, Math.ceil((memory.importance || 5) / 2)));
|
|
5654
|
+
console.log("");
|
|
5655
|
+
console.log(` ${categoryColor(memory.category)} ${chalk38.bold(memory.title)} ${chalk38.dim(`[${stars}]`)}`);
|
|
5656
|
+
const preview = memory.content.length > 120 ? memory.content.substring(0, 120) + "..." : memory.content;
|
|
5657
|
+
console.log(` ${chalk38.white(preview)}`);
|
|
5658
|
+
if (memory.tags && memory.tags.length > 0) {
|
|
5659
|
+
console.log(` ${memory.tags.map((t) => chalk38.yellow(`#${t}`)).join(" ")}`);
|
|
5660
|
+
}
|
|
5661
|
+
const meta = [
|
|
5662
|
+
chalk38.dim(`score:${score.toFixed(1)}`),
|
|
5663
|
+
chalk38.dim(`matched:${matchedFields.join(",")}`),
|
|
5664
|
+
chalk38.dim(`source:${memory.source}`)
|
|
5665
|
+
];
|
|
5666
|
+
if (memory.created_at) {
|
|
5667
|
+
const date = new Date(memory.created_at).toLocaleDateString("nb-NO");
|
|
5668
|
+
meta.push(chalk38.dim(`date:${date}`));
|
|
5669
|
+
}
|
|
5670
|
+
console.log(` ${meta.join(" ")}`);
|
|
5671
|
+
}
|
|
5672
|
+
console.log("");
|
|
5673
|
+
console.log(chalk38.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
5674
|
+
const stats = getMemoryStats();
|
|
5675
|
+
console.log(chalk38.dim(`Searched ${stats.total} memories in ${elapsed}ms`));
|
|
5676
|
+
console.log("");
|
|
5677
|
+
});
|
|
5678
|
+
}
|
|
5679
|
+
function getCategoryColor(category) {
|
|
5680
|
+
const colors = {
|
|
5681
|
+
"ADR": chalk38.bgBlue.white,
|
|
5682
|
+
"DECISION": chalk38.bgCyan.black,
|
|
5683
|
+
"LESSON": chalk38.bgYellow.black,
|
|
5684
|
+
"CONTEXT": chalk38.bgGreen.black,
|
|
5685
|
+
"INSTRUCTION": chalk38.bgMagenta.white,
|
|
5686
|
+
"PATTERN": chalk38.bgWhite.black,
|
|
5687
|
+
"GOTCHA": chalk38.bgRed.white
|
|
5688
|
+
};
|
|
5689
|
+
return colors[category] || chalk38.dim;
|
|
5690
|
+
}
|
|
5691
|
+
|
|
5692
|
+
// src/index.ts
|
|
5399
5693
|
init_version();
|
|
5400
5694
|
import dotenv from "dotenv";
|
|
5401
5695
|
var pkg = require_package();
|
|
5402
5696
|
dotenv.config();
|
|
5403
|
-
var program = new
|
|
5697
|
+
var program = new Command27();
|
|
5404
5698
|
program.name("rigstate").description("CLI for Rigstate - The AI-Native Dev Studio").version(pkg.version);
|
|
5405
5699
|
program.addCommand(createLoginCommand());
|
|
5406
5700
|
program.addCommand(createLinkCommand());
|
|
@@ -5426,30 +5720,32 @@ program.addCommand(createRoadmapCommand());
|
|
|
5426
5720
|
program.addCommand(createCouncilCommand());
|
|
5427
5721
|
program.addCommand(createPlanCommand());
|
|
5428
5722
|
program.addCommand(createGenesisCommand());
|
|
5723
|
+
program.addCommand(createRememberCommand());
|
|
5724
|
+
program.addCommand(createAskCommand());
|
|
5429
5725
|
program.hook("preAction", async () => {
|
|
5430
5726
|
await checkVersion();
|
|
5431
5727
|
});
|
|
5432
5728
|
program.on("--help", () => {
|
|
5433
5729
|
console.log("");
|
|
5434
|
-
console.log(
|
|
5730
|
+
console.log(chalk39.bold("Examples:"));
|
|
5435
5731
|
console.log("");
|
|
5436
|
-
console.log(
|
|
5437
|
-
console.log(
|
|
5732
|
+
console.log(chalk39.cyan(" $ rigstate login sk_rigstate_your_api_key"));
|
|
5733
|
+
console.log(chalk39.dim(" Authenticate with your Rigstate API key"));
|
|
5438
5734
|
console.log("");
|
|
5439
|
-
console.log(
|
|
5440
|
-
console.log(
|
|
5735
|
+
console.log(chalk39.cyan(" $ rigstate scan"));
|
|
5736
|
+
console.log(chalk39.dim(" Scan the current directory"));
|
|
5441
5737
|
console.log("");
|
|
5442
|
-
console.log(
|
|
5443
|
-
console.log(
|
|
5738
|
+
console.log(chalk39.cyan(" $ rigstate genesis"));
|
|
5739
|
+
console.log(chalk39.dim(" Initialize project foundation (auto-detects stack)"));
|
|
5444
5740
|
console.log("");
|
|
5445
|
-
console.log(
|
|
5446
|
-
console.log(
|
|
5741
|
+
console.log(chalk39.cyan(" $ rigstate genesis --status"));
|
|
5742
|
+
console.log(chalk39.dim(" Check genesis status without triggering"));
|
|
5447
5743
|
console.log("");
|
|
5448
|
-
console.log(
|
|
5449
|
-
console.log(
|
|
5744
|
+
console.log(chalk39.cyan(" $ rigstate scan ./src --project abc123"));
|
|
5745
|
+
console.log(chalk39.dim(" Scan a specific directory with project ID"));
|
|
5450
5746
|
console.log("");
|
|
5451
|
-
console.log(
|
|
5452
|
-
console.log(
|
|
5747
|
+
console.log(chalk39.cyan(" $ rigstate scan --json"));
|
|
5748
|
+
console.log(chalk39.dim(" Output results in JSON format (useful for IDE extensions)"));
|
|
5453
5749
|
console.log("");
|
|
5454
5750
|
});
|
|
5455
5751
|
program.parse(process.argv);
|