@g3nomaly/mods 0.1.0 → 0.1.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/README.md +13 -12
- package/dist/cli/commands/add.d.ts +11 -2
- package/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +7 -4
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/init.d.ts +15 -4
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +8 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/ls.d.ts +13 -3
- package/dist/cli/commands/ls.d.ts.map +1 -1
- package/dist/cli/commands/ls.js +6 -1
- package/dist/cli/commands/ls.js.map +1 -1
- package/dist/cli/commands/remove.d.ts +10 -1
- package/dist/cli/commands/remove.d.ts.map +1 -1
- package/dist/cli/commands/remove.js +11 -2
- package/dist/cli/commands/remove.js.map +1 -1
- package/dist/cli/commands/source.d.ts +37 -6
- package/dist/cli/commands/source.d.ts.map +1 -1
- package/dist/cli/commands/source.js +23 -4
- package/dist/cli/commands/source.js.map +1 -1
- package/dist/cli/commands/update.d.ts +10 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +5 -1
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +10 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/project.d.ts +34 -11
- package/dist/cli/project.d.ts.map +1 -1
- package/dist/cli/project.js +19 -5
- package/dist/cli/project.js.map +1 -1
- package/dist/cli/viewer.d.ts +17 -5
- package/dist/cli/viewer.d.ts.map +1 -1
- package/dist/cli/viewer.js +77 -18
- package/dist/cli/viewer.js.map +1 -1
- package/dist/registry/locate.d.ts +9 -4
- package/dist/registry/locate.d.ts.map +1 -1
- package/dist/registry/locate.js +4 -3
- package/dist/registry/locate.js.map +1 -1
- package/dist/registry/manifest.d.ts +2 -2
- package/dist/registry/manifest.js +2 -2
- package/dist/registry/readModDir.d.ts +2 -2
- package/dist/registry/readModDir.d.ts.map +1 -1
- package/dist/registry/readModDir.js +8 -3
- package/dist/registry/readModDir.js.map +1 -1
- package/dist/registry/readSource.d.ts +1 -1
- package/dist/registry/readSource.js +1 -1
- package/dist/registry/types.d.ts +15 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/types.js.map +1 -1
- package/dist/relay/index.d.ts +2 -0
- package/dist/relay/index.d.ts.map +1 -0
- package/dist/relay/index.js +9 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/lines.d.ts +25 -0
- package/dist/relay/lines.d.ts.map +1 -0
- package/dist/relay/lines.js +35 -0
- package/dist/relay/lines.js.map +1 -0
- package/dist/relay/protocol.d.ts +123 -0
- package/dist/relay/protocol.d.ts.map +1 -0
- package/dist/relay/protocol.js +70 -0
- package/dist/relay/protocol.js.map +1 -0
- package/dist/relay/relay.d.ts +16 -0
- package/dist/relay/relay.d.ts.map +1 -0
- package/dist/relay/relay.js +213 -0
- package/dist/relay/relay.js.map +1 -0
- package/dist/relay/sessions.d.ts +28 -0
- package/dist/relay/sessions.d.ts.map +1 -0
- package/dist/relay/sessions.js +86 -0
- package/dist/relay/sessions.js.map +1 -0
- package/dist/viewer/extension.d.ts +16 -6
- package/dist/viewer/extension.d.ts.map +1 -1
- package/dist/viewer/extension.js +10 -4
- package/dist/viewer/extension.js.map +1 -1
- package/dist/viewer/index.d.ts +6 -0
- package/dist/viewer/index.d.ts.map +1 -1
- package/dist/viewer/index.js +3 -0
- package/dist/viewer/index.js.map +1 -1
- package/dist/viewer/machine.d.ts +37 -0
- package/dist/viewer/machine.d.ts.map +1 -0
- package/dist/viewer/machine.js +55 -0
- package/dist/viewer/machine.js.map +1 -0
- package/dist/viewer/relay.d.ts +23 -0
- package/dist/viewer/relay.d.ts.map +1 -0
- package/dist/viewer/relay.js +51 -0
- package/dist/viewer/relay.js.map +1 -0
- package/dist/viewer/settings.d.ts +13 -7
- package/dist/viewer/settings.d.ts.map +1 -1
- package/dist/viewer/settings.js +10 -3
- package/dist/viewer/settings.js.map +1 -1
- package/dist/viewer/viewerExtension.d.ts +27 -0
- package/dist/viewer/viewerExtension.d.ts.map +1 -0
- package/dist/viewer/viewerExtension.js +48 -0
- package/dist/viewer/viewerExtension.js.map +1 -0
- package/dist/vscode/g3n-mods-viewer.vsix +0 -0
- package/package.json +9 -5
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
/** Lowest Claude Code release whose mod API the g3n mods are written against. */
|
|
2
2
|
export declare const MIN_ENGINE_VERSION = "2.1.296";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @brief One installed copy of the Claude Code VS Code extension.
|
|
5
|
+
*
|
|
6
|
+
* @property version - Release the folder name carries, e.g. `2.1.296`.
|
|
7
|
+
* @property dir - Absolute extension folder, e.g. `/home/me/.vscode/extensions/anthropic.claude-code-2.1.296`.
|
|
8
|
+
*/
|
|
4
9
|
export interface ClaudeExtension {
|
|
5
10
|
version: string;
|
|
6
|
-
/** Absolute extension folder */
|
|
7
11
|
dir: string;
|
|
8
12
|
}
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @brief Compares two `major.minor.patch` versions; negative when `a` is older than `b`.
|
|
15
|
+
*
|
|
16
|
+
* @param a - Version to compare, e.g. `2.1.296`.
|
|
17
|
+
* @param b - Version to compare against, e.g. `2.1.300`.
|
|
18
|
+
* @returns Negative when `a` is older, `0` when equal, positive when `a` is newer.
|
|
19
|
+
*/
|
|
10
20
|
export declare function compareVersions(a: string, b: string): number;
|
|
11
21
|
/**
|
|
12
|
-
* Newest Claude Code extension installed for any editor of the VS Code family.
|
|
22
|
+
* @brief Newest Claude Code extension installed for any editor of the VS Code family.
|
|
13
23
|
*
|
|
14
|
-
* @param home - Home directory to search under; the current user's by default
|
|
15
|
-
* @returns
|
|
24
|
+
* @param home - Home directory to search under; the current user's by default.
|
|
25
|
+
* @returns The newest copy with its version and folder, or `null` when none is installed.
|
|
16
26
|
*/
|
|
17
27
|
export declare function findClaudeExtension(home?: string): ClaudeExtension | null;
|
|
18
28
|
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/viewer/extension.ts"],"names":[],"mappings":"AAKA,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAO5C
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/viewer/extension.ts"],"names":[],"mappings":"AAKA,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAM,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAqB,GAAG,eAAe,GAAG,IAAI,CAYvF"}
|
package/dist/viewer/extension.js
CHANGED
|
@@ -7,7 +7,13 @@ export const MIN_ENGINE_VERSION = "2.1.296";
|
|
|
7
7
|
/** Extension folders of the VS Code family, relative to the home directory: local, WSL/SSH server, Insiders, Cursor. */
|
|
8
8
|
const EXTENSION_ROOTS = [".vscode/extensions", ".vscode-server/extensions", ".vscode-insiders/extensions", ".cursor/extensions"];
|
|
9
9
|
const EXTENSION_DIR = /^anthropic\.claude-code-(\d+\.\d+\.\d+)(?:-.+)?$/;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* @brief Compares two `major.minor.patch` versions; negative when `a` is older than `b`.
|
|
12
|
+
*
|
|
13
|
+
* @param a - Version to compare, e.g. `2.1.296`.
|
|
14
|
+
* @param b - Version to compare against, e.g. `2.1.300`.
|
|
15
|
+
* @returns Negative when `a` is older, `0` when equal, positive when `a` is newer.
|
|
16
|
+
*/
|
|
11
17
|
export function compareVersions(a, b) {
|
|
12
18
|
const pa = a.split(".").map(Number);
|
|
13
19
|
const pb = b.split(".").map(Number);
|
|
@@ -19,10 +25,10 @@ export function compareVersions(a, b) {
|
|
|
19
25
|
return 0;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
|
-
* Newest Claude Code extension installed for any editor of the VS Code family.
|
|
28
|
+
* @brief Newest Claude Code extension installed for any editor of the VS Code family.
|
|
23
29
|
*
|
|
24
|
-
* @param home - Home directory to search under; the current user's by default
|
|
25
|
-
* @returns
|
|
30
|
+
* @param home - Home directory to search under; the current user's by default.
|
|
31
|
+
* @returns The newest copy with its version and folder, or `null` when none is installed.
|
|
26
32
|
*/
|
|
27
33
|
export function findClaudeExtension(home = os.homedir()) {
|
|
28
34
|
let newest = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/viewer/extension.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,wHAAwH;AACxH,MAAM,eAAe,GAAG,CAAC,oBAAoB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,oBAAoB,CAAC,CAAC;AAEjI,MAAM,aAAa,GAAG,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/viewer/extension.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,w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SAAS;gBAAE,SAAS;YACpC,IAAI,MAAM,KAAK,IAAI,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;gBAAE,MAAM,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACvH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/viewer/index.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export { MIN_ENGINE_VERSION, compareVersions, findClaudeExtension } from "./exte
|
|
|
2
2
|
export type { ClaudeExtension } from "./extension";
|
|
3
3
|
export { ViewerLocationSchema, configureViewer } from "./settings";
|
|
4
4
|
export type { ViewerLocation, ViewerSettingsResult } from "./settings";
|
|
5
|
+
export { installRelay, relayBinaryPath } from "./relay";
|
|
6
|
+
export type { RelayInstallResult } from "./relay";
|
|
7
|
+
export { machineSettingsPath, setProcessWrapper } from "./machine";
|
|
8
|
+
export type { WrapperResult } from "./machine";
|
|
9
|
+
export { VIEWER_EXTENSION_ID, installViewer, viewerPackagePath } from "./viewerExtension";
|
|
10
|
+
export type { ViewerInstallResult } from "./viewerExtension";
|
|
5
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/viewer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvF,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/viewer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvF,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/viewer/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// packages/mods/src/viewer/index.ts
|
|
2
2
|
export { MIN_ENGINE_VERSION, compareVersions, findClaudeExtension } from "./extension";
|
|
3
3
|
export { ViewerLocationSchema, configureViewer } from "./settings";
|
|
4
|
+
export { installRelay, relayBinaryPath } from "./relay";
|
|
5
|
+
export { machineSettingsPath, setProcessWrapper } from "./machine";
|
|
6
|
+
export { VIEWER_EXTENSION_ID, installViewer, viewerPackagePath } from "./viewerExtension";
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
package/dist/viewer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/viewer/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/viewer/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settings file VS Code reads machine-scoped settings from on this
|
|
3
|
+
* machine: the server's `Machine/settings.json` under a remote (WSL, SSH),
|
|
4
|
+
* else the desktop's user settings.
|
|
5
|
+
*/
|
|
6
|
+
export declare function machineSettingsPath(home?: string): string;
|
|
7
|
+
/** What `setProcessWrapper` did. */
|
|
8
|
+
export type WrapperResult = {
|
|
9
|
+
kind: "written";
|
|
10
|
+
file: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "unchanged";
|
|
13
|
+
file: string;
|
|
14
|
+
}
|
|
15
|
+
/** Another wrapper is set; it was left in place */
|
|
16
|
+
| {
|
|
17
|
+
kind: "taken";
|
|
18
|
+
file: string;
|
|
19
|
+
current: string;
|
|
20
|
+
}
|
|
21
|
+
/** The file is not plain JSON (comments, trailing commas); nothing was written */
|
|
22
|
+
| {
|
|
23
|
+
kind: "unreadable";
|
|
24
|
+
file: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Sets `claudeCode.claudeProcessWrapper` to the relay, so the Claude Code
|
|
28
|
+
* extension launches every session through it. A different wrapper already
|
|
29
|
+
* set is kept unless `force` is passed; the file's other settings are kept.
|
|
30
|
+
*
|
|
31
|
+
* @param relay - Absolute path of the relay executable
|
|
32
|
+
*/
|
|
33
|
+
export declare function setProcessWrapper(relay: string, options?: {
|
|
34
|
+
force?: boolean;
|
|
35
|
+
home?: string;
|
|
36
|
+
}): WrapperResult;
|
|
37
|
+
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../src/viewer/machine.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,CAKvE;AAED,oCAAoC;AACpC,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACrC,mDAAmD;GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAClD,kFAAkF;GAChF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,aAAa,CAuBhH"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// packages/mods/src/viewer/machine.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const WRAPPER_KEY = "claudeCode.claudeProcessWrapper";
|
|
7
|
+
const SettingsSchema = z.record(z.string(), z.unknown());
|
|
8
|
+
/**
|
|
9
|
+
* The settings file VS Code reads machine-scoped settings from on this
|
|
10
|
+
* machine: the server's `Machine/settings.json` under a remote (WSL, SSH),
|
|
11
|
+
* else the desktop's user settings.
|
|
12
|
+
*/
|
|
13
|
+
export function machineSettingsPath(home = os.homedir()) {
|
|
14
|
+
if (fs.existsSync(path.join(home, ".vscode-server")))
|
|
15
|
+
return path.join(home, ".vscode-server", "data", "Machine", "settings.json");
|
|
16
|
+
if (process.platform === "darwin")
|
|
17
|
+
return path.join(home, "Library", "Application Support", "Code", "User", "settings.json");
|
|
18
|
+
if (process.platform === "win32")
|
|
19
|
+
return path.join(process.env.APPDATA ?? path.join(home, "AppData", "Roaming"), "Code", "User", "settings.json");
|
|
20
|
+
return path.join(home, ".config", "Code", "User", "settings.json");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sets `claudeCode.claudeProcessWrapper` to the relay, so the Claude Code
|
|
24
|
+
* extension launches every session through it. A different wrapper already
|
|
25
|
+
* set is kept unless `force` is passed; the file's other settings are kept.
|
|
26
|
+
*
|
|
27
|
+
* @param relay - Absolute path of the relay executable
|
|
28
|
+
*/
|
|
29
|
+
export function setProcessWrapper(relay, options = {}) {
|
|
30
|
+
const file = machineSettingsPath(options.home);
|
|
31
|
+
let current = {};
|
|
32
|
+
if (fs.existsSync(file)) {
|
|
33
|
+
const text = fs.readFileSync(file, "utf8");
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = text.trim() === "" ? {} : JSON.parse(text);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return { kind: "unreadable", file };
|
|
40
|
+
}
|
|
41
|
+
const settings = SettingsSchema.safeParse(parsed);
|
|
42
|
+
if (!settings.success)
|
|
43
|
+
return { kind: "unreadable", file };
|
|
44
|
+
current = settings.data;
|
|
45
|
+
}
|
|
46
|
+
const existing = current[WRAPPER_KEY];
|
|
47
|
+
if (existing === relay)
|
|
48
|
+
return { kind: "unchanged", file };
|
|
49
|
+
if (typeof existing === "string" && existing !== "" && options.force !== true)
|
|
50
|
+
return { kind: "taken", file, current: existing };
|
|
51
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
52
|
+
fs.writeFileSync(file, JSON.stringify({ ...current, [WRAPPER_KEY]: relay }, null, 2) + "\n");
|
|
53
|
+
return { kind: "written", file };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.js","sourceRoot":"","sources":["../../src/viewer/machine.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAEtD,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAI,GAAW,EAAE,CAAC,OAAO,EAAE;IAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IACnI,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7H,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAA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Q,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAEjI,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7F,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Where `init` builds the relay: one executable per machine, since VS Code sets the wrapper per machine. */
|
|
2
|
+
export declare function relayBinaryPath(home?: string): string;
|
|
3
|
+
/** What `installRelay` did. */
|
|
4
|
+
export type RelayInstallResult = {
|
|
5
|
+
kind: "built";
|
|
6
|
+
binary: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "current";
|
|
9
|
+
binary: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "failed";
|
|
12
|
+
binary: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Builds the relay into a standalone executable with `bun build --compile`,
|
|
17
|
+
* unless the one already there was built from the same sources. A stamp
|
|
18
|
+
* file beside it holds the hash of those sources.
|
|
19
|
+
*
|
|
20
|
+
* @param home - Home directory the executable goes under; the current user's by default
|
|
21
|
+
*/
|
|
22
|
+
export declare function installRelay(home?: string): Promise<RelayInstallResult>;
|
|
23
|
+
//# sourceMappingURL=relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/viewer/relay.ts"],"names":[],"mappings":"AAOA,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,CAEnE;AAED,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAevD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,MAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmB3F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// packages/mods/src/viewer/relay.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { hashString } from "@g3nomaly/core/hash";
|
|
6
|
+
import { findPackageRoot } from "@g3nomaly/core/utils";
|
|
7
|
+
/** Where `init` builds the relay: one executable per machine, since VS Code sets the wrapper per machine. */
|
|
8
|
+
export function relayBinaryPath(home = os.homedir()) {
|
|
9
|
+
return path.join(home, ".claude", "g3n-mods", "bin", "g3n-mods-relay");
|
|
10
|
+
}
|
|
11
|
+
/** The relay's entry and the files it is built from: the compiled ones of an installed package, else the sources of this repository. */
|
|
12
|
+
function relaySources() {
|
|
13
|
+
const root = findPackageRoot(import.meta.dir);
|
|
14
|
+
for (const [dir, entry] of [["dist/relay", "index.js"], ["src/relay", "index.ts"]]) {
|
|
15
|
+
const folder = path.join(root, dir);
|
|
16
|
+
if (fs.existsSync(path.join(folder, entry))) {
|
|
17
|
+
const files = fs.readdirSync(folder).filter((name) => /\.(js|ts)$/.test(name) && !name.endsWith(".d.ts")).sort().map((name) => path.join(folder, name));
|
|
18
|
+
return { entry: path.join(folder, entry), files };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`no relay sources under ${root}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Builds the relay into a standalone executable with `bun build --compile`,
|
|
25
|
+
* unless the one already there was built from the same sources. A stamp
|
|
26
|
+
* file beside it holds the hash of those sources.
|
|
27
|
+
*
|
|
28
|
+
* @param home - Home directory the executable goes under; the current user's by default
|
|
29
|
+
*/
|
|
30
|
+
export async function installRelay(home = os.homedir()) {
|
|
31
|
+
const binary = relayBinaryPath(home);
|
|
32
|
+
const stamp = `${binary}.sources`;
|
|
33
|
+
let sources;
|
|
34
|
+
try {
|
|
35
|
+
sources = relaySources();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return { kind: "failed", binary, reason: error instanceof Error ? error.message : String(error) };
|
|
39
|
+
}
|
|
40
|
+
const hash = await hashString(sources.files.map((file) => fs.readFileSync(file, "utf8")).join("\0"));
|
|
41
|
+
if (fs.existsSync(binary) && fs.existsSync(stamp) && fs.readFileSync(stamp, "utf8") === hash)
|
|
42
|
+
return { kind: "current", binary };
|
|
43
|
+
fs.mkdirSync(path.dirname(binary), { recursive: true });
|
|
44
|
+
const built = Bun.spawnSync(["bun", "build", "--compile", sources.entry, "--outfile", binary], { stdout: "pipe", stderr: "pipe" });
|
|
45
|
+
if (built.exitCode !== 0) {
|
|
46
|
+
return { kind: "failed", binary, reason: built.stderr.toString().trim() || `bun build exited with ${built.exitCode}` };
|
|
47
|
+
}
|
|
48
|
+
fs.writeFileSync(stamp, hash);
|
|
49
|
+
return { kind: "built", binary };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/viewer/relay.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAA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E,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnI,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,yBAAyB,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACzH,CAAC;IACD,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -4,28 +4,34 @@ export declare const ViewerLocationSchema: z.ZodEnum<{
|
|
|
4
4
|
panel: "panel";
|
|
5
5
|
sidebar: "sidebar";
|
|
6
6
|
}>;
|
|
7
|
+
/** Value of `ViewerLocationSchema`: `panel` for an editor tab, `sidebar` for the side bar. */
|
|
7
8
|
export type ViewerLocation = z.infer<typeof ViewerLocationSchema>;
|
|
8
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @brief What `configureViewer` did to the workspace settings.
|
|
11
|
+
*
|
|
12
|
+
* @property kind - `written` when the file changed, `unchanged` when it already held the values, `unreadable` when the file is not plain JSON (comments, trailing commas); nothing is written then.
|
|
13
|
+
* @property file - Absolute path of `.vscode/settings.json`.
|
|
14
|
+
* @property settings - Values that would have been written; present only with `unreadable`.
|
|
15
|
+
*/
|
|
9
16
|
export type ViewerSettingsResult = {
|
|
10
17
|
kind: "written";
|
|
11
18
|
file: string;
|
|
12
19
|
} | {
|
|
13
20
|
kind: "unchanged";
|
|
14
21
|
file: string;
|
|
15
|
-
}
|
|
16
|
-
/** The file exists but is not plain JSON (comments, trailing commas); nothing was written */
|
|
17
|
-
| {
|
|
22
|
+
} | {
|
|
18
23
|
kind: "unreadable";
|
|
19
24
|
file: string;
|
|
20
25
|
settings: Record<string, unknown>;
|
|
21
26
|
};
|
|
22
27
|
/**
|
|
23
|
-
* Points the project's VS Code workspace at the extension's native UI, the
|
|
28
|
+
* @brief Points the project's VS Code workspace at the extension's native UI, the
|
|
24
29
|
* surface mods draw on: sets where Claude opens and turns off terminal mode.
|
|
25
30
|
* Other settings in the file are kept.
|
|
26
31
|
*
|
|
27
|
-
* @param projectRoot - Absolute project root holding `.vscode
|
|
28
|
-
* @param location - Where Claude opens; when absent, a location already set is kept and `panel` is the default
|
|
32
|
+
* @param projectRoot - Absolute project root holding `.vscode/`.
|
|
33
|
+
* @param location - Where Claude opens; when absent, a location already set is kept and `panel` is the default.
|
|
34
|
+
* @returns What was done to the settings file.
|
|
29
35
|
*/
|
|
30
36
|
export declare function configureViewer(projectRoot: string, location?: ViewerLocation): ViewerSettingsResult;
|
|
31
37
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/viewer/settings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sFAAsF;AACtF,eAAO,MAAM,oBAAoB;;;EAA+B,CAAC;AAEjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAQlE
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/viewer/settings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sFAAsF;AACtF,eAAO,MAAM,oBAAoB;;;EAA+B,CAAC;AAEjE,8FAA8F;AAC9F,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAQlE;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAE5E;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,oBAAoB,CAkBpG"}
|
package/dist/viewer/settings.js
CHANGED
|
@@ -9,12 +9,13 @@ const LOCATION_KEY = "claudeCode.preferredLocation";
|
|
|
9
9
|
const TERMINAL_KEY = "claudeCode.useTerminal";
|
|
10
10
|
const SettingsSchema = z.record(z.string(), z.unknown());
|
|
11
11
|
/**
|
|
12
|
-
* Points the project's VS Code workspace at the extension's native UI, the
|
|
12
|
+
* @brief Points the project's VS Code workspace at the extension's native UI, the
|
|
13
13
|
* surface mods draw on: sets where Claude opens and turns off terminal mode.
|
|
14
14
|
* Other settings in the file are kept.
|
|
15
15
|
*
|
|
16
|
-
* @param projectRoot - Absolute project root holding `.vscode
|
|
17
|
-
* @param location - Where Claude opens; when absent, a location already set is kept and `panel` is the default
|
|
16
|
+
* @param projectRoot - Absolute project root holding `.vscode/`.
|
|
17
|
+
* @param location - Where Claude opens; when absent, a location already set is kept and `panel` is the default.
|
|
18
|
+
* @returns What was done to the settings file.
|
|
18
19
|
*/
|
|
19
20
|
export function configureViewer(projectRoot, location) {
|
|
20
21
|
const file = path.join(projectRoot, SETTINGS_FILE);
|
|
@@ -33,6 +34,12 @@ export function configureViewer(projectRoot, location) {
|
|
|
33
34
|
fs.writeFileSync(file, JSON.stringify({ ...current, ...wanted }, null, 2) + "\n");
|
|
34
35
|
return { kind: "written", file };
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @brief Parses JSON text, returning `undefined` instead of throwing.
|
|
39
|
+
*
|
|
40
|
+
* @param text - Raw file contents, e.g. the text of a `settings.json` file.
|
|
41
|
+
* @returns The parsed value, or `undefined` when the text is not valid JSON.
|
|
42
|
+
*/
|
|
36
43
|
function safeJson(text) {
|
|
37
44
|
try {
|
|
38
45
|
return JSON.parse(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/viewer/settings.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/viewer/settings.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAKjE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC5D,MAAM,YAAY,GAAI,8BAA8B,CAAC;AACrD,MAAM,YAAY,GAAI,wBAAwB,CAAC;AAE/C,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAczD;;;;;;;;GA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EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAClF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The viewer extension's id in VS Code: `<publisher>.<name>` from `vscode/package.json`. */
|
|
2
|
+
export declare const VIEWER_EXTENSION_ID = "g3nomaly.g3n-mods-viewer";
|
|
3
|
+
/** Absolute path of the packed viewer, built into `dist/vscode/` by `bun run build`. */
|
|
4
|
+
export declare function viewerPackagePath(): string;
|
|
5
|
+
/** What `installViewer` did. */
|
|
6
|
+
export type ViewerInstallResult = {
|
|
7
|
+
kind: "installed";
|
|
8
|
+
cli: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "no-package";
|
|
11
|
+
vsix: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "no-cli";
|
|
14
|
+
vsix: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "failed";
|
|
17
|
+
vsix: string;
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Installs the viewer extension into VS Code with `code --install-extension`,
|
|
22
|
+
* replacing an older copy.
|
|
23
|
+
*
|
|
24
|
+
* @param home - Home directory to look for a VS Code server under; the current user's by default
|
|
25
|
+
*/
|
|
26
|
+
export declare function installViewer(home?: string): ViewerInstallResult;
|
|
27
|
+
//# sourceMappingURL=viewerExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerExtension.d.ts","sourceRoot":"","sources":["../../src/viewer/viewerExtension.ts"],"names":[],"mappings":"AAMA,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,wFAAwF;AACxF,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,gCAAgC;AAChC,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAmBrD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAqB,GAAG,mBAAmB,CAQ9E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// packages/mods/src/viewer/viewerExtension.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { findPackageRoot } from "@g3nomaly/core/utils";
|
|
6
|
+
/** The viewer extension's id in VS Code: `<publisher>.<name>` from `vscode/package.json`. */
|
|
7
|
+
export const VIEWER_EXTENSION_ID = "g3nomaly.g3n-mods-viewer";
|
|
8
|
+
/** Absolute path of the packed viewer, built into `dist/vscode/` by `bun run build`. */
|
|
9
|
+
export function viewerPackagePath() {
|
|
10
|
+
return path.join(findPackageRoot(import.meta.dir), "dist", "vscode", "g3n-mods-viewer.vsix");
|
|
11
|
+
}
|
|
12
|
+
/** VS Code's `code` command: on the PATH, else the one a VS Code server ships for its own terminals. */
|
|
13
|
+
function findCodeCli(home) {
|
|
14
|
+
for (const dir of (process.env.PATH ?? "").split(path.delimiter)) {
|
|
15
|
+
for (const name of process.platform === "win32" ? ["code.cmd", "code"] : ["code"]) {
|
|
16
|
+
const candidate = path.join(dir, name);
|
|
17
|
+
if (dir !== "" && fs.existsSync(candidate))
|
|
18
|
+
return candidate;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const servers = path.join(home, ".vscode-server", "bin");
|
|
22
|
+
if (!fs.existsSync(servers))
|
|
23
|
+
return null;
|
|
24
|
+
const clis = fs.readdirSync(servers)
|
|
25
|
+
.map((commit) => path.join(servers, commit, "bin", "remote-cli", "code"))
|
|
26
|
+
.filter((cli) => fs.existsSync(cli))
|
|
27
|
+
.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
|
|
28
|
+
return clis[0] ?? null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Installs the viewer extension into VS Code with `code --install-extension`,
|
|
32
|
+
* replacing an older copy.
|
|
33
|
+
*
|
|
34
|
+
* @param home - Home directory to look for a VS Code server under; the current user's by default
|
|
35
|
+
*/
|
|
36
|
+
export function installViewer(home = os.homedir()) {
|
|
37
|
+
const vsix = viewerPackagePath();
|
|
38
|
+
if (!fs.existsSync(vsix))
|
|
39
|
+
return { kind: "no-package", vsix };
|
|
40
|
+
const cli = findCodeCli(home);
|
|
41
|
+
if (cli === null)
|
|
42
|
+
return { kind: "no-cli", vsix };
|
|
43
|
+
const run = Bun.spawnSync([cli, "--install-extension", vsix, "--force"], { stdout: "pipe", stderr: "pipe" });
|
|
44
|
+
if (run.exitCode !== 0)
|
|
45
|
+
return { kind: "failed", vsix, reason: (run.stderr.toString() || run.stdout.toString()).trim() };
|
|
46
|
+
return { kind: "installed", cli };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=viewerExtension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerExtension.js","sourceRoot":"","sources":["../../src/viewer/viewerExtension.ts"],"names":[],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AE,EAAE,CAAC;IACzH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACpC,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g3nomaly/mods",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Installer for Claude Code mods: registers mod sources and installs, updates and removes mods from them.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,18 +18,22 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "rm -rf dist && tsc --project tsconfig.build.json",
|
|
22
|
-
"typecheck": "tsc --noEmit",
|
|
23
|
-
"mods": "bun run src/cli/index.ts"
|
|
21
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json && bun run build:viewer",
|
|
22
|
+
"typecheck": "tsc --noEmit && tsc --noEmit --project vscode/tsconfig.json",
|
|
23
|
+
"mods": "bun run src/cli/index.ts",
|
|
24
|
+
"build:viewer": "bun scripts/build-viewer.ts"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@g3nomaly/core": "^0.3.
|
|
27
|
+
"@g3nomaly/core": "^0.3.3",
|
|
27
28
|
"chalk": "^6.0.0",
|
|
28
29
|
"commander": "^15.0.0",
|
|
29
30
|
"zod": "^4.4.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/bun": "^1.4.0",
|
|
34
|
+
"@types/node": "^22",
|
|
35
|
+
"@types/vscode": "~1.100.0",
|
|
36
|
+
"marked": "^16",
|
|
33
37
|
"typescript": "~7.0.2"
|
|
34
38
|
},
|
|
35
39
|
"license": "Elastic-2.0",
|