fix(ai): use shell set for opencode settings
This commit is contained in:
parent
7e50f8da41
commit
38addf85fd
@ -1,4 +1,4 @@
|
|||||||
local _VERSION = '0.2.1';
|
local _VERSION = '0.2.2';
|
||||||
|
|
||||||
local DEFAULT_PROMPT = 'reply with exactly: pong';
|
local DEFAULT_PROMPT = 'reply with exactly: pong';
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ local function createAiHelloWorld(opts)
|
|||||||
local function resolveConfig(options)
|
local function resolveConfig(options)
|
||||||
local url = options.serverUrl or settingsLib.get('opencc.server_url');
|
local url = options.serverUrl or settingsLib.get('opencc.server_url');
|
||||||
if not url or url == '' then
|
if not url or url == '' then
|
||||||
return nil, 'missing opencc.server_url; run: settings set opencc.server_url <url>';
|
return nil, 'missing opencc.server_url; run: set opencc.server_url <url>';
|
||||||
end
|
end
|
||||||
local username = options.username or settingsLib.get('opencc.username') or 'opencode';
|
local username = options.username or settingsLib.get('opencc.username') or 'opencode';
|
||||||
local password = options.password or settingsLib.get('opencc.password') or '';
|
local password = options.password or settingsLib.get('opencc.password') or '';
|
||||||
|
|||||||
@ -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:
|
To target a specific session from CC, grab the session ID shown in the TUI and run:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
settings set opencc.session_id ses_abc123
|
set opencc.session_id ses_abc123
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Configure CC settings
|
## 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
|
```sh
|
||||||
|
set opencc.server_url http://<host-ip>:4096
|
||||||
```lua
|
|
||||||
settings set opencc.server_url http://<host-ip>:4096
|
|
||||||
settings save
|
|
||||||
```
|
```
|
||||||
|
|
||||||
// TOFIX: same here
|
|
||||||
With auth:
|
With auth:
|
||||||
|
|
||||||
```lua
|
```sh
|
||||||
settings set opencc.password secret
|
set opencc.password secret
|
||||||
settings save
|
|
||||||
```
|
```
|
||||||
|
|
||||||
// TOFIX: same here
|
|
||||||
Optional — override the Basic Auth username (default `opencode`):
|
Optional — override the Basic Auth username (default `opencode`):
|
||||||
|
|
||||||
```lua
|
```sh
|
||||||
settings set opencc.username myuser
|
set opencc.username myuser
|
||||||
settings save
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **CraftOS-PC (localhost):** `http://127.0.0.1:4096`
|
- **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 |
|
| 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 |
|
| `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` |
|
| `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` |
|
| `session introuvable; lance: ai-helloworld --new` | Session was deleted or server restarted | Run `ai-helloworld --new` |
|
||||||
|
|||||||
@ -123,6 +123,8 @@ testlib.test('listSessions fails when server_url missing', function()
|
|||||||
|
|
||||||
testlib.assertTrue(not ok);
|
testlib.assertTrue(not ok);
|
||||||
testlib.assertTrue(string.find(err, 'opencc.server_url', 1, true) ~= nil);
|
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);
|
testlib.assertEquals(#httpStub.getCalls, 0);
|
||||||
end);
|
end);
|
||||||
|
|
||||||
@ -252,6 +254,8 @@ testlib.test('askHello fails with missing server_url', function()
|
|||||||
|
|
||||||
testlib.assertTrue(not ok);
|
testlib.assertTrue(not ok);
|
||||||
testlib.assertTrue(string.find(err, 'opencc.server_url', 1, true) ~= nil);
|
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);
|
testlib.assertEquals(#httpStub.postCalls, 0);
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user