Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions labs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Where the three top-level app folders sit:
| [`conductor/`](conductor) | This repository's own host for [`@flow-state-dev/harness-manager`](../packages/harness-manager): a row on a board becomes a supervised coding run. Something claims it, gives the run its own checkout of the repository, stays with it until it stops, reads the verdict before settling the row, and lets a failed attempt run again in the tree the last one left. One phase (`implement`), one issue at a time, two outcomes. A team's coding runs are watched in Shift Manager. |
| [`design-system/`](design-system) | The light and dark theme Shift Manager loads over FSD's component tokens. Values only, no components; a check keeps its values out of FSD's own packages. |
| [`knowledge-hub/`](knowledge-hub) | Incubation for the Knowledge Hub (FIX-882–884): typed capture into working-memory staging, a cron sweeper/manager that routes staged items into long-term OKF memory, and a personal workforce roster. The capture layer exists — `logActivity` into a user-scoped inbox with a deterministic mailroom pass (883/884 pending). The finished simple-wiki predecessor moved to [`examples/knowledge-base`](../examples/knowledge-base). |
| [`teammates/`](teammates) | A Grok Bot-style app on the workforce package: a list of workers on the left, each with one long conversation, and workers that message each other where you can see it. Built from configuration, React UI and small flows only, with an inventory that fails on anything else. Runs on fixtures until its package pieces land. |

Shift Manager, the app a Workforce team is worked through, is published as
[`@flow-state-dev/shift-manager`](../packages/shift-manager).
Expand Down
1 change: 1 addition & 0 deletions labs/teammates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist-client/
74 changes: 74 additions & 0 deletions labs/teammates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Teammates

A private lab that copies the core layout and interaction of Grok Bot, in the Flow State theme, on
the workforce package. It is one half of the evidence that the same package pieces make familiar
apps: an app adds only configuration, React UI and a few small flows, and anything else it needs is
a gap filed against the package.

- **Left:** the workers, lead, researcher and writer. Each row is a worker with an ongoing role,
never a list of sessions. A row shows what the worker is doing and how many new entries its
conversation has since you last looked.
- **Center:** the chosen worker's one conversation. It goes on for weeks. A divider marks where the
turns the worker reads word for word begin; it reads *summarized* only when the earlier turns were
summarized for the worker.
- **Right:** Talk, the worker's exchanges with the other workers, grouped by worker, from the
message log. It closes.

Workers message each other where you can see it. When lead messages researcher, a one-line card
shows in lead's conversation and the message lands in researcher's. The reply lands in lead's
conversation under researcher's name. A message never interrupts the turn you are in: while lead is
answering you, researcher's reply shows as a pending line, and lead reads it right after.

Scope is core messaging and session management. There are no group chats, no new-chat button and
no session list. The design and the decisions behind it are in the
[spec](../../specs/issues/FIX-2154/SPEC.md).

## Run it

Until wiring, the screen runs on fixtures that play the script on a timer:

```bash
pnpm --filter @flow-state-dev/teammates dev
```

Ask lead for something, say *"Ask researcher for our launch date, and help me outline the post."*
lead answers and messages researcher. Before researcher replies, send lead a second line: the reply
shows as pending, then lands after lead's answer. lead's conversation already runs past the 50-turn
history window, so the divider is in view.

After wiring, the lab runs against a real model and a durable store:

```bash
fsdev dev --app @flow-state-dev/teammates
```

Wiring adds the host file, which composes `@flow-state-dev/memory` into each worker's flow: the
capability in `uses` to read it, and `afterAnswer: mem.captureFromItems` to record each turn.

## Fixtures

Everything the screen reads and writes goes through one adapter, `src/adapter.ts`. Each function
names the package call it stands for, and until wiring they run on `src/fixtures.ts`, marked
`fixture:`. At wiring the fixtures are deleted and each function calls the package.

| Fixture stands in for | Package piece |
|---|---|
| The divider and its *summarized* label | G1: the history window's opt-in summary and the mark it leaves, tracked under FIX-1613 |
| The pending line, joined to the conversation by message id | G2: a received message as its own item, carrying its id (an ask of FIX-2070) |
| Workers messaging each other, the Talk panel | `sendMessage`, `receive` and the message log, as FIX-2070 ships them |
| The worker list, sending, the conversation, busy status | `roster()`, `ensureWorkerSession`, `respond`, session items, `listSessionRequests` |

## What this app adds

Every file in the lab, by kind. `node scripts/inventory.mjs` fails on a file that is none of these,
and on a flow over 200 lines; `--wired` also fails while a fixture is left.

<!-- inventory:start -->
| Kind | Files | Lines |
|---|---:|---:|
| Configuration | 13 | 253 |
| React UI | 14 | 822 |
| Small flows | 0 | 0 |
| Fixtures (deleted at wiring) | 1 | 267 |
| Checks (not app code) | 3 | 275 |
<!-- inventory:end -->
40 changes: 40 additions & 0 deletions labs/teammates/cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @flow-state-dev/teammates — a Grok Bot-style app on the workforce package.
*
* The package's module is the app contract `fsdev dev --app` reads, the same
* one `@flow-state-dev/devtool` exports: where the built pages are, and, in a
* checkout, where their source is. The lab is launched with
* `fsdev dev --app @flow-state-dev/teammates`.
*/
import { existsSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

/** The package's root: one up from `cli/` in a checkout and from `dist/` in an install. */
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");

/**
* The directory of the lab's built pages (`index.html` and its assets).
*
* @throws When the pages are not built: a checkout that hasn't run
* `pnpm --filter @flow-state-dev/teammates build`.
*/
export function getAssetPath(): string {
const dir = resolve(PACKAGE_ROOT, "dist-client");
if (!existsSync(resolve(dir, "index.html"))) {
throw new Error(
`@flow-state-dev/teammates: the pages are not built at ${dir}. Run: pnpm --filter @flow-state-dev/teammates build`,
);
}
return dir;
}

/**
* The folder holding the pages' source `index.html`, which `fsdev dev --watch`
* serves through Vite. `undefined` in an install, which ships built pages only.
*/
export function getSourceRoot(): string | undefined {
return existsSync(resolve(PACKAGE_ROOT, "src", "main.tsx")) && existsSync(resolve(PACKAGE_ROOT, "index.html"))
? PACKAGE_ROOT
: undefined;
}
17 changes: 17 additions & 0 deletions labs/teammates/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
Comment thread
jhoffner marked this conversation as resolved.
Resolved
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/components/flow-state/tokens.css",
"baseColor": "neutral",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui"
}
}
12 changes: 12 additions & 0 deletions labs/teammates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Teammates</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions labs/teammates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@flow-state-dev/teammates",
"version": "0.0.0",
"private": true,
"type": "module",
"description": "Private lab: a Grok Bot-style app on the workforce package. A list of workers on the left, each with one long conversation; workers message each other where you can see it. Built from config, React UI and small flows only.",
"main": "./cli/index.ts",
"exports": {
".": "./cli/index.ts"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"typecheck": "node ../../scripts/typecheck.mjs",
"test": "vitest run --root .",
"inventory": "node scripts/inventory.mjs",
"inventory:write": "node scripts/inventory.mjs --write",
"inventory:control": "node scripts/inventory.mjs --control"
},
"devDependencies": {
"@flow-state-dev/design-system": "workspace:*",
"@tailwindcss/vite": "^4.2.0",
"@testing-library/react": "^16.3.2",
"@types/node": "^22.0.0",
"@types/react": "^19.1.12",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^5.0.0",
"clsx": "^2.1.1",
"happy-dom": "^20.8.3",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"tailwind-merge": "^3.5.0",
"tailwindcss": "^4.1.12",
"vite": "^7.1.3",
"vitest": "^3.2.4"
}
}
127 changes: 127 additions & 0 deletions labs/teammates/scripts/inventory.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env node
/**
* The lab's inventory: every file this lab adds, by kind, with line counts.
* It is the "what this app adds" table in the README (the labs epic's rule ER-1).
*
* A lab has three kinds of app code: configuration, React UI, and small
* flows (each under 200 lines). Two more kinds are allowed and are not app
* code: checks (tests and this script), and fixtures, which stand in for the
* package until wiring and are deleted then. Any file that fits none of them
* is an *other* row, and the check fails.
*
* node scripts/inventory.mjs check: no other row, flows in size, README current
* node scripts/inventory.mjs --write rewrite the README's table
* node scripts/inventory.mjs --wired also fail while any fixture is left (the closure runs this)
* node scripts/inventory.mjs --control plant src/glue.ts; passes only if the check then fails
*/
import { execFileSync } from "node:child_process";
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const LAB = join(dirname(fileURLToPath(import.meta.url)), "..");
const README = join(LAB, "README.md");
const START = "<!-- inventory:start -->";
const END = "<!-- inventory:end -->";
const FLOW_LIMIT = 200;

/** Kind rules, first match wins. A path is relative to the lab, with `/`. */
const RULES = [
["check", /^(test\/.+|scripts\/inventory\.mjs)$/],
["fixture", /^src\/fixtures(\.ts|\/.+)$/],
["flow", /^src\/flows\/[^/]+\.ts$/],
["config", /^(package\.json|tsconfig\.json|vite\.config\.ts|vitest\.config\.ts|components\.json|index\.html|\.gitignore|README\.md|cli\/index\.ts|fsdev\.config\.mts|host\.mts)$/],
["config", /^workforce\/(.+\/)?(WORKER|SKILL|TEAM)\.md$/],
["config", /^workforce\/(.+\/)?resources\/.+$/],
["ui", /^src\/(main\.tsx|App\.tsx|styles\.css|adapter\.ts)$/],
Comment thread
jhoffner marked this conversation as resolved.
Resolved
["ui", /^src\/(components|lib)\/.+\.(tsx|ts|css)$/],
];

/** Every file the lab holds: tracked, plus new files git doesn't ignore. */
function labFiles() {
const out = execFileSync("git", ["ls-files", "-co", "--exclude-standard", "--", "."], { cwd: LAB, encoding: "utf8" });
return out.split("\n").filter(Boolean).sort();
}

function lines(path) {
const text = readFileSync(join(LAB, path), "utf8");
return text.length === 0 ? 0 : text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
}

/** Classify every file; return the rows and every problem found. */
export function inventory(files, { wired = false, linesOf = lines } = {}) {
const rows = files.map((path) => {
const kind = RULES.find(([, re]) => re.test(path))?.[0] ?? "other";
return { path, kind, lines: linesOf(path) };
});
const problems = [];
for (const row of rows) {
if (row.kind === "other") problems.push(`other: ${row.path} is not config, UI, a small flow, a check or a fixture`);
if (row.kind === "flow" && row.lines > FLOW_LIMIT) problems.push(`flow over ${FLOW_LIMIT} lines: ${row.path} (${row.lines})`);
if (wired && row.kind === "fixture") problems.push(`fixture left after wiring: ${row.path}`);
}
return { rows, problems };
}

const ORDER = ["config", "ui", "flow", "fixture", "check", "other"];
const LABEL = {
config: "Configuration",
ui: "React UI",
flow: "Small flows",
fixture: "Fixtures (deleted at wiring)",
check: "Checks (not app code)",
other: "Other",
};

/** The README table: one row per kind, with its files and lines. */
export function table(rows) {
const out = ["| Kind | Files | Lines |", "|---|---:|---:|"];
for (const kind of ORDER) {
const of = rows.filter((r) => r.kind === kind);
if (of.length === 0 && kind !== "flow") continue;
out.push(`| ${LABEL[kind]} | ${of.length} | ${of.reduce((n, r) => n + r.lines, 0)} |`);
}
return out.join("\n");
}

function readmeTable() {
const text = readFileSync(README, "utf8");
const a = text.indexOf(START);
const b = text.indexOf(END);
if (a < 0 || b < a) return { text, current: undefined };
return { text, current: text.slice(a + START.length, b).trim(), a, b };
}

function main(argv) {
const files = labFiles();
if (argv.includes("--control")) {
const { problems } = inventory([...files, "src/glue.ts"], { linesOf: (p) => (p === "src/glue.ts" ? 12 : lines(p)) });
if (problems.some((p) => p.includes("src/glue.ts"))) {
console.log("inventory control: FAIL as required · src/glue.ts is an other row");
return 0;
}
console.error("inventory control: the planted src/glue.ts was not caught");
return 1;
}
// The README counts itself, so it is written twice to settle its own line count.
const { rows, problems } = inventory(files, { wired: argv.includes("--wired") });
const want = table(rows);
if (argv.includes("--write")) {
for (let i = 0; i < 2; i++) {
const { text, a, b } = readmeTable();
if (a === undefined) throw new Error(`README.md has no ${START} … ${END} block`);
writeFileSync(README, `${text.slice(0, a + START.length)}\n${table(inventory(labFiles()).rows)}\n${text.slice(b)}`);
}
console.log("inventory: README table written");
} else if (readmeTable().current !== want) {
problems.push("README.md's inventory is out of date: run node scripts/inventory.mjs --write");
}
if (problems.length > 0) {
for (const p of problems) console.error(`inventory: ${p}`);
return 1;
}
console.log(`inventory: PASS · ${rows.length} files, no other row`);
return 0;
}

if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) process.exit(main(process.argv.slice(2)));
57 changes: 57 additions & 0 deletions labs/teammates/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useEffect, useState } from "react";
import type { LabAdapter, WorkerRow } from "./adapter";
import { Conversation } from "./components/Conversation";
import { TalkPanel } from "./components/TalkPanel";
import { WorkersList } from "./components/WorkersList";

/**
* The screen: the workers on the left, the chosen worker's one conversation
* in the center, and its talk with the other workers on the right. The app
* opens on the first worker on the roster.
*/
export function App({ adapter }: { adapter: LabAdapter }) {
const [workers, setWorkers] = useState<WorkerRow[]>([]);
const [sessions, setSessions] = useState<Record<string, string>>({});
const [selected, setSelected] = useState<string>();
const [talkOpen, setTalkOpen] = useState(true);

useEffect(() => {
let live = true;
void (async () => {
const roster = await adapter.listWorkers();
const ids = await Promise.all(roster.map((w) => adapter.openConversation(w.id)));
if (!live) return;
setWorkers(roster);
setSessions(Object.fromEntries(roster.map((w, i) => [w.id, ids[i]])));
setSelected((current) => current ?? roster[0]?.id);
})();
return () => {
live = false;
};
}, [adapter]);

const nameOf = (id: string) => workers.find((w) => w.id === id)?.name ?? id;
const worker = workers.find((w) => w.id === selected);
const sessionId = selected ? sessions[selected] : undefined;
return (
<div
className="grid h-full grid-rows-[minmax(0,1fr)] overflow-hidden"
style={{ gridTemplateColumns: talkOpen ? "15rem minmax(0,1fr) 18rem" : "15rem minmax(0,1fr)" }}
>
<WorkersList adapter={adapter} workers={workers} sessions={sessions} selected={selected} nameOf={nameOf} onSelect={setSelected} />
{worker && sessionId ? (
<Conversation
adapter={adapter}
worker={worker}
sessionId={sessionId}
nameOf={nameOf}
talkOpen={talkOpen}
onToggleTalk={() => setTalkOpen((open) => !open)}
/>
) : (
<main aria-label="Conversation" />
)}
{talkOpen && worker ? <TalkPanel adapter={adapter} worker={worker} nameOf={nameOf} onClose={() => setTalkOpen(false)} /> : null}
</div>
);
}
Loading
Loading