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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
0.7.1: production floor card reads as a sentence (no more "This is runs …") (#335)
Oleksandr Ivanchenko6fdc562822ca
diff --git a/frontend/src/components/dev/ProdFloorCard.tsx b/frontend/src/components/dev/ProdFloorCard.tsxindex 2ffb4478..d7feec1d 100644--- a/frontend/src/components/dev/ProdFloorCard.tsx+++ b/frontend/src/components/dev/ProdFloorCard.tsx@@ -2,7 +2,7 @@ import React, { useEffect, useReducer, useRef, useState } from 'react';import { Database, Loader2, ShieldAlert, Target, X, Check } from 'lucide-react';import type { BackupResult, ProdFloor } from '../../dev/types';import { parseBackupResult } from '../../dev/types';-import { allowReady, floorHeader, floorReducer, floorSubline, floorView, initialFloorUi, type RowTone } from '../../dev/logic';+import { allowReady, floorHeader, floorReducer, floorSentence, floorSubline, floorView, initialFloorUi, type RowTone } from '../../dev/logic';export type FloorDecision = 'allow_once' | 'deny';@@ -72,6 +72,7 @@ export const ProdFloorCard: React.FC<ProdFloorCardProps> = ({ id, floor, bot, coconst allowLabel = isDeploy ? 'Allow this deploy' : 'Allow';const off = disabled || view.busy;const headingId = `floor-${id}-h`;+ const why = floorSentence(floor.why);const mainRef = useRef<HTMLButtonElement>(null);const cardRef = useRef<HTMLDivElement>(null);@@ -133,7 +134,7 @@ export const ProdFloorCard: React.FC<ProdFloorCardProps> = ({ id, floor, bot, co<p className="mb-3 text-[11px] text-zinc-400 sm:pl-6">{floorSubline(floor)}</p><div className="mb-3 space-y-2 rounded-lg border border-zinc-800 bg-zinc-900/90 p-3 text-xs">- {floor.why && <p className="text-zinc-300 [overflow-wrap:anywhere]">This is {floor.why}.</p>}+ {why && <p className="text-zinc-300 [overflow-wrap:anywhere]">{why}</p>}<pre className="max-h-64 overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-zinc-800 bg-zinc-950/70 p-2 font-mono text-[12px] text-zinc-100">{command || '(empty command)'}</pre>diff --git a/frontend/src/dev/fixtures.ts b/frontend/src/dev/fixtures.tsindex d19c8828..1c31b39e 100644--- a/frontend/src/dev/fixtures.ts+++ b/frontend/src/dev/fixtures.ts@@ -143,7 +143,7 @@ const floorApproval = (id: string, bot: string, command: string, prod_floor: Rec});export const FLOOR_DEPLOY_FRESH = floorApproval('ap_1', 'Pixel', './scripts/deploy_test.sh 4049325', {- kind: 'deploy', why: 'a deploy to the test server', needs_backup: false,+ kind: 'deploy', why: 'This command runs ./scripts/deploy_test.sh, a deploy script', needs_backup: false,blast: [['Where', 'kwant.jumpin.games · production'], ['What changes', 'App 51f9141 → 4049325 · 1 change: #290 sidebar hover'],['Downtime', 'About 20 s while the container restarts'], ['Data', 'Nothing deleted. Database and uploads stay.'],['If it fails', 'Health check fails → it goes back to 51f9141 on its own']],@@ -151,13 +151,13 @@ export const FLOOR_DEPLOY_FRESH = floorApproval('ap_1', 'Pixel', './scripts/depl});export const FLOOR_DESTRUCTIVE = floorApproval('ap_2', 'Lin', 'sqlite3 data/kwant.db "DROP TABLE dev_cards_v0;"', {- kind: 'destructive', why: 'a database command that runs DROP TABLE', needs_backup: true,+ kind: 'destructive', why: 'This database command runs DROP TABLE', needs_backup: true,blast: [['Where', 'kwant.jumpin.games database · production'], ['Data', "Table dev_cards_v0 · 1,284 rows. Can't be undone without a backup."]],backup: { state: 'old', age_s: 3 * 3600, bytes: 412_000_000, path: '/home/demo/backups/backup-old.tgz', error: null },}, '~/work/kwant');export const FLOOR_MIGRATION = floorApproval('ap_3', 'Vega', './scripts/deploy_test.sh 7c41e0a', {- kind: 'deploy_migration', why: 'a deploy that changes the database', needs_backup: true,+ kind: 'deploy_migration', why: 'This command runs ./scripts/deploy_test.sh, a deploy script', needs_backup: true,blast: [['Where', 'kwant.jumpin.games · production'], ['What changes', 'App 4049325 → 7c41e0a · 1 change: #301 risk reasons'],['Migration', '0031_landed_risk.sql · adds 1 column to landed_cards · has a way back'],['If it fails', 'The app goes back on its own. The database goes back only from a backup.']],@@ -165,26 +165,26 @@ export const FLOOR_MIGRATION = floorApproval('ap_3', 'Vega', './scripts/deploy_t});export const FLOOR_DEPLOY_OLD = floorApproval('ap_4', 'Iris', './scripts/deploy_test.sh 9a2d5f3', {- kind: 'deploy', why: 'a deploy to the test server', needs_backup: false,+ kind: 'deploy', why: 'This command runs ./scripts/deploy_test.sh, a deploy script', needs_backup: false,blast: [['Where', 'kwant.jumpin.games · production'], ['What changes', 'App 7c41e0a → 9a2d5f3 · 1 change: #292 reactions'],['Data', 'No migration. Database and uploads stay.']],backup: { state: 'old', age_s: 3 * 3600, bytes: 412_000_000, path: null, error: null },});export const FLOOR_PAGES = floorApproval('ap_5', 'Pixel', 'npx wrangler pages deploy site/dist', {- kind: 'deploy', why: 'a Cloudflare Pages deploy', needs_backup: false,+ kind: 'deploy', why: 'wrangler pages ships to Cloudflare', needs_backup: false,blast: [['Where', 'kwant.si · production'], ['Key used', 'Cloudflare · production']],backup: { state: 'no_data', age_s: null, bytes: null, path: null, error: null },});export const FLOOR_NO_COMMAND = floorApproval('ap_6', 'Lin', 'psql -c "DELETE FROM sessions"', {- kind: 'destructive', why: 'a database command that runs DELETE without WHERE', needs_backup: true,+ kind: 'destructive', why: 'This database command runs DELETE FROM with no WHERE', needs_backup: true,blast: [['Where', 'db.example.com · production']],backup: { state: 'no_command', age_s: null, bytes: null, path: null, error: null },});export const FLOOR_FAILED = floorApproval('ap_7', 'Lin', 'sqlite3 data/kwant.db "DROP TABLE old_x;"', {- kind: 'destructive', why: 'a database command that runs DROP TABLE', needs_backup: true,+ kind: 'destructive', why: 'This database command runs DROP TABLE', needs_backup: true,blast: [['Where', 'kwant.jumpin.games database · production']],backup: { state: 'failed', age_s: null, bytes: null, path: null, error: 'disk full' },});diff --git a/frontend/src/dev/logic.ts b/frontend/src/dev/logic.tsindex 502d8d02..bae06a3f 100644--- a/frontend/src/dev/logic.ts+++ b/frontend/src/dev/logic.ts@@ -259,6 +259,17 @@ export function floorHeader(floor: ProdFloor, bot: string): string {return `Production floor: ${bot} wants to ${what[floor.kind]}`;}+/** Leads of the clauses 0.7.0 sent ("runs deploy.sh, a deploy script", "a force-push to main"):+ * a card saved before 0.7.1 still gets a capital. A command name ("git push …") stays as typed. */+const OLD_LEADS = /^(a|an|runs|starts)\b/;++/** `why` as its own sentence: the server sends one with its own subject and no period (0.7.1). */+export function floorSentence(why: string): string {+ const t = why.trim().replace(/[.\s]+$/, '');+ if (!t) return '';+ return `${OLD_LEADS.test(t) ? t[0].toUpperCase() + t.slice(1) : t}.`;+}+export function floorSubline(floor: ProdFloor): string {if (floor.kind === 'deploy_migration') return 'This deploy changes the database, so it counts as destructive: it needs a backup from the last 10 minutes first.';if (floor.kind === 'destructive') return 'Destructive commands need a backup from the last 10 minutes first.';diff --git a/frontend/tests/devCards.test.mjs b/frontend/tests/devCards.test.mjsindex 5d7481c2..d913a92e 100644--- a/frontend/tests/devCards.test.mjs+++ b/frontend/tests/devCards.test.mjs@@ -665,3 +665,27 @@ test('S4: each finding says its severity as a word, not only by colour', () => {assert.deepEqual(words.map(([s, w]) => [s, w]), [['high', 'High'], ['medium', 'Medium'], ['low', 'Low']]);for (const [, , cls] of words) assert.match(cls, /text-\[10px\] font-semibold uppercase tracking-wide text-(rose|amber|teal)-300/);});++test('the floor card shows why as its own sentence, never "This is runs …" (0.7.1)', () => {+ // What the server sends since 0.7.1: a subject of its own, no period+ assert.equal(m.floorSentence('This command runs deploy.sh, a deploy script'), 'This command runs deploy.sh, a deploy script.');+ assert.equal(m.floorSentence('fly deploy ships the app'), 'fly deploy ships the app.', 'a command name keeps its case');+ assert.equal(m.floorSentence('git push sends new commits to main. '), 'git push sends new commits to main.', 'one period');+ // Cards saved by 0.7.0 still read as a sentence+ assert.equal(m.floorSentence('runs deploy.sh, a deploy script'), 'Runs deploy.sh, a deploy script.');+ assert.equal(m.floorSentence('a force-push to main'), 'A force-push to main.');+ assert.equal(m.floorSentence(' '), '');+ const ap = (why) => ({ ...fx.FLOOR_DEPLOY_FRESH, details: { ...fx.FLOOR_DEPLOY_FRESH.details, prod_floor: { ...fx.FLOOR_DEPLOY_FRESH.details.prod_floor, why } } });+ for (const [why, want] of [+ ['This command runs deploy.sh, a deploy script', 'This command runs deploy.sh, a deploy script.'],+ ['vercel ships the app to production', 'vercel ships the app to production.'],+ ]) {+ const out = html(m.ModernApprovalCard, { approval: ap(why), onResolve() {} });+ assert.ok(out.includes(`>${want}</p>`), `${why}: ${out}`);+ assert.doesNotMatch(out, /This is /);+ }+ assert.doesNotMatch(html(m.ModernApprovalCard, { approval: ap(''), onResolve() {} }), /<p class="text-zinc-300 \[overflow-wrap:anywhere\]">/, 'no empty line');+ for (const f of [fx.FLOOR_DEPLOY_FRESH, fx.FLOOR_DESTRUCTIVE, fx.FLOOR_MIGRATION, fx.FLOOR_PAGES, fx.FLOOR_NO_COMMAND]) {+ assert.doesNotMatch(html(m.ModernApprovalCard, { approval: f, onResolve() {} }), /This is /);+ }+});diff --git a/src/mcp/prod_floor.rs b/src/mcp/prod_floor.rsindex 0ab81bf5..e8e14e9d 100644--- a/src/mcp/prod_floor.rs+++ b/src/mcp/prod_floor.rs@@ -50,6 +50,9 @@ impl FloorKind {#[derive(Debug, Clone, PartialEq, Eq, Serialize)]pub struct Floor {pub kind: FloorKind,+ /// One sentence with its own subject and no closing period: a command or tool name+ /// ("git push sends new commits to main") or a capitalised "This …" ("This command runs+ /// deploy.sh, a deploy script"). The card shows it as its own sentence.pub why: String,/// `(label, value)`, labels from: Where, What changes, Downtime, Data, Key used, Migration,/// If it fails. Serialised as `[label, value]` pairs.@@ -245,7 +248,7 @@ fn mcp_reason(server: &str, tool: &str, args: &Value, ctx: &DevCtx) -> Option<Flcontinue;}if w.iter().any(|x| DEPLOY_TOOL_WORDS.contains(&x.as_str())) && (infra || w.iter().any(|x| x == "deploy" || x == "redeploy" || x == "rollout")) {- add(ctx.deploy(format!("{slug} deploys")).row("Where", server.to_string()));+ add(ctx.deploy(format!("{slug} starts a deploy")).row("Where", server.to_string()));}if infra && w.iter().any(|x| DESTROY_WORDS.contains(&x.as_str())) {add(Floor::new(FloorKind::Destructive, format!("{slug} deletes or rebuilds something on {server}")).row("Data", "Can't be undone without a backup."));@@ -392,7 +395,7 @@ fn shell_reason_at(command: &str, ctx: &DevCtx, depth: usize, over_ssh: bool) ->// SQL through a database client anywhere in the commandif DB_CLIENTS.iter().any(|c| lower.split(|ch: char| !(ch.is_ascii_alphanumeric() || ch == '-' || ch == '_')).any(|w| w == *c)) {if let Some(why) = destructive_sql(command) {- add(Floor::new(FloorKind::Destructive, format!("a database command that runs {why}")).row("Data", "Can't be undone without a backup."));+ add(Floor::new(FloorKind::Destructive, format!("This database command runs {why}")).row("Data", "Can't be undone without a backup."));}}let mut ssh_host: Option<String> = None;@@ -624,7 +627,7 @@ fn ssh_target<'a>(args: &[&'a str]) -> Option<(String, Vec<&'a str>)> {fn script_reason(script: &str, ctx: &DevCtx) -> Option<Floor> {let name = script.rsplit('/').next().unwrap_or(script).to_lowercase();let ws = words(&name);- ws.iter().any(|w| SHIP_WORDS.contains(&w.as_str())).then(|| ctx.deploy(format!("runs {script}, a deploy script")))+ ws.iter().any(|w| SHIP_WORDS.contains(&w.as_str())).then(|| ctx.deploy(format!("This command runs {script}, a deploy script")))}fn has(args: &[&str], x: &str) -> bool {@@ -657,10 +660,10 @@ fn program_reason(program: &str, a: &[&str], ctx: &DevCtx, env_prod: bool, over_),("workflow", "run") => {let name = pos.get(2).copied().unwrap_or("");- ship_name(name).then(|| ctx.deploy(format!("starts the {name} workflow")))+ ship_name(name).then(|| ctx.deploy(format!("gh workflow run starts the {name} workflow")))}("release", "create") => Some(ctx.deploy("gh release create makes a release, which can start a deploy".into())),- ("release", "delete") | ("repo", "delete") => Some(destroy(format!("gh {sub} delete removes it from GitHub"))),+ ("release", "delete") | ("repo", "delete") => Some(destroy(format!("gh {sub} delete removes the {sub} from GitHub"))),_ => None,},"fly" | "flyctl" => {@@ -668,7 +671,13 @@ fn program_reason(program: &str, a: &[&str], ctx: &DevCtx, env_prod: bool, over_let f = match (sub, sub2) {("deploy", _) | ("releases", "rollback") => Some(ctx.deploy(format!("{program} deploy ships the app"))),("apps", "destroy") | ("volumes", "destroy") | ("volumes", "delete") | ("destroy", _) | ("postgres", "destroy") => {- Some(destroy(format!("{program} {sub} {sub2} destroys it")))+ let what = match sub {+ "volumes" => "a volume",+ "postgres" => "a Postgres cluster",+ _ => "the app",+ };+ let cmd = [program, sub, sub2].iter().filter(|w| !w.is_empty()).copied().collect::<Vec<_>>().join(" ");+ Some(destroy(format!("{cmd} deletes {what}")))}("machine", "destroy") | ("machines", "destroy") => Some(destroy(format!("{program} {sub} destroy removes a machine"))),("secrets", "set") | ("secrets", "unset") => Some(Floor::new(FloorKind::Deploy, format!("{program} secrets {sub2} restarts the app"))),@@ -704,7 +713,7 @@ fn program_reason(program: &str, a: &[&str], ctx: &DevCtx, env_prod: bool, over_"docker" | "docker-compose" | "podman" => docker_reason(program, a, ctx, over_ssh),"kubectl" | "oc" => match sub {"apply" | "rollout" | "set" | "replace" | "patch" | "scale" | "create" => Some(ctx.deploy(format!("{program} {sub} changes the cluster"))),- "delete" | "drain" => Some(destroy(format!("{program} {sub} removes it from the cluster"))),+ "delete" | "drain" => Some(destroy(format!("{program} {sub} removes resources from the cluster"))),_ => None,},"helm" => match sub {@@ -722,7 +731,7 @@ fn program_reason(program: &str, a: &[&str], ctx: &DevCtx, env_prod: bool, over_"destroy" => Some(destroy("pulumi destroy removes infrastructure".into())),_ => None,},- "vercel" => (has(a, "--prod") || sub == "promote" || sub == "rollback" || (sub == "deploy" && has(a, "--prod"))).then(|| ctx.deploy("vercel ships to production".into())),+ "vercel" => (has(a, "--prod") || sub == "promote" || sub == "rollback" || (sub == "deploy" && has(a, "--prod"))).then(|| ctx.deploy("vercel ships the app to production".into())),"netlify" => (sub == "deploy" && has(a, "--prod")).then(|| ctx.deploy("netlify deploy --prod ships the site".into())),"firebase" => (sub == "deploy").then(|| ctx.deploy("firebase deploy ships the project".into())),"railway" => (sub == "up" || sub == "redeploy").then(|| ctx.deploy(format!("railway {sub} ships the app"))),@@ -738,13 +747,13 @@ fn program_reason(program: &str, a: &[&str], ctx: &DevCtx, env_prod: bool, over_if a.contains(&"deploy") || a.contains(&"update-service") || a.contains(&"update-function-code") {Some(ctx.deploy("aws … changes a running service".into()))} else if (sub == "s3" && (sub2 == "rb" || (sub2 == "rm" && has(a, "--recursive")))) || a.iter().any(|x| x.starts_with("delete-") || x.starts_with("terminate-")) {- Some(destroy("an aws command that deletes resources or data".into()))+ Some(destroy("This aws command deletes resources or data".into()))} else {None}}"gsutil" => ((sub == "rm" && (has(a, "-r") || has(a, "-rf"))) || sub == "rb").then(|| destroy("gsutil deletes a bucket or its objects".into())),- "make" | "just" | "task" | "mage" | "rake" => pos.iter().find(|t| ship_name(t)).map(|t| ctx.deploy(format!("{program} {t}"))),+ "make" | "just" | "task" | "mage" | "rake" => pos.iter().find(|t| ship_name(t)).map(|t| ctx.deploy(format!("{program} {t} runs a deploy step"))),"npm" | "yarn" | "pnpm" | "bun" => {let script = if sub == "run" || sub == "run-script" { sub2 } else { sub };ship_name(script).then(|| ctx.deploy(format!("{program} runs the {script} script")))@@ -1013,9 +1022,9 @@ fn git_reason(a: &[&str], ctx: &DevCtx) -> Option<Floor> {} else if tag {add(ctx.deploy(format!("git push sends the tag {shown}, which can start a release")));} else if protected && force {- add(Floor::new(FloorKind::ForcePush, format!("a force-push to {shown}")).row("What changes", format!("{shown} is rewritten; commits others have can be lost.")));+ add(Floor::new(FloorKind::ForcePush, format!("This force-push rewrites {shown}")).row("What changes", format!("{shown} is rewritten; commits others have can be lost.")));} else if protected {- add(Floor::new(FloorKind::PushMain, format!("git push to {shown}")).row("What changes", format!("New commits land on {shown}.")));+ add(Floor::new(FloorKind::PushMain, format!("git push sends new commits to {shown}")).row("What changes", format!("New commits land on {shown}.")));}}best@@ -1511,4 +1520,108 @@ mod tests {assert_eq!(kind(cmd, &c), want, "{cmd}");}}++ /// The card shows `why` as its own sentence (it read "This is runs deploy.sh, a deploy+ /// script." in 0.7.0). Every constructor: a subject of its own, a verb, no closing period.+ #[test]+ fn every_why_reads_as_a_sentence_with_its_own_subject() {+ const BARE: &[&str] = &["a", "an", "the", "runs", "starts", "changes", "deploys", "ships", "makes", "removes", "pushes", "deletes", "destroys", "sends", "rewrites"];+ const VERBS: &[&str] = &[+ "runs", "starts", "changes", "deploys", "ships", "makes", "removes", "pushes", "deletes", "destroys", "sends", "rewrites", "lands", "goes", "restarts",+ "empties", "writes", "formats", "migrates", "stops",+ ];+ let check = |input: &str, f: Option<Floor>| {+ let f = f.unwrap_or_else(|| panic!("{input}: no floor"));+ let why = f.why.as_str();+ let ws: Vec<&str> = why.split(|c: char| c.is_whitespace() || c == ',').filter(|w| !w.is_empty()).collect();+ let first = ws.first().copied().unwrap_or("");+ assert!(!why.ends_with('.') && !why.contains(" ") && why.trim() == why, "{input}: {why:?}");+ assert!(!BARE.contains(&first.to_lowercase().as_str()), "{input}: no subject: {why:?}");+ let named = input.split(|c: char| c.is_whitespace() || c == '\'' || c == '"').any(|w| w == first);+ assert!(first.starts_with(char::is_uppercase) || named, "{input}: starts with neither a capital nor the command: {why:?}");+ assert!(ws.iter().skip(1).any(|w| VERBS.contains(w)), "{input}: no verb: {why:?}");+ };+ let c = ctx();+ let shell = [+ "./deploy.sh",+ "psql -c 'DROP TABLE users'",+ "gh pr merge 301 --squash",+ "gh workflow run deploy.yml",+ "gh release create v1.0.0",+ "gh release delete v1.0.0",+ "gh repo delete me/x",+ "fly deploy",+ "fly apps destroy myapp",+ "fly volumes destroy vol_1",+ "fly destroy myapp",+ "fly machine destroy 123",+ "fly secrets set A=b",+ "wrangler deploy",+ "wrangler d1 execute db --command 'DROP TABLE x'",+ "wrangler r2 object delete b/k",+ "kubectl apply -f x.yaml",+ "kubectl delete pod x",+ "helm upgrade app chart",+ "helm uninstall app",+ "terraform apply",+ "terraform apply -destroy",+ "terraform destroy",+ "pulumi up",+ "pulumi destroy",+ "vercel --prod",+ "netlify deploy --prod",+ "firebase deploy",+ "railway up",+ "kamal deploy",+ "serverless deploy",+ "heroku restart",+ "heroku pg:reset",+ "gcloud run deploy svc",+ "aws ecs update-service --cluster c",+ "aws s3 rb s3://b",+ "gsutil rm -r gs://b",+ "make deploy",+ "npm run deploy",+ "truncate -s 0 app.db",+ "dd if=x of=/dev/sda",+ "mkfs.ext4 /dev/sdb",+ "dropdb prod",+ "redis-cli flushall",+ "python manage.py migrate --settings=app.settings.production",+ "rm app.db",+ "rm -rf /",+ "rm -rf data/uploads",+ "docker compose down -v",+ "docker compose up -d",+ "docker volume rm v",+ "docker system prune --volumes",+ "docker rm -v c",+ "docker stack deploy -c x.yml s",+ "docker service rm s",+ "docker run -d --name web --restart always img",+ "docker restart web",+ "git push heroku main",+ "git push --tags",+ "git push --all origin",+ "git push origin :main",+ "git push origin v1.2.3",+ "git push -f origin main",+ "git push origin main",+ ];+ for cmd in shell {+ check(cmd, shell_reason(cmd, &c));+ }+ let unknown = DevCtx { head_branch: None, ..ctx() };+ check("git push", shell_reason("git push", &unknown));+ check("git push -f", shell_reason("git push -f", &unknown));+ let prod = DevCtx { prod_connections: vec!["stripe".into()], ..ctx() };+ for (server, tool, args, c) in [+ ("fly", "deploy_app", json!({}), &c),+ ("digitalocean-droplets", "droplet-delete", json!({}), &c),+ ("supabase", "execute_sql", json!({"query": "DROP TABLE users"}), &c),+ ("stripe", "create_refund", json!({}), &prod),+ ] {+ check(&format!("{server} {tool}"), reason(&req(server, tool, args), c));+ }+ }}