ts2077 1.0.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,11 +1,16 @@
1
- # Changelog
2
-
3
- ## 1.0.0
4
-
5
- First package prepared for the npm name `ts2077`. The installed commands are `ts77` and `open77-ts`.
6
-
7
- - Public CLI commands: `create`, `init`, `dev`, `build`, `watch`, `deploy`, `validate`, `doctor`, `types`, `docs`, `update`, `help`.
8
- - New plugins get `package.json` scripts for `dev`, `build`, `deploy`, and `validate`.
9
- - Optional `ts77.config.json` and `ts77.config.ts` overlay the resource config without replacing `open77-ts.json` on disk.
10
- - TypeScript declarations stay generated from the OPEN//77 Devkit catalogue. This release's catalogue is 2.50.0+op77.148.
11
- - `ts77 types` keeps the last generated declarations when the Devkit index is not on the machine, and says so.
1
+ # Changelog
2
+
3
+ ## 1.0.1
4
+
5
+ - `create`, `init`, and `build` write `tsconfig.json`. The editor reads that file and then the client or server project, so `@open77/sdk/client` and the native declarations resolve.
6
+ - The npm package name is `ts2077`. The installed commands remain `ts77` and `open77-ts`.
7
+
8
+ ## 1.0.0
9
+
10
+ First package prepared for the npm name `ts2077`. The installed commands are `ts77` and `open77-ts`.
11
+
12
+ - Public CLI commands: `create`, `init`, `dev`, `build`, `watch`, `deploy`, `validate`, `doctor`, `types`, `docs`, `update`, `help`.
13
+ - New plugins get `package.json` scripts for `dev`, `build`, `deploy`, and `validate`.
14
+ - Optional `ts77.config.json` and `ts77.config.ts` overlay the resource config without replacing `open77-ts.json` on disk.
15
+ - TypeScript declarations stay generated from the OPEN//77 Devkit catalogue. This release's catalogue is 2.50.0+op77.148.
16
+ - `ts77 types` keeps the last generated declarations when the Devkit index is not on the machine, and says so.
package/README.md CHANGED
@@ -1,174 +1,173 @@
1
- # TS77
2
-
3
- Compile OPEN//77 resources from TypeScript. Gameplay becomes Lua 5.4. A separate Node process runs backend services. React interfaces stay JavaScript inside the game's Chromium surface. Native names, parameters, and permissions come from the OPEN//77 Devkit catalogue, which in this workspace is **2.50.0+op77.148**.
4
-
5
- The long-form guide is in [docs/README.md](docs/README.md). [docs/index.html](docs/index.html) is the same guide as one page for GitHub Pages: set the site source to the `/docs` folder on the branch you publish.
6
-
7
- The server sandbox has no global `require` and no `debug` library. The compiler bundles each side into one Lua file and keeps source maps on your machine.
8
-
9
- ## Requirements
10
-
11
- - Node.js 20 or newer
12
- - An OPEN//77 server. This repo was checked against the server at `E:\CODING\VOSS`
13
- - The Devkit index cache created by `npx -y @open2077/mcp init --server-dir <server>`
14
-
15
- ## Install
16
-
17
- ```bash
18
- npm install
19
- npm run build:tools
20
- ```
21
-
22
- `build:tools` compiles the compiler and regenerates `packages/types/generated` from the Devkit index.
23
-
24
- ## Create a plugin
25
-
26
- The npm package name is `ts2077`. The commands it installs are `ts77` and `open77-ts`.
27
-
28
- ```bash
29
- npx ts2077 create my_plugin --template basic --no-install
30
- cd my_plugin
31
- npm install
32
- npm run dev
33
- npm run build
34
- ```
35
-
36
- `npm run dev` watches TypeScript and rebuilds Lua. Add `--server <server-directory>` at create time, or later run `npx ts2077 deploy --server <server-directory>`, to copy the resource into that server's `resources` folder. TS77 does not reload the dedicated server.
37
-
38
- ```bash
39
- npx open77-ts create my_resource --template basic
40
- npx open77-ts create my_job --template gameplay
41
- npx open77-ts create my_hud --template webui
42
- npx open77-ts create my_notes --template fullstack
43
- ```
44
-
45
- The directory name and `open77-ts.json` `name` must match: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters.
46
-
47
- ```bash
48
- npx open77-ts build my_resource
49
- npx open77-ts watch my_resource
50
- npx open77-ts validate my_resource
51
- npx open77-ts doctor my_resource
52
- ```
53
-
54
- `init` writes the basic template into an existing directory. `dev` watches TypeScript and, when `ui/` has Vite installed, starts the WebUI dev server at `http://127.0.0.1:5173/`.
55
-
56
- To copy a built resource into a server, set `serverResourcesDir` in `open77-ts.json` and run `npx open77-ts build <resource> --deploy`. Reloading a running server is a console command on that server (`reload <name>`). This CLI does not send it.
57
-
58
- ## Write gameplay
59
-
60
- Client code lives in `src/client`, server code in `src/server`, and modules imported by either side in `src/shared`. Shared modules are copied into each bundle. They are not `shared_script` files and they do not call `require` at runtime.
61
-
62
- ```ts
63
- import { emitServer, onClientResourceStart, onNet } from "@open77/sdk/client";
64
- import { greet } from "../shared/greeting";
65
-
66
- onClientResourceStart(() => {
67
- print(greet(GetCurrentResourceName()));
68
- const ok = emitServer("demo:ping", { text: "Night City" });
69
- if (!ok) print("demo:ping was not sent");
70
- });
71
- ```
72
-
73
- ```ts
74
- import { authenticatedPlayer, emitClient, onNet } from "@open77/sdk/server";
75
-
76
- onNet("demo:ping", (payload) => {
77
- const player = authenticatedPlayer();
78
- if (player === undefined) return;
79
- emitClient(player, "demo:pong", payload);
80
- });
81
- ```
82
-
83
- `authenticatedPlayer()` reads the server-assigned `source`. A client cannot choose that id. Check payload fields before using them, and do not let a client grant money, items, or character changes.
84
-
85
- Natives are the real catalogue functions. `Open77.webui.create`, `TriggerServerEvent`, and `TriggerClientEvent` are called with a dot. Page methods such as `page:send` use a colon. A native that returns a value and a reason is destructured so both Lua results are kept:
86
-
87
- ```ts
88
- const [page, reason] = Open77.webui.create({ entry: "web/index.html" });
89
- const [ok, failure] = TriggerClientEvent("demo:pong", playerId, payload);
90
- ```
91
-
92
- Cursor reads `tsconfig.client.json` or `tsconfig.server.json` in the resource. Those files are rewritten on each build and point at the generated declarations, so completion follows the catalogue.
93
-
94
- A client file cannot see `TriggerClientEvent`. A server file cannot see `TriggerServerEvent`. `class`, `async`, `Promise`, `Map`, `Set`, and Node.js imports are compile errors.
95
-
96
- The build writes `open77.lua` with the Lua files that were actually produced and the permissions of the natives it found. `network.events` is added when the resource sends or receives network events. Empty script globs are not written.
97
-
98
- ## React WebUI
99
-
100
- The `webui` template and `examples/hello_world` put a Vite React app in `ui/`. `npm run build` inside `ui/` writes `web/`, and the manifest lists those files one by one. The page talks to Lua through the documented bridge:
101
-
102
- ```ts
103
- window.Open77?.on("hud:state", (payload) => render(payload));
104
- window.Open77?.emit("hud:ping", { text: "Night City" });
105
- window.Open77?.ready();
106
- ```
107
-
108
- Lua listens with `page.on` and sends with `page.send`. For Vite during development, build with `--dev` or set the WebUI entry to `http://127.0.0.1:5173/`. That address is the player's PC. Call `Open77.ready()` again after a hot reload so Lua can send the current state.
109
-
110
- `hud` and `menu` do not need a WebUI permission. `modal`, `system`, and `debug` do, and the helper does not offer them.
111
-
112
- ## Targets
113
-
114
- A resource lists the runtimes it actually builds. The defaults are client Lua, server Lua, a WebUI when `web.root` is set, and a Node companion when `backend` is set.
115
-
116
- | Target | Result |
117
- |---|---|
118
- | `open77-client` | One Lua 5.4 client bundle |
119
- | `open77-server` | One Lua 5.4 server bundle |
120
- | `node` | CommonJS from `src/backend`, run with Node.js 22 |
121
- | `webui` | Vite bundle from `src/webui` or `ui` |
122
-
123
- `@open77-ts/client`, `@open77-ts/server`, and `@open77-ts/shared` are compiled into Lua. `@open77-ts/shared` in gameplay is the contract module: plain values and checks, no Node APIs. `@open77-ts/node` is the companion and is rejected in a Lua or page build. `@open77-ts/webui` is the page bridge and is rejected in Lua. The older `@open77/sdk/client` and `@open77/sdk/server` names still resolve.
124
-
125
- `npx open77-ts create my_notes --template fullstack` writes `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. `dev` rebuilds those targets, restarts `dist/backend/index.js` when that file exists, and starts Vite when its dependencies are installed. Set `OPEN77_BRIDGE_SECRET` in the environment before starting the companion. The game server reads the same value from the `open77_bridge_secret` convar or from that resource's tunable. Leave it empty and the server reports `bridge_secret_missing` instead of calling out.
126
-
127
- The companion listens on `127.0.0.1:11782` unless `OPEN77_BRIDGE_PORT` is set. The dedicated server must enable outbound HTTP and allow that host:
128
-
129
- ```jsonc
130
- "http": { "enabled": true, "allowedHosts": ["127.0.0.1"] }
131
- ```
132
-
133
- `http.allowedHosts` is a hostname, not a URL. Inbound calls from Node use `httpHandlers` and `Open77.http.listen`, which is off until the operator enables it. `OPEN77_NOTES_DRIVER` may be `memory` (the default), `mysql`, `postgres`, or `redis`. The database URL is `OPEN77_DATABASE_URL`. File reads stay inside the root configured on the companion and reject `..`.
134
-
135
- `examples/player_notes` is the full path: the React page emits `notes:submit`, client Lua sends `notes:save`, the server checks `authenticatedPlayer()` and the text, `Open77.http.request` calls `notes.save`, and the page renders the saved text or `backend_offline`. The page's health `fetch` does not save anything. Saving does not grant money, items, or vehicles. No play session in Cyberpunk 2077 was run for this example.
136
-
137
- ## Debugging
138
-
139
- Type errors name the TypeScript file and line. Lua is formatted by TypeScriptToLua and carries a source map next to the bundle. The sandbox cannot run `debug.traceback`, so the map is applied by the CLI:
140
-
141
- ```bash
142
- npx open77-ts map examples/hello_world/dist/server/main.lua 120
143
- ```
144
-
145
- When the map has a position, the output looks like:
146
-
147
- ```text
148
- [OPEN77-TS] Resource: hello_world
149
-
150
- Runtime Error:
151
- src/shared/greeting.ts:2
152
- ```
153
-
154
- ## Updating OPEN//77
155
-
156
- When a newer Devkit index is published, refresh the MCP cache and run `npm run generate` (or `npx open77-ts types`). Declarations, permissions, and reserved event prefixes are rewritten from that index. Do not hand-edit `packages/types/generated`.
157
-
158
- ## Example
159
-
160
- `examples/hello_world` is a client, a server, a shared greeting module, a typed ping, and a React HUD.
161
-
162
- - The server registers `/hello` with `RegisterCommand`. Arguments arrive as strings. A console `source` of `0` is not sent to a client, because target `0` is a host error.
163
- - The page emits `hud:ping`. The client sends `hello:ping`. The server checks the payload and replies to `authenticatedPlayer()` with `hello:notice`.
164
- - The client updates the HUD with `page.send`.
165
-
166
- ```bash
167
- npx open77-ts build examples/hello_world
168
- npx open77-ts validate examples/hello_world
169
- npm test
170
- ```
171
-
172
- Build, Lua parse, call syntax, the `require` shim, and source-map lookup are covered by `npm test`. `open77_validate` is the Devkit's static check. Neither one replaces joining the server in Cyberpunk 2077.
173
-
174
- See [docs/limitations.md](docs/limitations.md) for the runtime restrictions and what this project does not claim.
1
+ # TS77
2
+
3
+ Compile OPEN//77 resources from TypeScript. Gameplay becomes Lua 5.4. A separate Node process runs backend services. React interfaces stay JavaScript inside the game's Chromium surface. Native names, parameters, and permissions come from the OPEN//77 Devkit catalogue, which in this workspace is **2.50.0+op77.148**.
4
+
5
+ The long-form guide is in [docs/README.md](docs/README.md). [docs/index.html](docs/index.html) is the same guide as one page for GitHub Pages: set the site source to the `/docs` folder on the branch you publish.
6
+
7
+ The server sandbox has no global `require` and no `debug` library. The compiler bundles each side into one Lua file and keeps source maps on your machine.
8
+
9
+ ## Requirements
10
+
11
+ - Node.js 20 or newer
12
+ - The Devkit index cache created by `npx -y @open2077/mcp init --server-dir <server>`
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install
18
+ npm run build:tools
19
+ ```
20
+
21
+ `build:tools` compiles the compiler and regenerates `packages/types/generated` from the Devkit index.
22
+
23
+ ## Create a plugin
24
+
25
+ The npm package name is `ts2077`. The commands it installs are `ts77` and `open77-ts`.
26
+
27
+ ```bash
28
+ npx ts2077 create my_plugin --template basic --no-install
29
+ cd my_plugin
30
+ npm install
31
+ npm run dev
32
+ npm run build
33
+ ```
34
+
35
+ `npm run dev` watches TypeScript and rebuilds Lua. Add `--server <server-directory>` at create time, or later run `npx ts2077 deploy --server <server-directory>`, to copy the resource into that server's `resources` folder. TS77 does not reload the dedicated server.
36
+
37
+ ```bash
38
+ npx ts2077 create my_resource --template basic
39
+ npx ts2077 create my_job --template gameplay
40
+ npx ts2077 create my_hud --template webui
41
+ npx ts2077 create my_notes --template fullstack
42
+ ```
43
+
44
+ The directory name and `open77-ts.json` `name` must match: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters.
45
+
46
+ ```bash
47
+ npx ts2077 build my_resource
48
+ npx ts2077 watch my_resource
49
+ npx ts2077 validate my_resource
50
+ npx ts2077 doctor my_resource
51
+ ```
52
+
53
+ `init` writes the basic template into an existing directory. `dev` watches TypeScript and, when `ui/` has Vite installed, starts the WebUI dev server at `http://127.0.0.1:5173/`.
54
+
55
+ To copy a built resource into a server, set `serverResourcesDir` in `open77-ts.json` and run `npx ts2077 build <resource> --deploy`. Reloading a running server is a console command on that server (`reload <name>`). This CLI does not send it. Inside this repository, `npx open77-ts` runs the same local program.
56
+
57
+ ## Write gameplay
58
+
59
+ Client code lives in `src/client`, server code in `src/server`, and modules imported by either side in `src/shared`. Shared modules are copied into each bundle. They are not `shared_script` files and they do not call `require` at runtime.
60
+
61
+ ```ts
62
+ import { emitServer, onClientResourceStart, onNet } from "@open77/sdk/client";
63
+ import { greet } from "../shared/greeting";
64
+
65
+ onClientResourceStart(() => {
66
+ print(greet(GetCurrentResourceName()));
67
+ const ok = emitServer("demo:ping", { text: "Night City" });
68
+ if (!ok) print("demo:ping was not sent");
69
+ });
70
+ ```
71
+
72
+ ```ts
73
+ import { authenticatedPlayer, emitClient, onNet } from "@open77/sdk/server";
74
+
75
+ onNet("demo:ping", (payload) => {
76
+ const player = authenticatedPlayer();
77
+ if (player === undefined) return;
78
+ emitClient(player, "demo:pong", payload);
79
+ });
80
+ ```
81
+
82
+ `authenticatedPlayer()` reads the server-assigned `source`. A client cannot choose that id. Check payload fields before using them, and do not let a client grant money, items, or character changes.
83
+
84
+ Natives are the real catalogue functions. `Open77.webui.create`, `TriggerServerEvent`, and `TriggerClientEvent` are called with a dot. Page methods such as `page:send` use a colon. A native that returns a value and a reason is destructured so both Lua results are kept:
85
+
86
+ ```ts
87
+ const [page, reason] = Open77.webui.create({ entry: "web/index.html" });
88
+ const [ok, failure] = TriggerClientEvent("demo:pong", playerId, payload);
89
+ ```
90
+
91
+ `tsconfig.json` points the editor at `tsconfig.client.json` and `tsconfig.server.json`. Those two files are rewritten on each build and point at the generated declarations, so completion follows the catalogue.
92
+
93
+ A client file cannot see `TriggerClientEvent`. A server file cannot see `TriggerServerEvent`. `class`, `async`, `Promise`, `Map`, `Set`, and Node.js imports are compile errors.
94
+
95
+ The build writes `open77.lua` with the Lua files that were actually produced and the permissions of the natives it found. `network.events` is added when the resource sends or receives network events. Empty script globs are not written.
96
+
97
+ ## React WebUI
98
+
99
+ The `webui` template and `examples/hello_world` put a Vite React app in `ui/`. `npm run build` inside `ui/` writes `web/`, and the manifest lists those files one by one. The page talks to Lua through the documented bridge:
100
+
101
+ ```ts
102
+ window.Open77?.on("hud:state", (payload) => render(payload));
103
+ window.Open77?.emit("hud:ping", { text: "Night City" });
104
+ window.Open77?.ready();
105
+ ```
106
+
107
+ Lua listens with `page.on` and sends with `page.send`. For Vite during development, build with `--dev` or set the WebUI entry to `http://127.0.0.1:5173/`. That address is the player's PC. Call `Open77.ready()` again after a hot reload so Lua can send the current state.
108
+
109
+ `hud` and `menu` do not need a WebUI permission. `modal`, `system`, and `debug` do, and the helper does not offer them.
110
+
111
+ ## Targets
112
+
113
+ A resource lists the runtimes it actually builds. The defaults are client Lua, server Lua, a WebUI when `web.root` is set, and a Node companion when `backend` is set.
114
+
115
+ | Target | Result |
116
+ |---|---|
117
+ | `open77-client` | One Lua 5.4 client bundle |
118
+ | `open77-server` | One Lua 5.4 server bundle |
119
+ | `node` | CommonJS from `src/backend`, run with Node.js 22 |
120
+ | `webui` | Vite bundle from `src/webui` or `ui` |
121
+
122
+ `@open77-ts/client`, `@open77-ts/server`, and `@open77-ts/shared` are compiled into Lua. `@open77-ts/shared` in gameplay is the contract module: plain values and checks, no Node APIs. `@open77-ts/node` is the companion and is rejected in a Lua or page build. `@open77-ts/webui` is the page bridge and is rejected in Lua. The older `@open77/sdk/client` and `@open77/sdk/server` names still resolve.
123
+
124
+ `npx open77-ts create my_notes --template fullstack` writes `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. `dev` rebuilds those targets, restarts `dist/backend/index.js` when that file exists, and starts Vite when its dependencies are installed. Set `OPEN77_BRIDGE_SECRET` in the environment before starting the companion. The game server reads the same value from the `open77_bridge_secret` convar or from that resource's tunable. Leave it empty and the server reports `bridge_secret_missing` instead of calling out.
125
+
126
+ The companion listens on `127.0.0.1:11782` unless `OPEN77_BRIDGE_PORT` is set. The dedicated server must enable outbound HTTP and allow that host:
127
+
128
+ ```jsonc
129
+ "http": { "enabled": true, "allowedHosts": ["127.0.0.1"] }
130
+ ```
131
+
132
+ `http.allowedHosts` is a hostname, not a URL. Inbound calls from Node use `httpHandlers` and `Open77.http.listen`, which is off until the operator enables it. `OPEN77_NOTES_DRIVER` may be `memory` (the default), `mysql`, `postgres`, or `redis`. The database URL is `OPEN77_DATABASE_URL`. File reads stay inside the root configured on the companion and reject `..`.
133
+
134
+ `examples/player_notes` is the full path: the React page emits `notes:submit`, client Lua sends `notes:save`, the server checks `authenticatedPlayer()` and the text, `Open77.http.request` calls `notes.save`, and the page renders the saved text or `backend_offline`. The page's health `fetch` does not save anything. Saving does not grant money, items, or vehicles. No play session in Cyberpunk 2077 was run for this example.
135
+
136
+ ## Debugging
137
+
138
+ Type errors name the TypeScript file and line. Lua is formatted by TypeScriptToLua and carries a source map next to the bundle. The sandbox cannot run `debug.traceback`, so the map is applied by the CLI:
139
+
140
+ ```bash
141
+ npx open77-ts map examples/hello_world/dist/server/main.lua 120
142
+ ```
143
+
144
+ When the map has a position, the output looks like:
145
+
146
+ ```text
147
+ [OPEN77-TS] Resource: hello_world
148
+
149
+ Runtime Error:
150
+ src/shared/greeting.ts:2
151
+ ```
152
+
153
+ ## Updating OPEN//77
154
+
155
+ When a newer Devkit index is published, refresh the MCP cache and run `npm run generate` (or `npx open77-ts types`). Declarations, permissions, and reserved event prefixes are rewritten from that index. Do not hand-edit `packages/types/generated`.
156
+
157
+ ## Example
158
+
159
+ `examples/hello_world` is a client, a server, a shared greeting module, a typed ping, and a React HUD.
160
+
161
+ - The server registers `/hello` with `RegisterCommand`. Arguments arrive as strings. A console `source` of `0` is not sent to a client, because target `0` is a host error.
162
+ - The page emits `hud:ping`. The client sends `hello:ping`. The server checks the payload and replies to `authenticatedPlayer()` with `hello:notice`.
163
+ - The client updates the HUD with `page.send`.
164
+
165
+ ```bash
166
+ npx open77-ts build examples/hello_world
167
+ npx open77-ts validate examples/hello_world
168
+ npm test
169
+ ```
170
+
171
+ Build, Lua parse, call syntax, the `require` shim, and source-map lookup are covered by `npm test`. `open77_validate` is the Devkit's static check. Neither one replaces joining the server in Cyberpunk 2077.
172
+
173
+ See [docs/limitations.md](docs/limitations.md) for the runtime restrictions and what this project does not claim.
package/docs/commands.md CHANGED
@@ -1,125 +1,125 @@
1
- # Commands
2
-
3
- The public executable is `ts77`. `open77-ts` runs the same file. The npm package name is `ts2077`.
4
-
5
- | Command | What it does |
6
- |---|---|
7
- | `ts77 create` | Writes a plugin. In a terminal with no name, it asks four questions. `--no-install` skips `npm install`. |
8
- | `ts77 init` | Adds the basic template to a directory and skips files that already exist. |
9
- | `ts77 dev` | Watches `src`, rebuilds, restarts a Node companion only when `dist/backend` exists, and starts Vite only when its dependencies are installed. |
10
- | `ts77 build` | Compiles the plugin. |
11
- | `ts77 watch` | Rebuilds on change and does not start Vite. |
12
- | `ts77 deploy` | Builds and copies the resource. Refuses to run until a server resources directory is set. |
13
- | `ts77 validate` | Checks the manifest and the Lua bundles. |
14
- | `ts77 doctor` | Reports Node, TypeScriptToLua, the catalogue, and the plugin layout. |
15
- | `ts77 types` | Regenerates declarations from the local Devkit index. |
16
- | `ts77 docs` | Prints the path of `docs/index.html`. `--open` opens it. |
17
- | `ts77 update` | Prints the catalogue build and the command that refreshes the Devkit index. It does not download or publish. |
18
- | `ts77 help` | Prints the command list and examples. |
19
-
20
- `ts77 --version` prints the package version. `--quiet` hides the success banner.
21
-
22
- The sections below describe the same build in more detail.
23
-
24
- The CLI is `npx ts2077` from the registry, or `npx open77-ts` from this repository. Every command except `types` and `map` takes an optional resource directory. The default is the current directory.
25
-
26
- ```text
27
- open77-ts <command>
28
-
29
- init [dir]
30
- create <name> [--template basic|gameplay|webui|fullstack] [--out dir]
31
- build [dir] [--dev] [--deploy]
32
- watch [dir]
33
- dev [dir]
34
- validate [dir]
35
- doctor [dir]
36
- map <lua-file> <line> [column]
37
- types
38
- ```
39
-
40
- ## init
41
-
42
- `init` copies the `basic` template into an existing directory. The directory's basename becomes the resource name and must already be a legal slug. If `open77-ts.json` is already there, the command leaves the directory alone.
43
-
44
- ## create
45
-
46
- ```bash
47
- npx open77-ts create my_resource --template basic
48
- npx open77-ts create my_job --template gameplay
49
- npx open77-ts create my_hud --template webui
50
- npx open77-ts create my_notes --template fullstack --out E:\CODING\VOSS\resources\my_notes
51
- ```
52
-
53
- The destination folder name must equal `<name>`. `--out` sets that folder. Without `--out`, the folder is created in the current directory.
54
-
55
- | Template | Layout |
56
- |---|---|
57
- | `basic` | Client and server scripts that print on start. No network permission. |
58
- | `gameplay` | A typed ping from client to server and back. |
59
- | `webui` | Gameplay plus a React HUD in `ui/`. |
60
- | `fullstack` | `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. |
61
-
62
- `__RESOURCE__` in a template is replaced with the resource name. `fullstack` still needs `npm install` inside `src/webui` before the page will build, and `OPEN77_BRIDGE_SECRET` before the companion will listen.
63
-
64
- ## build
65
-
66
- ```bash
67
- npx open77-ts build examples/player_notes
68
- npx open77-ts build examples/hello_world --dev
69
- npx open77-ts build examples/hello_world --deploy
70
- ```
71
-
72
- For each selected target the build:
73
-
74
- 1. Writes `src/generated/flags.ts` with the WebUI entry. `--dev` uses `web.devEntry` when it is set, so the page can load Vite on the player's machine.
75
- 2. Writes `tsconfig.client.json` and `tsconfig.server.json` with paths to the SDK and the generated declarations.
76
- 3. Rejects classes, async, Node imports, and SDK imports from the wrong runtime.
77
- 4. Compiles client and server TypeScript to one Lua 5.4 bundle each, inlines the small TypeScriptToLua helpers, and removes the global `require` fallback. TypeScript under `src/modules` is compiled to `modules/*.lua` and listed as `file` entries for the client sandbox loader. `src/backend` is compiled with `tsc` so `require` and `import` of npm packages stay in Node.
78
- 5. Scans the Lua for natives, refuses unknown or wrong-side calls, and records permissions.
79
- 6. Compiles `src/backend` to `dist/backend/index.js` when the `node` target is on.
80
- 7. Runs Vite when the `webui` target is on and `--` the WebUI dependencies are installed. A resource that lists `webui` explicitly fails the build if Vite fails. A resource that only has a `web.root` and does not list targets keeps going and prints the Vite error.
81
- 8. Writes `open77.lua`. Scripts that were not built are omitted. `files/` and `web/` are listed file by file. Source maps are not listed.
82
-
83
- `--deploy` copies `open77.lua`, `dist`, and `web` into `<serverResourcesDir>/<resource name>`. It does not reload the server and it does not start Node. `dist/backend` is part of `dist`, so the JavaScript is copied, but the dedicated server does not execute it.
84
-
85
- ## watch
86
-
87
- `watch` rebuilds when anything under `src/` changes. If `dist/backend/index.js` exists after a successful build, the previous companion process is killed and a new one is started with the current environment. The secret has to already be in that environment.
88
-
89
- ## dev
90
-
91
- `dev` is `watch` plus Vite. It looks for `node_modules/vite/bin/vite.js` in `ui/` and then in `src/webui/`. The dev server binds `127.0.0.1:5173`. That address is the computer running Vite. In a real session that is the player's PC, not the dedicated server.
92
-
93
- ## validate
94
-
95
- `validate` checks that every `client_script`, `server_script`, `file`, and `web_file` in `open77.lua` exists, that both Lua bundles parse, that the bundle does not fall back to the global `require`, and that the native scan still matches the catalogue. It does not typecheck TypeScript. Run `build` first.
96
-
97
- ## doctor
98
-
99
- `doctor` prints `ok`, `warn`, or `fail` lines:
100
-
101
- - Node version
102
- - `typescript-to-lua` installed
103
- - Catalogue present, with its build and counts
104
- - A warning that the server binary may be newer than the catalogue
105
- - Resource name, directory name, client entry, server entry, backend entry, and target list
106
- - `serverResourcesDir` when it is set
107
-
108
- Exit code 1 means at least one `fail` line.
109
-
110
- ## map
111
-
112
- ```bash
113
- npx open77-ts map examples/hello_world/dist/server/main.lua 120
114
- npx open77-ts map examples/hello_world/dist/server/main.lua 120 4
115
- ```
116
-
117
- Reads the `.map` beside the Lua file and prints a TypeScript file and line. Column 0 often has no mapping, so the tool also tries columns 0, 1, 2, 4, 8, and 16. The game cannot do this. `debug.traceback` is not in the sandbox, and `sourceMapTraceback` is off.
118
-
119
- ## types
120
-
121
- Regenerates declarations from the Devkit index. Same as `npm run generate`.
122
-
123
- ## What the CLI does not do
124
-
125
- It does not join a server, send `reload`, or open Cyberpunk 2077. Reloading a resource is a console command on that server.
1
+ # Commands
2
+
3
+ The public executable is `ts77`. `open77-ts` runs the same file. The npm package name is `ts2077`.
4
+
5
+ | Command | What it does |
6
+ |---|---|
7
+ | `ts77 create` | Writes a plugin. In a terminal with no name, it asks four questions. `--no-install` skips `npm install`. |
8
+ | `ts77 init` | Adds the basic template to a directory and skips files that already exist. |
9
+ | `ts77 dev` | Watches `src`, rebuilds, restarts a Node companion only when `dist/backend` exists, and starts Vite only when its dependencies are installed. |
10
+ | `ts77 build` | Compiles the plugin. |
11
+ | `ts77 watch` | Rebuilds on change and does not start Vite. |
12
+ | `ts77 deploy` | Builds and copies the resource. Refuses to run until a server resources directory is set. |
13
+ | `ts77 validate` | Checks the manifest and the Lua bundles. |
14
+ | `ts77 doctor` | Reports Node, TypeScriptToLua, the catalogue, and the plugin layout. |
15
+ | `ts77 types` | Regenerates declarations from the local Devkit index. |
16
+ | `ts77 docs` | Prints the path of `docs/index.html`. `--open` opens it. |
17
+ | `ts77 update` | Prints the catalogue build and the command that refreshes the Devkit index. It does not download or publish. |
18
+ | `ts77 help` | Prints the command list and examples. |
19
+
20
+ `ts77 --version` prints the package version. `--quiet` hides the success banner.
21
+
22
+ The sections below describe the same build in more detail.
23
+
24
+ The CLI is `npx ts2077` from the registry, or `npx open77-ts` from this repository. Every command except `types` and `map` takes an optional resource directory. The default is the current directory.
25
+
26
+ ```text
27
+ open77-ts <command>
28
+
29
+ init [dir]
30
+ create <name> [--template basic|gameplay|webui|fullstack] [--out dir]
31
+ build [dir] [--dev] [--deploy]
32
+ watch [dir]
33
+ dev [dir]
34
+ validate [dir]
35
+ doctor [dir]
36
+ map <lua-file> <line> [column]
37
+ types
38
+ ```
39
+
40
+ ## init
41
+
42
+ `init` copies the `basic` template into an existing directory. The directory's basename becomes the resource name and must already be a legal slug. If `open77-ts.json` is already there, the command leaves the directory alone.
43
+
44
+ ## create
45
+
46
+ ```bash
47
+ npx ts2077 create my_resource --template basic
48
+ npx ts2077 create my_job --template gameplay
49
+ npx ts2077 create my_hud --template webui
50
+ npx ts2077 create my_notes --template fullstack --out D:\open77-server\resources\my_notes
51
+ ```
52
+
53
+ The destination folder name must equal `<name>`. `--out` sets that folder. Without `--out`, the folder is created in the current directory.
54
+
55
+ | Template | Layout |
56
+ |---|---|
57
+ | `basic` | Client and server scripts that print on start. No network permission. |
58
+ | `gameplay` | A typed ping from client to server and back. |
59
+ | `webui` | Gameplay plus a React HUD in `ui/`. |
60
+ | `fullstack` | `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. |
61
+
62
+ `__RESOURCE__` in a template is replaced with the resource name. `fullstack` still needs `npm install` inside `src/webui` before the page will build, and `OPEN77_BRIDGE_SECRET` before the companion will listen.
63
+
64
+ ## build
65
+
66
+ ```bash
67
+ npx open77-ts build examples/player_notes
68
+ npx open77-ts build examples/hello_world --dev
69
+ npx open77-ts build examples/hello_world --deploy
70
+ ```
71
+
72
+ For each selected target the build:
73
+
74
+ 1. Writes `src/generated/flags.ts` with the WebUI entry. `--dev` uses `web.devEntry` when it is set, so the page can load Vite on the player's machine.
75
+ 2. Writes `tsconfig.json`, `tsconfig.client.json`, and `tsconfig.server.json` with paths to the SDK and the generated declarations. The editor reads `tsconfig.json`.
76
+ 3. Rejects classes, async, Node imports, and SDK imports from the wrong runtime.
77
+ 4. Compiles client and server TypeScript to one Lua 5.4 bundle each, inlines the small TypeScriptToLua helpers, and removes the global `require` fallback. TypeScript under `src/modules` is compiled to `modules/*.lua` and listed as `file` entries for the client sandbox loader. `src/backend` is compiled with `tsc` so `require` and `import` of npm packages stay in Node.
78
+ 5. Scans the Lua for natives, refuses unknown or wrong-side calls, and records permissions.
79
+ 6. Compiles `src/backend` to `dist/backend/index.js` when the `node` target is on.
80
+ 7. Runs Vite when the `webui` target is on and `--` the WebUI dependencies are installed. A resource that lists `webui` explicitly fails the build if Vite fails. A resource that only has a `web.root` and does not list targets keeps going and prints the Vite error.
81
+ 8. Writes `open77.lua`. Scripts that were not built are omitted. `files/` and `web/` are listed file by file. Source maps are not listed.
82
+
83
+ `--deploy` copies `open77.lua`, `dist`, and `web` into `<serverResourcesDir>/<resource name>`. It does not reload the server and it does not start Node. `dist/backend` is part of `dist`, so the JavaScript is copied, but the dedicated server does not execute it.
84
+
85
+ ## watch
86
+
87
+ `watch` rebuilds when anything under `src/` changes. If `dist/backend/index.js` exists after a successful build, the previous companion process is killed and a new one is started with the current environment. The secret has to already be in that environment.
88
+
89
+ ## dev
90
+
91
+ `dev` is `watch` plus Vite. It looks for `node_modules/vite/bin/vite.js` in `ui/` and then in `src/webui/`. The dev server binds `127.0.0.1:5173`. That address is the computer running Vite. In a real session that is the player's PC, not the dedicated server.
92
+
93
+ ## validate
94
+
95
+ `validate` checks that every `client_script`, `server_script`, `file`, and `web_file` in `open77.lua` exists, that both Lua bundles parse, that the bundle does not fall back to the global `require`, and that the native scan still matches the catalogue. It does not typecheck TypeScript. Run `build` first.
96
+
97
+ ## doctor
98
+
99
+ `doctor` prints `ok`, `warn`, or `fail` lines:
100
+
101
+ - Node version
102
+ - `typescript-to-lua` installed
103
+ - Catalogue present, with its build and counts
104
+ - A warning that the server binary may be newer than the catalogue
105
+ - Resource name, directory name, client entry, server entry, backend entry, and target list
106
+ - `serverResourcesDir` when it is set
107
+
108
+ Exit code 1 means at least one `fail` line.
109
+
110
+ ## map
111
+
112
+ ```bash
113
+ npx open77-ts map examples/hello_world/dist/server/main.lua 120
114
+ npx open77-ts map examples/hello_world/dist/server/main.lua 120 4
115
+ ```
116
+
117
+ Reads the `.map` beside the Lua file and prints a TypeScript file and line. Column 0 often has no mapping, so the tool also tries columns 0, 1, 2, 4, 8, and 16. The game cannot do this. `debug.traceback` is not in the sandbox, and `sourceMapTraceback` is off.
118
+
119
+ ## types
120
+
121
+ Regenerates declarations from the Devkit index. Same as `npm run generate`.
122
+
123
+ ## What the CLI does not do
124
+
125
+ It does not join a server, send `reload`, or open Cyberpunk 2077. Reloading a resource is a console command on that server.