opencode-memoir 1.0.4 → 1.0.6

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.

Potentially problematic release.


This version of opencode-memoir might be problematic. Click here for more details.

package/dist/store.js DELETED
@@ -1,304 +0,0 @@
1
- import { execFile, execFileSync } from 'node:child_process';
2
- import { access, mkdir, rm } from 'node:fs/promises';
3
- import { join, resolve } from 'node:path';
4
- import { homedir, tmpdir } from 'node:os';
5
- import { promisify } from 'node:util';
6
- import { debugLog } from './debug.js';
7
- const execFileAsync = promisify(execFile);
8
- export const MEMOIR_PACKAGE = 'memoir-ai';
9
- /**
10
- * Pinned memoir-ai version for uvx/uv fallbacks.
11
- * Mirrors plugins/claude-code/scripts/resolve-memoir-cli.sh.
12
- * Bump deliberately after verifying the new release works with this plugin.
13
- */
14
- export const MEMOIR_AI_PIN = '0.2.2';
15
- /**
16
- * Cache of cwds confirmed to be outside a git repo.
17
- * Avoids redundant ~200ms failing `git rev-parse` calls on non-git directories.
18
- */
19
- export const _noGitCache = new Set();
20
- /**
21
- * Resolve the main worktree root path for a git repository.
22
- * Mirrors _main_worktree_root from plugins/claude-code/scripts/derive-store-path.sh.
23
- *
24
- * @returns The main worktree path, or empty string if not in a git repo.
25
- */
26
- export function _main_worktree_root(cwd) {
27
- if (_noGitCache.has(cwd))
28
- return '';
29
- try {
30
- // Fast path: check if --git-dir and --git-common-dir resolve to the same path
31
- const gitDir = execFileSync('git', ['rev-parse', '--git-dir'], { cwd, encoding: 'utf8', timeout: 3000 }).trim();
32
- const gitCommonDir = execFileSync('git', ['rev-parse', '--git-common-dir'], { cwd, encoding: 'utf8', timeout: 3000 }).trim();
33
- // Resolve to absolute paths
34
- const resolvePath = (path) => {
35
- if (path.startsWith('/'))
36
- return path;
37
- return join(cwd, path);
38
- };
39
- const gitDirAbs = resolvePath(gitDir);
40
- const gitCommonDirAbs = resolvePath(gitCommonDir);
41
- if (gitDirAbs === gitCommonDirAbs) {
42
- // Main worktree or non-worktree repo
43
- return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', timeout: 3000 }).trim();
44
- }
45
- // Slow path: parse `git worktree list --porcelain` for the main worktree
46
- const worktreeList = execFileSync('git', ['worktree', 'list', '--porcelain'], { cwd, encoding: 'utf8', timeout: 3000 });
47
- const firstLine = worktreeList.split('\n')[0];
48
- if (firstLine.startsWith('worktree ')) {
49
- const mainWorktree = firstLine.substring('worktree '.length).trim();
50
- if (mainWorktree && mainWorktree !== '(bare)') {
51
- return mainWorktree;
52
- }
53
- }
54
- // Fallback: try --show-toplevel (bare repo or older git)
55
- return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', timeout: 3000 }).trim();
56
- }
57
- catch (e) {
58
- debugLog('_main_worktree_root: not a git repo or git error:', e instanceof Error ? e.message : String(e));
59
- _noGitCache.add(cwd);
60
- return '';
61
- }
62
- }
63
- /**
64
- * Derive `~/.memoir/<slug>` from cwd.
65
- * Override via `store` plugin option or `MEMOIR_STORE` env var.
66
- *
67
- * Resolution order (mirrors plugins/claude-code/scripts/derive-store-path.sh):
68
- * 1. Plugin option override
69
- * 2. MEMOIR_STORE env var
70
- * 3. Git root (realpath) — all worktrees of a repo share one store
71
- * 4. `path.resolve()` of cwd — normalized deterministic slug for non-git folders
72
- * 5. Raw cwd fallback
73
- */
74
- export function deriveStorePath(cwd = process.cwd()) {
75
- if (pluginStoreOverride)
76
- return pluginStoreOverride;
77
- const configured = process.env.MEMOIR_STORE;
78
- if (configured)
79
- return configured;
80
- // Prefer git root so all subdirectories and worktrees share one store
81
- let projectDir;
82
- try {
83
- const gitRoot = _main_worktree_root(cwd);
84
- if (gitRoot) {
85
- projectDir = gitRoot;
86
- }
87
- else {
88
- // Not in git — normalize to deterministic absolute path
89
- projectDir = resolve(cwd);
90
- }
91
- }
92
- catch (e) {
93
- debugLog('deriveStorePath: unexpected error:', e instanceof Error ? e.message : String(e));
94
- // Fallback to raw cwd if everything else fails
95
- projectDir = cwd;
96
- }
97
- // Slug = absolute path with '/' and '.' replaced by '-'
98
- // Matches Claude Code's own ~/.claude/projects/ naming convention
99
- const slug = projectDir.replace(/[/.]/g, '-');
100
- return join(homedir(), '.memoir', slug);
101
- }
102
- /** Set by plugin options (`store` key). */
103
- export let pluginStoreOverride;
104
- /** Set `pluginStoreOverride` from plugin init. Exported as a function
105
- * because ES module imports are read-only bindings (direct assignment
106
- * from another module is a TS2632 error). */
107
- export function setPluginStoreOverride(store) {
108
- pluginStoreOverride = store;
109
- }
110
- /** Cache of stores already verified or created — avoids redundant access() + CLI calls. */
111
- export const ensuredStores = new Set();
112
- /**
113
- * Stores currently being created — prevents concurrent `memoir new` on
114
- * the same path (C5 fix).
115
- */
116
- const storeCreations = new Map();
117
- export async function ensureStore(store) {
118
- if (ensuredStores.has(store))
119
- return;
120
- // If another caller is already creating this store, await it
121
- const inFlight = storeCreations.get(store);
122
- if (inFlight) {
123
- await inFlight;
124
- return;
125
- }
126
- try {
127
- await access(join(store, '.git'));
128
- ensuredStores.add(store);
129
- return; // already exists
130
- }
131
- catch {
132
- // ensure parent dir exists (memoir new doesn't create intermediate dirs)
133
- await mkdir(join(store, '..'), { recursive: true }).catch((e) => debugLog('ensureStore: mkdir failed:', e instanceof Error ? e.message : String(e)));
134
- }
135
- // Register this creation so concurrent callers coallesce
136
- const creationPromise = (async () => {
137
- const tmpDir = join(tmpdir(), `memoir-scratch-${Date.now()}`);
138
- try {
139
- await mkdir(tmpDir, { recursive: true });
140
- await execFileAsync('git', ['init', '-q', tmpDir], { timeout: 5000 });
141
- const result = await runMemoir(['new', store, '--taxonomy-builtin'], { cwd: tmpDir });
142
- if (result.startsWith('Memoir command failed')) {
143
- throw new Error(result);
144
- }
145
- ensuredStores.add(store);
146
- }
147
- finally {
148
- rm(tmpDir, { recursive: true, force: true }).catch(() => undefined);
149
- }
150
- })();
151
- storeCreations.set(store, creationPromise);
152
- try {
153
- await creationPromise;
154
- }
155
- finally {
156
- storeCreations.delete(store);
157
- }
158
- }
159
- /** Which CLI launcher successfully resolved memoir. Cached to avoid redundant fallback probing. */
160
- export let memoirResolved = null;
161
- export async function runMemoir(args, options = {}) {
162
- const specs = memoirSpawnSpecs(args);
163
- // Put cached resolver first so we skip redundant fallback probing
164
- if (memoirResolved) {
165
- const idx = specs.findIndex(s => s.label === memoirResolved);
166
- if (idx > 0) {
167
- const [cached] = specs.splice(idx, 1);
168
- specs.unshift(cached);
169
- }
170
- }
171
- for (const spec of specs) {
172
- try {
173
- const { stdout } = await execFileAsync(spec.command, spec.args, {
174
- cwd: options.cwd ?? process.cwd(),
175
- env: process.env,
176
- maxBuffer: 1024 * 1024,
177
- timeout: 15_000, // prevent hang if memoir CLI stalls
178
- });
179
- memoirResolved = spec.label;
180
- return stdout.trim();
181
- }
182
- catch (e) {
183
- debugLog('runMemoir: fallback', spec.label, 'failed:', e instanceof Error ? e.message : String(e));
184
- // Invalidate cache so we don't keep trying a broken resolver on next call
185
- if (memoirResolved === spec.label)
186
- memoirResolved = null;
187
- }
188
- }
189
- // Build a fallback-free attempt at memoir direct for the error message
190
- try {
191
- const { stdout } = await execFileAsync('memoir', args, {
192
- cwd: options.cwd ?? process.cwd(),
193
- env: process.env,
194
- maxBuffer: 1024 * 1024,
195
- timeout: 15_000,
196
- });
197
- return stdout.trim(); // shouldn't get here since all specs failed, but defensive
198
- }
199
- catch (memoirError) {
200
- const err = memoirError;
201
- const detail = (err.stderr || err.stdout || err.message).trim();
202
- return `Memoir command failed${err.code ? ` (${err.code})` : ''}: ${detail}`;
203
- }
204
- }
205
- export function memoirSpawnSpecs(args) {
206
- return [
207
- { command: 'memoir', args, label: 'memoir' },
208
- { command: 'uvx', args: ['--from', `${MEMOIR_PACKAGE}==${MEMOIR_AI_PIN}`, 'memoir', ...args], label: 'uvx' },
209
- { command: 'uv', args: ['tool', 'run', '--from', `${MEMOIR_PACKAGE}==${MEMOIR_AI_PIN}`, 'memoir', ...args], label: 'uv tool run' },
210
- ];
211
- }
212
- /** Read the current memoir branch name for use in storage keys. */
213
- export async function getCurrentBranch(store) {
214
- try {
215
- const raw = await runMemoir(['--json', '-s', store, 'status'], { cwd: store });
216
- const data = JSON.parse(raw);
217
- return data.branch || 'unknown';
218
- }
219
- catch (e) {
220
- debugLog('getCurrentBranch: failed:', e instanceof Error ? e.message : String(e));
221
- return 'unknown';
222
- }
223
- }
224
- /**
225
- * Return the current git branch of the user's project (from cwd).
226
- * Empty string if not in a git repo or detached HEAD.
227
- * Mirrors code_git_branch from plugins/claude-code/hooks/common.sh.
228
- */
229
- export async function codeGitBranch() {
230
- try {
231
- const { stdout } = await execFileAsync('git', ['branch', '--show-current'], { encoding: 'utf8', timeout: 3000 });
232
- return stdout.trim();
233
- }
234
- catch (e) {
235
- debugLog('codeGitBranch: failed:', e instanceof Error ? e.message : String(e));
236
- return '';
237
- }
238
- }
239
- /**
240
- * Check whether a branch exists in the memoir store.
241
- * Mirrors branch_exists_in_memoir from plugins/claude-code/hooks/common.sh.
242
- */
243
- export async function branchExistsInMemoir(store, name) {
244
- if (!name)
245
- return false;
246
- try {
247
- const raw = await runMemoir(['--json', '-s', store, 'branch'], { cwd: store });
248
- const data = JSON.parse(raw);
249
- const branches = data?.branches ?? [];
250
- return branches.includes(name);
251
- }
252
- catch (e) {
253
- debugLog('branchExistsInMemoir: failed:', e instanceof Error ? e.message : String(e));
254
- return false;
255
- }
256
- }
257
- /**
258
- * Auto-match memoir branch to the current code git branch.
259
- * If the code branch differs from the memoir branch, creates the memoir branch
260
- * (forked from main) if needed and checks it out.
261
- * Mirrors auto_match_memoir_branch from plugins/claude-code/hooks/common.sh.
262
- */
263
- export async function autoMatchMemoirBranch(store) {
264
- const codeBranch = await codeGitBranch();
265
- if (!codeBranch) {
266
- return getCurrentBranch(store); // detached or non-git — just report current
267
- }
268
- const current = await getCurrentBranch(store);
269
- if (current === codeBranch)
270
- return current; // already matched
271
- // Create the branch from main if it doesn't exist yet
272
- if (!(await branchExistsInMemoir(store, codeBranch))) {
273
- const result = await runMemoir(['-s', store, 'branch', codeBranch, '--from', 'main'], { cwd: store });
274
- if (result.startsWith('Memoir command failed')) {
275
- debugLog('autoMatchMemoirBranch: create branch failed:', result);
276
- return getCurrentBranch(store);
277
- }
278
- }
279
- // Checkout the branch
280
- const result = await runMemoir(['-s', store, 'checkout', codeBranch], { cwd: store });
281
- if (result.startsWith('Memoir command failed')) {
282
- debugLog('autoMatchMemoirBranch: checkout failed:', result);
283
- return getCurrentBranch(store);
284
- }
285
- return codeBranch;
286
- }
287
- /**
288
- * Read the content of a single memoir key (first item found).
289
- * Returns empty string if key doesn't exist or on error.
290
- */
291
- export async function readMemoirValue(store, key, namespace = 'default') {
292
- try {
293
- const raw = await runMemoir(['--json', '-s', store, 'get', key, '-n', namespace], { cwd: store });
294
- const parsed = JSON.parse(raw);
295
- const items = parsed?.items ?? [];
296
- const value = items[0]?.value?.content;
297
- return typeof value === 'string' ? value : '';
298
- }
299
- catch (e) {
300
- debugLog('readMemoirValue: failed:', e instanceof Error ? e.message : String(e));
301
- return '';
302
- }
303
- }
304
- //# sourceMappingURL=store.js.map
package/dist/store.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,CAAC,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