Skip to content

Commit 567f958

Browse files
authored
Merge pull request #33 from activeloopai/remove-bytea-add-conv-column
Remove BYTEA column, add Conversation links to index.md
2 parents 2a04134 + 051e8c9 commit 567f958

15 files changed

Lines changed: 409 additions & 413 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tmp/
77
.env.*
88
coverage/
99
bench/
10+
.claude/

claude-code/bundle/capture.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,21 @@ var DeeplakeApi = class {
186186
log2(`commit: ${rows.length} rows`);
187187
}
188188
async upsertRowSql(row) {
189-
const hex = row.content.toString("hex");
190189
const ts = (/* @__PURE__ */ new Date()).toISOString();
191190
const cd = row.creationDate ?? ts;
192191
const lud = row.lastUpdateDate ?? ts;
193192
const exists = await this.query(`SELECT path FROM "${this.tableName}" WHERE path = '${sqlStr(row.path)}' LIMIT 1`);
194193
if (exists.length > 0) {
195-
let setClauses = `content = E'\\\\x${hex}', summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
194+
let setClauses = `summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
196195
if (row.project !== void 0)
197196
setClauses += `, project = '${sqlStr(row.project)}'`;
198197
if (row.description !== void 0)
199198
setClauses += `, description = '${sqlStr(row.description)}'`;
200199
await this.query(`UPDATE "${this.tableName}" SET ${setClauses} WHERE path = '${sqlStr(row.path)}'`);
201200
} else {
202201
const id = randomUUID();
203-
let cols = "id, path, filename, content, summary, mime_type, size_bytes, creation_date, last_update_date";
204-
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'\\\\x${hex}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
202+
let cols = "id, path, filename, summary, mime_type, size_bytes, creation_date, last_update_date";
203+
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
205204
if (row.project !== void 0) {
206205
cols += ", project";
207206
vals += `, '${sqlStr(row.project)}'`;
@@ -258,7 +257,7 @@ var DeeplakeApi = class {
258257
const tables = await this.listTables();
259258
if (!tables.includes(tbl)) {
260259
log2(`table "${tbl}" not found, creating`);
261-
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', content BYTEA NOT NULL DEFAULT ''::bytea, summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'application/octet-stream', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
260+
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'text/plain', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
262261
log2(`table "${tbl}" created`);
263262
} else {
264263
for (const col of ["project", "description", "creation_date", "last_update_date", "author"]) {

claude-code/bundle/pre-tool-use.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,21 @@ var DeeplakeApi = class {
194194
log2(`commit: ${rows.length} rows`);
195195
}
196196
async upsertRowSql(row) {
197-
const hex = row.content.toString("hex");
198197
const ts = (/* @__PURE__ */ new Date()).toISOString();
199198
const cd = row.creationDate ?? ts;
200199
const lud = row.lastUpdateDate ?? ts;
201200
const exists = await this.query(`SELECT path FROM "${this.tableName}" WHERE path = '${sqlStr(row.path)}' LIMIT 1`);
202201
if (exists.length > 0) {
203-
let setClauses = `content = E'\\\\x${hex}', summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
202+
let setClauses = `summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
204203
if (row.project !== void 0)
205204
setClauses += `, project = '${sqlStr(row.project)}'`;
206205
if (row.description !== void 0)
207206
setClauses += `, description = '${sqlStr(row.description)}'`;
208207
await this.query(`UPDATE "${this.tableName}" SET ${setClauses} WHERE path = '${sqlStr(row.path)}'`);
209208
} else {
210209
const id = randomUUID();
211-
let cols = "id, path, filename, content, summary, mime_type, size_bytes, creation_date, last_update_date";
212-
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'\\\\x${hex}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
210+
let cols = "id, path, filename, summary, mime_type, size_bytes, creation_date, last_update_date";
211+
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
213212
if (row.project !== void 0) {
214213
cols += ", project";
215214
vals += `, '${sqlStr(row.project)}'`;
@@ -266,7 +265,7 @@ var DeeplakeApi = class {
266265
const tables = await this.listTables();
267266
if (!tables.includes(tbl)) {
268267
log2(`table "${tbl}" not found, creating`);
269-
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', content BYTEA NOT NULL DEFAULT ''::bytea, summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'application/octet-stream', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
268+
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'text/plain', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
270269
log2(`table "${tbl}" created`);
271270
} else {
272271
for (const col of ["project", "description", "creation_date", "last_update_date", "author"]) {

claude-code/bundle/session-start.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,21 @@ var DeeplakeApi = class {
198198
log2(`commit: ${rows.length} rows`);
199199
}
200200
async upsertRowSql(row) {
201-
const hex = row.content.toString("hex");
202201
const ts = (/* @__PURE__ */ new Date()).toISOString();
203202
const cd = row.creationDate ?? ts;
204203
const lud = row.lastUpdateDate ?? ts;
205204
const exists = await this.query(`SELECT path FROM "${this.tableName}" WHERE path = '${sqlStr(row.path)}' LIMIT 1`);
206205
if (exists.length > 0) {
207-
let setClauses = `content = E'\\\\x${hex}', summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
206+
let setClauses = `summary = E'${sqlStr(row.contentText)}', mime_type = '${sqlStr(row.mimeType)}', size_bytes = ${row.sizeBytes}, last_update_date = '${lud}'`;
208207
if (row.project !== void 0)
209208
setClauses += `, project = '${sqlStr(row.project)}'`;
210209
if (row.description !== void 0)
211210
setClauses += `, description = '${sqlStr(row.description)}'`;
212211
await this.query(`UPDATE "${this.tableName}" SET ${setClauses} WHERE path = '${sqlStr(row.path)}'`);
213212
} else {
214213
const id = randomUUID();
215-
let cols = "id, path, filename, content, summary, mime_type, size_bytes, creation_date, last_update_date";
216-
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'\\\\x${hex}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
214+
let cols = "id, path, filename, summary, mime_type, size_bytes, creation_date, last_update_date";
215+
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'${sqlStr(row.contentText)}', '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
217216
if (row.project !== void 0) {
218217
cols += ", project";
219218
vals += `, '${sqlStr(row.project)}'`;
@@ -270,7 +269,7 @@ var DeeplakeApi = class {
270269
const tables = await this.listTables();
271270
if (!tables.includes(tbl)) {
272271
log2(`table "${tbl}" not found, creating`);
273-
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', content BYTEA NOT NULL DEFAULT ''::bytea, summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'application/octet-stream', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
272+
await this.query(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', summary TEXT NOT NULL DEFAULT '', author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'text/plain', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`);
274273
log2(`table "${tbl}" created`);
275274
} else {
276275
for (const col of ["project", "description", "creation_date", "last_update_date", "author"]) {
@@ -399,9 +398,8 @@ async function createPlaceholder(api, table, sessionId, cwd, userName, orgName,
399398
`- **Status**: in-progress`,
400399
""
401400
].join("\n");
402-
const hex = Buffer.from(content, "utf-8").toString("hex");
403401
const filename = `${sessionId}.md`;
404-
await api.query(`INSERT INTO "${table}" (id, path, filename, content, summary, author, mime_type, size_bytes, project, description, creation_date, last_update_date) VALUES ('${crypto.randomUUID()}', '${sqlStr(summaryPath)}', '${sqlStr(filename)}', E'\\\\x${hex}', E'${sqlStr(content)}', '${sqlStr(userName)}', 'text/markdown', ${Buffer.byteLength(content, "utf-8")}, '${sqlStr(projectName)}', 'in progress', '${now}', '${now}')`);
402+
await api.query(`INSERT INTO "${table}" (id, path, filename, summary, author, mime_type, size_bytes, project, description, creation_date, last_update_date) VALUES ('${crypto.randomUUID()}', '${sqlStr(summaryPath)}', '${sqlStr(filename)}', E'${sqlStr(content)}', '${sqlStr(userName)}', 'text/markdown', ${Buffer.byteLength(content, "utf-8")}, '${sqlStr(projectName)}', 'in progress', '${now}', '${now}')`);
405403
wikiLog(`SessionStart: created placeholder for ${sessionId} (${cwd})`);
406404
}
407405
async function main() {

0 commit comments

Comments
 (0)