@cmodjs/cli 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/bin/cmod +52 -0
  4. package/package.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jordan Parker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @cmodjs/cli
2
+
3
+ The `cmod` command. CMod is the Claude Mod Manager: it installs, tries, builds, checks, and publishes Claude Code mods, which are plugins with hooks, panes, commands, tools, permissions, and an install step that runs with your consent.
4
+
5
+ ```sh
6
+ npm i -g @cmodjs/cli
7
+ cmod new my-mod
8
+ ```
9
+
10
+ `cmod` runs the newest cmod program on this machine, and downloads its own version from the GitHub release the first time. A mod imports the library from [@cmodjs/core](https://www.npmjs.com/package/@cmodjs/core).
11
+
12
+ The guide and the CMod plugin live at [github.com/heyJordanParker/cmod](https://github.com/heyJordanParker/cmod).
package/bin/cmod ADDED
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ fail() {
5
+ echo "cmod: $1" >&2
6
+ exit 1
7
+ }
8
+
9
+ store="${XDG_DATA_HOME:-$HOME/.local/share}/cmod/bin/cmod"
10
+ package=$(CDPATH='' cd -- "$(dirname -- "$(readlink -f -- "$0")")/.." && pwd)
11
+
12
+ if [ -f "$package/package.json" ]; then
13
+ version=$(sed -n 's/^ "version": *"\([^"]*\)".*/\1/p' "$package/package.json")
14
+ [ -n "$version" ] || fail "$package/package.json names no version"
15
+ if [ ! -x "$store/$version/cmod" ]; then
16
+ case "$(uname -s)" in
17
+ Darwin) os=darwin ;;
18
+ Linux) os=linux ;;
19
+ *) fail "cmod has no build for $(uname -s). Build it from https://github.com/heyJordanParker/cmod/tree/main/cli" ;;
20
+ esac
21
+ case "$(uname -m)" in
22
+ arm64 | aarch64) arch=arm64 ;;
23
+ x86_64 | amd64) arch=x64 ;;
24
+ *) fail "cmod has no build for $(uname -m). Build it from https://github.com/heyJordanParker/cmod/tree/main/cli" ;;
25
+ esac
26
+ release="${CMOD_DIST_SERVER:-https://github.com/heyJordanParker/cmod/releases/download}/v$version"
27
+ build="cmod-$os-$arch"
28
+ folder="$store/$version"
29
+ partial="$folder/.cmod.$$"
30
+ sums="$folder/.SHA256SUMS.$$"
31
+ trap 'rm -f "$partial" "$sums"' EXIT
32
+ trap 'exit 1' HUP INT TERM
33
+ echo "Downloading cmod $version" >&2
34
+ mkdir -p "$folder"
35
+ curl -fsL -o "$sums" "$release/SHA256SUMS" || fail "could not fetch $release/SHA256SUMS (curl exit $?)"
36
+ curl -fsL -o "$partial" "$release/$build" || fail "could not fetch $release/$build (curl exit $?)"
37
+ expected=$(sed -n "s/^\([0-9a-f]\{64\}\) [ *]$build\$/\1/p" "$sums")
38
+ [ -n "$expected" ] || fail "$release/SHA256SUMS lists no $build, so the download cannot be checked"
39
+ actual=$( (sha256sum "$partial" 2>/dev/null || shasum -a 256 "$partial") | cut -d ' ' -f 1)
40
+ [ "$actual" = "$expected" ] || fail "$release/$build has SHA-256 $actual, but SHA256SUMS lists $expected, so nothing was installed"
41
+ chmod +x "$partial"
42
+ reported=$("$partial" --version) || fail "$release/$build downloaded, but running it with --version failed"
43
+ [ "$reported" = "$version" ] || fail "$release/$build reports version $reported, not $version"
44
+ mv -f "$partial" "$folder/cmod"
45
+ rm -f "$sums"
46
+ trap - EXIT HUP INT TERM
47
+ fi
48
+ fi
49
+
50
+ newest=$(for folder in "$store"/*/; do [ -x "${folder}cmod" ] && basename "$folder"; done | sort -V | tail -n 1)
51
+ [ -n "$newest" ] || fail "no cmod is installed in $store. Run npm i -g @cmodjs/cli, or install the CMod plugin in Claude Code."
52
+ exec "$store/$newest/cmod" "$@"
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@cmodjs/cli",
3
+ "version": "0.1.1",
4
+ "description": "Claude Mod Manager: install, try, build, check, and publish Claude Code mods.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/heyJordanParker/cmod.git",
10
+ "directory": "cli"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "bin": {
16
+ "cmod": "bin/cmod"
17
+ },
18
+ "files": [
19
+ "bin/"
20
+ ],
21
+ "scripts": {
22
+ "build": "bun build --compile --minify --target=bun-darwin-arm64 src/main.ts --outfile dist/cmod-darwin-arm64 && bun build --compile --minify --target=bun-darwin-x64 src/main.ts --outfile dist/cmod-darwin-x64 && bun build --compile --minify --target=bun-linux-x64 src/main.ts --outfile dist/cmod-linux-x64 && bun build --compile --minify --target=bun-linux-arm64 src/main.ts --outfile dist/cmod-linux-arm64",
23
+ "check": "tsc --noEmit",
24
+ "test": "bun test"
25
+ },
26
+ "cmod": {
27
+ "build": "bun run build",
28
+ "output": "dist"
29
+ },
30
+ "devDependencies": {
31
+ "@cmodjs/core": "file:../core",
32
+ "@types/bun": "^1.4.2",
33
+ "jsonc-parser": "^3.3.1",
34
+ "typescript": "^7.0.2"
35
+ }
36
+ }