Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
node_modules/
.pnp/
.pnp.js

*.js
*.d.ts
# Bun
bun.lockb
.bun/
Expand All @@ -12,6 +13,7 @@ dist/
build/
out/
*.tsbuildinfo
__tests__

# TypeScript
*.js.map
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ coverage
*.tsbuildinfo
bun.lock
docs
.husky/_
.husky/_
*.js
70 changes: 67 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default [
"**/*.d.ts",
".husky/_/**",
"docs/**",
"**/*.js",
"**/*.d.ts",
],
},

Expand Down
12 changes: 9 additions & 3 deletions packages/cli/src/DeleteCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Command } from "commander";
import { Config, DbProviderType } from "@bb/types";
import { getConfigValue } from "@bb/config";
import { ensureServerRunning, ServerStartTimeoutError } from "./serverSpawn.ts";
import { deleteJson, HttpClientError } from "./httpClient.ts";
import { promptRepoSelector } from "./repoSelectorPrompt.ts";
Expand All @@ -14,7 +16,10 @@ interface DeleteResponse {

export function buildDeleteCommand(): Command {
const cmd = new Command("delete");
cmd.description("Pick one or more indexed knowledge entries and delete them from Mongo + Neo4j.").action(runDelete);
const dbProvider = getConfigValue(Config.DbProvider) === DbProviderType.Sqlite ? "SQLite" : "Mongo";
cmd
.description(`Pick one or more indexed knowledge entries and delete them from ${dbProvider} + Neo4j.`)
.action(runDelete);
return cmd;
}

Expand Down Expand Up @@ -51,10 +56,11 @@ async function runDelete(): Promise<void> {
}

function formatDeletePrompt(labels: string[]): string {
const dbProvider = getConfigValue(Config.DbProvider) === DbProviderType.Sqlite ? "SQLite" : "Mongo";
if (labels.length === 1) {
return `Delete ${labels[0]} from Mongo + Neo4j? [y/N]`;
return `Delete ${labels[0]} from ${dbProvider} + Neo4j? [y/N]`;
}
return `Delete ${labels.length} entries from Mongo + Neo4j? [y/N]`;
return `Delete ${labels.length} entries from ${dbProvider} + Neo4j? [y/N]`;
}

function handleError(cause: unknown): void {
Expand Down
26 changes: 18 additions & 8 deletions packages/cli/src/LsInteractive.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { useState, useMemo } from "react";
import type { ReactElement } from "react";
import { Box, Text, useApp, useInput } from "ink";
import type { CommitHashRecord } from "@bb/types";

export interface RepoEntry {
knowledgeId: string;
source:
| { kind: "github"; repoUrl: string; branch?: string; commitId?: string; commitHashes?: string[] }
| {
kind: "github";
repoUrl: string;
branch?: string;
commitId?: string;
commitHashes?: (string | CommitHashRecord)[];
}
| { kind: "local"; sourcePath: string };
state: string;
createdAt: string;
Expand Down Expand Up @@ -204,13 +211,16 @@ export function LsInteractive({ repos, onDone }: LsInteractiveProps): ReactEleme
Indexed Commits ({s.commitHashes?.length ?? 0})
</Text>
</Box>
{(s.commitHashes ?? []).map((h, i) => (
<Box key={h} marginLeft={2}>
<Text dimColor>{i + 1}. </Text>
<Text color="yellow">{h.slice(0, 8)}</Text>
{h === s.commitId && <Text color="green"> (current head)</Text>}
</Box>
))}
{(s.commitHashes ?? []).map((h, i) => {
const hash = typeof h === "string" ? h : (h as { hash: string }).hash;
return (
<Box key={hash} marginLeft={2}>
<Text dimColor>{i + 1}. </Text>
<Text color="yellow">{hash.slice(0, 8)}</Text>
{hash === s.commitId && <Text color="green"> (current head)</Text>}
</Box>
);
})}
{(!s.commitHashes || s.commitHashes.length === 0) && (
<Box marginLeft={2}>
<Text dimColor>No commit history recorded.</Text>
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/repoSelectorPrompt.ts
Comment thread
bharatsachya marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render } from "ink";
import type { CommitHashRecord } from "@bb/types";
import { getJson } from "./httpClient.ts";
import {
RepoSelector,
Expand Down Expand Up @@ -27,7 +28,13 @@ import {
export interface RepoListEntry {
knowledgeId: string;
source:
| { kind: "github"; repoUrl: string; branch?: string; commitId?: string; commitHashes?: string[] }
| {
kind: "github";
repoUrl: string;
branch?: string;
commitId?: string;
commitHashes?: (string | CommitHashRecord)[];
}
| { kind: "local"; sourcePath: string };
state: string;
createdAt: string;
Expand Down
Loading
Loading