diff --git a/apis/libaihelloworld.lua b/apis/libaihelloworld.lua index fa88ee7..88bed37 100644 --- a/apis/libaihelloworld.lua +++ b/apis/libaihelloworld.lua @@ -1,4 +1,4 @@ -local _VERSION = '0.2.1'; +local _VERSION = '0.2.2'; local DEFAULT_PROMPT = 'reply with exactly: pong'; @@ -66,7 +66,7 @@ local function createAiHelloWorld(opts) local function resolveConfig(options) local url = options.serverUrl or settingsLib.get('opencc.server_url'); if not url or url == '' then - return nil, 'missing opencc.server_url; run: settings set opencc.server_url '; + return nil, 'missing opencc.server_url; run: set opencc.server_url '; end local username = options.username or settingsLib.get('opencc.username') or 'opencode'; local password = options.password or settingsLib.get('opencc.password') or ''; diff --git a/docs/opencode_server_guide.md b/docs/opencode_server_guide.md index 93c618c..6862f23 100644 --- a/docs/opencode_server_guide.md +++ b/docs/opencode_server_guide.md @@ -55,35 +55,28 @@ opencode attach http://127.0.0.1:4096 To target a specific session from CC, grab the session ID shown in the TUI and run: -``` -settings set opencc.session_id ses_abc123 +```sh +set opencc.session_id ses_abc123 ``` ## 3. Configure CC settings -Run in the ComputerCraft console or CraftOS-PC terminal: +Use the CraftOS shell `set` program at the ComputerCraft console or CraftOS-PC terminal. It persists immediately — no `save` step. The Lua [settings](https://tweaked.cc/module/settings.html) API would also work from a script, but at the shell prompt use `set`. -// TOFIX: "settings" does not exist, it was hallucinated by LLM at some point -> but set opencc.userver_url work - -```lua -settings set opencc.server_url http://:4096 -settings save +```sh +set opencc.server_url http://:4096 ``` -// TOFIX: same here With auth: -```lua -settings set opencc.password secret -settings save +```sh +set opencc.password secret ``` -// TOFIX: same here Optional — override the Basic Auth username (default `opencode`): -```lua -settings set opencc.username myuser -settings save +```sh +set opencc.username myuser ``` - **CraftOS-PC (localhost):** `http://127.0.0.1:4096` @@ -113,7 +106,7 @@ Set settings inside the harness before running, or inject them via the test API. | Error | Cause | Fix | |---|---|---| -| `missing opencc.server_url` | Setting not set | `settings set opencc.server_url http://...` | +| `missing opencc.server_url` | Setting not set | `set opencc.server_url http://...` | | `serveur injoignable` | Server not running or wrong URL | Start `opencode serve`, check URL/port | | `erreur message: HTTP 401` | Wrong password | Check `opencc.password` matches `OPENCODE_SERVER_PASSWORD` | | `session introuvable; lance: ai-helloworld --new` | Session was deleted or server restarted | Run `ai-helloworld --new` | diff --git a/tests/ai-helloworld.lua b/tests/ai-helloworld.lua index 261a6d1..39cf95f 100644 --- a/tests/ai-helloworld.lua +++ b/tests/ai-helloworld.lua @@ -123,6 +123,8 @@ testlib.test('listSessions fails when server_url missing', function() testlib.assertTrue(not ok); testlib.assertTrue(string.find(err, 'opencc.server_url', 1, true) ~= nil); + testlib.assertTrue(string.find(err, 'set opencc.server_url', 1, true) ~= nil); + testlib.assertTrue(string.find(err, 'settings set', 1, true) == nil); testlib.assertEquals(#httpStub.getCalls, 0); end); @@ -252,6 +254,8 @@ testlib.test('askHello fails with missing server_url', function() testlib.assertTrue(not ok); testlib.assertTrue(string.find(err, 'opencc.server_url', 1, true) ~= nil); + testlib.assertTrue(string.find(err, 'set opencc.server_url', 1, true) ~= nil); + testlib.assertTrue(string.find(err, 'settings set', 1, true) == nil); testlib.assertEquals(#httpStub.postCalls, 0); end);