better-claude-code
Version:
CLI auxiliary tools for Claude Code
104 lines (97 loc) • 3.6 kB
text/typescript
import { exec } from 'node:child_process';
import z from 'zod';
declare const CLAUDE_CODE_SESSION_COMPACTION_ID = "CLAUDE_CODE_SESSION_COMPACTION_ID";
declare enum MessageSource {
USER = "user",
CC = "assistant"
}
declare class ClaudeHelper {
static getClaudeDir(): string;
static getProjectsDir(): string;
static getProjectDir(projectName: string): string;
static getSessionPath(projectName: string, sessionId: string): string;
static getSessionMetadataPath(projectName: string, sessionId: string): string;
static getSessionsPath(projectName: string): string;
static getClaudeBinaryPath(): string;
static validateClaudeBinary(): void;
static normalizePathForClaudeProjects(dirPath: string): string;
static isUserMessage(messageSource: MessageSource): messageSource is MessageSource.USER;
static isCCMessage(messageSource: MessageSource): messageSource is MessageSource.CC;
static isCompactionSession(lines: string[]): boolean;
static executePromptNonInteractively(prompt: string): Promise<void>;
}
declare const execAsync: typeof exec.__promisify__;
declare enum NodeEnv {
DEVELOPMENT = "development",
PRODUCTION = "production"
}
declare function isDistMode(): boolean;
declare function getDefaultNodeEnv(): NodeEnv;
declare const backendEnvSchema: z.ZodObject<{
SERVER_PORT: z.ZodCoercedNumber<unknown>;
FRONTEND_STATIC_PATH: z.ZodOptional<z.ZodString>;
NODE_ENV: z.ZodEnum<typeof NodeEnv>;
SHELL: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type BackendEnvSchema = z.infer<typeof backendEnvSchema>;
declare const cliEnvSchema: z.ZodObject<{
NODE_ENV: z.ZodEnum<typeof NodeEnv>;
SHELL: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type CliEnvSchema = z.infer<typeof cliEnvSchema>;
declare enum MessageCountMode {
TURN = "turn",
EVENT = "event"
}
declare enum TitleSource {
FIRST_USER_MESSAGE = "first_user_message",
LAST_CC_MESSAGE = "last_cc_message"
}
declare enum SessionSortBy {
DATE = "date",
TOKEN_PERCENTAGE = "tokenPercentage"
}
interface SessionListOptions {
projectPath: string;
limit?: number;
page?: number;
search?: string;
sortBy?: SessionSortBy;
messageCountMode?: MessageCountMode;
titleSource?: TitleSource;
includeImages?: boolean;
includeCustomCommands?: boolean;
includeFilesOrFolders?: boolean;
includeUrls?: boolean;
includeLabels?: boolean;
enablePagination?: boolean;
}
interface SessionListItem {
id: string;
title: string;
messageCount: number;
createdAt: number;
tokenPercentage?: number;
imageCount?: number;
customCommandCount?: number;
filesOrFoldersCount?: number;
urlCount?: number;
labels?: string[];
searchMatchCount?: number;
filePath?: string;
shortId?: string;
userMessageCount?: number;
assistantMessageCount?: number;
}
interface SessionListResult {
items: SessionListItem[];
meta?: {
totalItems: number;
totalPages: number;
page: number;
limit: number;
};
}
declare function listSessions(options: SessionListOptions): Promise<SessionListResult>;
declare function generateUuid(): `${string}-${string}-${string}-${string}-${string}`;
export { type BackendEnvSchema, CLAUDE_CODE_SESSION_COMPACTION_ID, ClaudeHelper, type CliEnvSchema, MessageCountMode, MessageSource, NodeEnv, type SessionListItem, type SessionListOptions, type SessionListResult, SessionSortBy, TitleSource, backendEnvSchema, cliEnvSchema, execAsync, generateUuid, getDefaultNodeEnv, isDistMode, listSessions };