codemem 0.1.0 → 0.20.0-alpha.1
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/.opencode/lib/compat.js +171 -0
- package/.opencode/plugin/codemem.js +1851 -0
- package/dist/commands/claude-hook-ingest.d.ts +15 -0
- package/dist/commands/claude-hook-ingest.d.ts.map +1 -0
- package/dist/commands/db.d.ts +3 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/enqueue-raw-event.d.ts +3 -0
- package/dist/commands/enqueue-raw-event.d.ts.map +1 -0
- package/dist/commands/export-memories.d.ts +3 -0
- package/dist/commands/export-memories.d.ts.map +1 -0
- package/dist/commands/import-memories.d.ts +3 -0
- package/dist/commands/import-memories.d.ts.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/memory.d.ts +10 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/pack.d.ts +3 -0
- package/dist/commands/pack.d.ts.map +1 -0
- package/dist/commands/recent.d.ts +3 -0
- package/dist/commands/recent.d.ts.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/serve.d.ts +3 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/setup.d.ts +15 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/stats.d.ts +3 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/sync.d.ts +6 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/help-style.d.ts +9 -0
- package/dist/help-style.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1076 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -24
- package/README.md +0 -5
- package/index.js +0 -6
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export const parseSemver = (value) => {
|
|
2
|
+
const match = String(value || "").trim().match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
3
|
+
if (!match) return null;
|
|
4
|
+
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const isVersionAtLeast = (currentVersion, minVersion) => {
|
|
8
|
+
const current = parseSemver(currentVersion);
|
|
9
|
+
const minimum = parseSemver(minVersion);
|
|
10
|
+
if (!current || !minimum) return false;
|
|
11
|
+
for (let i = 0; i < 3; i += 1) {
|
|
12
|
+
if (current[i] > minimum[i]) return true;
|
|
13
|
+
if (current[i] < minimum[i]) return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const resolveUpgradeGuidance = ({ runner, runnerFrom }) => {
|
|
19
|
+
const normalizedRunner = String(runner || "").trim();
|
|
20
|
+
const normalizedFrom = String(runnerFrom || "").trim();
|
|
21
|
+
|
|
22
|
+
if (normalizedRunner === "node") {
|
|
23
|
+
return {
|
|
24
|
+
mode: "node-dev",
|
|
25
|
+
action: "In your codemem repo, pull latest changes and run `pnpm build`, then restart OpenCode.",
|
|
26
|
+
note: "detected TS dev mode",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (normalizedRunner === "npx") {
|
|
31
|
+
return {
|
|
32
|
+
mode: "npx",
|
|
33
|
+
action: "Run `npm install -g @codemem/cli` to update, then restart OpenCode.",
|
|
34
|
+
note: "detected npx runner mode",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (normalizedRunner === "uv") {
|
|
39
|
+
return {
|
|
40
|
+
mode: "uv-dev",
|
|
41
|
+
action: "In your codemem repo, pull latest changes and run `uv sync`, then restart OpenCode.",
|
|
42
|
+
note: "detected dev repo mode",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (normalizedRunner === "uvx") {
|
|
47
|
+
if (normalizedFrom.startsWith("git+") || normalizedFrom.includes(".git")) {
|
|
48
|
+
return {
|
|
49
|
+
mode: "uvx-git",
|
|
50
|
+
action: "Update CODEMEM_RUNNER_FROM to a newer git ref/source, then restart OpenCode.",
|
|
51
|
+
note: "detected uvx git mode",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
mode: "uvx-custom",
|
|
56
|
+
action: "Update CODEMEM_RUNNER_FROM to a newer source, then restart OpenCode.",
|
|
57
|
+
note: "detected uvx custom source mode",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
mode: "generic",
|
|
63
|
+
action: "Run `uv tool install --upgrade codemem`, then restart OpenCode.",
|
|
64
|
+
note: "fallback guidance",
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const parseBackendUpdatePolicy = (value) => {
|
|
69
|
+
const normalized = String(value || "").trim().toLowerCase();
|
|
70
|
+
if (!normalized) return "notify";
|
|
71
|
+
if (["notify", "auto", "off"].includes(normalized)) {
|
|
72
|
+
return normalized;
|
|
73
|
+
}
|
|
74
|
+
if (["1", "true", "yes", "on"].includes(normalized)) {
|
|
75
|
+
return "auto";
|
|
76
|
+
}
|
|
77
|
+
if (["0", "false", "no"].includes(normalized)) {
|
|
78
|
+
return "off";
|
|
79
|
+
}
|
|
80
|
+
return "notify";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const isPinnedGitSource = (runnerFrom) => {
|
|
84
|
+
const source = String(runnerFrom || "").trim();
|
|
85
|
+
if (!source) return false;
|
|
86
|
+
if (!(source.startsWith("git+") || source.includes(".git"))) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const withoutQuery = source.replace(/[?#].*$/, "");
|
|
90
|
+
if (withoutQuery.includes(".git@")) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (!withoutQuery.startsWith("git+")) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const urlValue = withoutQuery.slice(4);
|
|
97
|
+
try {
|
|
98
|
+
const parsed = new URL(urlValue);
|
|
99
|
+
const path = String(parsed.pathname || "");
|
|
100
|
+
if (path.includes(".git@")) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return /@[^/]+$/.test(path);
|
|
104
|
+
} catch {
|
|
105
|
+
return /@[^/]+$/.test(withoutQuery);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const resolveAutoUpdatePlan = ({ runner, runnerFrom }) => {
|
|
110
|
+
const normalizedRunner = String(runner || "").trim();
|
|
111
|
+
const source = String(runnerFrom || "").trim();
|
|
112
|
+
|
|
113
|
+
if (normalizedRunner === "node") {
|
|
114
|
+
return {
|
|
115
|
+
allowed: false,
|
|
116
|
+
reason: "dev-runner",
|
|
117
|
+
command: null,
|
|
118
|
+
commandText: null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (normalizedRunner === "npx") {
|
|
123
|
+
return {
|
|
124
|
+
allowed: true,
|
|
125
|
+
reason: null,
|
|
126
|
+
command: ["npm", "install", "-g", "@codemem/cli@latest"],
|
|
127
|
+
commandText: "npm install -g @codemem/cli@latest",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (normalizedRunner === "uv") {
|
|
132
|
+
return {
|
|
133
|
+
allowed: false,
|
|
134
|
+
reason: "dev-runner",
|
|
135
|
+
command: null,
|
|
136
|
+
commandText: null,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (normalizedRunner === "uvx") {
|
|
141
|
+
if (!source) {
|
|
142
|
+
return {
|
|
143
|
+
allowed: false,
|
|
144
|
+
reason: "missing-source",
|
|
145
|
+
command: null,
|
|
146
|
+
commandText: null,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (isPinnedGitSource(source)) {
|
|
150
|
+
return {
|
|
151
|
+
allowed: false,
|
|
152
|
+
reason: "pinned-source",
|
|
153
|
+
command: null,
|
|
154
|
+
commandText: null,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
allowed: true,
|
|
159
|
+
reason: null,
|
|
160
|
+
command: ["uvx", "--refresh", "--from", source, "codemem", "version"],
|
|
161
|
+
commandText: "uvx --refresh --from <source> codemem version",
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
allowed: true,
|
|
167
|
+
reason: null,
|
|
168
|
+
command: ["uv", "tool", "install", "--upgrade", "codemem"],
|
|
169
|
+
commandText: "uv tool install --upgrade codemem",
|
|
170
|
+
};
|
|
171
|
+
};
|