ricord 1.0.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.
Files changed (134) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -0
  3. package/commands/ricord-flush.md +29 -0
  4. package/commands/ricord-init.md +129 -0
  5. package/commands/ricord-lint.md +64 -0
  6. package/commands/ricord-query.md +71 -0
  7. package/dist/cli/auth.d.ts +16 -0
  8. package/dist/cli/auth.js +42 -0
  9. package/dist/cli/auth.js.map +1 -0
  10. package/dist/cli/bundle.d.ts +25 -0
  11. package/dist/cli/bundle.js +179 -0
  12. package/dist/cli/bundle.js.map +1 -0
  13. package/dist/cli/cache.d.ts +18 -0
  14. package/dist/cli/cache.js +39 -0
  15. package/dist/cli/cache.js.map +1 -0
  16. package/dist/cli/cli.d.ts +21 -0
  17. package/dist/cli/cli.js +355 -0
  18. package/dist/cli/cli.js.map +1 -0
  19. package/dist/cli/client.d.ts +12 -0
  20. package/dist/cli/client.js +35 -0
  21. package/dist/cli/client.js.map +1 -0
  22. package/dist/cli/commands/build.d.ts +44 -0
  23. package/dist/cli/commands/build.js +437 -0
  24. package/dist/cli/commands/build.js.map +1 -0
  25. package/dist/cli/commands/curate.d.ts +32 -0
  26. package/dist/cli/commands/curate.js +154 -0
  27. package/dist/cli/commands/curate.js.map +1 -0
  28. package/dist/cli/commands/doctor.d.ts +16 -0
  29. package/dist/cli/commands/doctor.js +92 -0
  30. package/dist/cli/commands/doctor.js.map +1 -0
  31. package/dist/cli/commands/ingest.d.ts +25 -0
  32. package/dist/cli/commands/ingest.js +121 -0
  33. package/dist/cli/commands/ingest.js.map +1 -0
  34. package/dist/cli/commands/install.d.ts +16 -0
  35. package/dist/cli/commands/install.js +82 -0
  36. package/dist/cli/commands/install.js.map +1 -0
  37. package/dist/cli/commands/pull.d.ts +24 -0
  38. package/dist/cli/commands/pull.js +104 -0
  39. package/dist/cli/commands/pull.js.map +1 -0
  40. package/dist/cli/commands/push.d.ts +28 -0
  41. package/dist/cli/commands/push.js +164 -0
  42. package/dist/cli/commands/push.js.map +1 -0
  43. package/dist/cli/commands/rollup.d.ts +21 -0
  44. package/dist/cli/commands/rollup.js +118 -0
  45. package/dist/cli/commands/rollup.js.map +1 -0
  46. package/dist/cli/commands/setup.d.ts +7 -0
  47. package/dist/cli/commands/setup.js +43 -0
  48. package/dist/cli/commands/setup.js.map +1 -0
  49. package/dist/cli/commands/sync.d.ts +15 -0
  50. package/dist/cli/commands/sync.js +63 -0
  51. package/dist/cli/commands/sync.js.map +1 -0
  52. package/dist/cli/commands/watch.d.ts +17 -0
  53. package/dist/cli/commands/watch.js +87 -0
  54. package/dist/cli/commands/watch.js.map +1 -0
  55. package/dist/cli/config.d.ts +29 -0
  56. package/dist/cli/config.js +52 -0
  57. package/dist/cli/config.js.map +1 -0
  58. package/dist/cli/extract.d.ts +101 -0
  59. package/dist/cli/extract.js +216 -0
  60. package/dist/cli/extract.js.map +1 -0
  61. package/dist/cli/ingest.d.ts +48 -0
  62. package/dist/cli/ingest.js +74 -0
  63. package/dist/cli/ingest.js.map +1 -0
  64. package/dist/cli/ledger.d.ts +44 -0
  65. package/dist/cli/ledger.js +67 -0
  66. package/dist/cli/ledger.js.map +1 -0
  67. package/dist/cli/llm.d.ts +21 -0
  68. package/dist/cli/llm.js +138 -0
  69. package/dist/cli/llm.js.map +1 -0
  70. package/dist/cli/parse.d.ts +13 -0
  71. package/dist/cli/parse.js +188 -0
  72. package/dist/cli/parse.js.map +1 -0
  73. package/dist/cli/run-explore.d.ts +56 -0
  74. package/dist/cli/run-explore.js +229 -0
  75. package/dist/cli/run-explore.js.map +1 -0
  76. package/dist/cli/summarize.d.ts +15 -0
  77. package/dist/cli/summarize.js +49 -0
  78. package/dist/cli/summarize.js.map +1 -0
  79. package/dist/cli/uninstall.d.ts +6 -0
  80. package/dist/cli/uninstall.js +277 -0
  81. package/dist/cli/uninstall.js.map +1 -0
  82. package/dist/cli/walk.d.ts +13 -0
  83. package/dist/cli/walk.js +62 -0
  84. package/dist/cli/walk.js.map +1 -0
  85. package/dist/cli/walker.d.ts +14 -0
  86. package/dist/cli/walker.js +120 -0
  87. package/dist/cli/walker.js.map +1 -0
  88. package/dist/hooks/pre-compact.d.ts +15 -0
  89. package/dist/hooks/pre-compact.js +127 -0
  90. package/dist/hooks/pre-compact.js.map +1 -0
  91. package/dist/hooks/pre-tool-use.d.ts +15 -0
  92. package/dist/hooks/pre-tool-use.js +25 -0
  93. package/dist/hooks/pre-tool-use.js.map +1 -0
  94. package/dist/hooks/session-end.d.ts +21 -0
  95. package/dist/hooks/session-end.js +186 -0
  96. package/dist/hooks/session-end.js.map +1 -0
  97. package/dist/hooks/session-start.d.ts +15 -0
  98. package/dist/hooks/session-start.js +233 -0
  99. package/dist/hooks/session-start.js.map +1 -0
  100. package/dist/hooks/turn-end-post.d.ts +17 -0
  101. package/dist/hooks/turn-end-post.js +66 -0
  102. package/dist/hooks/turn-end-post.js.map +1 -0
  103. package/dist/hooks/turn-end.d.ts +29 -0
  104. package/dist/hooks/turn-end.js +295 -0
  105. package/dist/hooks/turn-end.js.map +1 -0
  106. package/dist/index.d.ts +24 -0
  107. package/dist/index.js +1547 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/init.d.ts +45 -0
  110. package/dist/init.js +839 -0
  111. package/dist/init.js.map +1 -0
  112. package/dist/lib/active-project.d.ts +14 -0
  113. package/dist/lib/active-project.js +65 -0
  114. package/dist/lib/active-project.js.map +1 -0
  115. package/dist/lib/buffer.d.ts +34 -0
  116. package/dist/lib/buffer.js +79 -0
  117. package/dist/lib/buffer.js.map +1 -0
  118. package/dist/scripts/compile.d.ts +25 -0
  119. package/dist/scripts/compile.js +185 -0
  120. package/dist/scripts/compile.js.map +1 -0
  121. package/dist/scripts/config.d.ts +30 -0
  122. package/dist/scripts/config.js +68 -0
  123. package/dist/scripts/config.js.map +1 -0
  124. package/dist/scripts/flush.d.ts +23 -0
  125. package/dist/scripts/flush.js +230 -0
  126. package/dist/scripts/flush.js.map +1 -0
  127. package/dist/scripts/lint.d.ts +21 -0
  128. package/dist/scripts/lint.js +242 -0
  129. package/dist/scripts/lint.js.map +1 -0
  130. package/dist/scripts/utils.d.ts +43 -0
  131. package/dist/scripts/utils.js +165 -0
  132. package/dist/scripts/utils.js.map +1 -0
  133. package/package.json +74 -0
  134. package/scripts/postinstall.mjs +56 -0
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Shared utilities for Ricord scripts.
3
+ *
4
+ * Helpers for state tracking, file hashing, daily log manipulation,
5
+ * credential scrubbing, and JSONL transcript parsing.
6
+ */
7
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, appendFileSync } from "node:fs";
8
+ import { createHash } from "node:crypto";
9
+ import { join } from "node:path";
10
+ import { execSync } from "node:child_process";
11
+ import { STATE_FILE, FLUSH_STATE_FILE, DAILY_DIR, FLUSH_LOG_FILE } from "./config.js";
12
+ export function loadState() {
13
+ try {
14
+ if (existsSync(STATE_FILE)) {
15
+ return JSON.parse(readFileSync(STATE_FILE, "utf8"));
16
+ }
17
+ }
18
+ catch { }
19
+ return { ingested: {}, total_cost: 0, query_count: 0, last_lint: "" };
20
+ }
21
+ export function saveState(state) {
22
+ const dir = join(STATE_FILE, "..");
23
+ if (!existsSync(dir))
24
+ mkdirSync(dir, { recursive: true });
25
+ writeFileSync(STATE_FILE, JSON.stringify(state, null, 2), "utf8");
26
+ }
27
+ export function loadFlushState() {
28
+ try {
29
+ if (existsSync(FLUSH_STATE_FILE)) {
30
+ return JSON.parse(readFileSync(FLUSH_STATE_FILE, "utf8"));
31
+ }
32
+ }
33
+ catch { }
34
+ return null;
35
+ }
36
+ export function saveFlushState(state) {
37
+ const dir = join(FLUSH_STATE_FILE, "..");
38
+ if (!existsSync(dir))
39
+ mkdirSync(dir, { recursive: true });
40
+ writeFileSync(FLUSH_STATE_FILE, JSON.stringify(state), "utf8");
41
+ }
42
+ // ── File hashing ─────────────────────────────────────────────────────
43
+ export function fileHash(path) {
44
+ const content = readFileSync(path);
45
+ return createHash("sha256").update(content).digest("hex").slice(0, 16);
46
+ }
47
+ // ── Daily log operations ─────────────────────────────────────────────
48
+ export function ensureDailyDir() {
49
+ if (!existsSync(DAILY_DIR))
50
+ mkdirSync(DAILY_DIR, { recursive: true });
51
+ }
52
+ export function todayLogPath() {
53
+ const today = new Date().toLocaleDateString("en-CA"); // YYYY-MM-DD
54
+ return join(DAILY_DIR, `${today}.md`);
55
+ }
56
+ export function appendToDailyLog(content, section = "Session") {
57
+ ensureDailyDir();
58
+ const logPath = todayLogPath();
59
+ const today = new Date().toLocaleDateString("en-CA");
60
+ if (!existsSync(logPath)) {
61
+ writeFileSync(logPath, `# Daily Log: ${today}\n\n## Sessions\n\n## Memory Maintenance\n\n`, "utf8");
62
+ }
63
+ const timeStr = new Date().toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
64
+ const entry = `### ${section} (${timeStr})\n\n${content}\n\n`;
65
+ appendFileSync(logPath, entry, "utf8");
66
+ }
67
+ export function listDailyLogs() {
68
+ ensureDailyDir();
69
+ return readdirSync(DAILY_DIR)
70
+ .filter(f => f.endsWith(".md"))
71
+ .sort();
72
+ }
73
+ export function extractConversation(transcriptPath, maxTurns = 30, maxChars = 15_000) {
74
+ const allTurns = [];
75
+ const content = readFileSync(transcriptPath, "utf8");
76
+ for (const line of content.split("\n")) {
77
+ if (!line.trim())
78
+ continue;
79
+ try {
80
+ const entry = JSON.parse(line);
81
+ const msg = entry.message || entry;
82
+ const role = msg.role || "";
83
+ let text = msg.content || "";
84
+ if (!["user", "assistant"].includes(role))
85
+ continue;
86
+ if (Array.isArray(text)) {
87
+ text = text
88
+ .filter((b) => typeof b === "string" || (b.type === "text" && b.text))
89
+ .map((b) => (typeof b === "string" ? b : b.text))
90
+ .join("\n");
91
+ }
92
+ if (typeof text === "string" && text.trim()) {
93
+ allTurns.push({ role: role, text: text.trim() });
94
+ }
95
+ }
96
+ catch {
97
+ continue;
98
+ }
99
+ }
100
+ const recent = allTurns.slice(-maxTurns);
101
+ let context = recent
102
+ .map(t => `**${t.role === "user" ? "User" : "Assistant"}:** ${t.text}`)
103
+ .join("\n\n");
104
+ if (context.length > maxChars) {
105
+ context = context.slice(-maxChars);
106
+ const boundary = context.indexOf("\n**");
107
+ if (boundary > 0)
108
+ context = context.slice(boundary + 1);
109
+ }
110
+ return { turns: recent, context, turnCount: recent.length };
111
+ }
112
+ // ── Credential scrubbing ─────────────────────────────────────────────
113
+ const SCRUB_PATTERNS = [
114
+ /sk-[a-zA-Z0-9]{20,}/g, // OpenAI
115
+ /AKIA[A-Z0-9]{16}/g, // AWS
116
+ /ghp_[a-zA-Z0-9]{36,}/g, // GitHub
117
+ /gho_[a-zA-Z0-9]{36,}/g, // GitHub OAuth
118
+ /rc_(?:live|test)_[a-zA-Z0-9_]{10,}/g, // Ricord
119
+ /Bearer\s+[a-zA-Z0-9._\-]{20,}/gi, // Bearer tokens
120
+ /(?:api[_-]?key|password|secret|token)\s*[:=]\s*["']?[^\s"']{8,}/gi, // Generic secrets
121
+ /[a-zA-Z0-9+/]{40,200}={0,2}/g, // Base64 blobs
122
+ ];
123
+ export function scrubCredentials(text) {
124
+ let result = text;
125
+ for (const pattern of SCRUB_PATTERNS) {
126
+ result = result.replace(pattern, "[REDACTED]");
127
+ }
128
+ return result;
129
+ }
130
+ // ── Git helpers ──────────────────────────────────────────────────────
131
+ export function detectProject() {
132
+ try {
133
+ const remote = execSync("git remote get-url origin 2>/dev/null", { encoding: "utf8" }).trim();
134
+ const match = remote.match(/\/([^/]+?)(?:\.git)?$/);
135
+ return match?.[1] || "";
136
+ }
137
+ catch {
138
+ return "";
139
+ }
140
+ }
141
+ export function detectGitRepo() {
142
+ try {
143
+ return execSync("git remote get-url origin 2>/dev/null", { encoding: "utf8" }).trim();
144
+ }
145
+ catch {
146
+ return "";
147
+ }
148
+ }
149
+ export function detectGitBranch() {
150
+ try {
151
+ return execSync("git rev-parse --abbrev-ref HEAD 2>/dev/null", { encoding: "utf8" }).trim();
152
+ }
153
+ catch {
154
+ return "";
155
+ }
156
+ }
157
+ // ── Logging ──────────────────────────────────────────────────────────
158
+ export function logToFile(message, file = FLUSH_LOG_FILE) {
159
+ const timestamp = new Date().toISOString().slice(0, 19).replace("T", " ");
160
+ const dir = join(file, "..");
161
+ if (!existsSync(dir))
162
+ mkdirSync(dir, { recursive: true });
163
+ appendFileSync(file, `${timestamp} ${message}\n`, "utf8");
164
+ }
165
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/scripts/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAWtF,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC;QACH,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,C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CAAC;IAC1D,cAAc,CAAC,IAAI,EAAE,GAAG,SAAS,IAAI,OAAO,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "ricord",
3
+ "version": "1.0.0",
4
+ "description": "Ricord — knowledge wiki, auto-organized. Ships an MCP server (`ricord-mcp`) and a wiki authoring CLI (`ricord build`, `ricord push`, `ricord compile`, …).",
5
+ "type": "module",
6
+ "bin": {
7
+ "ricord-mcp": "dist/index.js",
8
+ "ricord": "dist/cli/cli.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist",
14
+ "commands",
15
+ "scripts/postinstall.mjs",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsx src/index.ts",
22
+ "dev:cli": "tsx src/cli/cli.ts",
23
+ "start": "node dist/index.js",
24
+ "flush": "node dist/scripts/flush.js",
25
+ "compile": "node dist/scripts/compile.js",
26
+ "lint:kb": "node dist/scripts/lint.js",
27
+ "compile:all": "node dist/scripts/compile.js --all",
28
+ "compile:dry-run": "node dist/scripts/compile.js --dry-run",
29
+ "lint:kb:structural": "node dist/scripts/lint.js --structural-only",
30
+ "test": "vitest run",
31
+ "test:smoke": "tsx src/index.ts --help || true",
32
+ "postinstall": "node scripts/postinstall.mjs",
33
+ "prepublishOnly": "npm run build && npm test"
34
+ },
35
+ "keywords": [
36
+ "ricord",
37
+ "mcp",
38
+ "memory",
39
+ "knowledge",
40
+ "ai",
41
+ "claude-code",
42
+ "cursor",
43
+ "windsurf",
44
+ "vscode",
45
+ "model-context-protocol",
46
+ "persistent-memory",
47
+ "knowledge-graph"
48
+ ],
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/ricord-ai/ricord-mcp.git"
53
+ },
54
+ "homepage": "https://ricord.ai",
55
+ "bugs": {
56
+ "url": "https://github.com/ricord-ai/ricord-mcp/issues"
57
+ },
58
+ "engines": {
59
+ "node": ">=20.0.0"
60
+ },
61
+ "publishConfig": {},
62
+ "dependencies": {
63
+ "@modelcontextprotocol/sdk": "^1.12.1",
64
+ "ignore": "^5.3.1",
65
+ "kleur": "^4.1.5",
66
+ "typescript": "^5.7.0",
67
+ "zod": "^3.23.0"
68
+ },
69
+ "devDependencies": {
70
+ "@types/node": "^22.0.0",
71
+ "tsx": "^4.19.0",
72
+ "vitest": "^4.1.5"
73
+ }
74
+ }
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ // Best-effort: copy bundled slash commands into ~/.claude/commands/ on install.
3
+ // Never fails the install — prints a hint on error and exits 0.
4
+
5
+ import fs from "node:fs";
6
+ import os from "node:os";
7
+ import path from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+
10
+ function main() {
11
+ try {
12
+ if (process.env.RICORD_SKIP_POSTINSTALL === "1") return 0;
13
+ if (process.env.CI === "true" && process.env.RICORD_FORCE_POSTINSTALL !== "1") return 0;
14
+
15
+ const here = path.dirname(fileURLToPath(import.meta.url));
16
+ const sourceDir = path.resolve(here, "..", "commands");
17
+ if (!fs.existsSync(sourceDir)) return 0;
18
+
19
+ const home = os.homedir();
20
+ if (!home) return 0;
21
+
22
+ const claudeDir = path.join(home, ".claude");
23
+ if (!fs.existsSync(claudeDir)) return 0;
24
+
25
+ const targetDir = path.join(claudeDir, "commands");
26
+ fs.mkdirSync(targetDir, { recursive: true });
27
+
28
+ const files = fs.readdirSync(sourceDir).filter((f) => f.endsWith(".md"));
29
+ let installed = 0;
30
+ let updated = 0;
31
+ for (const f of files) {
32
+ const src = path.join(sourceDir, f);
33
+ const dst = path.join(targetDir, f);
34
+ const newContent = fs.readFileSync(src, "utf8");
35
+ if (fs.existsSync(dst)) {
36
+ const oldContent = fs.readFileSync(dst, "utf8");
37
+ if (oldContent === newContent) continue;
38
+ updated++;
39
+ } else {
40
+ installed++;
41
+ }
42
+ fs.writeFileSync(dst, newContent, "utf8");
43
+ }
44
+ if (installed + updated > 0) {
45
+ console.log(`[ricord] installed ${installed} + updated ${updated} Claude Code slash command(s) into ${targetDir}`);
46
+ console.log(`[ricord] restart Claude Code to pick them up. Disable with RICORD_SKIP_POSTINSTALL=1.`);
47
+ }
48
+ return 0;
49
+ } catch (err) {
50
+ const msg = err && err.message ? err.message : String(err);
51
+ console.log(`[ricord] postinstall skipped (${msg}). Run 'ricord install-commands' to install slash commands.`);
52
+ return 0;
53
+ }
54
+ }
55
+
56
+ process.exit(main());