@rin-chat/rinext 0.0.0-stage → 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/LICENSE +24 -0
- package/README.md +31 -2
- package/bin/rinext.mjs +56 -0
- package/dist/THIRD-PARTY-LICENSES.txt +103 -0
- package/dist/quickjs.wasm +0 -0
- package/dist/test-runner.mjs +4693 -0
- package/package.json +36 -4
- package/rules.json +64 -0
- package/src/commands.mjs +180 -0
- package/src/package.mjs +595 -0
- package/template/README.md +17 -0
- package/template/extension/README.md +8 -0
- package/template/extension/main.js +35 -0
- package/template/extension/manifest.json +15 -0
- package/template/package.json +12 -0
- package/template/test/mood.test.mjs +41 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Run with: rinext test extension test/mood.test.mjs
|
|
2
|
+
// Each exported function is one test, given a harness: `open(chat?)` opens a fake chat with the extension on.
|
|
3
|
+
// The extension runs in Rin Chat's own sandbox, with the app's checks and limits: one it would hit in the app it hits here.
|
|
4
|
+
// A test fails when it throws, or when any hook failed (chat.errors) and the test did not clear the list.
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
|
|
7
|
+
export async function remindsTheModelEachTurn({ open }) {
|
|
8
|
+
const chat = await open({ cards: [{ id: "c1", data: { name: "Rin" } }] });
|
|
9
|
+
const [line] = await chat.turn();
|
|
10
|
+
// What the prompt gets: the text, made inert, at the depth and role asked for.
|
|
11
|
+
assert.match(line.text, /Rin is feeling calm right now/);
|
|
12
|
+
assert.equal(line.depth, 1);
|
|
13
|
+
assert.equal(line.role, "system");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function theMoodCommandSetsAChatVariable({ open }) {
|
|
17
|
+
const chat = await open();
|
|
18
|
+
assert.deepEqual(chat.commands().map((c) => c.cmd), ["/mood"]);
|
|
19
|
+
assert.equal(await chat.command("/mood cheerful"), true);
|
|
20
|
+
assert.equal(chat.vars.mood, "cheerful");
|
|
21
|
+
const [line] = await chat.turn();
|
|
22
|
+
assert.match(line.text, /feeling cheerful/);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function settingsChangeTheReminder({ open, storage }) {
|
|
26
|
+
// What the user saved in Settings > Extensions. A value the form could not save throws here.
|
|
27
|
+
storage.saveSettings({ style: "short", depth: 3 });
|
|
28
|
+
const chat = await open({ vars: { mood: "tired" } });
|
|
29
|
+
const [line] = await chat.turn();
|
|
30
|
+
assert.match(line.text, /\[Mood: tired\]/);
|
|
31
|
+
assert.equal(line.depth, 3);
|
|
32
|
+
storage.saveSettings({ remind: false });
|
|
33
|
+
assert.deepEqual(await chat.turn(), []);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function storageSurvivesReopening({ open, storage }) {
|
|
37
|
+
await (await open()).close();
|
|
38
|
+
const chat = await open();
|
|
39
|
+
assert.equal(JSON.parse(storage.rows.get("opened")), 2);
|
|
40
|
+
assert.match(chat.logs().join("\n"), /chats opened so far: 2/);
|
|
41
|
+
}
|