cogpit-memory 0.1.9 → 0.2.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/LICENSE +21 -0
- package/README.md +26 -5
- package/dist/cli.d.ts +30 -0
- package/dist/cli.js +1618 -338
- package/dist/commands/context.d.ts +20 -0
- package/dist/commands/index-cmd.d.ts +15 -0
- package/dist/commands/install-skill.d.ts +4 -0
- package/dist/commands/search.d.ts +39 -0
- package/dist/commands/sessions.d.ts +38 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1659 -386
- package/dist/lib/agentEnvelope.d.ts +24 -0
- package/dist/lib/codex-exec.d.ts +27 -0
- package/dist/lib/codex-patches.d.ts +9 -0
- package/dist/lib/codex-tool-normalization.d.ts +14 -0
- package/dist/lib/codex.d.ts +30 -0
- package/dist/lib/dirs.d.ts +8 -0
- package/dist/lib/helpers.d.ts +25 -0
- package/dist/lib/interactiveState.d.ts +40 -0
- package/dist/lib/messageTypeGuards.d.ts +26 -0
- package/dist/lib/metadata.d.ts +31 -0
- package/dist/lib/parser.d.ts +14 -0
- package/dist/lib/response.d.ts +2 -0
- package/dist/lib/search-index.d.ts +154 -0
- package/dist/lib/sessionStats.d.ts +10 -0
- package/dist/lib/sessionStatus.d.ts +42 -0
- package/dist/lib/token-costs.d.ts +27 -0
- package/dist/lib/turnBuilder.d.ts +38 -0
- package/dist/lib/types.d.ts +553 -0
- package/package.json +32 -8
- package/skill/SKILL.md +4 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context command — L1 (session overview), L2 (turn detail), L3 (sub-agent resolution).
|
|
3
|
+
* Ported from routes/session-context.ts to plain functions returning objects.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* L1: Session overview with all turns summarized.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSessionOverview(sessionId: string): Promise<object>;
|
|
9
|
+
/**
|
|
10
|
+
* L2: Detailed view of a single turn.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTurnDetail(sessionId: string, turnIndex: number): Promise<object>;
|
|
13
|
+
/**
|
|
14
|
+
* L3: Sub-agent's session overview.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAgentOverview(sessionId: string, agentId: string): Promise<object>;
|
|
17
|
+
/**
|
|
18
|
+
* L3+L2: Sub-agent turn detail.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAgentTurnDetail(sessionId: string, agentId: string, turnIndex: number): Promise<object>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index command — stats and rebuild for the FTS5 search index.
|
|
3
|
+
*
|
|
4
|
+
* Two entry points:
|
|
5
|
+
* indexStats(dbPath?) — returns IndexStats or error if DB doesn't exist
|
|
6
|
+
* indexRebuild(dbPath?) — creates/rebuilds the FTS5 index, returns stats
|
|
7
|
+
*/
|
|
8
|
+
import { type IndexStats } from "../lib/search-index";
|
|
9
|
+
export declare function indexStats(dbPath?: string): Promise<IndexStats | {
|
|
10
|
+
error: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function indexRebuild(dbPath?: string): Promise<{
|
|
13
|
+
status: string;
|
|
14
|
+
stats: IndexStats;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search command — dual-path session search.
|
|
3
|
+
*
|
|
4
|
+
* Fast path: FTS5 via SearchIndex (when DB exists or is passed as parameter)
|
|
5
|
+
* Fallback: 3-phase raw-scan (discover -> pre-filter -> structured walk)
|
|
6
|
+
*
|
|
7
|
+
* Ported from server/routes/session-search.ts (FTS5 path) and
|
|
8
|
+
* .worktrees/session-context-server/packages/cogpit-memory/src/routes/session-search.ts (raw-scan).
|
|
9
|
+
*/
|
|
10
|
+
import { SearchIndex } from "../lib/search-index";
|
|
11
|
+
export interface SearchOptions {
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
maxAge?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
caseSensitive?: boolean;
|
|
16
|
+
depth?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SearchHit {
|
|
19
|
+
location: string;
|
|
20
|
+
snippet: string;
|
|
21
|
+
matchCount: number;
|
|
22
|
+
toolName?: string;
|
|
23
|
+
agentName?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SessionSearchResult {
|
|
26
|
+
sessionId: string;
|
|
27
|
+
cwd: string;
|
|
28
|
+
hits: SearchHit[];
|
|
29
|
+
}
|
|
30
|
+
export interface SearchResponse {
|
|
31
|
+
query: string;
|
|
32
|
+
totalHits: number;
|
|
33
|
+
returnedHits: number;
|
|
34
|
+
sessionsSearched: number;
|
|
35
|
+
results: SessionSearchResult[];
|
|
36
|
+
}
|
|
37
|
+
export declare function searchSessions(query: string, opts: SearchOptions, searchIndex?: SearchIndex | null): Promise<SearchResponse | {
|
|
38
|
+
error: string;
|
|
39
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sessions command — list recent sessions and find the current session.
|
|
3
|
+
* Ported from the HTTP handlers in routes/sessions-list.ts.
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionSummary {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
model: string;
|
|
10
|
+
cwd: string;
|
|
11
|
+
gitBranch: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
firstMessage: string;
|
|
14
|
+
lastMessage: string;
|
|
15
|
+
turnCount: number;
|
|
16
|
+
status: string;
|
|
17
|
+
mtime: number;
|
|
18
|
+
source?: "claude" | "codex";
|
|
19
|
+
}
|
|
20
|
+
export interface SessionsOptions {
|
|
21
|
+
cwd?: string;
|
|
22
|
+
limit?: number;
|
|
23
|
+
maxAge?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* List recent sessions across all projects, sorted by mtime descending.
|
|
27
|
+
*
|
|
28
|
+
* Options:
|
|
29
|
+
* limit — max results (default 20, max 100)
|
|
30
|
+
* maxAge — filter by recency, e.g. "7d", "12h", "30m" (default "7d")
|
|
31
|
+
* cwd — optional filter: only return sessions whose cwd matches
|
|
32
|
+
*/
|
|
33
|
+
export declare function listSessions(opts?: SessionsOptions): Promise<SessionSummary[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Find the most recently active session for a given working directory.
|
|
36
|
+
* Returns null if no sessions exist for the given cwd.
|
|
37
|
+
*/
|
|
38
|
+
export declare function currentSession(cwd: string): Promise<SessionSummary | null>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cogpit-memory library — exports for cogpit integration.
|
|
3
|
+
*
|
|
4
|
+
* Usage from cogpit:
|
|
5
|
+
* import { SearchIndex } from "../packages/cogpit-memory"
|
|
6
|
+
* const index = new SearchIndex("~/.claude/cogpit-memory/search-index.db")
|
|
7
|
+
* index.startWatching(dirs.PROJECTS_DIR)
|
|
8
|
+
*/
|
|
9
|
+
export { SearchIndex, type IndexStats, type SearchHit } from "./lib/search-index";
|
|
10
|
+
export { parseSession, parseSessionAppend, getUserMessageText, getUserMessageImages, type ParseSessionOptions, } from "./lib/parser";
|
|
11
|
+
export { DEFAULT_DB_PATH, dirs } from "./lib/dirs";
|
|
12
|
+
export { searchSessions, type SearchOptions, type SearchResponse } from "./commands/search";
|
|
13
|
+
export { getSessionOverview, getTurnDetail, getAgentOverview, getAgentTurnDetail } from "./commands/context";
|
|
14
|
+
export { listSessions, currentSession, type SessionSummary, type SessionsOptions } from "./commands/sessions";
|
|
15
|
+
export { indexStats, indexRebuild } from "./commands/index-cmd";
|
|
16
|
+
export type { ParsedSession, Turn, ToolCall, SubAgentMessage, SessionStats } from "./lib/types";
|