engineering-memory 0.1.0 → 0.1.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/bin/engineering-memory.mjs +4 -44
- package/lib/stage-runtime.mjs +53 -0
- package/package.json +2 -1
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
5
4
|
import { dirname, join, resolve } from 'node:path';
|
|
6
5
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
readJson,
|
|
10
|
-
resolveProductionPackagePaths,
|
|
11
|
-
} from '../install/files.mjs';
|
|
6
|
+
import { exists, readJson } from '../install/files.mjs';
|
|
7
|
+
import { stageBridgeRuntime } from '../lib/stage-runtime.mjs';
|
|
12
8
|
import { runInstaller } from '../install/cli.mjs';
|
|
13
9
|
|
|
14
10
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
@@ -33,42 +29,6 @@ Choose the hook mode through the Codex or Claude native questionnaire before
|
|
|
33
29
|
passing a repository. The installer never opens a questionnaire or an
|
|
34
30
|
authentication web page.`;
|
|
35
31
|
|
|
36
|
-
// The published package cannot carry node_modules, because npm excludes it from
|
|
37
|
-
// every tarball. The bridge runtime is therefore assembled here from the
|
|
38
|
-
// dependencies npm installed for this package, into the exact layout the
|
|
39
|
-
// installer verifies against the bridge lockfile.
|
|
40
|
-
async function stageBridgeRuntime() {
|
|
41
|
-
const source = join(packageRoot, 'runtime');
|
|
42
|
-
const packageJson = await readJson(join(source, 'package.json'));
|
|
43
|
-
const packageLock = await readJson(join(source, 'package-lock.json'));
|
|
44
|
-
if (!packageJson || !packageLock) {
|
|
45
|
-
throw new Error(`Bridge runtime metadata is missing in ${source}`);
|
|
46
|
-
}
|
|
47
|
-
const staged = await mkdtemp(join(tmpdir(), 'engineering-memory-runtime-'));
|
|
48
|
-
await cp(join(source, 'dist'), join(staged, 'dist'), { recursive: true });
|
|
49
|
-
await cp(join(source, 'package.json'), join(staged, 'package.json'));
|
|
50
|
-
await cp(
|
|
51
|
-
join(source, 'package-lock.json'),
|
|
52
|
-
join(staged, 'package-lock.json'),
|
|
53
|
-
);
|
|
54
|
-
for (const entry of resolveProductionPackagePaths(packageJson, packageLock)) {
|
|
55
|
-
const name = entry.path.slice('node_modules/'.length);
|
|
56
|
-
let installed;
|
|
57
|
-
try {
|
|
58
|
-
installed = dirname(require.resolve(`${name}/package.json`));
|
|
59
|
-
} catch {
|
|
60
|
-
if (entry.optional) continue;
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Bridge dependency ${name} is not installed. Reinstall this package so npm resolves its dependencies.`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
const destination = join(staged, ...entry.path.split('/'));
|
|
66
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
67
|
-
await cp(installed, destination, { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
return staged;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
32
|
// The backend this package was published for. An installation only names one
|
|
73
33
|
// when it points at a different, self-hosted backend.
|
|
74
34
|
async function publishedApiUrl() {
|
|
@@ -95,7 +55,7 @@ async function main(argumentList) {
|
|
|
95
55
|
if (!(await exists(join(skillSource, 'SKILL.md')))) {
|
|
96
56
|
throw new Error(`Skill source is missing in ${skillSource}`);
|
|
97
57
|
}
|
|
98
|
-
const staged = await stageBridgeRuntime();
|
|
58
|
+
const staged = await stageBridgeRuntime(packageRoot, require);
|
|
99
59
|
try {
|
|
100
60
|
await runInstaller([
|
|
101
61
|
...rest,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cp, mkdir, mkdtemp, stat } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { readJson, resolveProductionPackagePaths } from '../install/files.mjs';
|
|
5
|
+
|
|
6
|
+
// The published package cannot carry node_modules, because npm excludes it from
|
|
7
|
+
// every tarball. The bridge runtime is assembled here from the dependencies npm
|
|
8
|
+
// installed for this package, into the exact layout the installer verifies
|
|
9
|
+
// against the bridge lockfile.
|
|
10
|
+
export async function stageBridgeRuntime(packageRoot, resolver) {
|
|
11
|
+
const source = join(packageRoot, 'runtime');
|
|
12
|
+
const packageJson = await readJson(join(source, 'package.json'));
|
|
13
|
+
const packageLock = await readJson(join(source, 'package-lock.json'));
|
|
14
|
+
if (!packageJson || !packageLock) {
|
|
15
|
+
throw new Error(`Bridge runtime metadata is missing in ${source}`);
|
|
16
|
+
}
|
|
17
|
+
const staged = await mkdtemp(join(tmpdir(), 'engineering-memory-runtime-'));
|
|
18
|
+
await cp(join(source, 'dist'), join(staged, 'dist'), { recursive: true });
|
|
19
|
+
await cp(join(source, 'package.json'), join(staged, 'package.json'));
|
|
20
|
+
await cp(
|
|
21
|
+
join(source, 'package-lock.json'),
|
|
22
|
+
join(staged, 'package-lock.json'),
|
|
23
|
+
);
|
|
24
|
+
for (const entry of resolveProductionPackagePaths(packageJson, packageLock)) {
|
|
25
|
+
const name = entry.path.slice('node_modules/'.length);
|
|
26
|
+
const installed = await locate(name, resolver);
|
|
27
|
+
if (!installed) {
|
|
28
|
+
if (entry.optional) continue;
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Bridge dependency ${name} is not installed. Reinstall this package so npm resolves its dependencies.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const destination = join(staged, ...entry.path.split('/'));
|
|
34
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
35
|
+
await cp(installed, destination, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
return staged;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// A package is free to keep package.json out of its exports map, and several do,
|
|
41
|
+
// so the directory is found on disk rather than through module resolution.
|
|
42
|
+
async function locate(name, resolver) {
|
|
43
|
+
for (const directory of resolver.resolve.paths(name) ?? []) {
|
|
44
|
+
const candidate = join(directory, ...name.split('/'));
|
|
45
|
+
try {
|
|
46
|
+
await stat(join(candidate, 'package.json'));
|
|
47
|
+
return candidate;
|
|
48
|
+
} catch {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "engineering-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Installs the Engineering Memory skill and its local MCP bridge. Sign in after installing; your organization and project are resolved from your account.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
15
|
"dispatcher",
|
|
16
|
+
"lib",
|
|
16
17
|
"install",
|
|
17
18
|
"skill",
|
|
18
19
|
"runtime"
|