Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Spaces S3b: remove bare kwant/kwnt/agent wording, readable archived sheet, server error text

Lin (kwant bot)2138f47c2184
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 22747c2d..f70c1cd2 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1189,7 +1189,9 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
const serverError = async (res: Response): Promise<string | null> => {
try {
const body = await res.clone().json();
- return typeof body?.error === 'string' && body.error ? body.error : null;
+ const text = typeof body?.error === 'string' ? body.error.trim() : '';
+ // The server writes lowercase fragments ("a team called x already exists…"); the UI shows sentences.
+ return text ? text[0].toUpperCase() + text.slice(1) : null;
} catch {
return null;
}
@@ -1381,9 +1383,9 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(kwantData),
});
- if (res.status === 409) return `Another bot in ${space.name} is already named "${agentData.name}".`;
+ if (res.status === 409) return (await serverError(res)) ?? `Another bot in ${space.name} is already named "${agentData.name}".`;
if (res.status === 400) return (await serverError(res)) ?? 'Check the name (no spaces or @) and that the account belongs to the chosen engine.';
- if (!res.ok) return `Couldn't save the bot (HTTP ${res.status}).`;
+ if (!res.ok) return (await serverError(res)) ?? `Couldn't save the bot (HTTP ${res.status}).`;
const updated: Kwant = await res.json();
setKwants((prev) => prev.map((k) => (k.id === updated.id ? updated : k)));
@@ -1456,9 +1458,9 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
setMessages([]);
return;
}
- if (res.status === 409) return `Another bot in ${space.name} is already named "${agentData.name}".`;
+ if (res.status === 409) return (await serverError(res)) ?? `Another bot in ${space.name} is already named "${agentData.name}".`;
if (res.status === 400) return (await serverError(res)) ?? 'Check the name (no spaces or @) and that the account belongs to the chosen engine.';
- return `Couldn't create the bot (HTTP ${res.status}).`;
+ return (await serverError(res)) ?? `Couldn't create the bot (HTTP ${res.status}).`;
} catch (err) {
console.error('Failed creating bot:', err);
return 'Could not reach the server.';
diff --git a/frontend/src/auth.ts b/frontend/src/auth.ts
index 86f3f9af..9c5e1f0f 100644
--- a/frontend/src/auth.ts
+++ b/frontend/src/auth.ts
@@ -54,7 +54,7 @@ export function installUnauthorizedListener(): void {
export async function fetchAuthStatus(): Promise<AuthStatus> {
const res = await fetch('/api/auth/status', { cache: 'no-store' });
- if (res.status === 403) throw new Error("This page's address isn't allowed to use the API (403). Open kwnt at its own address.");
+ if (res.status === 403) throw new Error("This page's address isn't allowed to use the API (403). Open kwant bots at its own address.");
if (!res.ok) throw new Error(`The server answered ${res.status}.`);
return res.json();
}
diff --git a/frontend/src/components/AuthGate.tsx b/frontend/src/components/AuthGate.tsx
index 8dcb5a53..665babd3 100644
--- a/frontend/src/components/AuthGate.tsx
+++ b/frontend/src/components/AuthGate.tsx
@@ -40,7 +40,7 @@ export const AuthGate: React.FC<{ children: React.ReactNode }> = ({ children })
const s = await fetchAuthStatus();
setState(s.auth_required && !s.authenticated ? { kind: 'locked', notice } : { kind: 'ready', authRequired: s.auth_required });
} catch (e) {
- setState({ kind: 'offline', message: e instanceof Error && e.message !== 'Failed to fetch' ? e.message : "Can't reach kwnt. Is it running?" });
+ setState({ kind: 'offline', message: e instanceof Error && e.message !== 'Failed to fetch' ? e.message : "Can't reach the kwant bots server. Is it running?" });
} finally {
checking.current = false;
}
@@ -81,10 +81,10 @@ export const AuthGate: React.FC<{ children: React.ReactNode }> = ({ children })
<div className="min-h-screen w-screen flex items-center justify-center bg-zinc-950 text-zinc-100 p-4 font-sans">
<div className="w-full max-w-md bg-zinc-900 border border-zinc-800 rounded-2xl p-6 shadow-2xl space-y-5">
<div className="flex items-center gap-3">
- <ModernAvatar role="brand" name="Kwant" size={36} />
+ <ModernAvatar role="brand" name="kwant bots" size={36} />
<div>
- <h1 className="text-sm font-semibold">Kwant</h1>
- <p className="text-xs text-zinc-400">Your team of kwant bots</p>
+ <h1 className="text-sm font-semibold">kwant bots</h1>
+ <p className="text-xs text-zinc-400">Your team of AI bots</p>
</div>
</div>
{state.kind === 'checking' && (
@@ -145,7 +145,7 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void }> = (
<KeyRound size={15} className="text-sky-400" /> Enter your access token
</h2>
<p className="text-xs text-zinc-400 leading-relaxed">
- This kwnt is reachable from other machines, so it needs its token once per browser. Get it on the server:
+ This server is reachable from other machines, so it needs its token once per browser. Get it on the server:
</p>
<div className="space-y-1 text-[11px] font-mono text-zinc-300">
<p className="flex items-center gap-1.5 bg-zinc-950 border border-zinc-800 rounded-md px-2 py-1">
@@ -187,7 +187,7 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void }> = (
>
{busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} Continue
</button>
- <p className="text-[11px] text-zinc-500">The browser keeps you signed in for a year. Anyone with the token controls this kwnt.</p>
+ <p className="text-[11px] text-zinc-500">The browser keeps you signed in for a year. Anyone with the token controls this server.</p>
</form>
);
};
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index 0bec3c0b..1aebaa50 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -1029,7 +1029,7 @@ export const ChatView: React.FC<ChatViewProps> = ({
<p className="text-zinc-300" role="status">
{queued.position ? <strong className="text-amber-200">#{queued.position} in line.</strong> : <strong className="text-amber-200">In line.</strong>}{' '}
{queued.reason === 'server_busy'
- ? 'kwnt is running as many turns as it allows right now; this one starts as soon as a slot frees up.'
+ ? 'The server is running as many turns as it allows right now; this one starts as soon as a slot frees up.'
: `${queued.speaker} is busy with other work; this starts as soon as one of those finishes.`}
</p>
) : streamingText ? (
diff --git a/frontend/src/components/ClaudeSignIn.tsx b/frontend/src/components/ClaudeSignIn.tsx
index 6baad515..b3a1b42d 100644
--- a/frontend/src/components/ClaudeSignIn.tsx
+++ b/frontend/src/components/ClaudeSignIn.tsx
@@ -254,7 +254,7 @@ export const ClaudeSignIn: React.FC<{ onSignedIn: () => void; focusRequest?: num
</button>
</div>
<p className="text-[10.5px] text-zinc-500 leading-snug">
- Why a code? kwnt runs the sign-in in the background, so claude.ai can’t hand the login back by itself. The code works once and isn’t kept.
+ Why a code? The server runs the sign-in in the background, so claude.ai can’t hand the login back by itself. The code works once and isn’t kept.
</p>
<p className="sr-only" role="status">
{state === 'verifying' ? 'Checking the code with Claude…' : ''}
diff --git a/frontend/src/components/EngineAccounts.tsx b/frontend/src/components/EngineAccounts.tsx
index 60943d89..2c925f09 100644
--- a/frontend/src/components/EngineAccounts.tsx
+++ b/frontend/src/components/EngineAccounts.tsx
@@ -215,7 +215,7 @@ const AddAccountForm: React.FC<{
) : (
<div>
<label htmlFor={`${id}-home`} className="block text-[11px] font-medium text-zinc-400 mb-1">
- Config folder <span className="text-zinc-600 font-normal">· optional; leave empty and kwnt keeps its own</span>
+ Config folder <span className="text-zinc-600 font-normal">· optional; leave empty and the app keeps its own</span>
</label>
<input id={`${id}-home`} value={homeDir} onChange={(e) => setHomeDir(e.target.value)} placeholder="/home/me/.claude-work" className={`${input} font-mono`} />
<p className="mt-1 text-[11px] text-zinc-500">Next, use “Sign in” on the new account to log it in.</p>
@@ -704,7 +704,7 @@ const LoginPanel: React.FC<{
)}
{login.needs_code && (
<p className="text-[10.5px] text-zinc-500 leading-snug">
- Why a code? kwnt runs the sign-in in the background, so the page can’t hand the login back by itself. The code works once and isn’t kept.
+ Why a code? The server runs the sign-in in the background, so the page can’t hand the login back by itself. The code works once and isn’t kept.
</p>
)}
<p className="flex items-center gap-1.5 text-[10px] text-zinc-500">
diff --git a/frontend/src/components/EnginesPanel.tsx b/frontend/src/components/EnginesPanel.tsx
index 2b6c05bc..7680ecbe 100644
--- a/frontend/src/components/EnginesPanel.tsx
+++ b/frontend/src/components/EnginesPanel.tsx
@@ -95,7 +95,7 @@ export const EngineCard: React.FC<{
role="switch"
aria-checked={!off}
aria-labelledby={labelId}
- title={off ? 'Off: kwnt never uses it' : 'On: kwnt may use it'}
+ title={off ? 'Off: bots never use it' : 'On: bots may use it'}
onClick={() => {
playSfx('click');
onToggle(off);
diff --git a/frontend/src/components/Instructions.tsx b/frontend/src/components/Instructions.tsx
index ceec6c6a..11d74d1b 100644
--- a/frontend/src/components/Instructions.tsx
+++ b/frontend/src/components/Instructions.tsx
@@ -31,7 +31,7 @@ export const InstructionsField: React.FC<{
onChange={(e) => onChange(e.target.value)}
aria-describedby={`${id}-hint ${id}-count`}
aria-invalid={over}
- placeholder="e.g. Answer in British English. Our repo is kwant-rust; never push to main."
+ placeholder="e.g. Answer in British English. Our repo is acme-web; never push to main."
className={`w-full bg-zinc-950 border rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:outline-none transition-colors resize-y ${
over ? 'border-rose-500/70 focus:border-rose-500' : 'border-zinc-800 focus:border-sky-500'
}`}
diff --git a/frontend/src/components/LayaStatus.tsx b/frontend/src/components/LayaStatus.tsx
index dab19f67..de28599e 100644
--- a/frontend/src/components/LayaStatus.tsx
+++ b/frontend/src/components/LayaStatus.tsx
@@ -75,7 +75,7 @@ export const LayaStatusRow: React.FC = () => {
{laya && (
<p className="mt-0.5 text-[11px] text-zinc-500 break-all">
{laya.url}
- {laya.managed ? ' (started by Kwant)' : ''}
+ {laya.managed ? ' (started by the app)' : ''}
{laya.detail ? ` · ${laya.detail}` : ''}
</p>
)}
diff --git a/frontend/src/components/McpServersModal.tsx b/frontend/src/components/McpServersModal.tsx
index 21418134..200b6492 100644
--- a/frontend/src/components/McpServersModal.tsx
+++ b/frontend/src/components/McpServersModal.tsx
@@ -65,7 +65,7 @@ const inputCls =
'w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors';
const TRANSPORTS: Array<{ id: McpTransport; title: string; blurb: string; icon: React.ReactNode }> = [
- { id: 'stdio', title: 'Runs on this machine', blurb: 'kwnt starts a command, like npx or uvx', icon: <Terminal size={18} /> },
+ { id: 'stdio', title: 'Runs on this machine', blurb: 'The server starts a command, like npx or uvx', icon: <Terminal size={18} /> },
{ id: 'http', title: 'Connects to a URL', blurb: 'A server already running somewhere else', icon: <Globe size={18} /> },
];
@@ -326,7 +326,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
setLoadError(null);
return list;
} catch (err) {
- setLoadError(err instanceof Error ? err.message : 'Could not reach kwnt.');
+ setLoadError(err instanceof Error ? err.message : 'Could not reach the server.');
setServers((prev) => prev ?? []);
return null;
}
@@ -355,7 +355,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
const res = await fetch(`/api/mcp/servers/${id}/test`, { method: 'POST' });
result = res.ok ? await res.json() : { ok: false, error: await readError(res) };
} catch {
- result = { ok: false, error: 'Could not reach kwnt.' };
+ result = { ok: false, error: 'Could not reach the server.' };
}
setTesting((t) => ({ ...t, [id]: false }));
setTestResults((r) => ({ ...r, [id]: result }));
@@ -456,12 +456,12 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
});
if (!res.ok) throw new Error(await readError(res));
const body = await res.json();
- if (typeof body?.authorize_url !== 'string' || !/^https?:\/\//.test(body.authorize_url)) throw new Error('kwnt didn’t return a sign-in page.');
+ if (typeof body?.authorize_url !== 'string' || !/^https?:\/\//.test(body.authorize_url)) throw new Error('The server didn’t return a sign-in page.');
url = body.authorize_url;
} catch (err) {
popup?.close();
setConnecting(null);
- setOauthErrors((e) => ({ ...e, [server.id]: err instanceof Error ? err.message : 'Could not reach kwnt.' }));
+ setOauthErrors((e) => ({ ...e, [server.id]: err instanceof Error ? err.message : 'Could not reach the server.' }));
playSfx('alert');
return;
}
@@ -489,7 +489,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
setConfirmDisconnect(null);
const res = await fetch(`/api/mcp/servers/${server.id}/oauth`, { method: 'DELETE' }).catch(() => null);
if (!res || !res.ok) {
- setLoadError(res ? await readError(res) : 'Could not reach kwnt.');
+ setLoadError(res ? await readError(res) : 'Could not reach the server.');
return;
}
setTestResults(({ [server.id]: _, ...rest }) => rest);
@@ -552,7 +552,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
setStatus(saved.id, null);
runTest(saved.id);
} catch {
- setFormError('Could not reach kwnt.');
+ setFormError('Could not reach the server.');
} finally {
setSaving(false);
}
@@ -563,7 +563,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
const res = await fetch(`/api/mcp/servers/${server.id}`, { method: 'DELETE' }).catch(() => null);
setConfirmDelete(null);
if (!res || !res.ok) {
- setLoadError(res ? await readError(res) : 'Could not reach kwnt.');
+ setLoadError(res ? await readError(res) : 'Could not reach the server.');
return;
}
setStatus(server.id, null);
@@ -578,7 +578,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ...formToPayload(serverToForm(server)), enabled: !server.enabled }),
}).catch(() => null);
- if (!res || !res.ok) setLoadError(res ? await readError(res) : 'Could not reach kwnt.');
+ if (!res || !res.ok) setLoadError(res ? await readError(res) : 'Could not reach the server.');
refresh();
};
@@ -953,7 +953,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
</div>
<div className="flex items-start gap-2 p-2.5 rounded-lg bg-amber-500/5 border border-amber-500/20 text-[11px] text-amber-200/90">
<ShieldAlert size={14} className="flex-shrink-0 mt-px text-amber-400" />
- <span>This command runs on the kwnt machine with your user’s permissions. Only add servers you trust.</span>
+ <span>This command runs on the server’s machine with your user’s permissions. Only add servers you trust.</span>
</div>
<div>
<p className="text-xs font-medium text-zinc-400 mb-1">
diff --git a/frontend/src/components/ModelPicker.tsx b/frontend/src/components/ModelPicker.tsx
index 7382a1cf..02d3530b 100644
--- a/frontend/src/components/ModelPicker.tsx
+++ b/frontend/src/components/ModelPicker.tsx
@@ -183,7 +183,7 @@ const PickHint: React.FC<{ id: string; health: ReturnType<typeof pickHealth>; on
return (
<p id={id} role="status" className="flex items-start gap-1.5 text-[11px] text-amber-300">
<AlertTriangle size={12} className="mt-px shrink-0" />
- “{health.value}” isn't a model kwnt knows. Pick an engine above.
+ “{health.value}” isn't a model the app knows. Pick an engine above.
</p>
);
}
diff --git a/frontend/src/components/ModernApprovalCard.tsx b/frontend/src/components/ModernApprovalCard.tsx
index b6203dfc..2834136d 100644
--- a/frontend/src/components/ModernApprovalCard.tsx
+++ b/frontend/src/components/ModernApprovalCard.tsx
@@ -123,7 +123,7 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({
{!shell && (
<button
onClick={() => handleDecision('always_allow')}
- title={mcp ? 'Allow this tool for this bot until Kwant restarts' : undefined}
+ title={mcp ? 'Allow this tool for this bot until the app restarts' : undefined}
className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors shadow-sm"
>
<CheckCheck size={14} />
diff --git a/frontend/src/components/SandboxViewer.tsx b/frontend/src/components/SandboxViewer.tsx
index ebedd1c0..690fd98f 100644
--- a/frontend/src/components/SandboxViewer.tsx
+++ b/frontend/src/components/SandboxViewer.tsx
@@ -143,7 +143,7 @@ export const SandboxViewer: React.FC<{ teamId: string }> = ({ teamId }) => {
}, [teamId, applyUrl]);
useEffect(() => {
- document.title = `${title || url || 'Sandbox browser'} · Kwant browser`;
+ document.title = `${title || url || 'Sandbox browser'} · kwant bots browser`;
}, [title, url]);
const toViewport = (clientX: number, clientY: number) => {
diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsx
index 9717a1fb..1dbcfff7 100644
--- a/frontend/src/components/SettingsModal.tsx
+++ b/frontend/src/components/SettingsModal.tsx
@@ -421,7 +421,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t
<div className="flex-1">
<p id="browser-notify-label" className="text-xs font-medium text-zinc-200">Notify me on this computer</p>
<p className="text-[11px] text-zinc-500">
- Only while Kwant is in a background tab. Each notification names its space.
+ Only while this tab is in the background. Each notification names its space.
{permission === 'denied' && <span className="text-amber-300"> Blocked by your browser; allow notifications for this site in its settings.</span>}
{permission === 'unsupported' && <span className="text-amber-300"> This browser can't show notifications.</span>}
</p>
@@ -480,7 +480,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t
? 'A webhook is saved. Type a new URL to replace it.'
: settings?.notify_webhook_url === MASK && !webhookUrl.trim()
? 'Saving will remove the webhook.'
- : 'https only. Kwant posts a short title and line, never message text.')}
+ : 'https only. Each post has a short title and line, never message text.')}
</p>
</div>
diff --git a/frontend/src/components/Spaces.tsx b/frontend/src/components/Spaces.tsx
index f0100e8d..b62eaffb 100644
--- a/frontend/src/components/Spaces.tsx
+++ b/frontend/src/components/Spaces.tsx
@@ -426,10 +426,12 @@ export const ArchivedSpacesModal: React.FC<{ onClose: () => void; onRestored: (s
<SpaceTile space={s} size={32} />
<div className="flex-1 min-w-0">
<p className="text-xs font-medium text-zinc-200 truncate">{s.name}</p>
- <p className="text-[11px] text-zinc-500 truncate">
- {spaceSummary(s.counts)}
- {s.paused_routines ? ` · ${s.paused_routines} ${s.paused_routines === 1 ? 'routine' : 'routines'} paused` : ''}
- </p>
+ <p className="text-[11px] text-zinc-500">{spaceSummary(s.counts)}</p>
+ {s.paused_routines ? (
+ <p className="text-[11px] text-amber-300/80">
+ {s.paused_routines} {s.paused_routines === 1 ? 'routine' : 'routines'} paused
+ </p>
+ ) : null}
</div>
<button
type="button"
diff --git a/frontend/src/computerMode.ts b/frontend/src/computerMode.ts
index 8c3c3093..926ac3d4 100644
--- a/frontend/src/computerMode.ts
+++ b/frontend/src/computerMode.ts
@@ -14,7 +14,7 @@ export const COMPUTER_MODES: { id: ComputerMode; label: string; short: string; h
{ id: 'vm', label: 'VM (isolated)', short: 'VM', hint: 'Runs in Docker containers, isolated from your files.' },
];
-export const LOCAL_BROWSER_NOTE = 'Kwant is using a Chrome window on your computer.';
+export const LOCAL_BROWSER_NOTE = 'Your bots are using a Chrome window on your computer.';
/** Fired on window after a successful switch so every open control shows the new mode. */
export const COMPUTER_MODE_EVENT = 'kwnt:computer-mode';
diff --git a/frontend/src/mcp.ts b/frontend/src/mcp.ts
index 57caaa10..c8a5136d 100644
--- a/frontend/src/mcp.ts
+++ b/frontend/src/mcp.ts
@@ -353,7 +353,7 @@ export const validateMcpForm = (form: McpFormState): string | null => {
if (!name) return 'Give the server a short name.';
if (!NAME_RE.test(name) || name.includes('__'))
return 'Use letters, numbers, - or _ for the name (no spaces, up to 48 characters).';
- if (name.toLowerCase() === 'kwnt') return '"kwnt" is reserved, pick another name.';
+ if (name.toLowerCase() === 'kwnt') return 'That name is reserved for the built-in tools, pick another.';
if (form.transport === 'stdio') {
if (splitCommandLine(form.commandLine).length === 0) return 'Add the command that starts the server.';
const bad = form.env.find((r) => r.key.trim() && !ENV_KEY_RE.test(r.key.trim()));
diff --git a/frontend/tests/computerMode.test.mjs b/frontend/tests/computerMode.test.mjs
index 82fbc0a1..73ee83b7 100644
--- a/frontend/tests/computerMode.test.mjs
+++ b/frontend/tests/computerMode.test.mjs
@@ -115,5 +115,5 @@ test('chip names the current mode and offers the other one', () => {
});
test('local note text', () => {
- assert.match(m.renderToStaticMarkup(m.createElement(m.LocalBrowserNote)), /Kwant is using a Chrome window on your computer\./);
+ assert.match(m.renderToStaticMarkup(m.createElement(m.LocalBrowserNote)), /Your bots are using a Chrome window on your computer\./);
});
diff --git a/frontend/tests/wording.test.mjs b/frontend/tests/wording.test.mjs
new file mode 100644
index 00000000..fbb62807
--- /dev/null
+++ b/frontend/tests/wording.test.mjs
@@ -0,0 +1,70 @@
+// Wording (Spaces IA §5): visible text says "kwant bots" in headings and "bot" in sentences,
+// never a bare "kwant", "kwnt" or "agent". Scans string literals and JSX text in src/ with the
+// TypeScript parser; comments, imports, ids, keys and other single lowercase words are skipped.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { readdirSync, readFileSync } from 'node:fs';
+import { join, relative } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import ts from 'typescript';
+
+const root = fileURLToPath(new URL('..', import.meta.url));
+const src = join(root, 'src');
+
+const files = (dir) =>
+ readdirSync(dir, { withFileTypes: true }).flatMap((e) =>
+ e.isDirectory() ? files(join(dir, e.name)) : /\.tsx?$/.test(e.name) && !e.name.endsWith('.d.ts') ? [join(dir, e.name)] : [],
+ );
+
+const BAD = /\b(kwants?|kwnt|agents?)\b/i;
+// The product term (headings, tagline) and the CLI commands shown on the sign-in screen.
+const ALLOWED = /\bkwant bots?\b|\b(?:exec kwnt )?kwnt token\b/gi;
+
+/** Whether a literal reads like text a person sees (a sentence, or a capitalised word). */
+const looksVisible = (text, node) => {
+ const p = node.parent;
+ if (ts.isJsxText(node)) return true;
+ if (p && ts.isJsxAttribute(p)) return /^(placeholder|title|aria-label|alt|label|description|hint)$/.test(p.name.getText());
+ if (p && (ts.isImportDeclaration(p) || ts.isExportDeclaration(p) || ts.isLiteralTypeNode(p))) return false;
+ if (p && ts.isPropertyAssignment(p) && p.name === node) return false;
+ if (p && ts.isElementAccessExpression(p)) return false;
+ // console.* and test-only ids
+ for (let a = p; a; a = a.parent) {
+ if (ts.isCallExpression(a) && /^console\./.test(a.expression.getText())) return false;
+ if (ts.isCallExpression(a) && /^(localStorage|sessionStorage)\./.test(a.expression.getText())) return false;
+ }
+ return /\s/.test(text.trim()) || /^[A-Z]/.test(text);
+};
+
+export function findBareWording() {
+ const hits = [];
+ for (const file of files(src)) {
+ const text = readFileSync(file, 'utf8');
+ const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, file.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
+ const visit = (node) => {
+ let s = null;
+ if (ts.isJsxText(node)) s = node.text;
+ else if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) s = node.text;
+ else if (ts.isTemplateHead(node) || ts.isTemplateMiddle(node) || ts.isTemplateTail(node)) s = node.text;
+ if (s !== null) {
+ const stripped = s.replace(ALLOWED, '');
+ // URLs, paths, event names and storage keys (kwnt:..., kwant.x) are not prose.
+ const prose = stripped.replace(/\S*(?:[:./_#=]\w)\S*/g, (w) => (/^[A-Za-z]+[.,;:!?)]?$/.test(w) ? w : ''));
+ const at = ts.isTemplateLiteralToken(node) ? node.parent.parent ?? node : node;
+ if (BAD.test(prose) && looksVisible(s, at)) {
+ const { line } = sf.getLineAndCharacterOfPosition(node.getStart());
+ hits.push(`${relative(root, file)}:${line + 1}: ${s.trim().replace(/\s+/g, ' ').slice(0, 120)}`);
+ }
+ }
+ ts.forEachChild(node, visit);
+ };
+ visit(sf);
+ }
+ return hits;
+}
+
+test('no visible text says a bare "kwant", "kwnt" or "agent"', () => {
+ assert.deepEqual(findBareWording(), []);
+});
+
+if (process.argv.includes('--list')) console.log(findBareWording().join('\n'));