openapps 0.0.0-stage → 0.0.151

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 (3) hide show
  1. package/README.md +19 -2
  2. package/bin/openapps.js +121 -0
  3. package/package.json +32 -4
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # openapps
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `openapps` CLI for [OpenApps](https://openapps.xyz): build and ship apps
4
+ that have their own agent, from your coding agent.
5
+
6
+ ```sh
7
+ npm install -D openapps
8
+ npx openapps init
9
+ ```
10
+
11
+ `openapps init` signs you in, creates `policy.json`, and installs the OpenApps
12
+ skills for the agents on your machine.
13
+
14
+ This package is a small launcher. npm installs the native binary for your
15
+ platform through one of the optional dependencies (`openapps-darwin-arm64`,
16
+ `openapps-darwin-x64`, `openapps-linux-arm64`, `openapps-linux-x64`), so keep
17
+ optional dependencies enabled. macOS and Linux; Node 20 or later.
18
+
19
+ Run every command through npx: `npx openapps init`, `npx openapps deploy`, and
20
+ so on. Update with `npm install -D openapps@latest`.
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Launcher for the CLI's npm package.
5
+ //
6
+ // The CLI itself is a native Go binary. npm installs exactly one of the
7
+ // per-platform packages listed as optional dependencies (each declares `os` and
8
+ // `cpu`, so npm skips the rest); this file finds that package next to itself and
9
+ // runs the binary with the caller's stdio, forwarding signals and the exit code.
10
+ // It has no dependencies and no install scripts. The child sees
11
+ // BOUNDED_INSTALL_CHANNEL=npm so its `update` command defers to npm instead of
12
+ // replacing a file npm owns.
13
+ //
14
+ // The same file ships in two packages built from one release (see
15
+ // release/npm-package.sh): @bounded-sh/cli runs `bounded` from
16
+ // @bounded-sh/cli-<os>-<cpu>, and openapps runs `openapps` from
17
+ // openapps-<os>-<cpu>. It reads which one it is from its own package.json.
18
+
19
+ const { spawn } = require('node:child_process');
20
+ const path = require('node:path');
21
+
22
+ const PLATFORMS = {
23
+ darwin: { arm64: 'darwin-arm64', x64: 'darwin-x64' },
24
+ linux: { arm64: 'linux-arm64', x64: 'linux-x64' },
25
+ win32: { x64: 'win32-x64' },
26
+ };
27
+ const OVERRIDE_ENV = 'BOUNDED_CLI_BINARY_OVERRIDE';
28
+ const CHANNEL_ENV = 'BOUNDED_INSTALL_CHANNEL';
29
+ const MANIFEST = require('../package.json');
30
+ const PACKAGE = MANIFEST.name;
31
+ const COMMAND = PACKAGE === 'openapps' ? 'openapps' : 'bounded';
32
+ const PLATFORM_PREFIX = PACKAGE === 'openapps' ? 'openapps-' : `${PACKAGE}-`;
33
+ const REINSTALL = `npm install -D ${PACKAGE}`;
34
+
35
+ function platformPackage() {
36
+ const byArch = PLATFORMS[process.platform];
37
+ const suffix = byArch && byArch[process.arch];
38
+ const shipped = MANIFEST.optionalDependencies;
39
+ if (!suffix || (shipped && !(`${PLATFORM_PREFIX}${suffix}` in shipped))) {
40
+ throw new Error(
41
+ `${PACKAGE} has no prebuilt binary for ${process.platform}-${process.arch}. ` +
42
+ `Supported: ${shipped ? Object.keys(shipped).map((name) => name.slice(PLATFORM_PREFIX.length)).join(', ') : 'darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64'}.`,
43
+ );
44
+ }
45
+ return {
46
+ name: `${PLATFORM_PREFIX}${suffix}`,
47
+ executable: process.platform === 'win32' ? `${COMMAND}.exe` : COMMAND,
48
+ };
49
+ }
50
+
51
+ function resolveBinary() {
52
+ const override = process.env[OVERRIDE_ENV];
53
+ if (override) return override;
54
+ const { name, executable } = platformPackage();
55
+ let manifest;
56
+ try {
57
+ manifest = require.resolve(`${name}/package.json`);
58
+ } catch {
59
+ throw new Error(
60
+ `${name} is not installed next to ${PACKAGE}. Reinstall with "${REINSTALL}" ` +
61
+ 'with optional dependencies enabled; npm installs only the package for this platform.',
62
+ );
63
+ }
64
+ return path.join(path.dirname(manifest), 'bin', executable);
65
+ }
66
+
67
+ function main() {
68
+ let binary;
69
+ try {
70
+ binary = resolveBinary();
71
+ } catch (error) {
72
+ console.error(`${COMMAND}: ${error.message}`);
73
+ process.exit(1);
74
+ }
75
+
76
+ const child = spawn(binary, process.argv.slice(2), {
77
+ stdio: 'inherit',
78
+ env: { ...process.env, [CHANNEL_ENV]: 'npm' },
79
+ });
80
+
81
+ const forwarders = new Map();
82
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
83
+ const forward = () => {
84
+ if (child.exitCode === null && child.signalCode === null) child.kill(signal);
85
+ };
86
+ try {
87
+ process.on(signal, forward);
88
+ forwarders.set(signal, forward);
89
+ } catch {
90
+ // A platform without this signal simply does not forward it.
91
+ }
92
+ }
93
+ const release = () => {
94
+ for (const [signal, forward] of forwarders) process.removeListener(signal, forward);
95
+ };
96
+
97
+ child.on('error', (error) => {
98
+ release();
99
+ console.error(`${COMMAND}: could not start ${binary}: ${error.message}`);
100
+ process.exit(1);
101
+ });
102
+ child.on('exit', (code, signal) => {
103
+ release();
104
+ if (signal !== null) {
105
+ if (process.platform !== 'win32') {
106
+ try {
107
+ process.kill(process.pid, signal);
108
+ // Keep the event loop alive for the signal to land; exit 1 otherwise.
109
+ setTimeout(() => process.exit(1), 1000);
110
+ return;
111
+ } catch {
112
+ // Fall through to a plain failure exit.
113
+ }
114
+ }
115
+ process.exit(1);
116
+ }
117
+ process.exit(code === null ? 1 : code);
118
+ });
119
+ }
120
+
121
+ main();
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "openapps",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.151",
4
+ "description": "The OpenApps CLI (openapps.xyz): build, ship and run apps with their own agent. Installs the native binary for this platform as an optional dependency.",
5
+ "license": "MIT",
6
+ "author": "OpenApps",
7
+ "homepage": "https://openapps.xyz",
8
+ "keywords": [
9
+ "openapps",
10
+ "cli",
11
+ "full-stack",
12
+ "app-builder",
13
+ "agents",
14
+ "policy"
15
+ ],
16
+ "bin": {
17
+ "openapps": "bin/openapps.js"
18
+ },
19
+ "files": [
20
+ "bin/"
21
+ ],
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "optionalDependencies": {
29
+ "openapps-darwin-arm64": "0.0.151",
30
+ "openapps-darwin-x64": "0.0.151",
31
+ "openapps-linux-arm64": "0.0.151",
32
+ "openapps-linux-x64": "0.0.151"
33
+ }
34
+ }