@shogo-ai/cli 1.4.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 +21 -0
- package/README.md +18 -0
- package/dist/chunk-UB4RE2UC.js +427 -0
- package/dist/chunk-YYO73V5H.js +227 -0
- package/dist/deploy.cjs +255 -0
- package/dist/deploy.d.cts +168 -0
- package/dist/deploy.d.ts +168 -0
- package/dist/deploy.js +15 -0
- package/dist/index.cjs +688 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +31 -0
- package/dist/pkg.cjs +457 -0
- package/dist/pkg.d.cts +139 -0
- package/dist/pkg.d.ts +139 -0
- package/dist/pkg.js +19 -0
- package/package.json +65 -0
package/dist/pkg.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { StdioOptions } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PlatformPackageManager — centralises Windows vs Unix differences for
|
|
5
|
+
* package-manager operations (install, exec, prisma, etc.).
|
|
6
|
+
*
|
|
7
|
+
* On Windows Bun 1.x's default hardlink backend can leave empty package
|
|
8
|
+
* directories in `node_modules/` (most visibly under transitive deps
|
|
9
|
+
* like `whatwg-url` → `webidl-conversions`, which then crashes any
|
|
10
|
+
* `expo export` / Vite build that imports them). We mitigate by
|
|
11
|
+
* preferring `npm.cmd` for installs when Node.js is on PATH; if it
|
|
12
|
+
* isn't (Shogo Desktop ships its own bun but not Node), we fall back
|
|
13
|
+
* to `bun install --backend=copyfile` which sidesteps the hardlink
|
|
14
|
+
* path entirely. The trade-off is a slower install vs. a half-broken
|
|
15
|
+
* `node_modules` that fails downstream commands without explanation.
|
|
16
|
+
*
|
|
17
|
+
* Lifted into the SDK from `@shogo/shared-runtime` (was AGPL) under MIT
|
|
18
|
+
* so the SDK CLI (`bin/shogo.ts`) and userland tooling can use it without
|
|
19
|
+
* dragging an AGPL runtime dependency into the published `@shogo-ai/sdk`
|
|
20
|
+
* package. Shogo Technologies, Inc. holds copyright; the file is
|
|
21
|
+
* dependency-free (only `node:child_process`, `node:fs`, `node:path`).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface PkgInstallOptions {
|
|
25
|
+
timeout?: number;
|
|
26
|
+
stdio?: StdioOptions;
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
/** Attempt --frozen-lockfile first, fall back to plain install (bun only). */
|
|
29
|
+
frozen?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Error thrown when the Windows Node.js prerequisite is missing. */
|
|
32
|
+
declare class NodeMissingError extends Error {
|
|
33
|
+
readonly code: "NODE_NOT_INSTALLED";
|
|
34
|
+
constructor();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* True if npm.cmd can be located via PATH or the standard Windows install dir.
|
|
38
|
+
* Cheap — only a single existsSync + PATH walk — so safe to call from hot paths.
|
|
39
|
+
* Always returns true on non-Windows (bun is used there).
|
|
40
|
+
*/
|
|
41
|
+
declare function isNodeAvailableOnWindows(pathEnv?: string | undefined): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* True if a `node` binary is on PATH (Unix-style search). The Shogo
|
|
44
|
+
* Desktop API process is spawned by Electron with a PATH inherited
|
|
45
|
+
* from `launchctl`, which on macOS frequently EXCLUDES the user's
|
|
46
|
+
* shell-managed paths (Homebrew, nvm, asdf). `process.env.PATH` is
|
|
47
|
+
* what child spawns see when they exec a `#!/usr/bin/env node` shim,
|
|
48
|
+
* so this is the right thing to check.
|
|
49
|
+
*
|
|
50
|
+
* Cached for the lifetime of the process — node-install state doesn't
|
|
51
|
+
* change between project opens, and re-walking PATH on every spawn
|
|
52
|
+
* adds up.
|
|
53
|
+
*
|
|
54
|
+
* Pass an explicit `pathEnv` only from tests; production callers should
|
|
55
|
+
* use the default.
|
|
56
|
+
*/
|
|
57
|
+
declare function isNodeAvailableOnUnix(pathEnv?: string | undefined): boolean;
|
|
58
|
+
/** Reset the cached node-availability probe — only used by tests. */
|
|
59
|
+
declare function _resetUnixNodeCache(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve a `node_modules/.bin/<name>` invocation that works whether
|
|
62
|
+
* or not a system `node` is on PATH.
|
|
63
|
+
*
|
|
64
|
+
* Why this exists: npm publishes its `.bin/<tool>` shims with
|
|
65
|
+
* `#!/usr/bin/env node` at the top of the underlying JS file. The
|
|
66
|
+
* kernel reads the shebang and tries to exec `/usr/bin/env node`;
|
|
67
|
+
* if `node` isn't on PATH the exec fails with `env: node: No such
|
|
68
|
+
* file or directory` and the spawn exits 127. Shogo Desktop ships
|
|
69
|
+
* the bundled `bun` runtime but does not bundle Node.js, and many
|
|
70
|
+
* end-user macOS PATHs (launchctl-default) don't expose any
|
|
71
|
+
* shell-installed node either — so every `spawn(.bin/vite, ...)`
|
|
72
|
+
* fails on first use. Observed in main.log:
|
|
73
|
+
* [CanvasBuildManager] Build error: env: node: No such file or directory
|
|
74
|
+
* [preview-manager] Vite build --watch exited (code=127, signal=null)
|
|
75
|
+
*
|
|
76
|
+
* Returns `null` if the shim doesn't exist (caller should treat
|
|
77
|
+
* this exactly like the historical `existsSync(viteBin)` no-op
|
|
78
|
+
* path). Otherwise returns `{ cmd, argsPrefix }`:
|
|
79
|
+
* - On Windows, or when `node` is on PATH: the shim itself with
|
|
80
|
+
* no prefix args (preserves the current behavior — fastest path).
|
|
81
|
+
* - When node is missing on Unix: `readlinkSync` resolves the shim
|
|
82
|
+
* to its underlying `.../bin/<tool>.js`, and we route through
|
|
83
|
+
* the bundled `bun` (`{ cmd: bunBinary, argsPrefix: [jsEntry] }`),
|
|
84
|
+
* which executes the JS directly and treats the shebang as a
|
|
85
|
+
* comment. Bun's CLI compatibility is a superset of node for
|
|
86
|
+
* the bundler tools we ship (vite, expo) — same exit codes,
|
|
87
|
+
* same flag parsing.
|
|
88
|
+
*/
|
|
89
|
+
declare function resolveBinInvocation(workspaceDir: string, binName: string): {
|
|
90
|
+
cmd: string;
|
|
91
|
+
argsPrefix: string[];
|
|
92
|
+
} | null;
|
|
93
|
+
interface PkgExecOptions {
|
|
94
|
+
timeout?: number;
|
|
95
|
+
stdio?: StdioOptions;
|
|
96
|
+
env?: NodeJS.ProcessEnv;
|
|
97
|
+
/** Use `bunx --bun` instead of plain `bunx` (needed for some tools). */
|
|
98
|
+
useBunFlag?: boolean;
|
|
99
|
+
}
|
|
100
|
+
declare class PlatformPackageManager {
|
|
101
|
+
readonly isWindows: boolean;
|
|
102
|
+
/** Resolved path to the bun binary — prefers SHOGO_BUN_PATH (set by desktop app) over bare `bun`. */
|
|
103
|
+
get bunBinary(): string;
|
|
104
|
+
private shellOpt;
|
|
105
|
+
private spawnEnv;
|
|
106
|
+
installSync(cwd: string, opts?: PkgInstallOptions): void;
|
|
107
|
+
/**
|
|
108
|
+
* Windows-only fallback path: `bun install [--frozen-lockfile]
|
|
109
|
+
* --backend=copyfile`. Used when npm.cmd isn't available on PATH
|
|
110
|
+
* (typically: Shogo Desktop bundles bun but the user didn't install
|
|
111
|
+
* Node.js separately).
|
|
112
|
+
*
|
|
113
|
+
* The `--backend=copyfile` flag forces bun to copy package contents
|
|
114
|
+
* into `node_modules/` instead of hardlinking from
|
|
115
|
+
* `~/.bun/install/cache`. Hardlinks are bun's default for speed but
|
|
116
|
+
* fail in confusing ways on Windows (the destination directory gets
|
|
117
|
+
* created but ends up empty, and downstream `require('webidl-conversions')`
|
|
118
|
+
* etc. then crash with MODULE_NOT_FOUND). See bun#10327 / #28653.
|
|
119
|
+
*/
|
|
120
|
+
private installSyncBunCopyfile;
|
|
121
|
+
installAsync(cwd: string, opts?: PkgInstallOptions): Promise<void>;
|
|
122
|
+
private installAsyncWindowsNpm;
|
|
123
|
+
private installAsyncBunCopyfile;
|
|
124
|
+
private installAsyncBun;
|
|
125
|
+
execToolSync(tool: string, args: string[], cwd: string, opts?: PkgExecOptions): string;
|
|
126
|
+
execToolAsync(tool: string, args: string[], cwd: string, opts?: PkgExecOptions): Promise<string>;
|
|
127
|
+
prismaGenerate(cwd: string, opts?: PkgExecOptions): void;
|
|
128
|
+
prismaDbPush(cwd: string, opts?: PkgExecOptions & {
|
|
129
|
+
acceptDataLoss?: boolean;
|
|
130
|
+
}): void;
|
|
131
|
+
prismaGenerateAsync(cwd: string, opts?: PkgExecOptions): Promise<void>;
|
|
132
|
+
prismaDbPushAsync(cwd: string, opts?: PkgExecOptions & {
|
|
133
|
+
acceptDataLoss?: boolean;
|
|
134
|
+
}): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/** Singleton — most consumers just need one. */
|
|
137
|
+
declare const pkg: PlatformPackageManager;
|
|
138
|
+
|
|
139
|
+
export { NodeMissingError, type PkgExecOptions, type PkgInstallOptions, PlatformPackageManager, _resetUnixNodeCache, isNodeAvailableOnUnix, isNodeAvailableOnWindows, pkg, resolveBinInvocation };
|
package/dist/pkg.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NodeMissingError,
|
|
3
|
+
PlatformPackageManager,
|
|
4
|
+
_resetUnixNodeCache,
|
|
5
|
+
isNodeAvailableOnUnix,
|
|
6
|
+
isNodeAvailableOnWindows,
|
|
7
|
+
pkg,
|
|
8
|
+
resolveBinInvocation
|
|
9
|
+
} from "./chunk-UB4RE2UC.js";
|
|
10
|
+
export {
|
|
11
|
+
NodeMissingError,
|
|
12
|
+
PlatformPackageManager,
|
|
13
|
+
_resetUnixNodeCache,
|
|
14
|
+
isNodeAvailableOnUnix,
|
|
15
|
+
isNodeAvailableOnWindows,
|
|
16
|
+
pkg,
|
|
17
|
+
resolveBinInvocation
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=pkg.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shogo-ai/cli",
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "Shogo CLI helpers — deploy/manifest validation and packager for Shogo agents.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./deploy": {
|
|
18
|
+
"types": "./dist/deploy.d.ts",
|
|
19
|
+
"import": "./dist/deploy.js",
|
|
20
|
+
"require": "./dist/deploy.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./pkg": {
|
|
23
|
+
"types": "./dist/pkg.d.ts",
|
|
24
|
+
"import": "./dist/pkg.js",
|
|
25
|
+
"require": "./dist/pkg.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/**/*.js",
|
|
30
|
+
"dist/**/*.cjs",
|
|
31
|
+
"dist/**/*.d.ts",
|
|
32
|
+
"dist/**/*.d.cts"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"dev": "tsup --watch",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "bun --no-env-file test src/"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^25.5.0",
|
|
42
|
+
"tsup": "^8.0.0",
|
|
43
|
+
"typescript": "^6.0.2"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"shogo",
|
|
50
|
+
"cli",
|
|
51
|
+
"deploy",
|
|
52
|
+
"agent",
|
|
53
|
+
"manifest"
|
|
54
|
+
],
|
|
55
|
+
"author": "Shogo Labs",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/shogo-labs/shogo-ai.git",
|
|
59
|
+
"directory": "packages/cli"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/shogo-labs/shogo-ai/tree/main/packages/cli#readme",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/shogo-labs/shogo-ai/issues"
|
|
64
|
+
}
|
|
65
|
+
}
|