wip: remove opencode, searxng, resources; fix user settings read

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 07:27:19 +00:00
co-authored by Claude Opus 4.6
parent 5925ac49a1
commit 7bbcccabf1
46 changed files with 325 additions and 2037 deletions
+124 -119
View File
@@ -8,143 +8,148 @@ import { users } from './auth';
// ── Tasks ──
// Complex frontmatter: inputs, outputs, dependencies, triggers, config, tags, tools, skills
export const tasks = pgTable('tasks', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
tags: jsonb('tags').$type<string[]>(),
tools: jsonb('tools').$type<string[]>(),
skills: jsonb('skills').$type<string[]>(),
inputs: jsonb('inputs'),
outputs: jsonb('outputs'),
dependencies: jsonb('dependencies'),
config: jsonb('config'),
trigger: jsonb('trigger'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_tasks_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_tasks_scope').on(table.scope),
index('idx_tasks_user').on(table.userId),
]);
export const tasks = pgTable(
'tasks',
{
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
tags: jsonb('tags').$type<string[]>(),
tools: jsonb('tools').$type<string[]>(),
skills: jsonb('skills').$type<string[]>(),
inputs: jsonb('inputs'),
outputs: jsonb('outputs'),
dependencies: jsonb('dependencies'),
config: jsonb('config'),
trigger: jsonb('trigger'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_tasks_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_tasks_scope').on(table.scope),
index('idx_tasks_user').on(table.userId),
],
);
// ── Skills ──
// Minimal frontmatter: name, description only. Rich markdown body.
export const skills = pgTable('skills', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_skills_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_skills_scope').on(table.scope),
index('idx_skills_user').on(table.userId),
]);
export const skills = pgTable(
'skills',
{
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_skills_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_skills_scope').on(table.scope),
index('idx_skills_user').on(table.userId),
],
);
// ── Processes ──
// Same shape as skills. Represents documented workflows.
export const processes = pgTable('processes', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_processes_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_processes_scope').on(table.scope),
index('idx_processes_user').on(table.userId),
]);
// ── Resources ──
// Has separate config (key-value for external service settings). No user scope.
export const resources = pgTable('resources', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
config: jsonb('config').$type<Record<string, string>>().notNull().default({}),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_resources_scope_dir').on(table.scope, table.dirName),
index('idx_resources_scope').on(table.scope),
]);
export const processes = pgTable(
'processes',
{
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_processes_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_processes_scope').on(table.scope),
index('idx_processes_user').on(table.userId),
],
);
// ── Tools ──
// Has implementation code, language, structured input params, label.
export const tools = pgTable('tools', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
label: text('label'),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
language: text('language'),
inputs: jsonb('inputs'),
implementation: text('implementation'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_tools_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_tools_scope').on(table.scope),
index('idx_tools_user').on(table.userId),
]);
export const tools = pgTable(
'tools',
{
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
label: text('label'),
description: text('description'),
body: text('body'),
version: integer('version').notNull().default(1),
language: text('language'),
inputs: jsonb('inputs'),
implementation: text('implementation'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_tools_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_tools_scope').on(table.scope),
index('idx_tools_user').on(table.userId),
],
);
// ── Extensions ──
// Code-only, no markdown, no chat. Just implementation.
export const extensions = pgTable('extensions', {
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
implementation: text('implementation'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_extensions_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_extensions_scope').on(table.scope),
index('idx_extensions_user').on(table.userId),
]);
export const extensions = pgTable(
'extensions',
{
id: serial('id').primaryKey(),
scope: text('scope').notNull(),
userId: integer('user_id').references(() => users.id, { onDelete: 'cascade' }),
dirName: text('dir_name').notNull(),
name: text('name').notNull(),
implementation: text('implementation'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_extensions_scope_user_dir').on(table.scope, table.userId, table.dirName),
index('idx_extensions_scope').on(table.scope),
index('idx_extensions_user').on(table.userId),
],
);
// ── Item Chats ──
// Chat history for tasks, skills, processes, resources, tools.
// Uses polymorphic reference (item_type + item_id) instead of per-table FKs.
export const itemChats = pgTable('item_chats', {
id: text('id').primaryKey(),
itemType: text('item_type').notNull(),
itemId: integer('item_id').notNull(),
messages: jsonb('messages').notNull().default([]),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
unique('uq_item_chats_type_item').on(table.itemType, table.itemId),
index('idx_item_chats_type_item').on(table.itemType, table.itemId),
]);
export const itemChats = pgTable(
'item_chats',
{
id: text('id').primaryKey(),
itemType: text('item_type').notNull(),
itemId: integer('item_id').notNull(),
messages: jsonb('messages').notNull().default([]),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
unique('uq_item_chats_type_item').on(table.itemType, table.itemId),
index('idx_item_chats_type_item').on(table.itemType, table.itemId),
],
);
-5
View File
@@ -74,11 +74,6 @@ export type SkillInsert = typeof Schema.skills.$inferInsert;
export type ProcessSelect = typeof Schema.processes.$inferSelect;
export type ProcessInsert = typeof Schema.processes.$inferInsert;
// ── Resources ──
export type ResourceSelect = typeof Schema.resources.$inferSelect;
export type ResourceInsert = typeof Schema.resources.$inferInsert;
// ── Tools ──
export type ToolSelect = typeof Schema.tools.$inferSelect;