{"draft":null,"from":14,"to":318,"files":[{"path":"client/src/command-env.ts","added":34,"removed":6,"diff":"--- a/client/src/command-env.ts\n+++ b/client/src/command-env.ts\n@@ -1,8 +1,12 @@\n // What every abso command shares: its output, its environment, the folder it opens, and the news it took.\n \n-import { Api, type News, newsLines, type RunKind } from \"./api.ts\";\n+import { createHash } from \"node:crypto\";\n+import { hostname } from \"node:os\";\n+import { callerHeader } from \"../../src/caller.ts\";\n+import { Api, type News, newsLines, type RunKind, takeSeatNotices } from \"./api.ts\";\n import { UsageError } from \"./args.ts\";\n import { type Config, findRoot, readConfig } from \"./config.ts\";\n+import { newsBlockLines, newsShown } from \"./core.ts\";\n import { logNews } from \"./folder.ts\";\n \n export const EXIT = { ok: 0, error: 1, refused: 2 } as const;\n@@ -18,12 +22,19 @@\n \treadonly env: Readonly<Record<string, string | undefined>>;\n \t/** Where `run` streams the box's output as it arrives. */\n \treadonly write: (text: string) => void;\n+\t/** --token-file: this machine's ~/.abso/token may sign in, where nothing else does. Never read otherwise. */\n+\treadonly tokenFile?: boolean;\n \t/** Where `run` streams the box's stderr; `write` when not given. */\n \treadonly writeErr?: (text: string) => void;\n \t/** What a box run is for, when a command runs one for its own ends (shot, bisect, publish --check). */\n \treadonly runKind?: RunKind;\n \t/** What a -file flag of - reads: stdin, unless a test gives it. */\n \treadonly readStdin?: () => string;\n+\t/**\n+\t * The server --server named, checked (server-choice.ts), when the command was given one. It is used as given,\n+\t * so no environment setting redirects it (ABSO_ISSUES_SERVER included).\n+\t */\n+\treadonly server?: string;\n }\n \n export function plural(n: number, word: string): string {\n@@ -34,13 +45,30 @@\n \tconst root = findRoot(env.cwd);\n \tif (root === undefined)\n \t\tthrow new UsageError(\n-\t\t\t`${env.cwd} is not in an abso folder (no .avcs/config.json here or above); run abso init or abso join first`,\n+\t\t\t`You're not in an abso folder: ${env.cwd} has no .abso/config.json, nor does any folder above it. abso join <project> makes one, or abso init a new project.`,\n \t\t);\n-\tconst config = readConfig(root, env.env);\n-\treturn { root, config, api: new Api(config) };\n+\tconst config = readConfig(root, env.env, env.tokenFile === true);\n+\tconst api = new Api(config);\n+\tapi.caller = callerFor(env.env.CLAUDE_CODE_SESSION_ID, hostname(), root);\n+\treturn { root, config, api };\n }\n \n /**\n+ * The caller header for this chat, computer and folder. The chat's session id goes as a short SHA-256 of it and the\n+ * folder as its last part, so neither the raw id nor the path (which names the person) leaves the machine.\n+ */\n+export function callerFor(session: string | undefined, machine: string, root: string): string | undefined {\n+\tconst hashed = session ? createHash(\"sha256\").update(session).digest(\"hex\").slice(0, 16) : undefined;\n+\t// The last part on either separator, so a Windows path names its folder on any machine.\n+\tconst folder =\n+\t\troot\n+\t\t\t.split(/[\\\\/]+/)\n+\t\t\t.filter((p) => p !== \"\")\n+\t\t\t.at(-1) ?? \"\";\n+\treturn callerHeader({ session: hashed, machine, folder });\n+}\n+\n+/**\n  * News a command took from the server while recording first. main() prints it\n  * after whatever the command says, so every command that takes news shows it\n  * (#37, News Report: sync, run and diff took it, wrote it to .avcs/news.log and\n@@ -48,7 +76,7 @@\n  */\n const takenNews: string[] = [];\n export function takeNews(): string[] {\n-\treturn takenNews.splice(0);\n+\treturn [...takeSeatNotices(), ...takenNews.splice(0)];\n }\n \n /** News a record answered with: kept in .avcs/news.log, and printed by main(). */\n@@ -60,5 +88,5 @@\n \n export function newsText(news: News): string[] {\n \tconst lines = newsLines(news);\n-\treturn lines.length === 0 ? [] : [\"News:\", ...lines.map((n) => `  ${n}`)];\n+\treturn newsBlockLines(lines.map((n) => newsShown(n)));\n }"}],"unmatched":[]}