@xqli02/mneme 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/README.md +175 -0
- package/bin/mneme.mjs +275 -0
- package/package.json +31 -0
- package/src/commands/auto.mjs +654 -0
- package/src/commands/compact.mjs +137 -0
- package/src/commands/doctor.mjs +91 -0
- package/src/commands/facts.mjs +148 -0
- package/src/commands/init.mjs +344 -0
- package/src/commands/propose.mjs +150 -0
- package/src/commands/review.mjs +210 -0
- package/src/commands/status.mjs +164 -0
- package/src/opencode-client.mjs +126 -0
- package/src/templates/AGENTS.md +259 -0
- package/src/templates/facts-architecture.md +6 -0
- package/src/templates/facts-invariants.md +6 -0
- package/src/templates/facts-performance_rules.md +5 -0
- package/src/templates/facts-pitfalls.md +5 -0
- package/src/templates/gitignore +23 -0
- package/src/templates/opencode-prompt.md +48 -0
- package/src/utils.mjs +90 -0
package/src/utils.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities: colored output, command execution, platform detection.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { execSync, execFileSync } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { platform, arch } from "node:os";
|
|
8
|
+
|
|
9
|
+
// ── Colors ──────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
const isColorSupported =
|
|
12
|
+
process.env.FORCE_COLOR !== "0" && process.stdout.isTTY;
|
|
13
|
+
|
|
14
|
+
const c = (code) => (isColorSupported ? `\x1b[${code}m` : "");
|
|
15
|
+
|
|
16
|
+
export const color = {
|
|
17
|
+
red: (s) => `${c("0;31")}${s}${c("0")}`,
|
|
18
|
+
green: (s) => `${c("0;32")}${s}${c("0")}`,
|
|
19
|
+
yellow: (s) => `${c("1;33")}${s}${c("0")}`,
|
|
20
|
+
blue: (s) => `${c("0;34")}${s}${c("0")}`,
|
|
21
|
+
dim: (s) => `${c("2")}${s}${c("0")}`,
|
|
22
|
+
bold: (s) => `${c("1")}${s}${c("0")}`,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const log = {
|
|
26
|
+
info: (msg) => console.log(`${color.blue("==>")} ${msg}`),
|
|
27
|
+
ok: (msg) => console.log(`${color.green("[OK]")} ${msg}`),
|
|
28
|
+
warn: (msg) => console.log(`${color.yellow("[!!]")} ${msg}`),
|
|
29
|
+
fail: (msg) => console.log(`${color.red("[FAIL]")} ${msg}`),
|
|
30
|
+
step: (n, total, msg) =>
|
|
31
|
+
console.log(`\n${color.bold(`--- ${n}/${total}`)} ${msg} ---`),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// ── Command execution ───────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if a command exists in PATH.
|
|
38
|
+
*/
|
|
39
|
+
export function has(cmd) {
|
|
40
|
+
try {
|
|
41
|
+
execSync(`command -v ${cmd}`, { stdio: "ignore" });
|
|
42
|
+
return true;
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Run a command and return stdout (trimmed). Returns null on failure.
|
|
50
|
+
*/
|
|
51
|
+
export function run(cmd, opts = {}) {
|
|
52
|
+
try {
|
|
53
|
+
return execSync(cmd, {
|
|
54
|
+
encoding: "utf-8",
|
|
55
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
56
|
+
timeout: opts.timeout ?? 60_000,
|
|
57
|
+
...opts,
|
|
58
|
+
}).trim();
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Run a command, inheriting stdio (user sees output). Returns exit code.
|
|
66
|
+
*/
|
|
67
|
+
export function runLive(cmd, opts = {}) {
|
|
68
|
+
try {
|
|
69
|
+
execSync(cmd, {
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
timeout: opts.timeout ?? 120_000,
|
|
72
|
+
...opts,
|
|
73
|
+
});
|
|
74
|
+
return 0;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return e.status ?? 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Platform detection ──────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
export function getPlatform() {
|
|
83
|
+
const os = platform(); // 'linux', 'darwin', 'win32'
|
|
84
|
+
const ar = arch(); // 'x64', 'arm64'
|
|
85
|
+
return { os, arch: ar };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ── File helpers ────────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
export { existsSync };
|