@maintainer-pro/ai-cli 0.1.0
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/dist/db-entry.cjs +388 -0
- package/dist/db-entry.d.cts +43 -0
- package/dist/db-entry.d.ts +43 -0
- package/dist/db-entry.js +238 -0
- package/dist/index.cjs +1117 -0
- package/dist/index.d.cts +239 -0
- package/dist/index.d.ts +239 -0
- package/dist/index.js +1057 -0
- package/dist/mysql-EKKUF6CP.js +34 -0
- package/dist/pg-QSUOKTP3.js +33 -0
- package/dist/sqlite-6L33HVYQ.js +28 -0
- package/drizzle/mysql/0001_init.sql +24 -0
- package/drizzle/postgres/0001_init.sql +26 -0
- package/drizzle/sqlite/0001_init.sql +26 -0
- package/package.json +64 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/db/schema/mysql.ts
|
|
2
|
+
import {
|
|
3
|
+
mysqlTable,
|
|
4
|
+
varchar,
|
|
5
|
+
text,
|
|
6
|
+
timestamp,
|
|
7
|
+
json
|
|
8
|
+
} from "drizzle-orm/mysql-core";
|
|
9
|
+
import { sql } from "drizzle-orm";
|
|
10
|
+
var conversations = mysqlTable("ai_cli_conversations", {
|
|
11
|
+
id: varchar("id", { length: 128 }).primaryKey(),
|
|
12
|
+
createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
13
|
+
updatedAt: timestamp("updated_at").default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
14
|
+
});
|
|
15
|
+
var messages = mysqlTable("ai_cli_messages", {
|
|
16
|
+
id: varchar("id", { length: 36 }).primaryKey(),
|
|
17
|
+
conversationId: varchar("conversation_id", { length: 128 }).notNull(),
|
|
18
|
+
role: varchar("role", { length: 32 }).notNull(),
|
|
19
|
+
content: text("content").notNull(),
|
|
20
|
+
provider: varchar("provider", { length: 64 }),
|
|
21
|
+
createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
22
|
+
});
|
|
23
|
+
var toolEvents = mysqlTable("ai_cli_tool_events", {
|
|
24
|
+
id: varchar("id", { length: 36 }).primaryKey(),
|
|
25
|
+
conversationId: varchar("conversation_id", { length: 128 }).notNull(),
|
|
26
|
+
tool: varchar("tool", { length: 128 }).notNull(),
|
|
27
|
+
args: json("args").$type().notNull(),
|
|
28
|
+
createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
conversations,
|
|
32
|
+
messages,
|
|
33
|
+
toolEvents
|
|
34
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/db/schema/pg.ts
|
|
2
|
+
import {
|
|
3
|
+
pgTable,
|
|
4
|
+
text,
|
|
5
|
+
timestamp,
|
|
6
|
+
uuid,
|
|
7
|
+
jsonb
|
|
8
|
+
} from "drizzle-orm/pg-core";
|
|
9
|
+
var conversations = pgTable("ai_cli_conversations", {
|
|
10
|
+
id: text("id").primaryKey(),
|
|
11
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
|
12
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull()
|
|
13
|
+
});
|
|
14
|
+
var messages = pgTable("ai_cli_messages", {
|
|
15
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
16
|
+
conversationId: text("conversation_id").notNull().references(() => conversations.id, { onDelete: "cascade" }),
|
|
17
|
+
role: text("role").notNull(),
|
|
18
|
+
content: text("content").notNull(),
|
|
19
|
+
provider: text("provider"),
|
|
20
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull()
|
|
21
|
+
});
|
|
22
|
+
var toolEvents = pgTable("ai_cli_tool_events", {
|
|
23
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
24
|
+
conversationId: text("conversation_id").notNull().references(() => conversations.id, { onDelete: "cascade" }),
|
|
25
|
+
tool: text("tool").notNull(),
|
|
26
|
+
args: jsonb("args").$type().notNull(),
|
|
27
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull()
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
conversations,
|
|
31
|
+
messages,
|
|
32
|
+
toolEvents
|
|
33
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/db/schema/sqlite.ts
|
|
2
|
+
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
3
|
+
import { sql } from "drizzle-orm";
|
|
4
|
+
var conversations = sqliteTable("ai_cli_conversations", {
|
|
5
|
+
id: text("id").primaryKey(),
|
|
6
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(unixepoch() * 1000)`).notNull(),
|
|
7
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).default(sql`(unixepoch() * 1000)`).notNull()
|
|
8
|
+
});
|
|
9
|
+
var messages = sqliteTable("ai_cli_messages", {
|
|
10
|
+
id: text("id").primaryKey(),
|
|
11
|
+
conversationId: text("conversation_id").notNull(),
|
|
12
|
+
role: text("role").notNull(),
|
|
13
|
+
content: text("content").notNull(),
|
|
14
|
+
provider: text("provider"),
|
|
15
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(unixepoch() * 1000)`).notNull()
|
|
16
|
+
});
|
|
17
|
+
var toolEvents = sqliteTable("ai_cli_tool_events", {
|
|
18
|
+
id: text("id").primaryKey(),
|
|
19
|
+
conversationId: text("conversation_id").notNull(),
|
|
20
|
+
tool: text("tool").notNull(),
|
|
21
|
+
args: text("args", { mode: "json" }).$type().notNull(),
|
|
22
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(unixepoch() * 1000)`).notNull()
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
conversations,
|
|
26
|
+
messages,
|
|
27
|
+
toolEvents
|
|
28
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- ai-cli schema (MySQL)
|
|
2
|
+
CREATE TABLE IF NOT EXISTS ai_cli_conversations (
|
|
3
|
+
id VARCHAR(128) PRIMARY KEY,
|
|
4
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
5
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE TABLE IF NOT EXISTS ai_cli_messages (
|
|
9
|
+
id VARCHAR(36) PRIMARY KEY,
|
|
10
|
+
conversation_id VARCHAR(128) NOT NULL,
|
|
11
|
+
role VARCHAR(32) NOT NULL,
|
|
12
|
+
content TEXT NOT NULL,
|
|
13
|
+
provider VARCHAR(64) NULL,
|
|
14
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
INDEX ai_cli_messages_conversation_id_idx (conversation_id)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE TABLE IF NOT EXISTS ai_cli_tool_events (
|
|
19
|
+
id VARCHAR(36) PRIMARY KEY,
|
|
20
|
+
conversation_id VARCHAR(128) NOT NULL,
|
|
21
|
+
tool VARCHAR(128) NOT NULL,
|
|
22
|
+
args JSON NOT NULL,
|
|
23
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
24
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- ai-cli schema (Postgres)
|
|
2
|
+
CREATE TABLE IF NOT EXISTS ai_cli_conversations (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
5
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE TABLE IF NOT EXISTS ai_cli_messages (
|
|
9
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
10
|
+
conversation_id TEXT NOT NULL REFERENCES ai_cli_conversations(id) ON DELETE CASCADE,
|
|
11
|
+
role TEXT NOT NULL,
|
|
12
|
+
content TEXT NOT NULL,
|
|
13
|
+
provider TEXT,
|
|
14
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS ai_cli_tool_events (
|
|
18
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
19
|
+
conversation_id TEXT NOT NULL REFERENCES ai_cli_conversations(id) ON DELETE CASCADE,
|
|
20
|
+
tool TEXT NOT NULL,
|
|
21
|
+
args JSONB NOT NULL,
|
|
22
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS ai_cli_messages_conversation_id_idx
|
|
26
|
+
ON ai_cli_messages (conversation_id);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- ai-cli schema (SQLite)
|
|
2
|
+
CREATE TABLE IF NOT EXISTS ai_cli_conversations (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
created_at INTEGER NOT NULL DEFAULT (CAST(unixepoch() * 1000 AS INTEGER)),
|
|
5
|
+
updated_at INTEGER NOT NULL DEFAULT (CAST(unixepoch() * 1000 AS INTEGER))
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE TABLE IF NOT EXISTS ai_cli_messages (
|
|
9
|
+
id TEXT PRIMARY KEY,
|
|
10
|
+
conversation_id TEXT NOT NULL,
|
|
11
|
+
role TEXT NOT NULL,
|
|
12
|
+
content TEXT NOT NULL,
|
|
13
|
+
provider TEXT,
|
|
14
|
+
created_at INTEGER NOT NULL DEFAULT (CAST(unixepoch() * 1000 AS INTEGER))
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS ai_cli_tool_events (
|
|
18
|
+
id TEXT PRIMARY KEY,
|
|
19
|
+
conversation_id TEXT NOT NULL,
|
|
20
|
+
tool TEXT NOT NULL,
|
|
21
|
+
args TEXT NOT NULL,
|
|
22
|
+
created_at INTEGER NOT NULL DEFAULT (CAST(unixepoch() * 1000 AS INTEGER))
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS ai_cli_messages_conversation_id_idx
|
|
26
|
+
ON ai_cli_messages (conversation_id);
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maintainer-pro/ai-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Maintainer Pro server SDK: Claude/Cursor CLI, chat HTTP handlers, and optional SQL persistence",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./db": {
|
|
17
|
+
"types": "./dist/db-entry.d.ts",
|
|
18
|
+
"import": "./dist/db-entry.js",
|
|
19
|
+
"require": "./dist/db-entry.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"drizzle"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup src/index.ts src/db-entry.ts --format esm,cjs --dts --clean --external postgres --external mysql2 --external better-sqlite3 --external drizzle-orm",
|
|
31
|
+
"dev": "tsup src/index.ts src/db-entry.ts --format esm,cjs --dts --watch --external postgres --external mysql2 --external better-sqlite3 --external drizzle-orm",
|
|
32
|
+
"db:migrate": "tsx src/db/migrate-cli.ts"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"drizzle-orm": "^0.44.5",
|
|
36
|
+
"execa": "^9.6.1",
|
|
37
|
+
"zod": "^4.4.3"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^20",
|
|
41
|
+
"tsup": "^8.5.0",
|
|
42
|
+
"tsx": "^4.20.5",
|
|
43
|
+
"typescript": "^5"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"better-sqlite3": "^11.0.0",
|
|
47
|
+
"mysql2": "^3.0.0",
|
|
48
|
+
"postgres": "^3.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"better-sqlite3": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"mysql2": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"postgres": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=22"
|
|
63
|
+
}
|
|
64
|
+
}
|