@tolmete/cli 0.2.10 → 0.2.11
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 -2
- package/cursor/.cursor-plugin/plugin.json +11 -0
- package/cursor/hooks/hooks.json +29 -0
- package/cursor/runtime/bootstrap.ps1 +91 -0
- package/cursor/runtime/bootstrap.sh +147 -0
- package/cursor/runtime/tolmete.mjs +1868 -0
- package/cursor/runtime/tolmete.ps1 +66 -0
- package/cursor/runtime/tolmete.sh +95 -0
- package/install.mjs +49 -5
- package/package.json +2 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Runs the bundled Tolmete program with Node 22 or newer. Windows PowerShell 5.1, no Git Bash.
|
|
2
|
+
# tolmete.ps1 hook called by Codex: exits 0 whatever happens (Cursor's hooks use tolmete.sh)
|
|
3
|
+
# tolmete.ps1 <command> status, login, logout (people)
|
|
4
|
+
# Node comes from ~\.tolmete\node (a portable copy bootstrap.ps1 downloads) or from PATH. When
|
|
5
|
+
# neither is usable, bootstrap.ps1 is started in the background and this exits 0 at once.
|
|
6
|
+
# ASCII only: PowerShell 5.1 reads a script without a byte order mark in the ANSI code page.
|
|
7
|
+
#
|
|
8
|
+
# Node is run as the last command, with no pipeline and no redirection: that way it inherits
|
|
9
|
+
# the hook's stdin and stdout as they are, and the JSON reaches it as the UTF-8 bytes Codex wrote.
|
|
10
|
+
|
|
11
|
+
$ErrorActionPreference = 'Continue'
|
|
12
|
+
|
|
13
|
+
# The Node.js bootstrap.ps1 installs; a test keeps this equal to its version.
|
|
14
|
+
$pinned = '22.23.5'
|
|
15
|
+
|
|
16
|
+
$runtime = $PSScriptRoot
|
|
17
|
+
$bundle = Join-Path $runtime 'tolmete.mjs'
|
|
18
|
+
$root = Join-Path $env:USERPROFILE '.tolmete\node'
|
|
19
|
+
|
|
20
|
+
function Start-Bootstrap {
|
|
21
|
+
# The same rules as bootstrap.ps1: no new attempt for 6 hours after a failure, none while a
|
|
22
|
+
# download holds the lock (30 minutes). Without this every prompt would start a PowerShell
|
|
23
|
+
# when nodejs.org is blocked.
|
|
24
|
+
foreach ($stamp in @(@('.failed', 360), @('.lock', 30))) {
|
|
25
|
+
$item = Get-Item -LiteralPath (Join-Path $root $stamp[0]) -Force -ErrorAction SilentlyContinue
|
|
26
|
+
if ($item -and ((Get-Date) - $item.LastWriteTime).TotalMinutes -lt $stamp[1]) { return }
|
|
27
|
+
}
|
|
28
|
+
# ShellExecute under the hood: the child inherits no pipe, so Codex does not wait for it. It
|
|
29
|
+
# runs in the Windows folder, so it does not hold the repository folder open. Not the profile
|
|
30
|
+
# folder: Start-Process refuses a -WorkingDirectory with [ ] in its name.
|
|
31
|
+
$script = Join-Path $runtime 'bootstrap.ps1'
|
|
32
|
+
try {
|
|
33
|
+
Start-Process -FilePath (Join-Path $PSHOME 'powershell.exe') -WorkingDirectory $env:SystemRoot -WindowStyle Hidden -ArgumentList "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$script`""
|
|
34
|
+
} catch { }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Find-Portable($filter) {
|
|
38
|
+
Get-ChildItem -LiteralPath $root -Directory -Filter $filter -ErrorAction SilentlyContinue |
|
|
39
|
+
ForEach-Object { Join-Path $_.FullName 'node.exe' } |
|
|
40
|
+
Where-Object { Test-Path -LiteralPath $_ } |
|
|
41
|
+
Select-Object -First 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# The pinned portable Node first. An older one still runs, while the pinned one is fetched.
|
|
45
|
+
$node = Find-Portable "v$pinned-*"
|
|
46
|
+
if (-not $node) {
|
|
47
|
+
$node = Find-Portable 'v22*'
|
|
48
|
+
if ($node) { Start-Bootstrap }
|
|
49
|
+
}
|
|
50
|
+
if (-not $node) {
|
|
51
|
+
$found = Get-Command node.exe -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
52
|
+
if ($found) { $node = $found.Source }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
$hook = ($args.Count -gt 0 -and $args[0] -eq 'hook')
|
|
56
|
+
|
|
57
|
+
if ($node) {
|
|
58
|
+
& $node $bundle @args
|
|
59
|
+
$status = $LASTEXITCODE
|
|
60
|
+
# 64: this Node is older than 22; the program starts nothing else that fails a hook. No status
|
|
61
|
+
# at all: a node.exe that could not start, which is no answer either.
|
|
62
|
+
if ($null -ne $status -and $status -ne 64) { if ($hook) { exit 0 } else { exit $status } }
|
|
63
|
+
}
|
|
64
|
+
Start-Bootstrap
|
|
65
|
+
if (-not $hook) { Write-Output 'Tolmete is preparing the Node.js it needs (about 30 MB, once). Run this again in a minute.' }
|
|
66
|
+
exit 0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Runs the bundled Tolmete program with Node 22 or newer.
|
|
3
|
+
# tolmete.sh hook called by a hook (Claude Code, Codex or Cursor): never fails, never prints
|
|
4
|
+
# tolmete.sh <command> status, login, logout (skills and people)
|
|
5
|
+
# Node comes from ~/.tolmete/node (a portable copy bootstrap.sh downloads) or from PATH. When
|
|
6
|
+
# neither is usable, bootstrap.sh is started in the background and this exits 0 at once.
|
|
7
|
+
#
|
|
8
|
+
# On Windows every child process of Git Bash costs tens of milliseconds, so the start-up below
|
|
9
|
+
# uses shell built-ins only: no tr, no command substitution unless the path needs converting.
|
|
10
|
+
|
|
11
|
+
# Backslashes to slashes, built-ins only. The result is in $r.
|
|
12
|
+
forward() {
|
|
13
|
+
r=$1
|
|
14
|
+
while :; do
|
|
15
|
+
case $r in
|
|
16
|
+
*\\*) r=${r%%\\*}/${r#*\\} ;;
|
|
17
|
+
*) break ;;
|
|
18
|
+
esac
|
|
19
|
+
done
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# The Node.js bootstrap.sh installs; a test keeps this equal to its VERSION.
|
|
23
|
+
pinned=22.23.5
|
|
24
|
+
|
|
25
|
+
forward "$0"
|
|
26
|
+
self=$r
|
|
27
|
+
base=${USERPROFILE:-$HOME}
|
|
28
|
+
# WSL can pass USERPROFILE through WSLENV, but Node there looks in HOME.
|
|
29
|
+
[ -n "$WSL_DISTRO_NAME" ] && base=$HOME
|
|
30
|
+
forward "$base"
|
|
31
|
+
home=$r
|
|
32
|
+
|
|
33
|
+
# The bundle path goes to node, which is not an MSYS program: it needs C:/..., not /c/..., and
|
|
34
|
+
# MSYS_NO_PATHCONV=1 (common with Docker) turns off the automatic conversion.
|
|
35
|
+
case $self in
|
|
36
|
+
[A-Za-z]:/*) dir=${self%/*} ;;
|
|
37
|
+
*/*) dir=$(cd "${self%/*}" 2>/dev/null && { pwd -W 2>/dev/null || pwd; }) || exit 0 ;;
|
|
38
|
+
*) dir=$(pwd -W 2>/dev/null || pwd) ;;
|
|
39
|
+
esac
|
|
40
|
+
bundle="$dir/tolmete.mjs"
|
|
41
|
+
|
|
42
|
+
bootstrap() {
|
|
43
|
+
if command -v nohup >/dev/null 2>&1; then
|
|
44
|
+
nohup sh "$dir/bootstrap.sh" </dev/null >/dev/null 2>&1 &
|
|
45
|
+
else
|
|
46
|
+
sh "$dir/bootstrap.sh" </dev/null >/dev/null 2>&1 &
|
|
47
|
+
fi
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# The pinned portable Node first. An older one still runs, while the pinned one is fetched.
|
|
51
|
+
portable=
|
|
52
|
+
older=
|
|
53
|
+
for candidate in "$home"/.tolmete/node/v"$pinned"-*/bin/node "$home"/.tolmete/node/v"$pinned"-*/node.exe; do
|
|
54
|
+
if [ -f "$candidate" ]; then
|
|
55
|
+
portable=$candidate
|
|
56
|
+
break
|
|
57
|
+
fi
|
|
58
|
+
done
|
|
59
|
+
if [ -z "$portable" ]; then
|
|
60
|
+
for candidate in "$home"/.tolmete/node/v22*/bin/node "$home"/.tolmete/node/v22*/node.exe; do
|
|
61
|
+
if [ -f "$candidate" ]; then
|
|
62
|
+
portable=$candidate
|
|
63
|
+
older=1
|
|
64
|
+
break
|
|
65
|
+
fi
|
|
66
|
+
done
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
if [ "$1" = "hook" ]; then
|
|
70
|
+
if [ -n "$portable" ]; then
|
|
71
|
+
[ -n "$older" ] && bootstrap
|
|
72
|
+
exec "$portable" "$bundle" "$@" 2>/dev/null
|
|
73
|
+
fi
|
|
74
|
+
if command -v node >/dev/null 2>&1; then
|
|
75
|
+
node "$bundle" "$@" 2>/dev/null && exit 0
|
|
76
|
+
fi
|
|
77
|
+
# No Node, or one older than 22 (the bundle exits 64): fetch the portable one, once.
|
|
78
|
+
bootstrap
|
|
79
|
+
exit 0
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
if [ -n "$portable" ]; then
|
|
83
|
+
[ -n "$older" ] && bootstrap
|
|
84
|
+
exec "$portable" "$bundle" "$@"
|
|
85
|
+
fi
|
|
86
|
+
if command -v node >/dev/null 2>&1; then
|
|
87
|
+
node "$bundle" "$@"
|
|
88
|
+
status=$?
|
|
89
|
+
if [ "$status" -ne 64 ] && [ "$status" -ne 127 ]; then
|
|
90
|
+
exit "$status"
|
|
91
|
+
fi
|
|
92
|
+
fi
|
|
93
|
+
bootstrap
|
|
94
|
+
echo "Tolmete is preparing the Node.js it needs (about 30 MB, once). Run this again in a minute."
|
|
95
|
+
exit 0
|
package/install.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `npx @tolmete/cli <tool>`: installs the Tolmete plugin without access to the (private) repository.
|
|
3
3
|
// Claude Code gets it from the catalog on plugins.tolmete.com, so its auto-update keeps working.
|
|
4
|
-
// Codex only takes git or a local folder, so scripts/release.mjs
|
|
5
|
-
// as `codex/` beside this file.
|
|
4
|
+
// Codex only takes git or a local folder, and Cursor has no install command, so scripts/release.mjs
|
|
5
|
+
// puts their plugins in this package, as `codex/` and `cursor/` beside this file.
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
|
-
import { cpSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
@@ -15,6 +15,7 @@ const PLUGIN = "tolmete@tolmete";
|
|
|
15
15
|
const USAGE = [
|
|
16
16
|
"npx @tolmete/cli claude install or update the Tolmete plugin in Claude Code",
|
|
17
17
|
"npx @tolmete/cli codex install or update the Tolmete plugin in Codex CLI",
|
|
18
|
+
"npx @tolmete/cli cursor install or update the Tolmete plugin in Cursor (experimental)",
|
|
18
19
|
" --no-login do not open the sign-in",
|
|
19
20
|
" --remove remove the plugin from that tool",
|
|
20
21
|
].join("\n");
|
|
@@ -152,7 +153,50 @@ const codex = {
|
|
|
152
153
|
},
|
|
153
154
|
};
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
// Cursor has no command to add a plugin, so the plugin folder is copied where Cursor reads local
|
|
157
|
+
// plugins. Cursor is not a command here, so there is no version check for it.
|
|
158
|
+
const cursorPlugin = () => join(homedir(), ".cursor", "plugins", "local", "tolmete");
|
|
159
|
+
|
|
160
|
+
const isOurCursorPlugin = (dir) => {
|
|
161
|
+
try {
|
|
162
|
+
return (
|
|
163
|
+
JSON.parse(readFileSync(join(dir, ".cursor-plugin", "plugin.json"), "utf8")).name ===
|
|
164
|
+
"tolmete"
|
|
165
|
+
);
|
|
166
|
+
} catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const cursor = {
|
|
172
|
+
name: "Cursor",
|
|
173
|
+
cli: false,
|
|
174
|
+
install: (login) => {
|
|
175
|
+
const dir = cursorPlugin();
|
|
176
|
+
// A folder of the same name that is not Tolmete's is never replaced.
|
|
177
|
+
if (existsSync(dir) && !isOurCursorPlugin(dir)) {
|
|
178
|
+
say(`${dir} exists and is not the Tolmete plugin. Move it away, then run this again.`);
|
|
179
|
+
return 1;
|
|
180
|
+
}
|
|
181
|
+
rmSync(dir, { recursive: true, force: true });
|
|
182
|
+
cpSync(fileURLToPath(new URL("./cursor", import.meta.url)), dir, { recursive: true });
|
|
183
|
+
const runtime = runtimeOf(dir);
|
|
184
|
+
if (!runtime) {
|
|
185
|
+
say("The plugin did not install. Reinstall it with this command.");
|
|
186
|
+
return 1;
|
|
187
|
+
}
|
|
188
|
+
say("Installed for Cursor. Restart Cursor or run Developer: Reload Window.");
|
|
189
|
+
return signIn(runtime, login);
|
|
190
|
+
},
|
|
191
|
+
remove: () => {
|
|
192
|
+
const dir = cursorPlugin();
|
|
193
|
+
if (!existsSync(dir) || !isOurCursorPlugin(dir)) return true;
|
|
194
|
+
rmSync(dir, { recursive: true, force: true });
|
|
195
|
+
return true;
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const TOOLS = { claude, codex, cursor };
|
|
156
200
|
|
|
157
201
|
const main = ([command, ...flags]) => {
|
|
158
202
|
if (!Object.hasOwn(TOOLS, command ?? "")) {
|
|
@@ -160,7 +204,7 @@ const main = ([command, ...flags]) => {
|
|
|
160
204
|
return command === undefined || command === "--help" ? 0 : 2;
|
|
161
205
|
}
|
|
162
206
|
const tool = TOOLS[command];
|
|
163
|
-
if (!works(command, ["--version"], { errors: false })) {
|
|
207
|
+
if (tool.cli !== false && !works(command, ["--version"], { errors: false })) {
|
|
164
208
|
say(`${tool.name} was not found. Install it first, then run this again.`);
|
|
165
209
|
return 1;
|
|
166
210
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolmete/cli",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Installs the Tolmete plugin into Claude Code
|
|
3
|
+
"version": "0.2.11",
|
|
4
|
+
"description": "Installs the Tolmete plugin into Claude Code, Codex CLI and Cursor. Never sends prompt text.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|