@g3nomaly/mods 0.0.0-stage → 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/LICENSE +95 -0
- package/README.md +95 -2
- package/dist/cli/commands/add.d.ts +24 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +29 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/init.d.ts +21 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +27 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +22 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +25 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +21 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +37 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/source.d.ts +60 -0
- package/dist/cli/commands/source.d.ts.map +1 -0
- package/dist/cli/commands/source.js +49 -0
- package/dist/cli/commands/source.js.map +1 -0
- package/dist/cli/commands/update.d.ts +21 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +17 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +100 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/project.d.ts +72 -0
- package/dist/cli/project.d.ts.map +1 -0
- package/dist/cli/project.js +72 -0
- package/dist/cli/project.js.map +1 -0
- package/dist/cli/viewer.d.ts +12 -0
- package/dist/cli/viewer.d.ts.map +1 -0
- package/dist/cli/viewer.js +33 -0
- package/dist/cli/viewer.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +7 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/locate.d.ts +21 -0
- package/dist/registry/locate.d.ts.map +1 -0
- package/dist/registry/locate.js +42 -0
- package/dist/registry/locate.js.map +1 -0
- package/dist/registry/manifest.d.ts +8 -0
- package/dist/registry/manifest.d.ts.map +1 -0
- package/dist/registry/manifest.js +13 -0
- package/dist/registry/manifest.js.map +1 -0
- package/dist/registry/readModDir.d.ts +20 -0
- package/dist/registry/readModDir.d.ts.map +1 -0
- package/dist/registry/readModDir.js +84 -0
- package/dist/registry/readModDir.js.map +1 -0
- package/dist/registry/readSource.d.ts +9 -0
- package/dist/registry/readSource.d.ts.map +1 -0
- package/dist/registry/readSource.js +27 -0
- package/dist/registry/readSource.js.map +1 -0
- package/dist/registry/types.d.ts +69 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +20 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/sources/builtins.d.ts +4 -0
- package/dist/sources/builtins.d.ts.map +1 -0
- package/dist/sources/builtins.js +5 -0
- package/dist/sources/builtins.js.map +1 -0
- package/dist/sources/index.d.ts +2 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +3 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/viewer/extension.d.ts +28 -0
- package/dist/viewer/extension.d.ts.map +1 -0
- package/dist/viewer/extension.js +49 -0
- package/dist/viewer/extension.js.map +1 -0
- package/dist/viewer/index.d.ts +5 -0
- package/dist/viewer/index.d.ts.map +1 -0
- package/dist/viewer/index.js +4 -0
- package/dist/viewer/index.js.map +1 -0
- package/dist/viewer/settings.d.ts +37 -0
- package/dist/viewer/settings.d.ts.map +1 -0
- package/dist/viewer/settings.js +51 -0
- package/dist/viewer/settings.js.map +1 -0
- package/package.json +37 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// packages/mods/src/registry/readSource.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { errorMessage } from "@g3nomaly/core/utils";
|
|
4
|
+
import { locateMods } from "./locate";
|
|
5
|
+
import { readModDir } from "./readModDir";
|
|
6
|
+
/**
|
|
7
|
+
* @brief Reads every mod a checked-out source provides, with the source as group.
|
|
8
|
+
* An unreadable mod is skipped with a warning. Handed to
|
|
9
|
+
* `loadSourceRegistry` by every mods command.
|
|
10
|
+
*/
|
|
11
|
+
export const readModSource = async (checkout) => {
|
|
12
|
+
const { dirs, warnings } = locateMods(checkout.dir);
|
|
13
|
+
const entries = [];
|
|
14
|
+
for (const modDir of dirs) {
|
|
15
|
+
try {
|
|
16
|
+
entries.push(await readModDir(modDir, {
|
|
17
|
+
origin: { source: checkout.name, dir: path.relative(checkout.dir, path.dirname(modDir)), commit: checkout.commit, version: checkout.version },
|
|
18
|
+
group: checkout.name,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
warnings.push(`skipped ${path.relative(checkout.dir, modDir) || "."}: ${errorMessage(error)}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return { entries, warnings };
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=readSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readSource.js","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB,KAAK,EAAE,QAAQ,EAAE,EAAE;IACnE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,MAAM,EAAE;gBACpC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;gBAC7I,KAAK,EAAG,QAAQ,CAAC,IAAI;aACtB,CAAC,CAAC,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** What part of a mod a file is: its manifests, its hooks module, its type contract, or anything else it ships. */
|
|
3
|
+
export declare const ModFileTypeSchema: z.ZodEnum<{
|
|
4
|
+
asset: "asset";
|
|
5
|
+
hooks: "hooks";
|
|
6
|
+
manifest: "manifest";
|
|
7
|
+
types: "types";
|
|
8
|
+
}>;
|
|
9
|
+
/** Kind of a mod file: `manifest`, `hooks`, `types` or `asset`. */
|
|
10
|
+
export type ModFileType = z.infer<typeof ModFileTypeSchema>;
|
|
11
|
+
/** One installed or installable file of a mod; `path` is `<mod>/<file>`, relative to the install directory. */
|
|
12
|
+
export declare const ModFileSchema: z.ZodObject<{
|
|
13
|
+
path: z.ZodString;
|
|
14
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
15
|
+
version: z.ZodOptional<z.ZodString>;
|
|
16
|
+
type: z.ZodEnum<{
|
|
17
|
+
asset: "asset";
|
|
18
|
+
hooks: "hooks";
|
|
19
|
+
manifest: "manifest";
|
|
20
|
+
types: "types";
|
|
21
|
+
}>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* File entry of a mod, as `ModFileSchema` parses it.
|
|
25
|
+
*
|
|
26
|
+
* @property path - `<mod>/<file>`, relative to the install directory.
|
|
27
|
+
* @property type - Kind of the file.
|
|
28
|
+
*/
|
|
29
|
+
export type ModFile = z.infer<typeof ModFileSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* One installable mod. Built from a mod folder's `plugin.json` by
|
|
32
|
+
* `readModDir`, and written per install into `mods.json` by the `add` and
|
|
33
|
+
* `update` commands. `group` is the source name, so `ls` groups by source.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ModMetaSchema: z.ZodObject<{
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
description: z.ZodOptional<z.ZodString>;
|
|
38
|
+
version: z.ZodOptional<z.ZodString>;
|
|
39
|
+
registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
origin: z.ZodObject<{
|
|
41
|
+
source: z.ZodString;
|
|
42
|
+
dir: z.ZodString;
|
|
43
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
44
|
+
version: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
forkedFrom: z.ZodOptional<z.ZodString>;
|
|
47
|
+
group: z.ZodString;
|
|
48
|
+
files: z.ZodArray<z.ZodObject<{
|
|
49
|
+
path: z.ZodString;
|
|
50
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
51
|
+
version: z.ZodOptional<z.ZodString>;
|
|
52
|
+
type: z.ZodEnum<{
|
|
53
|
+
asset: "asset";
|
|
54
|
+
hooks: "hooks";
|
|
55
|
+
manifest: "manifest";
|
|
56
|
+
types: "types";
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/**
|
|
61
|
+
* Entry of one mod in `mods.json`, as `ModMetaSchema` parses it.
|
|
62
|
+
*
|
|
63
|
+
* @property group - Source name, so `ls` groups by source.
|
|
64
|
+
* @property files - Installable files of the mod.
|
|
65
|
+
*/
|
|
66
|
+
export type ModMeta = z.infer<typeof ModMetaSchema>;
|
|
67
|
+
/** Mods keyed by their folder name. */
|
|
68
|
+
export type ModRegistry = Record<string, ModMeta>;
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,mHAAmH;AACnH,eAAO,MAAM,iBAAiB;;;;;EAAkD,CAAC;AAEjF,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,+GAA+G;AAC/G,eAAO,MAAM,aAAa;;;;;;;;;;iBAExB,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;iBAGxB,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAO,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACxD,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// packages/mods/src/registry/types.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BaseFileEntrySchema } from "@g3nomaly/core/registry";
|
|
4
|
+
import { OriginEntrySchema } from "@g3nomaly/core/installer";
|
|
5
|
+
/** What part of a mod a file is: its manifests, its hooks module, its type contract, or anything else it ships. */
|
|
6
|
+
export const ModFileTypeSchema = z.enum(["manifest", "hooks", "types", "asset"]);
|
|
7
|
+
/** One installed or installable file of a mod; `path` is `<mod>/<file>`, relative to the install directory. */
|
|
8
|
+
export const ModFileSchema = BaseFileEntrySchema.extend({
|
|
9
|
+
type: ModFileTypeSchema,
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* One installable mod. Built from a mod folder's `plugin.json` by
|
|
13
|
+
* `readModDir`, and written per install into `mods.json` by the `add` and
|
|
14
|
+
* `update` commands. `group` is the source name, so `ls` groups by source.
|
|
15
|
+
*/
|
|
16
|
+
export const ModMetaSchema = OriginEntrySchema.extend({
|
|
17
|
+
group: z.string().min(1),
|
|
18
|
+
files: z.array(ModFileSchema).min(1),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,mHAAmH;AACnH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAKjF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,MAAM,CAAC;IACtD,IAAI,EAAE,iBAAiB;CACxB,CAAC,CAAC;AAUH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC;IACpD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceRecord } from "@g3nomaly/core/sources";
|
|
2
|
+
/** Sources every install scope reads from without registering them; never written to `mods.json` and never removable. */
|
|
3
|
+
export declare const BUILTIN_SOURCES: SourceRecord;
|
|
4
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/sources/builtins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,yHAAyH;AACzH,eAAO,MAAM,eAAe,EAAE,YAE7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../../src/sources/builtins.ts"],"names":[],"mappings":"AAGA,yHAAyH;AACzH,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE;CAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Lowest Claude Code release whose mod API the g3n mods are written against. */
|
|
2
|
+
export declare const MIN_ENGINE_VERSION = "2.1.296";
|
|
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
|
+
*/
|
|
9
|
+
export interface ClaudeExtension {
|
|
10
|
+
version: string;
|
|
11
|
+
dir: string;
|
|
12
|
+
}
|
|
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
|
+
*/
|
|
20
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* @brief Newest Claude Code extension installed for any editor of the VS Code family.
|
|
23
|
+
*
|
|
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.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findClaudeExtension(home?: string): ClaudeExtension | null;
|
|
28
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +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;;;;;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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// packages/mods/src/viewer/extension.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
/** Lowest Claude Code release whose mod API the g3n mods are written against. */
|
|
6
|
+
export const MIN_ENGINE_VERSION = "2.1.296";
|
|
7
|
+
/** Extension folders of the VS Code family, relative to the home directory: local, WSL/SSH server, Insiders, Cursor. */
|
|
8
|
+
const EXTENSION_ROOTS = [".vscode/extensions", ".vscode-server/extensions", ".vscode-insiders/extensions", ".cursor/extensions"];
|
|
9
|
+
const EXTENSION_DIR = /^anthropic\.claude-code-(\d+\.\d+\.\d+)(?:-.+)?$/;
|
|
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
|
+
*/
|
|
17
|
+
export function compareVersions(a, b) {
|
|
18
|
+
const pa = a.split(".").map(Number);
|
|
19
|
+
const pb = b.split(".").map(Number);
|
|
20
|
+
for (let i = 0; i < 3; i++) {
|
|
21
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
22
|
+
if (diff !== 0)
|
|
23
|
+
return diff;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @brief Newest Claude Code extension installed for any editor of the VS Code family.
|
|
29
|
+
*
|
|
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.
|
|
32
|
+
*/
|
|
33
|
+
export function findClaudeExtension(home = os.homedir()) {
|
|
34
|
+
let newest = null;
|
|
35
|
+
for (const root of EXTENSION_ROOTS) {
|
|
36
|
+
const dir = path.join(home, root);
|
|
37
|
+
if (!fs.existsSync(dir))
|
|
38
|
+
continue;
|
|
39
|
+
for (const name of fs.readdirSync(dir)) {
|
|
40
|
+
const version = EXTENSION_DIR.exec(name)?.[1];
|
|
41
|
+
if (version === undefined)
|
|
42
|
+
continue;
|
|
43
|
+
if (newest === null || compareVersions(version, newest.version) > 0)
|
|
44
|
+
newest = { version, dir: path.join(dir, name) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return newest;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +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;AAazE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAI,GAAW,EAAE,CAAC,OAAO,EAAE;IAC7D,IAAI,MAAM,GAA2B,IAAI,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAClC,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,OAAO,KAAK,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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MIN_ENGINE_VERSION, compareVersions, findClaudeExtension } from "./extension";
|
|
2
|
+
export type { ClaudeExtension } from "./extension";
|
|
3
|
+
export { ViewerLocationSchema, configureViewer } from "./settings";
|
|
4
|
+
export type { ViewerLocation, ViewerSettingsResult } from "./settings";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Where the Claude Code extension opens: an editor tab (`panel`) or the side bar. */
|
|
3
|
+
export declare const ViewerLocationSchema: z.ZodEnum<{
|
|
4
|
+
panel: "panel";
|
|
5
|
+
sidebar: "sidebar";
|
|
6
|
+
}>;
|
|
7
|
+
/** Value of `ViewerLocationSchema`: `panel` for an editor tab, `sidebar` for the side bar. */
|
|
8
|
+
export type ViewerLocation = z.infer<typeof ViewerLocationSchema>;
|
|
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
|
+
*/
|
|
16
|
+
export type ViewerSettingsResult = {
|
|
17
|
+
kind: "written";
|
|
18
|
+
file: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "unchanged";
|
|
21
|
+
file: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "unreadable";
|
|
24
|
+
file: string;
|
|
25
|
+
settings: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @brief Points the project's VS Code workspace at the extension's native UI, the
|
|
29
|
+
* surface mods draw on: sets where Claude opens and turns off terminal mode.
|
|
30
|
+
* Other settings in the file are kept.
|
|
31
|
+
*
|
|
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.
|
|
35
|
+
*/
|
|
36
|
+
export declare function configureViewer(projectRoot: string, location?: ViewerLocation): ViewerSettingsResult;
|
|
37
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// packages/mods/src/viewer/settings.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
/** Where the Claude Code extension opens: an editor tab (`panel`) or the side bar. */
|
|
6
|
+
export const ViewerLocationSchema = z.enum(["panel", "sidebar"]);
|
|
7
|
+
const SETTINGS_FILE = path.join(".vscode", "settings.json");
|
|
8
|
+
const LOCATION_KEY = "claudeCode.preferredLocation";
|
|
9
|
+
const TERMINAL_KEY = "claudeCode.useTerminal";
|
|
10
|
+
const SettingsSchema = z.record(z.string(), z.unknown());
|
|
11
|
+
/**
|
|
12
|
+
* @brief Points the project's VS Code workspace at the extension's native UI, the
|
|
13
|
+
* surface mods draw on: sets where Claude opens and turns off terminal mode.
|
|
14
|
+
* Other settings in the file are kept.
|
|
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.
|
|
18
|
+
* @returns What was done to the settings file.
|
|
19
|
+
*/
|
|
20
|
+
export function configureViewer(projectRoot, location) {
|
|
21
|
+
const file = path.join(projectRoot, SETTINGS_FILE);
|
|
22
|
+
let current = {};
|
|
23
|
+
if (fs.existsSync(file)) {
|
|
24
|
+
const parsed = SettingsSchema.safeParse(safeJson(fs.readFileSync(file, "utf8")));
|
|
25
|
+
current = parsed.success ? parsed.data : undefined;
|
|
26
|
+
}
|
|
27
|
+
const kept = ViewerLocationSchema.safeParse(current?.[LOCATION_KEY]);
|
|
28
|
+
const wanted = { [LOCATION_KEY]: location ?? (kept.success ? kept.data : "panel"), [TERMINAL_KEY]: false };
|
|
29
|
+
if (current === undefined)
|
|
30
|
+
return { kind: "unreadable", file, settings: wanted };
|
|
31
|
+
if (Object.entries(wanted).every(([key, value]) => current[key] === value))
|
|
32
|
+
return { kind: "unchanged", file };
|
|
33
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
34
|
+
fs.writeFileSync(file, JSON.stringify({ ...current, ...wanted }, null, 2) + "\n");
|
|
35
|
+
return { kind: "written", file };
|
|
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
|
+
*/
|
|
43
|
+
function safeJson(text) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(text);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +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;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;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,QAAyB;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAEnD,IAAI,OAAO,GAAwC,EAAE,CAAC;IACtD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACjF,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;IAED,MAAM,IAAI,GAAK,oBAAoB,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;IAC3G,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEjF,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAE/G,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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g3nomaly/mods",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Installer for Claude Code mods: registers mod sources and installs, updates and removes mods from them.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"g3n-mods": "./dist/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"mods": "bun run src/cli/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@g3nomaly/core": "^0.3.2",
|
|
27
|
+
"chalk": "^6.0.0",
|
|
28
|
+
"commander": "^15.0.0",
|
|
29
|
+
"zod": "^4.4.3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/bun": "^1.4.0",
|
|
33
|
+
"typescript": "~7.0.2"
|
|
34
|
+
},
|
|
35
|
+
"license": "Elastic-2.0",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|