@remotehost/cli 1.0.1 → 2.0.0
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 +80 -8
- package/THIRD-PARTY-NOTICES.md +0 -658
- package/bin/remote.js +158 -0
- package/dist/node-commands.js +66 -0
- package/package.json +15 -12
- package/dist/index.js +0 -67467
package/bin/remote.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The `remote` command of an npm installation (REM-6874). `remote` is a Rust
|
|
3
|
+
// program; npm installs it as one of four optional platform packages
|
|
4
|
+
// (@remotehost/cli-<darwin|linux>-<arm64|x64>, clients/remote/npm), and this
|
|
5
|
+
// file finds the one for this machine and runs it with the terminal
|
|
6
|
+
// inherited, exiting as it exits. Nothing is downloaded: a machine whose
|
|
7
|
+
// package is missing is told why.
|
|
8
|
+
//
|
|
9
|
+
// It tells the program three things through the environment:
|
|
10
|
+
// REMOTEHOST_LAUNCHER this file
|
|
11
|
+
// REMOTEHOST_NODE_COMMANDS dist/node-commands.js, the Node entry of the
|
|
12
|
+
// commands that stayed in Node: none since
|
|
13
|
+
// Remotehost Claims was removed (REM-6889), so
|
|
14
|
+
// the program no longer runs it
|
|
15
|
+
// REMOTEHOST_NODE the Node.js running this file, to run it with
|
|
16
|
+
//
|
|
17
|
+
// Plain JavaScript: it runs on the Node.js of whoever installed the package.
|
|
18
|
+
|
|
19
|
+
import { spawn } from "node:child_process";
|
|
20
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
21
|
+
import { createRequire } from "node:module";
|
|
22
|
+
import { constants } from "node:os";
|
|
23
|
+
import { dirname, join } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
|
|
26
|
+
const CLI_PACKAGE = "@remotehost/cli";
|
|
27
|
+
|
|
28
|
+
/** Node's `${process.platform}-${process.arch}` to the package that holds its program. */
|
|
29
|
+
export const PLATFORM_PACKAGES = {
|
|
30
|
+
"darwin-arm64": "@remotehost/cli-darwin-arm64",
|
|
31
|
+
"darwin-x64": "@remotehost/cli-darwin-x64",
|
|
32
|
+
"linux-x64": "@remotehost/cli-linux-x64",
|
|
33
|
+
"linux-arm64": "@remotehost/cli-linux-arm64",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const SUPPORTED = "macOS (arm64, x64) and Linux (arm64, x64)";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The program for this machine: { binary }, or { message } saying why there
|
|
40
|
+
* is none. `resolve` finds a module as require.resolve does, from this file.
|
|
41
|
+
*/
|
|
42
|
+
export function findBinary({ platform, arch, resolve, exists = existsSync, nodeOnlyVersion }) {
|
|
43
|
+
const name = PLATFORM_PACKAGES[`${platform}-${arch}`];
|
|
44
|
+
if (!name) {
|
|
45
|
+
const older = nodeOnlyVersion
|
|
46
|
+
? [
|
|
47
|
+
`The last version that runs wherever Node.js does is ${nodeOnlyVersion}:`,
|
|
48
|
+
` npm install -g ${CLI_PACKAGE}@${nodeOnlyVersion}`,
|
|
49
|
+
]
|
|
50
|
+
: [];
|
|
51
|
+
return {
|
|
52
|
+
message: [
|
|
53
|
+
`remote: ${CLI_PACKAGE} has no build for ${platform} ${arch}. It runs on ${SUPPORTED}.`,
|
|
54
|
+
...older,
|
|
55
|
+
].join("\n"),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let manifest;
|
|
59
|
+
try {
|
|
60
|
+
manifest = resolve(`${name}/package.json`);
|
|
61
|
+
} catch {
|
|
62
|
+
return {
|
|
63
|
+
message: [
|
|
64
|
+
`remote: ${name} is not installed. It holds the remote program for ${platform} ${arch}.`,
|
|
65
|
+
`It is an optional dependency of ${CLI_PACKAGE}, which npm leaves out under --omit=optional or --no-optional, or with omit=optional or optional=false in an .npmrc. Install again with it:`,
|
|
66
|
+
` npm install -g ${CLI_PACKAGE} --include=optional`,
|
|
67
|
+
].join("\n"),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const binary = join(dirname(manifest), "bin", "remote");
|
|
71
|
+
if (!exists(binary)) {
|
|
72
|
+
return {
|
|
73
|
+
message: [
|
|
74
|
+
`remote: ${name} is installed without its program (${binary} is missing). Install again:`,
|
|
75
|
+
` npm install -g ${CLI_PACKAGE} --include=optional`,
|
|
76
|
+
].join("\n"),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return { binary };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The program's environment: the caller's, and where this installation's Node parts are. */
|
|
83
|
+
export function childEnv(env, { launcher, node }) {
|
|
84
|
+
return {
|
|
85
|
+
...env,
|
|
86
|
+
REMOTEHOST_LAUNCHER: launcher,
|
|
87
|
+
REMOTEHOST_NODE_COMMANDS: join(dirname(dirname(launcher)), "dist", "node-commands.js"),
|
|
88
|
+
REMOTEHOST_NODE: node,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The exit status a shell reports for a process a signal ended. */
|
|
93
|
+
export function signalStatus(signal) {
|
|
94
|
+
return 128 + (constants.signals[signal] ?? 0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function nodeOnlyVersion(launcher) {
|
|
98
|
+
try {
|
|
99
|
+
const manifest = JSON.parse(readFileSync(join(dirname(dirname(launcher)), "package.json"), "utf8"));
|
|
100
|
+
const version = manifest.remotehostCli?.nodeOnlyVersion;
|
|
101
|
+
return typeof version === "string" ? version : undefined;
|
|
102
|
+
} catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function main() {
|
|
108
|
+
const launcher = realpathSync(fileURLToPath(import.meta.url));
|
|
109
|
+
const require = createRequire(launcher);
|
|
110
|
+
const found = findBinary({
|
|
111
|
+
platform: process.platform,
|
|
112
|
+
arch: process.arch,
|
|
113
|
+
resolve: (specifier) => require.resolve(specifier),
|
|
114
|
+
nodeOnlyVersion: nodeOnlyVersion(launcher),
|
|
115
|
+
});
|
|
116
|
+
if (!found.binary) {
|
|
117
|
+
console.error(found.message);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const child = spawn(found.binary, process.argv.slice(2), {
|
|
122
|
+
stdio: "inherit",
|
|
123
|
+
env: childEnv(process.env, { launcher, node: process.execPath }),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Ctrl-C and Ctrl-\ reach the program from the terminal, which signals the
|
|
127
|
+
// whole foreground group: this process only has to outlive it. A signal
|
|
128
|
+
// sent to this process alone (a supervisor's SIGTERM, a closed session's
|
|
129
|
+
// SIGHUP) is passed on.
|
|
130
|
+
const ignored = ["SIGINT", "SIGQUIT"];
|
|
131
|
+
const forwarded = ["SIGTERM", "SIGHUP"];
|
|
132
|
+
const handlers = new Map();
|
|
133
|
+
for (const signal of ignored) handlers.set(signal, () => {});
|
|
134
|
+
for (const signal of forwarded) handlers.set(signal, () => child.kill(signal));
|
|
135
|
+
for (const [signal, handler] of handlers) process.on(signal, handler);
|
|
136
|
+
|
|
137
|
+
child.on("error", (error) => {
|
|
138
|
+
console.error(`remote: could not run ${found.binary}: ${error.message}`);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
});
|
|
141
|
+
child.on("exit", (code, signal) => {
|
|
142
|
+
if (signal === null) process.exit(code ?? 1);
|
|
143
|
+
// End as the program ended, so a shell or a supervisor sees the signal.
|
|
144
|
+
for (const [name, handler] of handlers) process.off(name, handler);
|
|
145
|
+
process.exitCode = signalStatus(signal);
|
|
146
|
+
process.kill(process.pid, signal);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function invokedDirectly() {
|
|
151
|
+
try {
|
|
152
|
+
return realpathSync(process.argv[1] ?? "") === realpathSync(fileURLToPath(import.meta.url));
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (invokedDirectly()) main();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
// ../session/dist/index.js
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
var REFRESH_SKEW_MS = 60 * 1e3;
|
|
9
|
+
function configDir(env = process.env) {
|
|
10
|
+
return env.REMOTEHOST_CONFIG_DIR?.trim() || join(homedir(), ".config", "remotehost");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/claims-removed.ts
|
|
14
|
+
var CLAIMS_INSTALLED = ["check-commit", "check-push", "hook", "mcp"];
|
|
15
|
+
var CLAIMS_REMOVED = [
|
|
16
|
+
"Remotehost Claims has been removed from RemoteHost, and `{cli} claims` no longer does anything.",
|
|
17
|
+
"",
|
|
18
|
+
"This command now exits 0 whatever it is given, so that the hooks `{cli} claims init` and `{cli} claims integrate` installed do not block your commits, pushes or agents. It goes away in the next release, and those hooks will fail then, so remove them now:",
|
|
19
|
+
"",
|
|
20
|
+
'1. Git hooks. In each repository where you ran `{cli} claims init`, delete the pre-commit and pre-push hooks it wrote (they hold the line "# agentsync:managed") and put back any hook of yours it set aside as <hook>.agentsync-backup:',
|
|
21
|
+
"",
|
|
22
|
+
" hooks=$(git rev-parse --git-path hooks)",
|
|
23
|
+
" for h in pre-commit pre-push; do",
|
|
24
|
+
' if grep -q \'# agentsync:managed\' "${hooks:?}/$h" 2>/dev/null; then rm "${hooks:?}/$h"; fi',
|
|
25
|
+
' if [ -e "${hooks:?}/$h.agentsync-backup" ]; then mv "${hooks:?}/$h.agentsync-backup" "${hooks:?}/$h"; fi',
|
|
26
|
+
" done",
|
|
27
|
+
"",
|
|
28
|
+
' A hook from an older release may already refuse a commit with "the agentsync CLI could not be found". AGENTSYNC_SKIP_HOOKS=1 gets past it until it is deleted.',
|
|
29
|
+
"",
|
|
30
|
+
'2. Repository files. Delete the .agentsync folder at the top of the repository and the agentsync folder inside its git directory (`git rev-parse --git-common-dir` prints that directory), and take the four .agentsync/ lines under "# Remotehost Claims runtime state" out of .gitignore.',
|
|
31
|
+
"",
|
|
32
|
+
'3. MCP server. Remove the server named "agentsync" from .mcp.json, .cursor/mcp.json and .vscode/mcp.json in the repository. If you ran `{cli} claims integrate`, remove it too from ~/.codeium/windsurf/mcp_config.json, ~/.gemini/settings.json and ~/.codex/config.toml (the [mcp_servers.agentsync] table).',
|
|
33
|
+
"",
|
|
34
|
+
'4. Claude Code hooks. If you ran `{cli} claims integrate`, remove the SessionStart, PreToolUse and SessionEnd hooks whose command ends in "claims hook claude-code" from .claude/settings.json in the repository, or from ~/.claude/settings.json if you installed them for every project.',
|
|
35
|
+
"",
|
|
36
|
+
"5. Sign-in cache. Delete {config}/claims-cache.json. Your `{cli} login` session is not affected."
|
|
37
|
+
].join("\n");
|
|
38
|
+
var CLAIMS_REMOVED_HOOK = "{cli}: Remotehost Claims has been removed from RemoteHost, so this hook checks nothing, and it will fail once `{cli} claims` is gone in the next release. Run `{cli} claims` to see how to remove it.";
|
|
39
|
+
function claimsRemovedNotice(cli, config = configDir()) {
|
|
40
|
+
return `${CLAIMS_REMOVED.replaceAll("{cli}", cli).replaceAll("{config}", config)}
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
function claimsRemovedHookLine(cli) {
|
|
44
|
+
return CLAIMS_REMOVED_HOOK.replaceAll("{cli}", cli);
|
|
45
|
+
}
|
|
46
|
+
function isInstalledClaimsRun(args) {
|
|
47
|
+
const subcommand = args.find((word) => !word.startsWith("-"));
|
|
48
|
+
return subcommand !== void 0 && CLAIMS_INSTALLED.includes(subcommand);
|
|
49
|
+
}
|
|
50
|
+
function printClaimsRemoved(cli, args) {
|
|
51
|
+
if (isInstalledClaimsRun(args)) {
|
|
52
|
+
process.stderr.write(`${claimsRemovedHookLine(cli)}
|
|
53
|
+
`);
|
|
54
|
+
} else {
|
|
55
|
+
process.stdout.write(claimsRemovedNotice(cli));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/node-commands.ts
|
|
60
|
+
var cliName = process.env.REMOTEHOST_CLI_NAME?.trim() || "remote";
|
|
61
|
+
var command = process.argv[2];
|
|
62
|
+
if (command !== "claims") {
|
|
63
|
+
console.error(`${cliName}: node-commands runs no command; \`${cliName}\` runs every command itself.`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
printClaimsRemoved(cliName, process.argv.slice(3));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotehost/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Create, attach to, and manage RemoteHost sandboxes from your terminal.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://remotehost.ai",
|
|
@@ -21,20 +21,23 @@
|
|
|
21
21
|
"devbox"
|
|
22
22
|
],
|
|
23
23
|
"bin": {
|
|
24
|
-
"remote": "./
|
|
25
|
-
"rh": "./
|
|
24
|
+
"remote": "./bin/remote.js",
|
|
25
|
+
"rh": "./bin/remote.js"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist/index.js",
|
|
29
|
-
"README.md",
|
|
30
28
|
"LICENSE.md",
|
|
31
|
-
"
|
|
29
|
+
"README.md",
|
|
30
|
+
"THIRD-PARTY-NOTICES.md",
|
|
31
|
+
"bin/remote.js",
|
|
32
|
+
"dist/node-commands.js"
|
|
32
33
|
],
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"@remotehost/cli-darwin-arm64": "2.0.0",
|
|
36
|
+
"@remotehost/cli-darwin-x64": "2.0.0",
|
|
37
|
+
"@remotehost/cli-linux-x64": "2.0.0",
|
|
38
|
+
"@remotehost/cli-linux-arm64": "2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"remotehostCli": {
|
|
41
|
+
"nodeOnlyVersion": "1.0.1"
|
|
39
42
|
}
|
|
40
43
|
}
|