Files
HomerandClaude Opus 5.5 eab47acb39 VS Code: only project files go along, the account change lets go, review fixes
Privacy: the text of other open files with a suggestion, and the paths of other open tabs with
a message, now come only from files inside the window's folders, never from a file that looks
like it holds secrets (the table both editors share, tests/rules/private_files.json), and never
from one the project's .gitignore leaves out. In a file that looks secret no suggestion is
asked for; said once. The README (What is sent) and the settings' descriptions say exactly
what is sent and what is not.

- Signing in elsewhere, or out, drops the old account's models, this window's model choice and
  the listed sessions, and reads the models again.
- A rewrite or generation holds the file only while it is written; asked again before the
  instruction was typed, the question that waits gets the keyboard.
- The Mode and model lists are rebuilt only when what they offer changed.
- Session times are local time.
- _lembas/session/deleted is gone: the CLI sends it only on the LLeMbas link, never on
  serve --stdio. Deleting says why it could not (agent, too old, working) and reads the list
  again when the CLI no longer has the session.
- Dead page messages (focus, insertText, keepBeside), data-line and hooks.filesChanged removed.
- Sign-in lines and versions read as the Neovim plugin reads them (tests/rules/).
- Texts: one sentence for "still working" and one for "this CLI is too old"; Open a File of This
  Project; Send now; Approve: edit without asking / ask before each edit; "You (sent while
  working)" as in Neovim; the Status rows named in words, no Harness row; the hero image has no
  "LLeMbas IDE" alt text; Choose the Main Model removed (Models does it); Stop the Agent.
- README: "nothing is stored in the editor"; the VS Code 1.85 subgrid note names Electron 25 /
  Chromium 114 and 1.86's Electron 27 / Chromium 118 (read from each tag's cgmanifest.json).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 07:52:23 +00:00

123 lines
5.7 KiB
JavaScript

'use strict';
// The rules both editors keep, against the cases in tests/rules/ (the Neovim plugin reads the
// same files in nvim/tests/rules.lua). A rule changed here fails until the other editor follows.
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { compareVersions } = require('../src/words');
const priv = require('../src/private');
const { serverAddress } = require('../src/messages');
const login = require('../src/login');
const { Rpc } = require('../src/rpc');
const media = require('../src/media');
const cases = (name) => JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'tests', 'rules', name + '.json'), 'utf8'));
test('rules: which of two versions is newer, and what is no version', () => {
const v = cases('versions');
for (const [a, b, want] of v.compare) {
assert.equal(compareVersions(a, b), want, `${a} against ${b}`);
assert.equal(compareVersions(b, a), want === 0 ? 0 : -want, `${b} against ${a}`);
}
for (const s of v.not_versions) {
assert.equal(compareVersions(s, '1.0.0'), null, JSON.stringify(s));
assert.equal(compareVersions('1.0.0', s), null, JSON.stringify(s));
}
});
test('rules: which files look like they hold secrets, and what is inside a folder', () => {
const f = cases('private_files');
for (const p of f.secret) assert.equal(priv.looksSecret(p), true, p);
for (const p of f.plain) assert.equal(priv.looksSecret(p), false, p);
for (const [p, roots, want] of f.inside) assert.equal(priv.inside(p, roots), want, `${p} inside ${JSON.stringify(roots)}`);
});
test("rules: what may be handed to `lembas login` as the server's address", () => {
const a = cases('server_address');
for (const s of a.ok) assert.equal(serverAddress(s), s.trim(), JSON.stringify(s));
for (const s of a.refused) assert.equal(serverAddress(s), '', JSON.stringify(s));
});
test("rules: the sign-in's events, in whatever pieces they arrive", () => {
cases('login_events').forEach((c, i) => {
const got = [];
const feed = login.reader((ev) => got.push(ev.event));
for (const chunk of c.chunks) feed(chunk);
assert.deepEqual(got, c.events, 'case ' + (i + 1));
});
});
test('rules: a line longer than the reader keeps is dropped whole, and nothing after it', () => {
const r = cases('rpc_lines');
r.cases.forEach((c, i) => {
const got = [];
const rpc = new Rpc({ write: () => {}, maxLine: r.max, onNotify: (m) => got.push(m) });
for (const chunk of c.chunks) rpc.feed(chunk);
assert.deepEqual(got, c.methods, 'case ' + (i + 1));
});
});
test('rules: which shown files may be opened, by their first bytes and their name', () => {
for (const c of cases('openable')) {
const o = media.openable(Buffer.from(c.head, 'hex'), c.name);
assert.equal(o ? o.kind : null, c.kind, c.name);
}
});
test('private: a file goes along only inside the project, not secret, and known not to be ignored', async () => {
const asked = [];
const ignored = new priv.Ignored({
run: async (dir, file) => {
asked.push([dir, file]);
return file.endsWith('build.log');
},
});
const roots = ['/home/sam/app'];
// Not known yet: left out, and the question is on its way.
assert.equal(priv.maySend('/home/sam/app/main.py', roots, ignored), false);
assert.equal(await ignored.check('/home/sam/app/main.py'), false);
assert.equal(priv.maySend('/home/sam/app/main.py', roots, ignored), true);
assert.equal(await ignored.check('/home/sam/app/build.log'), true);
assert.equal(priv.maySend('/home/sam/app/build.log', roots, ignored), false);
// Asked once a file, in the file's own folder.
await ignored.check('/home/sam/app/main.py');
assert.deepEqual(asked, [['/home/sam/app', '/home/sam/app/main.py'], ['/home/sam/app', '/home/sam/app/build.log']]);
// Outside the project, or secret by its name: never, and git is not even asked.
assert.equal(priv.maySend('/home/sam/other/main.py', roots, ignored), false);
assert.equal(priv.maySend('/home/sam/app/.env', roots, ignored), false);
assert.equal(priv.maySend('/home/sam/app/main.py', [], ignored), false);
assert.equal(asked.length, 2);
// A .gitignore that changed: asked again.
ignored.forget();
assert.equal(ignored.known('/home/sam/app/main.py'), undefined);
// git that fails (not installed, no repository): nothing is ignored.
const none = new priv.Ignored({ run: () => Promise.reject(new Error('no git')) });
assert.equal(await none.check('/home/sam/app/main.py'), false);
});
test('private: git itself is asked, in a real repository', async (t) => {
const os = require('node:os');
const { execFileSync } = require('node:child_process');
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'llembas-private-'));
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
try {
execFileSync('git', ['init', '-q', dir], { stdio: 'ignore' });
} catch {
return t.skip('git is not installed');
}
fs.writeFileSync(path.join(dir, '.gitignore'), 'local.yml\nout/\n');
fs.mkdirSync(path.join(dir, 'out'));
for (const f of ['local.yml', 'main.py', 'out/report.txt']) fs.writeFileSync(path.join(dir, f), 'x\n');
const ignored = new priv.Ignored();
assert.equal(await ignored.check(path.join(dir, 'local.yml')), true);
assert.equal(await ignored.check(path.join(dir, 'out', 'report.txt')), true);
assert.equal(await ignored.check(path.join(dir, 'main.py')), false);
// No repository there: nothing is ignored.
const bare = fs.mkdtempSync(path.join(os.tmpdir(), 'llembas-private-'));
t.after(() => fs.rmSync(bare, { recursive: true, force: true }));
fs.writeFileSync(path.join(bare, 'a.txt'), 'x\n');
assert.equal(await new priv.Ignored().check(path.join(bare, 'a.txt')), false);
});