@mnemonik/shared 7.39.0 → 7.39.2
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/LICENSE +38 -0
- package/dist/ambientPointer.d.ts +4 -0
- package/dist/ambientPointer.d.ts.map +1 -0
- package/dist/ambientPointer.js +6 -0
- package/dist/ambientPointer.js.map +1 -0
- package/dist/hookRuntime.d.ts +10 -0
- package/dist/hookRuntime.d.ts.map +1 -0
- package/dist/hookRuntime.js +48 -0
- package/dist/hookRuntime.js.map +1 -0
- package/package.json +10 -2
- package/src/ambientPointer.ts +7 -0
- package/src/hookRuntime.ts +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
MNEMONIK PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 JayDeeCo Limited. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This licence applies to the Mnemonik software distributed with this file
|
|
6
|
+
(the "Software").
|
|
7
|
+
|
|
8
|
+
Subject to the Mnemonik Terms of Service and while you are an authorised
|
|
9
|
+
Mnemonik account holder, JayDeeCo Limited grants you a limited, revocable,
|
|
10
|
+
non-exclusive, non-transferable, non-sublicensable licence to download,
|
|
11
|
+
install, and run unmodified copies of the Software solely to access and use
|
|
12
|
+
the Mnemonik service. This permission applies to authorised free, trial, and
|
|
13
|
+
paid accounts.
|
|
14
|
+
|
|
15
|
+
You may not:
|
|
16
|
+
|
|
17
|
+
1. modify the Software or create derivative works from it;
|
|
18
|
+
2. reverse engineer, decompile, or disassemble the Software, except to the
|
|
19
|
+
extent that applicable law does not permit this restriction;
|
|
20
|
+
3. redistribute, publish, sell, rent, lease, sublicense, or resell the
|
|
21
|
+
Software or access to it;
|
|
22
|
+
4. use the Software to build or operate a product or service that competes
|
|
23
|
+
with Mnemonik;
|
|
24
|
+
5. remove or alter any copyright, trade mark, attribution, or proprietary
|
|
25
|
+
notice; or
|
|
26
|
+
6. bypass authentication, service limits, or technical restrictions.
|
|
27
|
+
|
|
28
|
+
JayDeeCo Limited and its licensors retain all right, title, and interest in
|
|
29
|
+
the Software. No rights are granted except those expressly stated here.
|
|
30
|
+
|
|
31
|
+
This licence ends automatically when your right to use Mnemonik ends or if
|
|
32
|
+
you breach this licence or the Mnemonik Terms of Service. When it ends, you
|
|
33
|
+
must stop using the Software and delete copies in your possession or control.
|
|
34
|
+
|
|
35
|
+
Third-party components remain subject to their own licences. The warranty
|
|
36
|
+
disclaimers, limitations of liability, termination terms, and governing law
|
|
37
|
+
in the Mnemonik Terms of Service at https://mnemonik.ai/terms apply to this
|
|
38
|
+
licence and the Software.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const AMBIENT_ID_PREFIX_LENGTH = 8;
|
|
2
|
+
export declare const AMBIENT_ITEM_POINTER_SOURCE = "\u2014\\s*memory_get\\s+([0-9A-Za-z_-]{8})(?![0-9A-Za-z_-])";
|
|
3
|
+
export declare function ambientItemPointerRegex(flags?: string): RegExp;
|
|
4
|
+
//# sourceMappingURL=ambientPointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambientPointer.d.ts","sourceRoot":"","sources":["../src/ambientPointer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,eAAO,MAAM,2BAA2B,gEAAqF,CAAC;AAE9H,wBAAgB,uBAAuB,CAAC,KAAK,SAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const AMBIENT_ID_PREFIX_LENGTH = 8;
|
|
2
|
+
export const AMBIENT_ITEM_POINTER_SOURCE = `—\\s*memory_get\\s+([0-9A-Za-z_-]{${AMBIENT_ID_PREFIX_LENGTH}})(?![0-9A-Za-z_-])`;
|
|
3
|
+
export function ambientItemPointerRegex(flags = 'g') {
|
|
4
|
+
return new RegExp(AMBIENT_ITEM_POINTER_SOURCE, flags);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ambientPointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambientPointer.js","sourceRoot":"","sources":["../src/ambientPointer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,2BAA2B,GAAG,qCAAqC,wBAAwB,qBAAqB,CAAC;AAE9H,MAAM,UAAU,uBAAuB,CAAC,KAAK,GAAG,GAAG;IACjD,OAAO,IAAI,MAAM,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ProjectIdentity {
|
|
2
|
+
projectId?: string;
|
|
3
|
+
projectName?: string;
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function findProjectIdentity(startCwd: string, opts?: {
|
|
7
|
+
maxDepth?: number;
|
|
8
|
+
}): Promise<ProjectIdentity | null>;
|
|
9
|
+
export declare function parseHookResponse<T>(response: Response): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=hookRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hookRuntime.d.ts","sourceRoot":"","sources":["../src/hookRuntime.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA6BjC;AAID,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAYzE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
|
+
import { stderr } from 'node:process';
|
|
4
|
+
const identityCache = new Map();
|
|
5
|
+
export async function findProjectIdentity(startCwd, opts = {}) {
|
|
6
|
+
if (!startCwd)
|
|
7
|
+
return null;
|
|
8
|
+
if (identityCache.has(startCwd))
|
|
9
|
+
return identityCache.get(startCwd);
|
|
10
|
+
let directory = isAbsolute(startCwd) ? startCwd : resolve(startCwd);
|
|
11
|
+
const maxDepth = opts.maxDepth ?? 10;
|
|
12
|
+
for (let depth = 0; depth <= maxDepth; depth += 1) {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(await readFile(join(directory, '.mnemonik.json'), 'utf8'));
|
|
15
|
+
if (typeof parsed.projectId === 'string' && parsed.projectId.length > 0) {
|
|
16
|
+
const identity = {
|
|
17
|
+
projectId: parsed.projectId,
|
|
18
|
+
projectName: typeof parsed.projectName === 'string' ? parsed.projectName : undefined,
|
|
19
|
+
projectRoot: directory,
|
|
20
|
+
};
|
|
21
|
+
identityCache.set(startCwd, identity);
|
|
22
|
+
return identity;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Missing, unreadable, or malformed: keep walking upward.
|
|
27
|
+
}
|
|
28
|
+
const parent = dirname(directory);
|
|
29
|
+
if (parent === directory)
|
|
30
|
+
break;
|
|
31
|
+
directory = parent;
|
|
32
|
+
}
|
|
33
|
+
identityCache.set(startCwd, null);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
let mismatchEmitted = false;
|
|
37
|
+
export async function parseHookResponse(response) {
|
|
38
|
+
const body = (await response.json());
|
|
39
|
+
const result = body;
|
|
40
|
+
if (!mismatchEmitted && result?.ok === false && result.reason === 'identity_mismatch') {
|
|
41
|
+
stderr.write('mnemonik-hook: project identity mismatch — .mnemonik.json points to one project, ' +
|
|
42
|
+
'but this directory is registered to a different one on the server. ' +
|
|
43
|
+
'Fix .mnemonik.json (delete it and let session_bootstrap rewrite it) or cd to the correct project root.\n');
|
|
44
|
+
mismatchEmitted = true;
|
|
45
|
+
}
|
|
46
|
+
return body;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=hookRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hookRuntime.js","sourceRoot":"","sources":["../src/hookRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAgB,EAChB,IAAI,GAA0B,EAAE;IAEhC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;IAErE,IAAI,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACrC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAC/B,CAAC;YAC7B,IAAI,OAAO,MA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|
"name": "@mnemonik/shared",
|
|
3
|
-
"version": "7.39.
|
|
3
|
+
"version": "7.39.2",
|
|
4
4
|
"description": "Shared constants and utilities for Mnemonik packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"./hook-timeouts": {
|
|
14
14
|
"import": "./dist/hookTimeouts.js",
|
|
15
15
|
"types": "./dist/hookTimeouts.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./hook-runtime": {
|
|
18
|
+
"import": "./dist/hookRuntime.js",
|
|
19
|
+
"types": "./dist/hookRuntime.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./ambient-pointer": {
|
|
22
|
+
"import": "./dist/ambientPointer.js",
|
|
23
|
+
"types": "./dist/ambientPointer.d.ts"
|
|
16
24
|
}
|
|
17
25
|
},
|
|
18
26
|
"scripts": {
|
|
@@ -26,7 +34,7 @@
|
|
|
26
34
|
"constants"
|
|
27
35
|
],
|
|
28
36
|
"author": "Anthony",
|
|
29
|
-
"license": "
|
|
37
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
30
38
|
"dependencies": {
|
|
31
39
|
"ignore": "^7.0.6",
|
|
32
40
|
"web-tree-sitter": "0.26.11"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const AMBIENT_ID_PREFIX_LENGTH = 8;
|
|
2
|
+
|
|
3
|
+
export const AMBIENT_ITEM_POINTER_SOURCE = `—\\s*memory_get\\s+([0-9A-Za-z_-]{${AMBIENT_ID_PREFIX_LENGTH}})(?![0-9A-Za-z_-])`;
|
|
4
|
+
|
|
5
|
+
export function ambientItemPointerRegex(flags = 'g'): RegExp {
|
|
6
|
+
return new RegExp(AMBIENT_ITEM_POINTER_SOURCE, flags);
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
|
+
import { stderr } from 'node:process';
|
|
4
|
+
|
|
5
|
+
export interface ProjectIdentity {
|
|
6
|
+
projectId?: string;
|
|
7
|
+
projectName?: string;
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const identityCache = new Map<string, ProjectIdentity | null>();
|
|
12
|
+
|
|
13
|
+
export async function findProjectIdentity(
|
|
14
|
+
startCwd: string,
|
|
15
|
+
opts: { maxDepth?: number } = {}
|
|
16
|
+
): Promise<ProjectIdentity | null> {
|
|
17
|
+
if (!startCwd) return null;
|
|
18
|
+
if (identityCache.has(startCwd)) return identityCache.get(startCwd)!;
|
|
19
|
+
|
|
20
|
+
let directory = isAbsolute(startCwd) ? startCwd : resolve(startCwd);
|
|
21
|
+
const maxDepth = opts.maxDepth ?? 10;
|
|
22
|
+
for (let depth = 0; depth <= maxDepth; depth += 1) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(
|
|
25
|
+
await readFile(join(directory, '.mnemonik.json'), 'utf8')
|
|
26
|
+
) as Record<string, unknown>;
|
|
27
|
+
if (typeof parsed.projectId === 'string' && parsed.projectId.length > 0) {
|
|
28
|
+
const identity: ProjectIdentity = {
|
|
29
|
+
projectId: parsed.projectId,
|
|
30
|
+
projectName: typeof parsed.projectName === 'string' ? parsed.projectName : undefined,
|
|
31
|
+
projectRoot: directory,
|
|
32
|
+
};
|
|
33
|
+
identityCache.set(startCwd, identity);
|
|
34
|
+
return identity;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// Missing, unreadable, or malformed: keep walking upward.
|
|
38
|
+
}
|
|
39
|
+
const parent = dirname(directory);
|
|
40
|
+
if (parent === directory) break;
|
|
41
|
+
directory = parent;
|
|
42
|
+
}
|
|
43
|
+
identityCache.set(startCwd, null);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let mismatchEmitted = false;
|
|
48
|
+
|
|
49
|
+
export async function parseHookResponse<T>(response: Response): Promise<T> {
|
|
50
|
+
const body = (await response.json()) as T;
|
|
51
|
+
const result = body as { ok?: boolean; reason?: string };
|
|
52
|
+
if (!mismatchEmitted && result?.ok === false && result.reason === 'identity_mismatch') {
|
|
53
|
+
stderr.write(
|
|
54
|
+
'mnemonik-hook: project identity mismatch — .mnemonik.json points to one project, ' +
|
|
55
|
+
'but this directory is registered to a different one on the server. ' +
|
|
56
|
+
'Fix .mnemonik.json (delete it and let session_bootstrap rewrite it) or cd to the correct project root.\n'
|
|
57
|
+
);
|
|
58
|
+
mismatchEmitted = true;
|
|
59
|
+
}
|
|
60
|
+
return body;
|
|
61
|
+
}
|