From c03d9f33c9b51725d506a3dfc4f1003a19c3aa95 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Thu, 5 Nov 2026 22:09:46 -0300 Subject: [PATCH 1/2] feat(desktop): edit Device aliases with retained prompt ownership --- desktop/src/l10n/zh.ts | 3 + desktop/src/model/deviceNames.test.ts | 36 ++++++++ desktop/src/model/models.ts | 2 + desktop/src/model/store.ts | 34 ++++++++ desktop/src/model/wire.ts | 2 + .../src/ui/settings/deviceNames.browser.tsx | 83 +++++++++++++++++++ desktop/src/ui/settings/panes.tsx | 45 +++++++++- desktop/test-browser.ts | 1 + docs/architecture/desktop-app.md | 1 + 9 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 desktop/src/model/deviceNames.test.ts create mode 100644 desktop/src/ui/settings/deviceNames.browser.tsx diff --git a/desktop/src/l10n/zh.ts b/desktop/src/l10n/zh.ts index 2de70de2..eac317cb 100644 --- a/desktop/src/l10n/zh.ts +++ b/desktop/src/l10n/zh.ts @@ -634,6 +634,9 @@ export const zh: Record = { "Remove…": "移除…", "Removing…": "正在移除…", "Rename": "重命名", + "Rename Device": "重命名设备", + "Leave blank to use the machine name.": "留空以使用机器名称。", + "Device names must be at most 64 characters": "设备名称最多为 64 个字符", "Rename Chat": "重命名聊天", "Rename Chat…": "重命名聊天…", "Rename…": "重命名…", diff --git a/desktop/src/model/deviceNames.test.ts b/desktop/src/model/deviceNames.test.ts new file mode 100644 index 00000000..515f0ea8 --- /dev/null +++ b/desktop/src/model/deviceNames.test.ts @@ -0,0 +1,36 @@ +import { beforeAll, expect, test } from "bun:test"; +import type { AppStore } from "./store"; + +let Store: typeof AppStore; +beforeAll(async () => { + const location = Object.getOwnPropertyDescriptor(globalThis, "location"); + Object.defineProperty(globalThis, "location", { configurable: true, value: { search: "?platform=linux" } }); + try { Store = (await import("./store")).AppStore; } + finally { + if (location) Object.defineProperty(globalThis, "location", location); + else Reflect.deleteProperty(globalThis, "location"); + } +}); + +test("Device aliases preserve original names, reset blank input, and reject revoked ownership", async () => { + class DemoStore extends Store { override get isMock() { return true; } } + const store = new DemoStore(); + store.isConnected = true; + store.hasIdentity = true; + store.identityID = "account-a"; + store.devices = [{ id: "peer", name: "Original", model: "PC", os: "linux", osVersion: "", isThisDevice: false, status: "offline", lastSeen: 0, machineKey: "key", plugins: [], version: "" }]; + const owner = store.deviceNamingOwner("peer"); + await store.setDeviceName("peer", "Office", owner); + expect(store.device("peer")).toMatchObject({ name: "Office", machineName: "Original" }); + await store.setDeviceName("peer", "", owner); + expect(store.device("peer")).toMatchObject({ name: "Original", machineName: "Original" }); + store.identityID = "account-b"; + expect(owner()).toBe(false); + await store.setDeviceName("peer", "Wrong account", owner); + expect(store.device("peer")?.name).toBe("Original"); + const cancelled = store.deviceNamingOwner("peer"); + await store.setDeviceName("peer", "Cancelled", () => false); + expect(store.device("peer")?.name).toBe("Original"); + store.devices = []; + expect(cancelled()).toBe(false); +}); diff --git a/desktop/src/model/models.ts b/desktop/src/model/models.ts index 497ff7c9..2614c93d 100644 --- a/desktop/src/model/models.ts +++ b/desktop/src/model/models.ts @@ -475,6 +475,8 @@ export function deviceStatusLabel(status: DeviceStatus): string { export interface Device { id: string; name: string; + /** Original machine-reported name, separate from the account alias. */ + machineName?: string; model: string; os: DeviceOS; osVersion: string; diff --git a/desktop/src/model/store.ts b/desktop/src/model/store.ts index 5db90a32..24eff2a8 100644 --- a/desktop/src/model/store.ts +++ b/desktop/src/model/store.ts @@ -299,6 +299,7 @@ export class AppStore { private started = false; private startupTimer: ReturnType | null = null; private bootstrapGeneration = 0; + private deviceNamingGeneration = 0; private isBootstrapping = true; private bootstrapEvents: { name: string; data: unknown }[] = []; private isApplyingBootstrap = false; @@ -741,6 +742,7 @@ export class AppStore { private emit(event: StoreEvent): void { if (this.isApplyingBootstrap) return; + if (event.kind === "snapshotReplaced" || event.kind === "identityChanged" || event.kind === "connectionChanged") this.deviceNamingGeneration++; for (const listener of [...this.listeners]) listener(event); } @@ -1920,6 +1922,38 @@ export class AppStore { return created.phrase; } + /** Captures account, snapshot, connection and target ownership for a naming prompt. */ + deviceNamingOwner(id: string): () => boolean { + const identity = this.identityID, generation = this.deviceNamingGeneration; + const target = this.device(id), key = target?.machineKey, os = target?.os; + return () => { + const current = this.device(id); + return this.isConnected && this.hasIdentity === true && (this.isMock || !!identity) + && identity === this.identityID && generation === this.deviceNamingGeneration + && !!current && current.os !== "unknown" && current.machineKey === key && current.os === os; + }; + } + + /** Sets an account alias; confirmed blank input resets to the machine-reported name. */ + async setDeviceName(id: string, name: string, owns: () => boolean): Promise { + const admitted = this.deviceNamingOwner(id); + if (!owns() || !admitted()) return; + if (!this.isMock) { + await this.request("device.set_name", { id, name }); + if (!owns() || !admitted()) return; + return; + } + const trimmed = name.trim(); + if (Array.from(trimmed).length > 64) throw new RequestError(L("Device names must be at most 64 characters")); + if (!owns()) return; + this.devices = this.devices.map((device) => { + if (device.id !== id) return device; + const machineName = device.machineName ?? device.name; + return { ...device, machineName, name: trimmed || machineName }; + }); + this.emit({ kind: "rosterChanged" }); + } + /** Unpairs another Device. The CLI has the relay drop its key; the Device wipes its copy of the * account the next time it connects. Throws when the relay could not be told. */ async unpairDevice(id: string): Promise { diff --git a/desktop/src/model/wire.ts b/desktop/src/model/wire.ts index 794cca9c..ab4e6a29 100644 --- a/desktop/src/model/wire.ts +++ b/desktop/src/model/wire.ts @@ -92,6 +92,7 @@ export interface WireParsedServers { export interface WireDevice { id: string; name: string; + machine_name?: string; model: string; os: string; os_version: string; @@ -489,6 +490,7 @@ export function toDevice(wire: WireDevice): Device { return { id: wire.id, name: wire.unknown ? L("Unknown Device") : wire.name, + machineName: wire.machine_name ?? wire.name, model: wire.model, os: wire.unknown ? "unknown" : (oses as string[]).includes(wire.os) ? (wire.os as DeviceOS) : "linux", osVersion: wire.os_version, diff --git a/desktop/src/ui/settings/deviceNames.browser.tsx b/desktop/src/ui/settings/deviceNames.browser.tsx new file mode 100644 index 00000000..269fdbb6 --- /dev/null +++ b/desktop/src/ui/settings/deviceNames.browser.tsx @@ -0,0 +1,83 @@ +import { flush } from "solid-js"; +import { render } from "@solidjs/web"; +import { setLanguage } from "../../l10n"; +import { store } from "../../model/store"; +import type { WireSnapshot } from "../../model/wire"; +import { settingsDeviceID } from "../root"; +import { SheetHost } from "../overlay"; +import { SettingsPage } from "./panes"; + +export async function checkDeviceNamingConsumer() { + const assert = (value: unknown, message: string) => { if (!value) throw new Error(message); }; + const settle = async () => { await Promise.resolve(); flush(); await new Promise((r) => setTimeout(r, 0)); flush(); }; + setLanguage("en"); + Object.defineProperty(store, "isMock", { configurable: true, get: () => false }); + const events = store as unknown as { handle(name: string, data: unknown): void }; + const snapshot = (identity = "account-a"): WireSnapshot => ({ + version: "fixture", identity_id: identity, has_identity: true, is_identity_device: true, + relay_connected: false, running_chat_ids: [], bots: [], chats: [], devices: ["peer", "other"].map((id) => ({ + id, name: "Original", machine_name: "Machine", model: "PC", os: "linux", os_version: "", + is_this_device: false, status: "offline", last_seen: 0, machine_key: id, plugins: [], version: "fixture", + })), + }); + events.handle("snapshot", snapshot()); + store.setConnected(true); + const calls: { method: string; params: Record }[] = []; + let resolve!: (value: unknown) => void; + let reject!: (error: Error) => void; + Object.defineProperty(store, "transport", { configurable: true, value: { + request: (method: string, params: Record) => { + calls.push({ method, params }); + return new Promise((yes, no) => { resolve = yes; reject = no; }); + }, + } }); + const root = document.createElement("div"); + root.id = "root"; + document.body.append(root); + settingsDeviceID.set("peer"); + const dispose = render(() => <>, root); + const button = (text: string) => [...document.querySelectorAll("button")].find((x) => x.textContent?.trim() === text); + const dialogs = () => document.querySelectorAll("[role=dialog]").length; + const open = async () => { + await settle(); + const rename = button("Rename…"); + assert(rename, "Device pane has no Rename action"); rename!.click(); await settle(); + assert(dialogs() === 1, "Naming prompt did not mount"); + const input = document.querySelector("[role=dialog] input")!; + assert(input?.value === "Original" && input.placeholder === "Machine", "Alias and machine names are not distinct"); + return input; + }; + const submit = async (value: string) => { + const input = await open(); input.value = value; input.dispatchEvent(new Event("input", { bubbles: true })); await settle(); + button("Rename")!.click(); await settle(); + assert(button("Rename")!.disabled, "Pending alias can be submitted twice"); + }; + try { + await submit(""); + assert(calls.length === 1 && calls[0]!.method === "device.set_name" && calls[0]!.params.id === "peer" && calls[0]!.params.name === "", `Blank reset did not reach the real store transport: ${JSON.stringify(calls)}`); + resolve(null); await settle(); assert(dialogs() === 0, "Accepted alias did not close prompt"); + await submit("Office"); reject(new Error("Synthetic refusal")); await settle(); + assert(document.querySelector("[role=alert]")?.textContent?.includes("Synthetic refusal"), "Current refusal is not visible"); + assert(document.querySelector("[role=dialog] input")?.value === "Office", "Refusal discarded the draft"); + button("Cancel")!.click(); await settle(); + for (const transition of ["account", "reconnect", "target", "cancel"] as const) { + settingsDeviceID.set("peer"); events.handle("snapshot", snapshot()); store.setConnected(true); await settle(); + const owner = store.deviceNamingOwner("peer"); + await submit("Pending"); + if (transition === "account") { events.handle("snapshot", snapshot("account-b")); events.handle("snapshot", snapshot()); } + if (transition === "reconnect") { store.setConnected(false); store.setConnected(true); } + if (transition === "target") settingsDeviceID.set("other"); + if (transition === "cancel") button("Cancel")!.click(); + await settle(); assert(dialogs() === 0, `${transition} retained the prompt`); + reject(new Error("Late refusal")); await settle(); + assert(!document.querySelector("[role=alert]"), `${transition} published a stale failure`); + assert(store.device("peer")?.name === "Original", `${transition} changed a replacement view`); + if (transition === "account" || transition === "reconnect") { + assert(!owner(), `${transition} restored stale ownership`); + const before = calls.length; await store.setDeviceName("peer", "Late", owner); + assert(calls.length === before, `${transition} admitted a stale request`); + } + } + return { reset: "transport verified", refusal: "draft retained", transitions: 4, lateErrors: "suppressed", accountABA: "rejected" }; + } finally { dispose(); root.remove(); } +} diff --git a/desktop/src/ui/settings/panes.tsx b/desktop/src/ui/settings/panes.tsx index 42ebc071..274b2b17 100644 --- a/desktop/src/ui/settings/panes.tsx +++ b/desktop/src/ui/settings/panes.tsx @@ -2,7 +2,7 @@ // controllers: section cards and footnotes in one scrolling column, the window's title bar carrying // the page title. General and Advanced also fill the small Settings window onboarding opens. -import { createEffect, createMemo, createSignal, For, onSettled, Show } from "solid-js"; +import { createEffect, createMemo, createSignal, For, onCleanup, onSettled, Show } from "solid-js"; import type { JSX } from "@solidjs/web"; import { files, host, hostInfo, onUpdaterChanged, preferences, setPreferences, type UpdaterState } from "../../host"; import { parseCLIPort } from "../../host/cliPort"; @@ -29,7 +29,7 @@ import { import { onStoreEvent, track } from "../../model/reactive"; import { errorText, store } from "../../model/store"; import { newBot, presentMarketplace } from "../actions"; -import { HoverButton, PopUpButton, Switch, TextArea } from "../controls"; +import { HoverButton, PopUpButton, Switch, TextArea, TextField } from "../controls"; import { Icon } from "../icons"; import { alert, presentSheet, Sheet } from "../overlay"; import { open, revealed, settingsDeviceID } from "../root"; @@ -773,9 +773,49 @@ function StatusDot(props: { status: Device["status"] }) { return ; } +function DeviceNamePrompt(props: { device: Device; owns: () => boolean; dismiss: () => void }) { + const [name, setName] = createSignal(props.device.name); + const [busy, setBusy] = createSignal(false); + const [error, setError] = createSignal(null); + const stop = store.subscribe(() => { if (!props.owns()) props.dismiss(); }); + onCleanup(stop); + const save = async () => { + if (busy() || !props.owns()) return; + setBusy(true); + setError(null); + try { + await store.setDeviceName(props.device.id, name(), props.owns); + if (props.owns()) props.dismiss(); + } catch (failure) { + if (props.owns()) setError(errorText(failure)); + } finally { + if (props.owns()) setBusy(false); + } + }; + return void save()} onCancel={props.dismiss}> + + {(message) => } + ; +} + /** The picked Device itself: what it is, whether it is online, its machine key, and Unpair. */ function DevicePane() { const device = pickedDevice; + let namingSheet: { dismiss(): void } | undefined; + let namingActive = true; + onCleanup(() => { namingActive = false; namingSheet?.dismiss(); }); + createEffect(() => settingsDeviceID.read(), () => { namingSheet?.dismiss(); }); + const rename = () => { + const current = device(); + if (!current) return; + const admitted = store.deviceNamingOwner(current.id); + let open = true; + const owns = () => open && namingActive && settingsDeviceID.get() === current.id && admitted(); + if (!owns()) return; + namingSheet?.dismiss(); + namingSheet = presentSheet((dismiss) => , () => { open = false; }); + }; + const relay = () => { track.roster(); track.connection(); @@ -825,6 +865,7 @@ function DevicePane() { + diff --git a/desktop/test-browser.ts b/desktop/test-browser.ts index 0d618383..a0966fac 100644 --- a/desktop/test-browser.ts +++ b/desktop/test-browser.ts @@ -7,6 +7,7 @@ import { createServer } from "vite"; import type { ViteDevServer } from "vite"; const expected: Record = { + "src/ui/settings/deviceNames.browser.tsx": "checkDeviceNamingConsumer", "src/ui/chat/cards.browser.tsx": "checkCommandCardInput", "src/ui/chat/composer.browser.tsx": "checkComposerSendAck", "src/ui/motion.browser.tsx": "checkReducedMotion", diff --git a/docs/architecture/desktop-app.md b/docs/architecture/desktop-app.md index 46a173dd..c9443787 100644 --- a/docs/architecture/desktop-app.md +++ b/docs/architecture/desktop-app.md @@ -41,6 +41,7 @@ The opt-in native window offers Diagnostics through `native_diagnostics.go`. Gen Under the OS Reduce Motion setting the presence dot, the spinner, the working row's shimmer and the sheet and popover entrances hold still instead of pulsing, spinning, sweeping, fading or sliding; the elements stay and keep their state. The Solid command palette uses shared `chats.search` content matches for Chats, Messages and Files, while actions/settings keep fuzzy matching. File rows open the existing owning chat; no file bytes are indexed. Store changes invalidate and refresh an unchanged query. The input names its listbox and active option; arrows select, Return opens and Escape dismisses. An incomplete-history notice identifies local downloaded-history coverage. Task results await the durable task API. - **Updates** (`updater.go`): the app owns MyGo archive checks and guarded install-on-quit. Every candidate is a stable `beans-v` release from `bloodf/beans` with signed readiness, a validated archive hash and compatible selected relay. Automatic checks run every 15 minutes when enabled; saved preferences and skipped versions remain in `updater.json`. Users choose Install on Quit, Later or Skip; the app never forces an unattended relaunch. Installation requires the app-owned drain-capable CLI and its private update-control token. Before spawn the launcher supplies only the eventual token path; the current app-owned child's matching READY precedes existing-directory/format admission and exclusive token creation. It creates neither directory nor marker, and preserves existing token bytes and permissions. Explicit operator settings, including an empty disable, remain inherited, but app-owned installation does not read operator token files. Token failure leaves the admitted CLI running with installation unavailable. Quit checks retain drafts and reject running work, pin a separate local websocket to the child PID/launcher generation/selected port, and take a 30-minute Runner admission lease before approval. The page becomes inert during the guard; cancellation restores it and releases the same Runner's lease. Relay selection and lease readiness are checked again before quit. The quit callback waits for the idle child to exit before swapping resources, while retaining the instance lock; Windows stops the approved idle child without waiting for the app's own exit. Native update dialogs use the page's live `L()` bridge. Development and package-managed non-writable installs omit update controls. [Desktop releases](../releasing-desktop.md) describes prerequisites and platform constraints. +- **Device aliases**: known Devices offer Rename in Settings, using `device.set_name` and blank input to restore the machine name. The prompt retains account, connection, snapshot and target ownership; losing that ownership closes it and rejects late publication. See [Device names](device-names.md). - **Device versions**: Device details shows the reported CLI/core version. Beans leaves standalone CLI self-update status absent and rejects its requests; this does not change the app-owned signed updater. Windows update-control admission queries the opened directory, marker and token handles for owner/DACL evidence. The owner belongs to the current account or LocalSystem; process group membership, including Administrators, is not a privacy grant. Effective foreign token data-read/write grants and directory/marker replacement, write or security-control grants are refused, including inherited grants. Missing DACLs, unsupported ACE forms and security-query failures fail closed. Existing objects are never repaired or repermissioned. Only an exclusively created token receives the current-user owner and a protected current-user DACL, which are checked before its secret is written. From 7cb08ad61289049a53e466740d715288758d43d7 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Fri, 6 Nov 2026 11:51:58 +0000 Subject: [PATCH 2/2] chore(tooling): propagate reviewed Beans AI tooling --- .codegraph-version | 1 + .codegraph/.gitignore | 5 +++ AGENTS.md | 2 + docs/ai-tooling.md | 86 +++++++++++++++++++++++++++++++++++++++++++ scripts/codegraph.sh | 17 +++++++++ 5 files changed, 111 insertions(+) create mode 100644 .codegraph-version create mode 100644 .codegraph/.gitignore create mode 100644 docs/ai-tooling.md create mode 100755 scripts/codegraph.sh diff --git a/.codegraph-version b/.codegraph-version new file mode 100644 index 00000000..fdd3be6d --- /dev/null +++ b/.codegraph-version @@ -0,0 +1 @@ +1.6.2 diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore new file mode 100644 index 00000000..d20c0fe4 --- /dev/null +++ b/.codegraph/.gitignore @@ -0,0 +1,5 @@ +# CodeGraph data files — local to each machine, not for committing. +# Ignore everything in .codegraph/ except this file itself, so transient +# files (the database, daemon.pid, sockets, logs) never show up in git. +* +!.gitignore diff --git a/AGENTS.md b/AGENTS.md index a6f3edd8..e4ffb564 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Beans +For T3 onboarding, retrieval, command output and model reservations, follow [AI tooling](docs/ai-tooling.md). Product work remains HOLD until Heitor explicitly says OK. + Read [ARCHITECTURE.md](./ARCHITECTURE.md) before writing code, then the subject docs it lists for the parts you change. Identity is a local key pair. Paired Devices sync through an E2E relay. Provider credentials belong to the account: they sync to every paired Device as a blob encrypted with the account key. The AppKit app talks to the local CLI. diff --git a/docs/ai-tooling.md b/docs/ai-tooling.md new file mode 100644 index 00000000..b781f692 --- /dev/null +++ b/docs/ai-tooling.md @@ -0,0 +1,86 @@ +# Prepare and use AI tooling + +Read [AGENTS.md](../AGENTS.md), [BEANS.md](../BEANS.md) and [ARCHITECTURE.md](../ARCHITECTURE.md) before changing Beans. `CLAUDE.md` points to `AGENTS.md`; preserve that link and all existing instructions. + +## Keep product work on HOLD + +This preparation permits onboarding, tooling installation, independently reviewed tooling PRs, normal tooling merges and branch propagation. Product work remains HOLD until Heitor explicitly says OK. Green checks, a tooling merge and completed propagation do not release product work. Do not merge product PRs during this rollout. + +The central coordinator owns global settings and routing. Read `/Users/heitor/.config/ai-tooling/COORDINATION.md` and the current `GLOBAL-ROLLOUT.md` linked there. Report global configuration gaps to that coordinator. Keep one external rollout REPORT with commands, exit codes, receipt hashes, exact heads, resources and blockers. + +Target `bloodf/beans` explicitly for GitHub operations. `origin` is the Beans repository; `upstream` is `egoist/lorca`. T3's upstream canonical identity does not authorize upstream publication or integration. Confirm remotes, branch, HEAD, current base, worktrees and dirty state before writing. Similar source content does not prove ancestry. + +Preserve all refs with a verified Git bundle before propagation. Save staged and unstaged patches, untracked files and their hashes separately. Use an isolated tooling checkout. Preserve existing worktrees and previous work. Do not use automatic stash, `reset --hard`, force push or shared cleanup. + +## Retrieve source with CodeGraph 1.6.2 + +The standalone CLI is pinned by `.codegraph-version`. `scripts/codegraph.sh` checks the installed version, disables telemetry for its process and runs from this checkout's root. Keep CodeGraph outside application dependencies. + +Use the existing installation when it matches the pin. For workstation installation, inspect the installer at `https://raw.githubusercontent.com/colbymchenry/codegraph/f72c9d2efb14454ff4f9fd7b8460abd82f19a287/install.sh`, then run the inspected file with `CODEGRAPH_VERSION=v1.6.2`. Installation and user-specific MCP configuration belong to the central coordinator. + +Run these commands from the repository root: + +```sh +sh scripts/codegraph.sh init --yes +sh scripts/codegraph.sh sync +sh scripts/codegraph.sh status --json +sh scripts/codegraph.sh query dispatch --limit 5 --json +sh scripts/codegraph.sh callers dispatch --file crates/cli/src/api.rs --limit 5 --json +sh scripts/codegraph.sh explore --max-files 3 'api dispatch websocket serve' +``` + +Start with a bounded query before broad source reads. For exact text, missing results or unsupported syntax, use bounded `rg` and exact file ranges. Inspect the actual definition and caller before changing a flow. A graph relationship does not prove runtime behavior or complete dynamic call coverage. + +Each worktree has its own `.codegraph/` index. Do not copy databases between checkouts. Run `sync` and inspect `status --json` after checkout or edits. Check indexed languages, file/node counts, pending changes, worktree mismatch and index completion. Rebuild with `index` after changing include/exclude/extension rules. Version 1.6.2 has no `--strict` flag. + +Track only `.codegraph/.gitignore` inside `.codegraph/`. The ignore file excludes databases, logs, sockets, locks and daemon state. Never commit generated graphs or index data. With a configured CodeGraph MCP, keep the default single `codegraph_explore` tool; otherwise use the same bounded CLI commands. + +## Preserve command status with RTK 1.0.1 + +Read `/Users/heitor/.codex/RTK.md` when present. With a native RTK PreToolUse hook, run normal commands and do not wrap them twice. Without a native hook, use supported explicit commands such as `rtk git status` and `rtk gh pr list --repo bloodf/beans`. MiniMax uses this CLI route. Do not assume one harness's hooks apply to another. + +Preserve the actual exit code and first failure receipt. If condensed output is empty, contradictory or unusable, recover it with `rtk bypass ` or the stored raw receipt. Diagnose the first failure before another attempt. Do not weaken a check, timeout, baseline, security boundary or review requirement to obtain green results. + +## Use Caveman and Ponytail + +Use concise, complete Portuguese sentences with the user. Keep errors, identifiers, numbers and negations exact. Write code, persisted documents and critical instructions in complete language. + +Inspect the affected flow and callers, reuse existing code and standard libraries, and make the smallest complete change. Verify behavior at the relevant boundary. Preserve security, accessibility, approval, encryption and data-loss controls. Installation, synthetic probes, local checks, hosted checks and live behavior are separate evidence. + +## Verify TokenEconomizer per harness + +Reuse the central installation. Preserve the mode without auxiliary paid model calls: `microskills=envfacts`, `loopguard=off`, `repomap=off` and `toolprune=propose`. Do not set a paid model or enable paid proposers. Keep orchestration, review, device and required verification tools available; proposals cannot override project policy. + +From the checkout, inspect effective state without a model call: + +```sh +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" status +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" config show +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" repos list +``` + +Confirm the repository identity is the Beans origin and verify a worktree maps to that same repository. Record the installed adapter's supported events for each harness actually used. Codex's installed hook file declares `SessionStart`, `UserPromptSubmit`, `PostToolUse`, `Stop` and `SessionEnd`; declaration alone does not prove delivery through T3. + +Separate configuration present from fresh-session runtime proof. Loading a skill, starting a process or seeing a zero-session status does not prove the full lifecycle. Record unproved events as UNKNOWN. Do not invent adapters or hook support for Antigravity, MiniMax or another harness. TokenEconomizer learns repository facts and proposes tool pruning; it is not a generic output compressor. No local token savings are claimed without measurement. + +## Reserve every worker through the central dispatcher + +Before each tooling worker, reserve a route: + +```sh +t3-model-route reserve --project beans --purpose tooling --task '' +``` + +Launch only the exact returned provider, model and options through the applicable T3 delegation mechanism. Antigravity accepts Google models only. MiniMax M3.1 Flash requires `m:minimax:MiniMax-M3.1-Flash:v:thinking`. Quota UNKNOWN is not proof of capacity. Never substitute another project, provider or model, retry quota blindly, edit the global helper or implement a local round robin. + +Give each worker exact scope and file ownership. State that concurrent work must be preserved. Record the lease, task/run, provider, model and terminal outcome. Release only the exact lease after terminal evidence. Start no top-level thread for a worker. Use a fresh independent reviewer for each review or re-check, with the exact base/head and applicable risk requirements. No author approves their own change. + +## Verify and propagate tooling + +Keep the existing Beans gates. `bun run check:docs`, `bun run check:catalog` and the same-repository PR test matrix remain applicable. Inspect the current workflow definitions before execution; a local tooling smoke does not replace hosted checks. Product homes, accounts, relays, signing inputs and deployments are not tooling fixtures. + +Create one tooling PR against current Beans `main` and link it immediately to T3. Merge only after independent exact-head review and the real required checks pass. When waiting for hosted checks, use T3's PR watch and end the run; do not poll CI. + +Before propagation, prepare a per-ref plan with original head, target payload, old-head ancestry proof and recovery instructions. Append only tooling to every existing local and origin branch, including historical branches and open PR heads. Preserve each branch's existing instruction and ignore bytes. Do not merge unrelated product history, silently resolve divergence or recreate a branch absent from the server. Push fast-forward with explicit refspecs. Stop on the first remote write failure, re-read remote state and report to central before retry or a strategy change. + +Recheck current remote and PR heads, rescan for new refs, validate indexes in used checkouts and settle owned processes and leases. Record any uncovered ref as BLOCKED with a concrete reason. Product work still waits for Heitor's explicit OK. diff --git a/scripts/codegraph.sh b/scripts/codegraph.sh new file mode 100755 index 00000000..d6aa27fb --- /dev/null +++ b/scripts/codegraph.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Run from any directory with the repository's reviewed CodeGraph version. +set -eu +codegraph_root=$(CDPATH= cd "$(dirname "$0")/.." && pwd) +cd "$codegraph_root" +codegraph_expected=$(cat .codegraph-version) +if ! command -v codegraph >/dev/null 2>&1; then + echo "CodeGraph $codegraph_expected required. See docs/ai-tooling.md." >&2 + exit 1 +fi +codegraph_actual=$(codegraph --version) +if [ "$codegraph_actual" != "$codegraph_expected" ]; then + echo "CodeGraph $codegraph_expected required; found $codegraph_actual. See docs/ai-tooling.md." >&2 + exit 1 +fi +export CODEGRAPH_TELEMETRY=0 +exec codegraph "$@"