unify agent items into a flat file-based store, drop the marketplace

Replace the marketplace service dependency and the native/global/user
scope tiers with a single external directory ($OFFICER_ITEMS_DIR) holding
skills, tools, tasks, processes and extensions as plain files.

- tasks move from Postgres to TASK.md files (new file-backed task layer);
  task editing now works, which the DB path never supported
- skills/tools/processes collapse into one shared file router (single dir)
- remove the marketplace client (sync-marketplace/sync-version) and the
  boot-time sync; pi-bridge/pi-manager/sandbox point at the flat store
- drop the dead tasks + vestigial skills/tools/processes/extensions +
  item_chats tables (migration 0004)
- one-time migration script exports DB tasks and consolidates disk items

Migration verified: all 6 tasks round-trip through the runtime parser
identically to their DB rows (pipeline steps, triggers, script impls and
agentic bodies all intact).

NOTE: not yet functionally tested end-to-end — every item (each task mode,
tool, skill, extension) still needs to be run/exercised in the app before
this is trusted. To be done manually.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 00:39:17 +00:00
co-authored by Claude Opus 4.8
parent 5fd3d4faac
commit f3492512ba
29 changed files with 2366 additions and 1357 deletions
+11 -22
View File
@@ -1,15 +1,6 @@
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import {
getGlobalToolsDir,
getUserToolsDir,
getGlobalSkillsDir,
getUserSkillsDir,
getGlobalTasksDir,
getUserTasksDir,
getHomeDir,
DATA_PATH,
} from '@@/data-path';
import { itemsDir, getHomeDir, DATA_PATH } from '@@/data-path';
type HookEntry = { type: string; command: string };
type HookRule = { matcher?: Record<string, unknown>; hooks: HookEntry[] };
@@ -57,14 +48,13 @@ function formatList(entries: FrontmatterEntry[]): string {
}
export function generateContainerContext(email: string): string {
const tools = dedup([...scanDir(getGlobalToolsDir(), 'TOOL.md'), ...scanDir(getUserToolsDir(email), 'TOOL.md')]);
const skills = dedup([...scanDir(getGlobalSkillsDir(), 'SKILL.md'), ...scanDir(getUserSkillsDir(email), 'SKILL.md')]);
const tasks = dedup([...scanDir(getGlobalTasksDir(), 'TASK.md'), ...scanDir(getUserTasksDir(email), 'TASK.md')]);
const toolsDir = itemsDir('tools');
const skillsDir = itemsDir('skills');
const tasksDir = itemsDir('tasks');
const tools = dedup(scanDir(toolsDir, 'TOOL.md'));
const skills = dedup(scanDir(skillsDir, 'SKILL.md'));
const tasks = dedup(scanDir(tasksDir, 'TASK.md'));
const globalToolsDir = getGlobalToolsDir();
const userToolsDir = getUserToolsDir(email);
const globalSkillsDir = getGlobalSkillsDir();
const userSkillsDir = getUserSkillsDir(email);
const userDataDir = join(DATA_PATH, email);
const content = `# Officer — User Environment
@@ -78,14 +68,13 @@ This is an isolated Linux user environment managed by the Officer platform.
| \`~\` | User home directory (read-write) |
| \`~/Projects/\` | User projects |
| \`~/Downloads/\` | Downloaded files |
| \`${globalToolsDir}/\` | Global tools |
| \`${userToolsDir}/\` | User tools |
| \`${globalSkillsDir}/\` | Reference skills |
| \`${toolsDir}/\` | Tools |
| \`${skillsDir}/\` | Reference skills |
| \`${userDataDir}/\` | User data (emails.db, attachments, etc.) |
## Available Tools
Tools are callable capabilities used by the Officer AI agent (Pi). Each tool has a \`TOOL.md\` with documentation and an \`index.ts\` that exports an \`execute()\` function. Read individual tool docs at \`${globalToolsDir}/<name>/TOOL.md\` or \`${userToolsDir}/<name>/TOOL.md\`.
Tools are callable capabilities used by the Officer AI agent (Pi). Each tool has a \`TOOL.md\` with documentation and an \`index.ts\` that exports an \`execute()\` function. Read individual tool docs at \`${toolsDir}/<name>/TOOL.md\`.
${formatList(tools)}
## Available Skills
@@ -100,7 +89,7 @@ Tasks are predefined instruction sets the AI agent can execute.
${formatList(tasks)}
## Creating New Tools
Create a directory in \`${userToolsDir}/<tool-name>/\` with two files:
Create a directory in \`${toolsDir}/<tool-name>/\` with two files:
**TOOL.md** — Frontmatter metadata + markdown documentation:
\`\`\`yaml