@shumai-one/shumai 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/shumai.js +66 -0
- package/package.json +34 -0
- package/prisma/migrations/000000000000_squashed_migrations/migration.sql +809 -0
- package/prisma/migrations/20260529071403_add_hnsw_index_to_asset_embeddings/migration.sql +17 -0
- package/prisma/migrations/20260529071410_add_natural_sort_collation_to_assets_name/migration.sql +17 -0
- package/prisma/migrations/20260530090320_add_agent_tool_call/migration.sql +2 -0
- package/prisma/migrations/20260605131333_add_asset_id_to_session/migration.sql +6 -0
- package/prisma/migrations/20260606035819_add_creator_to_share_and_collection/migration.sql +11 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +778 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Enable iterative index scans for HNSW so filtered queries don't fall back to seq scan.
|
|
2
|
+
-- Uses current_database() so this works across all environments without hardcoding the DB name.
|
|
3
|
+
-- ALTER DATABASE ... SET persists the GUC for all future connections to this database.
|
|
4
|
+
DO $$
|
|
5
|
+
BEGIN
|
|
6
|
+
EXECUTE format('ALTER DATABASE %I SET hnsw.iterative_scan = ''relaxed_order''', current_database());
|
|
7
|
+
END;
|
|
8
|
+
$$;
|
|
9
|
+
|
|
10
|
+
-- CreateIndex: HNSW index on asset_embeddings.embedding
|
|
11
|
+
-- Uses cosine distance ops (suited for normalized OpenAI-style embeddings)
|
|
12
|
+
-- m=16: controls graph connectivity (higher = better recall, more memory)
|
|
13
|
+
-- ef_construction=64: build-time search width (higher = better quality, slower build)
|
|
14
|
+
CREATE INDEX "AssetEmbedding_embedding_idx"
|
|
15
|
+
ON "asset_embeddings"
|
|
16
|
+
USING hnsw (embedding vector_cosine_ops)
|
|
17
|
+
WITH (m = 16, ef_construction = 64);
|
package/prisma/migrations/20260529071410_add_natural_sort_collation_to_assets_name/migration.sql
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Create ICU collation for natural sort (numbers sort by value, not lexicographically)
|
|
2
|
+
-- Named 'natural_sort' to avoid conflict with the 'numeric' reserved keyword / built-in type in PostgreSQL
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
IF NOT EXISTS (SELECT 1 FROM pg_collation WHERE collname = 'natural_sort') THEN
|
|
6
|
+
CREATE COLLATION natural_sort (provider = icu, locale = 'en@colNumeric=yes');
|
|
7
|
+
END IF;
|
|
8
|
+
END;
|
|
9
|
+
$$;
|
|
10
|
+
|
|
11
|
+
-- Alter assets.name to use the natural_sort collation
|
|
12
|
+
-- This makes all ORDER BY name queries (ORM and raw SQL) use natural sort automatically
|
|
13
|
+
ALTER TABLE "assets" ALTER COLUMN "name" TYPE TEXT COLLATE natural_sort;
|
|
14
|
+
|
|
15
|
+
-- CreateIndex: B-tree index on name using the natural_sort collation
|
|
16
|
+
-- Supports efficient ORDER BY name ASC/DESC without seq scans
|
|
17
|
+
CREATE INDEX "assets_name_idx" ON "assets" ("name" COLLATE natural_sort);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- AlterTable
|
|
2
|
+
ALTER TABLE "agent_sessions" ADD COLUMN "asset_id" TEXT,
|
|
3
|
+
ADD COLUMN "user_comment_id" TEXT;
|
|
4
|
+
|
|
5
|
+
-- AddForeignKey
|
|
6
|
+
ALTER TABLE "agent_sessions" ADD CONSTRAINT "agent_sessions_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- AlterTable
|
|
2
|
+
ALTER TABLE "collections" ADD COLUMN "creator_id" TEXT;
|
|
3
|
+
|
|
4
|
+
-- AlterTable
|
|
5
|
+
ALTER TABLE "share_links" ADD COLUMN "creator_id" TEXT;
|
|
6
|
+
|
|
7
|
+
-- AddForeignKey
|
|
8
|
+
ALTER TABLE "share_links" ADD CONSTRAINT "share_links_creator_id_fkey" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
9
|
+
|
|
10
|
+
-- AddForeignKey
|
|
11
|
+
ALTER TABLE "collections" ADD CONSTRAINT "collections_creator_id_fkey" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|