The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Chat: skills kept on in a project (#134)
riverisbuilding61654ecf8db5
diff --git a/.changeset/skills-kept-on.md b/.changeset/skills-kept-on.mdnew file mode 100644index 0000000..9cca0bf--- /dev/null+++ b/.changeset/skills-kept-on.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++The chat can keep skills on in a project: the pin on a skill's pill in the message keeps it for every message, so it no longer has to be put in each one. Kept-on skills show above the message box, where × turns one off. Each conversation gives an agent a kept-on skill once, with its next message; they are saved with the project's chat.diff --git a/apps/desktop/chat/src/App.tsx b/apps/desktop/chat/src/App.tsxindex 8dcc1f1..e910574 100644--- a/apps/desktop/chat/src/App.tsx+++ b/apps/desktop/chat/src/App.tsx@@ -71,7 +71,8 @@ import { app, type FfmpegState, type Project, type SkillListing, type StudioRef,import { Divider } from './components/Divider';import { draftRefs, pillCard, refFromPill, refPill, sameStudioThing, selectionMoment, selectionRange, selectionRefs, studioReferencesText } from './studio-refs';import { inChat } from './lib/chat-layer';-import { useProjectChat } from './lib/chat-store';+import { chatSkillsOn, setChatSkillsOn, useProjectChat } from './lib/chat-store';+import { sentAfter, skillsOnLine, skillsToSend } from './lib/skills-on';import { ChatProjectContext, WaitingContext } from './lib/developer';const NO_ITEMS: TranscriptItem[] = [];@@ -349,6 +350,13 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: ProjecsetSkillRefs((list) => (list.some((p) => p.id === pill.id) ? list : [...list, pill]));return pill;}, [skillWords]);+ /* the skills kept on in this project (a skill pill's pin): every message's agent gets them (lib/skills-on) */+ const [skillsOn, setSkillsOn] = React.useState<string[]>(() => chatSkillsOn(projectKey));+ const keepSkillsOn = React.useCallback((names: string[]) => { setSkillsOn(names); setChatSkillsOn(projectKey, names); }, [projectKey]);+ const pinSkill = React.useCallback((pill: PromptReference) => {+ const name = skillReferencePackage(pill.id);+ if (name && !skillsOn.includes(name)) keepSkillsOn([...skillsOn, name]);+ }, [skillsOn, keepSkillsOn]);const pickSkill = React.useCallback((skill: PickedSkill) => {const pill = skillPill(skill);requestAnimationFrame(() => { composerRef.current?.insertReference(pill); composerRef.current?.focus(); });@@ -699,8 +707,11 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projecused[index - 1] = ref;return `[${index}: ${refPill(pillId, ref).label}]`;}, (pillId) => { const name = skillReferencePackage(pillId); return name ? `skill “${name}”` : null; }).trim();- /* the skills it names: each one's SKILL.md follows the message, for the agent to read */+ /* the skills it names: each one's SKILL.md follows the message, for the agent to read; and those kept on that this+ conversation's agent has not had yet (lib/skills-on) */const skillNames = activatedSkillIds(followUpRefs);+ const usable = skillsOn.filter((name) => nameableSkills.some((s) => s.name === name));+ const keptOn = skillsToSend(usable, sessions.find((s) => s.id === sessionId)?.skillsSent, agent, skillNames);if (!instruction) return;const blocker = attachmentBlocker(composerFiles.files, t);if (blocker) { setFollowUpError(blocker); return; }@@ -715,11 +726,13 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: ProjecsetSkillRefs([]);const files = composerFiles.take();const id = makeLocalAgentTurnId();- const said = instruction + attachedText(files);+ const said = instruction + skillsOnLine(keptOn) + attachedText(files);const refs = used.filter(Boolean);const stage = selection?.stage ?? null;/* each reference's picture is kept in the project for the agent (the block names it), and sent to one that takes pictures */- const skillTexts = skillNames.length ? (app.skills?.texts(project.path, agent, skillNames).catch(() => []) ?? Promise.resolve([])) : Promise.resolve([]);+ const pages = [...skillNames, ...keptOn];+ const skillTexts = pages.length ? (app.skills?.texts(project.path, agent, pages).catch(() => []) ?? Promise.resolve([])) : Promise.resolve([]);+ if (keptOn.length) touchSession(sessionId, (s) => ({ skillsSent: sentAfter(s.skillsSent, agent, keptOn) }));/* an example pointed at: its folder fetched now if it is not yet (the turn waits, as it waits for its reply) */const withFolders = Promise.all(refs.map(async (ref) => (ref.kind === 'example' && !ref.folder? { ...ref, folder: await app.exampleFolder?.(ref.id).catch(() => undefined) } : ref)));@@ -852,6 +865,27 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec</div>)}{openedFile ? <AttachmentPreview item={openedFile} onClose={() => setOpenedFile(null)} /> : null}+ {/* the skills kept on: every message goes with them; × turns one off */}+ {skillsOn.length ? (+ <div className="flex flex-wrap items-center gap-1.5 px-3.5 pt-2.5">+ <span className="text-[11.5px] text-[var(--text-faint)]">{t('skills.keptOn')}</span>+ {skillsOn.map((name) => {+ const words = skillWords(name, nameableSkills.find((s) => s.name === name)?.description);+ return (+ <span key={name} title={words.summary || words.title}+ className="inline-flex h-6 max-w-[220px] items-center gap-1 rounded-[6px] border border-[var(--border)] pl-1.5 pr-0.5 text-[12px] text-[var(--text)]">+ <Blocks size={12} className="shrink-0 text-[var(--text-muted)]" aria-hidden />+ <span className="min-w-0 truncate">{words.title}</span>+ <button type="button" aria-label={t('skills.turnOff').replace('{name}', words.title)} title={t('skills.turnOff').replace('{name}', words.title)}+ onClick={() => keepSkillsOn(skillsOn.filter((n) => n !== name))}+ className="flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] text-[var(--text-faint)] transition hover:bg-[var(--bg-hover)] hover:text-[var(--text)]">+ <X size={10} />+ </button>+ </span>+ );+ })}+ </div>+ ) : null}<div className="flex items-end gap-1 py-2.5 pl-3.5 pr-2"><div className="min-w-0 flex-1"><PromptEditor@@ -865,6 +899,8 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: ProjeconTransferReferences={onTransferReferences}revealLabel={t('library.revealReference')}removeLabel={t('library.removeReference')}+ onPin={pinSkill}+ pinLabel={t('skills.keepOn')}placeholder={t(blank ? 'project.composerPlaceholderBlank' : 'project.composerPlaceholder')}minHeight={22}maxHeight={158}diff --git a/apps/desktop/chat/src/app-bridge.ts b/apps/desktop/chat/src/app-bridge.tsindex a01b30f..d87e79e 100644--- a/apps/desktop/chat/src/app-bridge.ts+++ b/apps/desktop/chat/src/app-bridge.ts@@ -62,8 +62,8 @@ interface AppBridge {setMenuOpen(open: boolean): void;/** the project's chat record, in its folder: conversations and finished turns (.film/chat), each turn's log (.film/logs) */chat: {- load(project: string): Promise<{ sessions: unknown[]; last: string | null; turns: unknown[] }>;- saveSessions(project: string, sessions: unknown[], last: string | null): Promise<unknown>;+ load(project: string): Promise<{ sessions: unknown[]; last: string | null; skills?: unknown[]; turns: unknown[] }>;+ saveSessions(project: string, sessions: unknown[], last: string | null, skills?: string[]): Promise<unknown>;saveTurn(project: string, turn: unknown, items: unknown[]): Promise<unknown>;/** `unless`: the sizes of the log already read; when it has not grown, `{ same: true }` */log(project: string, turnId: string, unless?: { size: number; callsSize: number }): Promise<TurnLog | { same: true } | null>;diff --git a/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx b/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsxindex 61b9e5f..edd3e57 100644--- a/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx+++ b/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx@@ -98,6 +98,9 @@ export interface PromptEditorProps {onReveal?: (reference: PromptReference) => void;revealLabel?: string;removeLabel: string;+ /** A skill pill's pin: keep that skill on (for every message); without it, skill pills have none. */+ onPin?: (reference: PromptReference) => void;+ pinLabel?: string;placeholder: string;ariaLabel?: string;minHeight: number;@@ -134,6 +137,8 @@ export const PromptEditor = React.forwardRef<PromptEditorHandle, PromptEditorProonReveal,revealLabel,removeLabel,+ onPin,+ pinLabel,placeholder,ariaLabel,minHeight,@@ -158,9 +163,11 @@ export const PromptEditor = React.forwardRef<PromptEditorHandle, PromptEditorPro...(onReveal ? { onReveal } : {}),...(revealLabel ? { revealLabel } : {}),...(describe ? { describe } : {}),+ ...(onPin ? { onPin } : {}),+ ...(pinLabel ? { pinLabel } : {}),removeLabel,}),- [onReveal, removeLabel, revealLabel, describe],+ [onReveal, removeLabel, revealLabel, describe, onPin, pinLabel],);const initialConfig = React.useMemo(diff --git a/apps/desktop/chat/src/components/prompt-editor/PromptReferenceNode.tsx b/apps/desktop/chat/src/components/prompt-editor/PromptReferenceNode.tsxindex c55887a..fc2cab0 100644--- a/apps/desktop/chat/src/components/prompt-editor/PromptReferenceNode.tsx+++ b/apps/desktop/chat/src/components/prompt-editor/PromptReferenceNode.tsx@@ -1,7 +1,7 @@'use client';import React from 'react';-import { X } from 'lucide-react';+import { Pin, X } from 'lucide-react';import {$getNodeByKey,DecoratorNode,@@ -102,6 +102,9 @@ interface PromptReferencePillHandlers {onReveal?: (reference: PromptReference) => void;revealLabel?: string;removeLabel: string;+ /** A skill pill's pin: keep that skill on for every message. */+ onPin?: (reference: PromptReference) => void;+ pinLabel?: string;/** What the hover card says. */describe?: (reference: PromptReference) => PromptPillCard | null;}@@ -142,22 +145,40 @@ function PromptReferencePill({} : {})}{...(reveal && handlers?.revealLabel ? { title: `${reference.label} · ${handlers.revealLabel}` } : {})}trailing={(- <button- type="button"- aria-label={handlers?.removeLabel}- /* Keep focus in the editor on mouse down, so typing continues after removing. */- onMouseDown={(event) => event.preventDefault()}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- editor.update(() => {- $getNodeByKey(nodeKey)?.remove();- });- }}- className="flex h-[1.05em] w-[1.05em] shrink-0 items-center justify-center rounded-[4px] text-[var(--text-faint)] transition hover:bg-[var(--bg-hover)] hover:text-[var(--text)]"- >- <X size={10} />- </button>+ <>+ {reference.kind === 'skill' && handlers?.onPin ? (+ <button+ type="button"+ aria-label={handlers.pinLabel}+ title={handlers.pinLabel}+ onMouseDown={(event) => event.preventDefault()}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ handlers.onPin?.(reference);+ }}+ className="flex h-[1.05em] w-[1.05em] shrink-0 items-center justify-center rounded-[4px] text-[var(--text-faint)] transition hover:bg-[var(--bg-hover)] hover:text-[var(--text)]"+ >+ <Pin size={10} />+ </button>+ ) : null}+ <button+ type="button"+ aria-label={handlers?.removeLabel}+ /* Keep focus in the editor on mouse down, so typing continues after removing. */+ onMouseDown={(event) => event.preventDefault()}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ editor.update(() => {+ $getNodeByKey(nodeKey)?.remove();+ });+ }}+ className="flex h-[1.05em] w-[1.05em] shrink-0 items-center justify-center rounded-[4px] text-[var(--text-faint)] transition hover:bg-[var(--bg-hover)] hover:text-[var(--text)]"+ >+ <X size={10} />+ </button>+ </>)}/>);diff --git a/apps/desktop/chat/src/i18n/locales/en-US.ts b/apps/desktop/chat/src/i18n/locales/en-US.tsindex 4d4d0e9..832a652 100644--- a/apps/desktop/chat/src/i18n/locales/en-US.ts+++ b/apps/desktop/chat/src/i18n/locales/en-US.ts@@ -273,6 +273,9 @@ export const enUS = {/* the composer's button that opens the Community over the film: skills and examples (Studio's ExamplesGallery) */community: { button: 'Community', tooltip: 'Community: skills and examples' },skills: {+ keepOn: 'Keep on for every message in this project',+ keptOn: 'Always on',+ turnOff: 'Turn off {name}',chooseCover: 'Choose cover',removeCover: 'Undo cover choice',coverHint: 'Optional · PNG, JPEG or WebP, up to 5 MB. Keeps the original cover when left unchanged.',diff --git a/apps/desktop/chat/src/i18n/locales/es.ts b/apps/desktop/chat/src/i18n/locales/es.tsindex 28f101f..9235afe 100644--- a/apps/desktop/chat/src/i18n/locales/es.ts+++ b/apps/desktop/chat/src/i18n/locales/es.ts@@ -273,6 +273,9 @@ export const es: Words = {/* the composer's button that opens the Community over the film: skills and examples (Studio's ExamplesGallery) */community: { button: 'Comunidad', tooltip: 'Comunidad: skills y ejemplos' },skills: {+ keepOn: 'Usar en todos los mensajes de este proyecto',+ keptOn: 'Siempre activas',+ turnOff: 'Desactivar {name}',chooseCover: 'Elegir portada',removeCover: 'Deshacer selección',coverHint: 'Opcional · PNG, JPEG o WebP, hasta 5 MB. Sin cambios, se conserva la portada original.',diff --git a/apps/desktop/chat/src/i18n/locales/ja.ts b/apps/desktop/chat/src/i18n/locales/ja.tsindex 29a4b9b..8a564c4 100644--- a/apps/desktop/chat/src/i18n/locales/ja.ts+++ b/apps/desktop/chat/src/i18n/locales/ja.ts@@ -273,6 +273,9 @@ export const ja: Words = {/* the composer's button that opens the Community over the film: skills and examples (Studio's ExamplesGallery) */community: { button: 'コミュニティ', tooltip: 'コミュニティ:スキルとサンプル' },skills: {+ keepOn: 'このプロジェクトのすべてのメッセージで使う',+ keptOn: '常に使用',+ turnOff: '{name} をオフにする',chooseCover: 'カバーを選択',removeCover: '選択を元に戻す',coverHint: '任意 · PNG、JPEG、WebP、最大 5 MB。変更しなければ元のカバーを保持します。',diff --git a/apps/desktop/chat/src/i18n/locales/ko.ts b/apps/desktop/chat/src/i18n/locales/ko.tsindex 1fcf152..4aed049 100644--- a/apps/desktop/chat/src/i18n/locales/ko.ts+++ b/apps/desktop/chat/src/i18n/locales/ko.ts@@ -273,6 +273,9 @@ export const ko: Words = {/* the composer's button that opens the Community over the film: skills and examples (Studio's ExamplesGallery) */community: { button: '커뮤니티', tooltip: '커뮤니티: 스킬과 예시' },skills: {+ keepOn: '이 프로젝트의 모든 메시지에 계속 사용',+ keptOn: '항상 사용',+ turnOff: '{name} 끄기',chooseCover: '표지 선택',removeCover: '표지 선택 취소',coverHint: '선택 사항 · PNG, JPEG 또는 WebP, 최대 5 MB. 변경하지 않으면 원래 표지를 유지합니다.',diff --git a/apps/desktop/chat/src/i18n/locales/zh-CN.ts b/apps/desktop/chat/src/i18n/locales/zh-CN.tsindex 68e698d..c63e9de 100644--- a/apps/desktop/chat/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/chat/src/i18n/locales/zh-CN.ts@@ -273,6 +273,9 @@ export const zhCN: Words = {/* the composer's button that opens the Community over the film: skills and examples (Studio's ExamplesGallery) */community: { button: '社区', tooltip: '社区:Skill 和示例' },skills: {+ keepOn: '在这个项目里常驻:每条消息都带上它',+ keptOn: '常驻',+ turnOff: '关闭 {name}',chooseCover: '选择封面',removeCover: '撤销封面选择',coverHint: '可选 · PNG、JPEG 或 WebP,最大 5 MB。不选择则保留原封面。',diff --git a/apps/desktop/chat/src/lib/chat-store.ts b/apps/desktop/chat/src/lib/chat-store.tsindex 287c133..1a04d1f 100644--- a/apps/desktop/chat/src/lib/chat-store.ts+++ b/apps/desktop/chat/src/lib/chat-store.ts@@ -10,14 +10,14 @@ import type { ProjectSessionItem } from '@/lib/project-sessions';import { app } from '../app-bridge';export interface SavedTurn { turn: Turn; items: TranscriptItem[] }-interface ProjectChat { sessions: ProjectSessionItem[]; last: string | null; turns: SavedTurn[] }+interface ProjectChat { sessions: ProjectSessionItem[]; last: string | null; skills: string[]; turns: SavedTurn[] }const projects = new Map<string, ProjectChat>();const loading = new Map<string, Promise<void>>();/** which project each folder's record was read for: a project deleted and another made in its folder (a new* "Untitled" where the last one was) is not the same project, and does not get its chat */const readFor = new Map<string, string>();-const EMPTY: ProjectChat = { sessions: [], last: null, turns: [] };+const EMPTY: ProjectChat = { sessions: [], last: null, skills: [], turns: [] };/*** Read the project's record from its folder (once a launch, and again when another project takes the folder); the@@ -39,11 +39,12 @@ export function openProjectChat(project: string, id: string): Promise<void> {projects.set(project, {sessions: Array.isArray(chat?.sessions) ? chat.sessions as ProjectSessionItem[] : [],last: typeof chat?.last === 'string' ? chat.last : null,+ skills: Array.isArray(chat?.skills) ? (chat.skills as unknown[]).filter((n): n is string => typeof n === 'string') : [],turns: Array.isArray(chat?.turns) ? chat.turns as SavedTurn[] : [],});})/* not readable (not one of Studio's projects yet, a folder gone): an empty record, written once it changes */- .catch(() => { if (mine()) projects.set(project, { ...EMPTY, sessions: [], turns: [] }); })+ .catch(() => { if (mine()) projects.set(project, { ...EMPTY, sessions: [], skills: [], turns: [] }); }).finally(() => { loading.delete(key); });loading.set(key, pending);return pending;@@ -51,7 +52,7 @@ export function openProjectChat(project: string, id: string): Promise<void> {const record = (project: string): ProjectChat => {let chat = projects.get(project);- if (!chat) { chat = { ...EMPTY, sessions: [], turns: [] }; projects.set(project, chat); }+ if (!chat) { chat = { ...EMPTY, sessions: [], skills: [], turns: [] }; projects.set(project, chat); }return chat;};@@ -62,7 +63,7 @@ function writeSessions(project: string) {sessionWrites.set(project, setTimeout(() => {sessionWrites.delete(project);const chat = record(project);- void app.chat.saveSessions(project, chat.sessions, chat.last).catch(() => { /* written next time */ });+ void app.chat.saveSessions(project, chat.sessions, chat.last, chat.skills).catch(() => { /* written next time */ });}, 150));}@@ -80,6 +81,13 @@ export function setLastSession(project: string, id: string) {writeSessions(project);}+/** The skills kept on in this project: each message's agent gets them without their pill (lib/skills-on). */+export const chatSkillsOn = (project: string): string[] => record(project).skills;+export function setChatSkillsOn(project: string, names: string[]) {+ record(project).skills = [...new Set(names)];+ writeSessions(project);+}+export const chatTurns = (project: string): SavedTurn[] => record(project).turns;export function putChatTurn(project: string, entry: SavedTurn) {const chat = record(project);diff --git a/apps/desktop/chat/src/lib/project-sessions.ts b/apps/desktop/chat/src/lib/project-sessions.tsindex e068e3d..57952a1 100644--- a/apps/desktop/chat/src/lib/project-sessions.ts+++ b/apps/desktop/chat/src/lib/project-sessions.ts@@ -11,6 +11,8 @@ export interface ProjectSessionItem {turns: number;/** Each agent's own id of this conversation (by agent): its next turn goes on with it, after a restart too. */agentSessions?: Record<string, string>;+ /** The skills kept on in the project that each agent has had in this conversation (lib/skills-on), by agent. */+ skillsSent?: Record<string, string[]>;}export type SessionRecencyKey = 'today' | 'yesterday' | 'week' | 'earlier';diff --git a/apps/desktop/chat/src/lib/skills-on.ts b/apps/desktop/chat/src/lib/skills-on.tsnew file mode 100644index 0000000..863554c--- /dev/null+++ b/apps/desktop/chat/src/lib/skills-on.ts@@ -0,0 +1,27 @@+/**+ * Skills kept on in a project (a skill pill's pin in the composer): every message's agent works with them, without+ * their pill. Each conversation gives an agent a skill's SKILL.md once, with the first message it+ * gets after the skill is on; the agent keeps it from then on. Reads nothing, so `node --test` can use it.+ */++/**+ * The skills kept on that go with this message: those `agent` has not had in this conversation (`sent`, by agent),+ * and not named in the message already (`named`, whose pages go with it anyway).+ */+export function skillsToSend(on: readonly string[], sent: Readonly<Record<string, readonly string[]>> | undefined, agent: string, named: readonly string[]): string[] {+ const had = new Set([...(sent?.[agent] ?? []), ...named]);+ return on.filter((name) => !had.has(name));+}++/** What the conversation has given `agent` once this message goes: the skills kept on that are with it now too. */+export function sentAfter(sent: Readonly<Record<string, readonly string[]>> | undefined, agent: string, given: readonly string[]): Record<string, string[]> {+ const out: Record<string, string[]> = {};+ for (const [by, names] of Object.entries(sent ?? {})) out[by] = [...names];+ out[agent] = [...new Set([...(out[agent] ?? []), ...given])];+ return out;+}++/** The line the agent reads for them, before their pages: the skills, as a pill names one. */+export function skillsOnLine(names: readonly string[]): string {+ return names.length ? `\n\nKept on in this project: ${names.map((name) => `skill “${name}”`).join(', ')}.` : '';+}diff --git a/apps/desktop/src/chat-ipc.mjs b/apps/desktop/src/chat-ipc.mjsindex 2db0606..5dfc67b 100644--- a/apps/desktop/src/chat-ipc.mjs+++ b/apps/desktop/src/chat-ipc.mjs@@ -81,7 +81,7 @@ export function registerChatIpc(ipcMain, { trusted, projects, dataDir, reveal, t});handle('desktop:chat:load', async ({ project: path }) => loadChat(await project(path)));- handle('desktop:chat:sessions', async ({ project: path, sessions, last }) => { saveSessions(await project(path), { sessions, last }); return { ok: true }; });+ handle('desktop:chat:sessions', async ({ project: path, sessions, last, skills }) => { saveSessions(await project(path), { sessions, last, skills }); return { ok: true }; });handle('desktop:chat:turn', async ({ project: path, turn, items }) => { saveTurn(await project(path), { turn, items }); return { ok: true }; });handle('desktop:chat:ref-image', async ({ project: path, turnId, n, bytes }) => saveRefImage(await project(path), turnId, n, bytes));handle('desktop:chat:attachment', async ({ project: path, name, bytes }) => saveAttachment(await project(path), name, bytes));diff --git a/apps/desktop/src/chat-store.mjs b/apps/desktop/src/chat-store.mjsindex 7b2e221..4e48522 100644--- a/apps/desktop/src/chat-store.mjs+++ b/apps/desktop/src/chat-store.mjs@@ -73,13 +73,20 @@ export function loadChat(project) {if (entry?.turn?.id && Array.isArray(entry.items)) turns.push(entry);}turns.sort((a, b) => String(a.turn.createdAt).localeCompare(String(b.turn.createdAt)));- return { sessions, last: typeof kept.last === 'string' ? kept.last : null, turns };+ return { sessions, last: typeof kept.last === 'string' ? kept.last : null, skills: skillNames(kept.skills), turns };}-export function saveSessions(project, { sessions, last }) {+/** The skills kept on in a project's chat: names only, each once. */+const skillNames = (names) => [...new Set(Array.isArray(names) ? names.filter((n) => typeof n === 'string' && SKILL_NAME.test(n)) : [])];+const SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;++/** The conversations, the one shown last, and `skills`: the skills kept on for every message in this project. */+export function saveSessions(project, { sessions, last, skills }) {const dir = chatDir(project);mkdirSync(dir, { recursive: true });- writeAtomic(join(dir, 'sessions.json'), `${JSON.stringify({ version: 1, last: typeof last === 'string' ? last : null, sessions: Array.isArray(sessions) ? sessions : [] }, null, 1)}\n`);+ writeAtomic(join(dir, 'sessions.json'), `${JSON.stringify({+ version: 1, last: typeof last === 'string' ? last : null, skills: skillNames(skills), sessions: Array.isArray(sessions) ? sessions : [],+ }, null, 1)}\n`);}export function saveTurn(project, entry) {diff --git a/apps/desktop/src/chat-store.test.mjs b/apps/desktop/src/chat-store.test.mjsindex b989156..8efc337 100644--- a/apps/desktop/src/chat-store.test.mjs+++ b/apps/desktop/src/chat-store.test.mjs@@ -20,7 +20,7 @@ const logOnDisk = (dir, id, lines = 1) => until(() => readLog(dir, id), (read) =test('a project with no chat yet has none; what is saved comes back, the turns in the order they were asked', () => {const dir = project();- assert.deepEqual(loadChat(dir), { sessions: [], last: null, turns: [] });+ assert.deepEqual(loadChat(dir), { sessions: [], last: null, skills: [], turns: [] });saveSessions(dir, { sessions: [{ id: 's1', title: 'One', createdAt: '2026-10-07T00:00:00Z' }], last: 's1' });saveTurn(dir, turn('t2', '2026-10-07T00:00:02Z'));saveTurn(dir, turn('t1', '2026-10-07T00:00:01Z'));@@ -32,6 +32,14 @@ test('a project with no chat yet has none; what is saved comes back, the turns iassert.deepEqual(loadChat(dir).turns.find((t) => t.turn.id === 't1').items, [], 'a turn saved again replaces itself');});+test("the skills kept on in a project's chat are kept with its conversations: names only, each once", () => {+ const dir = project();+ saveSessions(dir, { sessions: [], last: null, skills: ['brand-voice', 'pace', 'brand-voice', '../x', 7, ''] });+ assert.deepEqual(loadChat(dir).skills, ['brand-voice', 'pace']);+ saveSessions(dir, { sessions: [], last: null });+ assert.deepEqual(loadChat(dir).skills, [], 'none given: none kept');+});+test('a turn is written to its log as it happens and read back, a broken last line left out', async () => {const dir = project();const log = openLog(dir, 't1');diff --git a/apps/desktop/src/preload.cjs b/apps/desktop/src/preload.cjsindex a77a44a..2fe7543 100644--- a/apps/desktop/src/preload.cjs+++ b/apps/desktop/src/preload.cjs@@ -87,7 +87,7 @@ contextBridge.exposeInMainWorld('openfilmNative', {/* the chat's record of a project (chat-store.mjs): conversations, finished turns (.film/chat), each turn's log (.film/logs) */chat: {load: (project) => ipcRenderer.invoke('desktop:chat:load', { project }),- saveSessions: (project, sessions, last) => ipcRenderer.invoke('desktop:chat:sessions', { project, sessions, last }),+ saveSessions: (project, sessions, last, skills) => ipcRenderer.invoke('desktop:chat:sessions', { project, sessions, last, skills }),saveTurn: (project, turn, items) => ipcRenderer.invoke('desktop:chat:turn', { project, turn, items }),log: (project, turnId, unless) => ipcRenderer.invoke('desktop:chat:log', { project, turnId, unless }),reveal: (project, turnId) => ipcRenderer.invoke('desktop:chat:reveal', { project, turnId }),diff --git a/apps/desktop/src/skills-on.test.mjs b/apps/desktop/src/skills-on.test.mjsnew file mode 100644index 0000000..8e3874e--- /dev/null+++ b/apps/desktop/src/skills-on.test.mjs@@ -0,0 +1,18 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { sentAfter, skillsOnLine, skillsToSend } from '../chat/src/lib/skills-on.ts';++test('a skill kept on goes to each agent once a conversation, and not again beside its own pill', () => {+ assert.deepEqual(skillsToSend(['brand', 'pace'], undefined, 'codex', []), ['brand', 'pace']);+ const sent = sentAfter(undefined, 'codex', ['brand', 'pace']);+ assert.deepEqual(skillsToSend(['brand', 'pace'], sent, 'codex', []), [], 'the agent has them');+ assert.deepEqual(skillsToSend(['brand', 'pace'], sent, 'claude', []), ['brand', 'pace'], 'another agent has not');+ assert.deepEqual(skillsToSend(['brand', 'pace', 'new'], sent, 'codex', []), ['new'], 'one kept on since');+ assert.deepEqual(skillsToSend(['brand'], undefined, 'codex', ['brand']), [], 'named in the message, it goes with its pill');+ assert.deepEqual(sentAfter(sent, 'codex', ['new']).codex, ['brand', 'pace', 'new']);+});++test('the agent reads them named as a pill names a skill', () => {+ assert.equal(skillsOnLine([]), '');+ assert.equal(skillsOnLine(['brand', 'pace']), '\n\nKept on in this project: skill “brand”, skill “pace”.');+});