@enhance-eng/enhance 0.1.160 → 0.1.165
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/dist/{cli-output-identity.lib-DrfKWcGw.mjs → cli-output-identity.lib-Z9ISwnoo.mjs} +3849 -2180
- package/dist/enhance-mcp.cjs +4 -0
- package/dist/enhance.cjs +4 -0
- package/dist/file-credential.adapter-CShGZcd5.mjs +63 -0
- package/dist/launch.cjs +36 -0
- package/dist/main.mjs +1617 -269
- package/dist/{mcp-invocation.adapter-DrEm-z3C.mjs → mcp-invocation.adapter-Cn7Cr0UH.mjs} +30 -6
- package/dist/mcp-main.mjs +10 -9
- package/dist/{mcp-server.adapter-YQLl2Wec.mjs → mcp-server.adapter-DJ2BZrIw.mjs} +14 -8
- package/dist/mcp.mjs +2 -2
- package/dist/older-node.mjs +7320 -0
- package/dist/remote-mcp-main.mjs +117 -28
- package/dist/rolldown-runtime-b6G8-vqI.mjs +6 -0
- package/dist/{mutation-key.adapter-DFjvJyX6.mjs → zod-messages.lib-BrqCGdLn.mjs} +2262 -903
- package/package.json +6 -4
- package/dist/file-credential.adapter-C78gc9OK.mjs +0 -51
package/dist/enhance.cjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { chmod, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
|
|
7
|
+
//#region src/infrastructure/file-credential.adapter.ts
|
|
8
|
+
const credentialSchema = z.object({ token: z.string().startsWith("enh_") });
|
|
9
|
+
const DIRECTORY_MODE = 448;
|
|
10
|
+
const FILE_MODE = 384;
|
|
11
|
+
const isMissing = (error) => typeof error === "object" && error !== null && Reflect.get(error, "code") === "ENOENT";
|
|
12
|
+
const tokenIn = async (file) => {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(await readFile(file, "utf8"));
|
|
15
|
+
return credentialSchema.parse(parsed).token;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (isMissing(error)) return null;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const removed = async (file) => {
|
|
22
|
+
try {
|
|
23
|
+
await unlink(file);
|
|
24
|
+
return true;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (isMissing(error)) return false;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The sign-in kept in `directory`. `earlierDirectory` is where an earlier tool kept it: it is read
|
|
32
|
+
* when `directory` has none, never written, and emptied on sign-out so that signing out holds.
|
|
33
|
+
*/
|
|
34
|
+
const createFileCredentialAdapter = (directory, earlierDirectory) => {
|
|
35
|
+
const credentialPath = path.join(directory, "credentials.json");
|
|
36
|
+
const earlierPath = earlierDirectory === void 0 ? null : path.join(earlierDirectory, "credentials.json");
|
|
37
|
+
return {
|
|
38
|
+
path: credentialPath,
|
|
39
|
+
read: async () => await tokenIn(credentialPath) ?? (earlierPath === null ? null : tokenIn(earlierPath)),
|
|
40
|
+
write: async (token) => {
|
|
41
|
+
await mkdir(directory, {
|
|
42
|
+
recursive: true,
|
|
43
|
+
mode: DIRECTORY_MODE
|
|
44
|
+
});
|
|
45
|
+
await chmod(directory, DIRECTORY_MODE);
|
|
46
|
+
const temporary = path.join(directory, `credentials.${String(process.pid)}.tmp`);
|
|
47
|
+
await writeFile(temporary, `${JSON.stringify({ token })}\n`, {
|
|
48
|
+
mode: FILE_MODE,
|
|
49
|
+
flag: "wx"
|
|
50
|
+
});
|
|
51
|
+
await rename(temporary, credentialPath);
|
|
52
|
+
await chmod(credentialPath, FILE_MODE);
|
|
53
|
+
},
|
|
54
|
+
remove: async () => {
|
|
55
|
+
const wasHere = await removed(credentialPath);
|
|
56
|
+
const wasEarlier = earlierPath !== null && await removed(earlierPath);
|
|
57
|
+
return wasHere || wasEarlier;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { createFileCredentialAdapter as t };
|
package/dist/launch.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Every installed command starts here. This file stays in syntax a Node from 2020 can read, so a
|
|
5
|
+
* person on an old Node gets one sentence instead of a syntax error from the tool's own code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const { pathToFileURL } = require('node:url');
|
|
10
|
+
|
|
11
|
+
const OLDEST_NODE = 20;
|
|
12
|
+
/** The tool and the packages it carries use functions that arrived in Node 22. */
|
|
13
|
+
const FIRST_NODE_WITH_EVERYTHING = 22;
|
|
14
|
+
|
|
15
|
+
const runtime = {
|
|
16
|
+
version: process.versions.node,
|
|
17
|
+
say: (line) => process.stderr.write(`${line}\n`),
|
|
18
|
+
load: (file) => import(pathToFileURL(path.join(__dirname, file)).href),
|
|
19
|
+
fail: () => {
|
|
20
|
+
process.exitCode = 1;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Starts the tool's entry file, or says which Node Enhance needs. */
|
|
25
|
+
const launch = async (entry, node = runtime) => {
|
|
26
|
+
const major = Number(node.version.split('.')[0]);
|
|
27
|
+
if (major < OLDEST_NODE) {
|
|
28
|
+
node.say(`Enhance needs Node ${OLDEST_NODE} or later. This is Node ${node.version}.`);
|
|
29
|
+
node.fail();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (major < FIRST_NODE_WITH_EVERYTHING) await node.load('older-node.mjs');
|
|
33
|
+
await node.load(entry);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = { launch };
|