roblox-opencode 1.0.1 → 1.0.2

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/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import { tool } from "@opencode-ai/plugin";
3
3
  import { fileURLToPath } from "node:url";
4
- var VERSION = "1.0.1";
4
+ var VERSION = "1.0.2";
5
5
  var MARKER_BEGIN = `<!-- roblox-opencode ${VERSION} BEGIN - managed block, edits inside will be overwritten -->`;
6
6
  var MARKER_END = "<!-- roblox-opencode END -->";
7
7
  var RobloxOpenCode = async (ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roblox-opencode",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "OpenCode plugin for Roblox/Luau development - skills, commands, vendor libs, and config",
5
5
  "keywords": [
6
6
  "opencode-plugin",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: roblox-architecture
3
3
  description: Service hierarchy, 7 foundational patterns, cross-platform input. Client-server architecture, module patterns, framework options.
4
- last_reviewed: 2026-05-21
4
+ last_reviewed: 2026-05-26
5
5
  ---
6
6
 
7
7
  <!-- Source: brockmartin/roblox-game-skill (MIT) -->
@@ -259,12 +259,17 @@ end)
259
259
 
260
260
  ### RunContext (Script Behavior Override)
261
261
 
262
- By default, `Script` runs on the server. Setting `Script.RunContext` changes this:
262
+ `Script.RunContext` overrides where a script runs, breaking the traditional container-based restrictions:
263
263
 
264
- - **`Enum.RunContext.Server`** (default) - runs on the server, only in server-valid containers
265
- - **`Enum.RunContext.Client`** - runs on the client, can be placed ANYWHERE (Workspace, ReplicatedStorage, etc.)
264
+ | Value | Behavior | Notes |
265
+ |-------|----------|-------|
266
+ | `Enum.RunContext.Legacy` | Script runs only in traditional server containers (ServerScriptService, ServerStorage) | **Default** when not set |
267
+ | `Enum.RunContext.Server` | Script runs anywhere in the place, on the server | Useful for scripts in ReplicatedStorage or Workspace |
268
+ | `Enum.RunContext.Client` | Script runs anywhere in the place, on the client | Place in Workspace for local effects, or ReplicatedStorage for shared UI logic |
266
269
 
267
- `RunContext = Client` is powerful for workspace-local effects, proximity scripts, or anything the client sees but doesn't belong in StarterPlayerScripts:
270
+ `Legacy` replicates the old behavior - `Script` must be in server-valid containers, `LocalScript` in client-valid containers. Setting `Server` or `Client` frees the script from those container restrictions.
271
+
272
+ `RunContext = Client` is powerful for workspace-local effects or anything the client sees but doesn't belong in StarterPlayerScripts:
268
273
 
269
274
  ```lua
270
275
  -- A Script in Workspace with RunContext = Client
@@ -277,6 +282,15 @@ RunService.Heartbeat:Connect(function(dt)
277
282
  end)
278
283
  ```
279
284
 
285
+ `RunContext = Server` lets you place server scripts outside the usual server containers:
286
+
287
+ ```lua
288
+ -- A Script in ReplicatedStorage with RunContext = Server
289
+ -- Server logic lives alongside shared modules
290
+ local SharedConfig = require(script.Parent.SharedConfig)
291
+ print(`Server running with: {SharedConfig.setting}`)
292
+ ```
293
+
280
294
  > **Note:** `LocalScript` does NOT have RunContext. It always runs on the client in client-valid containers only. Use `Script` + `RunContext = Client` when you need client scripts outside the usual client containers.
281
295
 
282
296
  ### LocalScript (Client Script)
@@ -2,7 +2,7 @@
2
2
  name: roblox-luau-mastery
3
3
  description: >
4
4
  Luau language fundamentals, type system, OOP, deprecation table, error patterns.
5
- last_reviewed: 2026-05-21
5
+ last_reviewed: 2026-05-26
6
6
  ---
7
7
 
8
8
  <!-- Source: brockmartin/roblox-game-skill (MIT) -->
@@ -50,10 +50,11 @@ Key rules:
50
50
  - Always use `task.wait/spawn/delay` (never deprecated `wait/spawn/delay`)
51
51
  - Instance.new: configure properties THEN set Parent last (replication race)
52
52
  - Services: `game:GetService("Name")` at top of script, stored in locals
53
- - OOP: `.` for constructors, `:` for methods. `__index = self` pattern.
53
+ - Methods: use `:` (implicit self) for instance methods, `.` (explicit self) for constructors/static methods. Prefix private methods with `_`.
54
54
  - Type system: gradual typing, `typeof()` for narrowing, `::` for casting, `export type` for cross-module
55
55
  - Prefer backtick interpolation over `..` concatenation
56
56
  - Use vendored libs (Promise, Trove, Signal, Comm, Component, ProfileStore) over raw equivalents
57
+ - Local function order: callees above callers (no hoisting). Forward-declare for mutual recursion.
57
58
 
58
59
  ---
59
60
 
@@ -1155,6 +1156,30 @@ end
1155
1156
  return InventoryManager
1156
1157
  ```
1157
1158
 
1159
+ ### Method Definitions
1160
+
1161
+ - Use `:` (colon) for instance methods - self is implicit
1162
+ - Use `.` (dot) for constructors and static methods - self must be explicit
1163
+
1164
+ ```luau
1165
+ -- : for instance methods (self is implicit)
1166
+ function MyClass:methodName()
1167
+ -- self refers to the instance
1168
+ end
1169
+
1170
+ -- . for constructors and static methods (self must be explicit)
1171
+ function MyClass.new()
1172
+ local self = setmetatable({}, MyClass)
1173
+ return self
1174
+ end
1175
+
1176
+ -- Calling conventions match definition
1177
+ obj:methodName() -- colon: self passed implicitly
1178
+ MyClass.new() -- dot: no self
1179
+ ```
1180
+
1181
+ **Key rule:** `:` is syntactic sugar for `.` with automatic `self` injection. `obj:method(a)` is equivalent to `obj.method(obj, a)`.
1182
+
1158
1183
  ### General Guidelines
1159
1184
 
1160
1185
  - Use `local` for every variable and function declaration.
@@ -1167,6 +1192,8 @@ return InventoryManager
1167
1192
  - Use `pcall` / `xpcall` around any call that can fail (DataStores, HTTP, etc.).
1168
1193
  - Use backtick interpolation (`{expr}`) for all string building. Never use `..` concatenation.
1169
1194
  - Use `table.freeze()` for configuration tables that should not be modified.
1195
+ - Never use Luau reserved keywords (`return`, `continue`, `local`, `end`, `function`, etc.) as identifiers - parameter names, local variables, function names, or module methods like `module:return()` all cause parse-time syntax errors.
1196
+ - Declare local functions before they are called - Luau has no hoisting. Callees above callers. Use forward declaration (`local fnName`) for mutual recursion.
1170
1197
 
1171
1198
  ---
1172
1199
 
@@ -1365,10 +1392,7 @@ local obj = MyClass.new()
1365
1392
  obj:doSomething() --> ERROR: attempt to call a nil value
1366
1393
  -- Because __index is not set, method lookup fails
1367
1394
 
1368
- -- Common mistake: using . instead of : for method definitions
1369
- function MyClass.method(self: any) end -- explicit self with . (verbose, avoid)
1370
- function MyClass:method() end -- implicit self with : (idiomatic, use this)
1371
- -- Use : for all instance methods. Use . only for static constructors (new).
1395
+ -- See ### Method Definitions in Best Practices for . vs : conventions
1372
1396
 
1373
1397
  -- Common mistake: modifying the metatable instead of the instance
1374
1398
  function MyClass:setName(name: string)
@@ -1380,6 +1404,81 @@ function MyClass:setName(name: string)
1380
1404
  end
1381
1405
  ```
1382
1406
 
1407
+ ### Reserved Keywords as Identifiers
1408
+
1409
+ Luau reserves certain words for the language syntax. These cannot be used as identifiers - variable names, function names, parameter names, or module method names:
1410
+
1411
+ ```
1412
+ and, break, do, else, elseif, end, false, for, function, if, in,
1413
+ local, nil, not, or, repeat, return, then, true, until, while,
1414
+ continue (Luau-specific)
1415
+ ```
1416
+
1417
+ ```luau
1418
+ -- BAD: keyword used as parameter name - syntax error
1419
+ local function onComplete(return: number) end -- ERROR
1420
+ local function process(continue: boolean) end -- ERROR
1421
+
1422
+ -- BAD: keyword used as module method - syntax error
1423
+ local module = {}
1424
+ function module:return() end -- ERROR
1425
+ function module:continue() end -- ERROR
1426
+ ```
1427
+
1428
+ Simply rename to avoid the keyword:
1429
+
1430
+ ```luau
1431
+ -- GOOD: renamed to avoid reserved keyword
1432
+ local function onComplete(result: number) end
1433
+ local function process(shouldContinue: boolean) end
1434
+
1435
+ local module = {}
1436
+ function module:onReturn() end
1437
+ function module:onResume() end
1438
+ ```
1439
+
1440
+ ### Local Function Declaration Order
1441
+
1442
+ Luau has no hoisting - a `local function` is invisible to code above its declaration. This is a common pitfall because many languages (JS, Lua, Python) do hoist function declarations.
1443
+
1444
+ ```luau
1445
+ -- BAD: helperB is nil when functionA runs
1446
+ local function functionA()
1447
+ helperB() -- ERROR: attempt to call a nil value
1448
+ end
1449
+
1450
+ local function helperB()
1451
+ print("helper")
1452
+ end
1453
+
1454
+ -- GOOD: callee declared before caller
1455
+ local function helperB()
1456
+ print("helper")
1457
+ end
1458
+
1459
+ local function functionA()
1460
+ helperB() -- works
1461
+ end
1462
+ ```
1463
+
1464
+ For mutual recursion (A calls B, B calls A), use a forward declaration:
1465
+
1466
+ ```luau
1467
+ local functionB -- forward declaration (declares variable, no assignment)
1468
+
1469
+ local function functionA(x: number)
1470
+ if x <= 0 then return end
1471
+ functionB(x - 1)
1472
+ end
1473
+
1474
+ function functionB(x: number) -- no 'local' here (already declared above)
1475
+ if x <= 0 then return end
1476
+ functionA(x - 1)
1477
+ end
1478
+ ```
1479
+
1480
+ **Rule:** Callees above callers, always. If a `local function` is called by code above its definition, that is a runtime nil-error bug.
1481
+
1383
1482
  ### Equality and Type Coercion
1384
1483
 
1385
1484
  ```luau