@aliou/sesame 0.8.0 → 0.9.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/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/format-tool-call.d.ts.map +1 -1
- package/dist/indexer/format-tool-call.js.map +1 -1
- package/dist/indexer/index.d.ts +1 -2
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +4 -1
- package/dist/indexer/index.js.map +1 -1
- package/dist/parsers/pi.d.ts +2 -2
- package/dist/parsers/pi.d.ts.map +1 -1
- package/dist/parsers/pi.js.map +1 -1
- package/dist/storage/db.d.ts +9 -0
- package/dist/storage/db.d.ts.map +1 -1
- package/dist/storage/db.js +30 -0
- package/dist/storage/db.js.map +1 -1
- package/dist/storage/migrations/001-add-is-error.d.ts.map +1 -1
- package/dist/storage/migrations/001-add-is-error.js.map +1 -1
- package/dist/storage/migrations/002-add-metadata.d.ts.map +1 -1
- package/dist/storage/migrations/002-add-metadata.js.map +1 -1
- package/dist/storage/migrations/003-add-tree-fields.d.ts.map +1 -1
- package/dist/storage/migrations/003-add-tree-fields.js.map +1 -1
- package/dist/storage/migrations/index.d.ts.map +1 -1
- package/dist/storage/migrations/index.js.map +1 -1
- package/dist/test-helpers/session-factory.d.ts.map +1 -1
- package/dist/test-helpers/session-factory.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/session.d.ts +3 -15
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +2 -3
- package/dist/types/session.js.map +1 -1
- package/dist/utils/config.d.ts +2 -5
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +5 -8
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/index-lock.d.ts.map +1 -1
- package/dist/utils/index-lock.js +3 -1
- package/dist/utils/index-lock.js.map +1 -1
- package/dist/utils/xdg.d.ts.map +1 -1
- package/dist/utils/xdg.js.map +1 -1
- package/package.json +7 -36
- package/README.md +0 -61
- package/bin/sesame +0 -19
- package/dist/commands/index-cmd.d.ts +0 -5
- package/dist/commands/index-cmd.d.ts.map +0 -1
- package/dist/commands/index-cmd.js +0 -83
- package/dist/commands/index-cmd.js.map +0 -1
- package/dist/commands/search-cmd.d.ts +0 -5
- package/dist/commands/search-cmd.d.ts.map +0 -1
- package/dist/commands/search-cmd.js +0 -134
- package/dist/commands/search-cmd.js.map +0 -1
- package/dist/commands/status-cmd.d.ts +0 -5
- package/dist/commands/status-cmd.d.ts.map +0 -1
- package/dist/commands/status-cmd.js +0 -30
- package/dist/commands/status-cmd.js.map +0 -1
- package/dist/commands/watch-cmd.d.ts +0 -5
- package/dist/commands/watch-cmd.d.ts.map +0 -1
- package/dist/commands/watch-cmd.js +0 -178
- package/dist/commands/watch-cmd.js.map +0 -1
- package/dist/commands/watch-queue.d.ts +0 -14
- package/dist/commands/watch-queue.d.ts.map +0 -1
- package/dist/commands/watch-queue.js +0 -68
- package/dist/commands/watch-queue.js.map +0 -1
- package/dist/sesame.d.ts +0 -18
- package/dist/sesame.d.ts.map +0 -1
- package/dist/sesame.js +0 -65
- package/dist/sesame.js.map +0 -1
- package/share/pi-extension/src/index.ts +0 -7
- package/share/pi-extension/src/tools/sesame-search.ts +0 -143
- package/skills/sesame/SKILL.md +0 -71
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Watch command - monitors and indexes session files on change
|
|
3
|
-
*/
|
|
4
|
-
import { mkdirSync, watch } from "node:fs";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { indexSessions } from "../indexer/index";
|
|
7
|
-
import { PiParser } from "../parsers/pi";
|
|
8
|
-
import { openDatabase, setMetadata } from "../storage/db";
|
|
9
|
-
import { expandPath, loadConfig } from "../utils/config";
|
|
10
|
-
import { acquireIndexLock } from "../utils/index-lock";
|
|
11
|
-
import { getXDGPaths } from "../utils/xdg";
|
|
12
|
-
import { createReindexQueue } from "./watch-queue";
|
|
13
|
-
export default async function watchCommand(args) {
|
|
14
|
-
// Parse --interval flag
|
|
15
|
-
let pollInterval = null;
|
|
16
|
-
const intervalIndex = args.indexOf("--interval");
|
|
17
|
-
if (intervalIndex !== -1 && args[intervalIndex + 1]) {
|
|
18
|
-
const intervalValue = parseInt(args[intervalIndex + 1], 10);
|
|
19
|
-
if (Number.isNaN(intervalValue) || intervalValue <= 0) {
|
|
20
|
-
console.error("Error: --interval must be a positive number");
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
pollInterval = intervalValue * 1000; // Convert to milliseconds
|
|
24
|
-
}
|
|
25
|
-
// Load configuration
|
|
26
|
-
const config = await loadConfig();
|
|
27
|
-
// Get data directory and ensure it exists
|
|
28
|
-
const paths = getXDGPaths();
|
|
29
|
-
mkdirSync(paths.data, { recursive: true });
|
|
30
|
-
const indexLock = acquireIndexLock(paths.data, "watch");
|
|
31
|
-
// Open database
|
|
32
|
-
const dbPath = join(paths.data, "index.sqlite");
|
|
33
|
-
const db = openDatabase(dbPath);
|
|
34
|
-
const state = {
|
|
35
|
-
db,
|
|
36
|
-
indexLock,
|
|
37
|
-
watchers: [],
|
|
38
|
-
debounceTimers: new Map(),
|
|
39
|
-
isShuttingDown: false,
|
|
40
|
-
};
|
|
41
|
-
const reindexQueue = createReindexQueue((sources) => runIndexing(state, sources), () => state.isShuttingDown, console.error);
|
|
42
|
-
// Set up graceful shutdown
|
|
43
|
-
const shutdown = () => {
|
|
44
|
-
if (state.isShuttingDown) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
state.isShuttingDown = true;
|
|
48
|
-
console.error("\n[%s] Shutting down...", new Date().toISOString());
|
|
49
|
-
// Clear all debounce timers
|
|
50
|
-
for (const timer of state.debounceTimers.values()) {
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
}
|
|
53
|
-
state.debounceTimers.clear();
|
|
54
|
-
// Close all watchers
|
|
55
|
-
for (const watcher of state.watchers) {
|
|
56
|
-
watcher.close();
|
|
57
|
-
}
|
|
58
|
-
state.watchers = [];
|
|
59
|
-
// Clear interval if polling
|
|
60
|
-
if (state.intervalId) {
|
|
61
|
-
clearInterval(state.intervalId);
|
|
62
|
-
}
|
|
63
|
-
// Close database and release process lock
|
|
64
|
-
state.db.close();
|
|
65
|
-
state.indexLock.release();
|
|
66
|
-
console.error("[%s] Shutdown complete", new Date().toISOString());
|
|
67
|
-
process.exit(0);
|
|
68
|
-
};
|
|
69
|
-
process.on("SIGINT", shutdown);
|
|
70
|
-
process.on("SIGTERM", shutdown);
|
|
71
|
-
try {
|
|
72
|
-
console.error("[%s] Starting watch mode...", new Date().toISOString());
|
|
73
|
-
// Run initial index pass
|
|
74
|
-
console.error("[%s] Running initial index...", new Date().toISOString());
|
|
75
|
-
await runIndexing(state, config.sources);
|
|
76
|
-
if (pollInterval) {
|
|
77
|
-
// Polling mode
|
|
78
|
-
console.error("[%s] Starting poll-based monitoring (interval: %d seconds)", new Date().toISOString(), pollInterval / 1000);
|
|
79
|
-
state.intervalId = setInterval(() => {
|
|
80
|
-
if (!state.isShuttingDown) {
|
|
81
|
-
reindexQueue.enqueue(config.sources, "scheduled");
|
|
82
|
-
}
|
|
83
|
-
}, pollInterval);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// File system watch mode
|
|
87
|
-
console.error("[%s] Starting file system monitoring...", new Date().toISOString());
|
|
88
|
-
for (const source of config.sources) {
|
|
89
|
-
const expandedPath = expandPath(source.path);
|
|
90
|
-
if (source.parser !== "pi") {
|
|
91
|
-
console.error("[%s] Skipping watch for %s: unsupported parser '%s'", new Date().toISOString(), source.path, source.parser);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const watcher = watch(expandedPath, { recursive: true }, (eventType, filename) => {
|
|
96
|
-
if (state.isShuttingDown) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const timestamp = new Date().toISOString();
|
|
100
|
-
console.error("[%s] Detected %s: %s", timestamp, eventType, filename || "unknown");
|
|
101
|
-
// Debounce: clear existing timer and set new one
|
|
102
|
-
const existingTimer = state.debounceTimers.get(expandedPath);
|
|
103
|
-
if (existingTimer) {
|
|
104
|
-
clearTimeout(existingTimer);
|
|
105
|
-
}
|
|
106
|
-
const timer = setTimeout(() => {
|
|
107
|
-
state.debounceTimers.delete(expandedPath);
|
|
108
|
-
if (!state.isShuttingDown) {
|
|
109
|
-
reindexQueue.enqueue([source], `fs:${eventType}`);
|
|
110
|
-
}
|
|
111
|
-
}, 500);
|
|
112
|
-
state.debounceTimers.set(expandedPath, timer);
|
|
113
|
-
});
|
|
114
|
-
watcher.on("error", (error) => {
|
|
115
|
-
console.error("[%s] Watcher error for %s: %s", new Date().toISOString(), expandedPath, error.message);
|
|
116
|
-
});
|
|
117
|
-
state.watchers.push(watcher);
|
|
118
|
-
console.error("[%s] Watching: %s", new Date().toISOString(), expandedPath);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error("[%s] Failed to watch %s: %s", new Date().toISOString(), expandedPath, error instanceof Error ? error.message : String(error));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
console.error("[%s] Watch mode active. Press Ctrl+C to stop.", new Date().toISOString());
|
|
126
|
-
// Keep the process alive
|
|
127
|
-
await new Promise(() => { });
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
console.error("[%s] Fatal error: %s", new Date().toISOString(), error instanceof Error ? error.message : String(error));
|
|
131
|
-
shutdown();
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async function runIndexing(state, sources) {
|
|
136
|
-
const timestamp = new Date().toISOString();
|
|
137
|
-
let totalAdded = 0;
|
|
138
|
-
let totalUpdated = 0;
|
|
139
|
-
let totalErrors = 0;
|
|
140
|
-
for (const source of sources) {
|
|
141
|
-
const expandedPath = expandPath(source.path);
|
|
142
|
-
if (source.parser !== "pi") {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
const parser = new PiParser();
|
|
146
|
-
try {
|
|
147
|
-
const result = await indexSessions(state.db, expandedPath, parser);
|
|
148
|
-
totalAdded += result.added;
|
|
149
|
-
totalUpdated += result.updated;
|
|
150
|
-
totalErrors += result.errors;
|
|
151
|
-
// Log to stderr (human-readable)
|
|
152
|
-
console.error("[%s] Indexed %s - added: %d, updated: %d, skipped: %d, errors: %d", timestamp, expandedPath, result.added, result.updated, result.skipped, result.errors);
|
|
153
|
-
// Log to stdout (JSON for machine consumption)
|
|
154
|
-
console.log(JSON.stringify({
|
|
155
|
-
timestamp,
|
|
156
|
-
path: expandedPath,
|
|
157
|
-
added: result.added,
|
|
158
|
-
updated: result.updated,
|
|
159
|
-
skipped: result.skipped,
|
|
160
|
-
errors: result.errors,
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
totalErrors += 1;
|
|
165
|
-
console.error("[%s] Error indexing %s: %s", timestamp, expandedPath, error instanceof Error ? error.message : String(error));
|
|
166
|
-
// Log error to stdout as JSON
|
|
167
|
-
console.log(JSON.stringify({
|
|
168
|
-
timestamp,
|
|
169
|
-
path: expandedPath,
|
|
170
|
-
error: error instanceof Error ? error.message : String(error),
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (totalErrors === 0 && totalAdded + totalUpdated > 0) {
|
|
175
|
-
setMetadata(state.db, "last_sync_at", new Date().toISOString());
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
//# sourceMappingURL=watch-cmd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch-cmd.js","sourceRoot":"","sources":["../../src/commands/watch-cmd.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,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AE,MAAM,CAAC,MAAM;aACtB,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,IAAI,CAAC,CAAC;YAEjB,OAAO,CAAC,KAAK,CACX,4BAA4B,EAC5B,SAAS,EACT,YAAY,EACZ,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;YAEF,8BAA8B;YAC9B,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC;gBACb,SAAS;gBACT,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,WAAW,KAAK,CAAC,IAAI,UAAU,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC;QACvD,WAAW,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type SourceConfig = {
|
|
2
|
-
path: string;
|
|
3
|
-
parser: string;
|
|
4
|
-
};
|
|
5
|
-
type RunBatch = (sources: SourceConfig[]) => Promise<void>;
|
|
6
|
-
type IsShuttingDown = () => boolean;
|
|
7
|
-
type Log = (message: string, ...args: unknown[]) => void;
|
|
8
|
-
export interface ReindexQueue {
|
|
9
|
-
enqueue: (sources: SourceConfig[], reason: string) => void;
|
|
10
|
-
waitForIdle: () => Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export declare function createReindexQueue(runBatch: RunBatch, isShuttingDown: IsShuttingDown, log: Log): ReindexQueue;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=watch-queue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch-queue.d.ts","sourceRoot":"","sources":["../../src/commands/watch-queue.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3D,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;AACpC,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,GAAG,GACP,YAAY,CAmFd"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { expandPath } from "../utils/config";
|
|
2
|
-
export function createReindexQueue(runBatch, isShuttingDown, log) {
|
|
3
|
-
let isIndexing = false;
|
|
4
|
-
const pendingSources = new Map();
|
|
5
|
-
const idleResolvers = new Set();
|
|
6
|
-
function resolveIdleIfIdle() {
|
|
7
|
-
if (!isShuttingDown() && (isIndexing || pendingSources.size > 0)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
for (const resolve of idleResolvers) {
|
|
11
|
-
resolve();
|
|
12
|
-
}
|
|
13
|
-
idleResolvers.clear();
|
|
14
|
-
}
|
|
15
|
-
async function drain() {
|
|
16
|
-
if (isIndexing || isShuttingDown()) {
|
|
17
|
-
resolveIdleIfIdle();
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
isIndexing = true;
|
|
21
|
-
try {
|
|
22
|
-
while (!isShuttingDown()) {
|
|
23
|
-
const sources = Array.from(pendingSources.values());
|
|
24
|
-
pendingSources.clear();
|
|
25
|
-
if (sources.length === 0) {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
log("[%s] Re-indexing %d source(s)...", new Date().toISOString(), sources.length);
|
|
29
|
-
await runBatch(sources);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
finally {
|
|
33
|
-
isIndexing = false;
|
|
34
|
-
if (!isShuttingDown() && pendingSources.size > 0) {
|
|
35
|
-
void drain();
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
resolveIdleIfIdle();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
enqueue: (sources, reason) => {
|
|
44
|
-
for (const source of sources) {
|
|
45
|
-
pendingSources.set(expandPath(source.path), source);
|
|
46
|
-
}
|
|
47
|
-
if (isShuttingDown()) {
|
|
48
|
-
pendingSources.clear();
|
|
49
|
-
resolveIdleIfIdle();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (isIndexing) {
|
|
53
|
-
log("[%s] Indexing in progress; queued %d source(s) (%s)", new Date().toISOString(), pendingSources.size, reason);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
void drain();
|
|
57
|
-
},
|
|
58
|
-
waitForIdle: () => {
|
|
59
|
-
if (isShuttingDown() || (!isIndexing && pendingSources.size === 0)) {
|
|
60
|
-
return Promise.resolve();
|
|
61
|
-
}
|
|
62
|
-
return new Promise((resolve) => {
|
|
63
|
-
idleResolvers.add(resolve);
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=watch-queue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch-queue.js","s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IAAI,cAAc,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBACjD,KAAK,KAAK,EAAE,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,iBAAiB,EAAE,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,OAAuB,EAAE,MAAc,EAAE,EAAE;YACnD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;YACtD,CAAC;YAED,IAAI,cAAc,EAAE,EAAE,CAAC;gBACrB,cAAc,CAAC,KAAK,EAAE,CAAC;gBACvB,iBAAiB,EAAE,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,GAAG,CACD,qDAAqD,EACrD,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EACxB,cAAc,CAAC,IAAI,EACnB,MAAM,CACP,CAAC;gBACF,OAAO;YACT,CAAC;YAED,KAAK,KAAK,EAAE,CAAC;QACf,CAAC;QACD,WAAW,EAAE,GAAG,EAAE;YAChB,IAAI,cAAc,EAAE,IAAI,CAAC,CAAC,UAAU,IAAI,cAAc,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;gBACnE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;YAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBACnC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/sesame.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Sesame - Semantic search for coding agent sessions
|
|
4
|
-
* Main CLI entry point
|
|
5
|
-
*/
|
|
6
|
-
declare const commands: {
|
|
7
|
-
index: () => Promise<typeof import("./commands/index-cmd")>;
|
|
8
|
-
search: () => Promise<typeof import("./commands/search-cmd")>;
|
|
9
|
-
status: () => Promise<typeof import("./commands/status-cmd")>;
|
|
10
|
-
watch: () => Promise<typeof import("./commands/watch-cmd")>;
|
|
11
|
-
help: () => Promise<{
|
|
12
|
-
default: (..._args: unknown[]) => Promise<void>;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
type Command = keyof typeof commands;
|
|
16
|
-
declare function printUsage(): void;
|
|
17
|
-
declare function main(): Promise<void>;
|
|
18
|
-
//# sourceMappingURL=sesame.d.ts.map
|
package/dist/sesame.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sesame.d.ts","sourceRoot":"","sources":["../src/sesame.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,QAAA,MAAM,QAAQ;;;;;;4BAOY,OAAO,EAAE;;CAElC,CAAC;AAEF,KAAK,OAAO,GAAG,MAAM,OAAO,QAAQ,CAAC;AAErC,iBAAS,UAAU,SAsBlB;AAED,iBAAe,IAAI,kBA+BlB"}
|
package/dist/sesame.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* Sesame - Semantic search for coding agent sessions
|
|
5
|
-
* Main CLI entry point
|
|
6
|
-
*/
|
|
7
|
-
const commands = {
|
|
8
|
-
index: () => import("./commands/index-cmd"),
|
|
9
|
-
search: () => import("./commands/search-cmd"),
|
|
10
|
-
status: () => import("./commands/status-cmd"),
|
|
11
|
-
watch: () => import("./commands/watch-cmd"),
|
|
12
|
-
help: () => Promise.resolve({
|
|
13
|
-
default: (..._args) => Promise.resolve(printUsage()),
|
|
14
|
-
}),
|
|
15
|
-
};
|
|
16
|
-
function printUsage() {
|
|
17
|
-
console.log(`Sesame - Search for coding agent sessions
|
|
18
|
-
|
|
19
|
-
Usage: sesame <command> [options]
|
|
20
|
-
|
|
21
|
-
Commands:
|
|
22
|
-
index Index session files (incremental)
|
|
23
|
-
index --full Drop and rebuild index
|
|
24
|
-
search <query> Search sessions
|
|
25
|
-
status Show index statistics
|
|
26
|
-
watch Watch session files and index on change
|
|
27
|
-
watch --interval <seconds> Poll-based re-indexing at fixed interval
|
|
28
|
-
|
|
29
|
-
Search options:
|
|
30
|
-
--cwd <path> Filter by project directory
|
|
31
|
-
--after <date> Filter sessions after date (7d, 2w, 1m, or ISO date)
|
|
32
|
-
--before <date> Filter sessions before date
|
|
33
|
-
--limit <n> Max results (default: 10)
|
|
34
|
-
--tools Search only tool call chunks
|
|
35
|
-
--tool <name> Search specific tool type
|
|
36
|
-
--json Output as JSON
|
|
37
|
-
`);
|
|
38
|
-
}
|
|
39
|
-
async function main() {
|
|
40
|
-
const args = process.argv.slice(2);
|
|
41
|
-
if (args.length === 0 ||
|
|
42
|
-
args[0] === "help" ||
|
|
43
|
-
args[0] === "--help" ||
|
|
44
|
-
args[0] === "-h") {
|
|
45
|
-
printUsage();
|
|
46
|
-
process.exit(0);
|
|
47
|
-
}
|
|
48
|
-
const commandName = args[0];
|
|
49
|
-
const commandArgs = args.slice(1);
|
|
50
|
-
if (!(commandName in commands)) {
|
|
51
|
-
console.error(`Unknown command: ${commandName}`);
|
|
52
|
-
console.error(`Run 'sesame help' for usage information.`);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const commandModule = await commands[commandName]();
|
|
57
|
-
await commandModule.default(commandArgs);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
main();
|
|
65
|
-
//# sourceMappingURL=sesame.js.map
|
package/dist/sesame.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACpD,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Type,
|
|
3
|
-
type ExtensionAPI,
|
|
4
|
-
type ToolDefinition,
|
|
5
|
-
} from "@mariozechner/pi-coding-agent";
|
|
6
|
-
|
|
7
|
-
interface SearchResult {
|
|
8
|
-
sessionId: string;
|
|
9
|
-
source: string;
|
|
10
|
-
path: string;
|
|
11
|
-
cwd: string | null;
|
|
12
|
-
name: string | null;
|
|
13
|
-
score: number;
|
|
14
|
-
created: string | null;
|
|
15
|
-
matchedSnippet: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface SearchResponse {
|
|
19
|
-
query: string;
|
|
20
|
-
resultCount: number;
|
|
21
|
-
results: SearchResult[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createSesameSearchTool(
|
|
25
|
-
pi: ExtensionAPI,
|
|
26
|
-
): ToolDefinition {
|
|
27
|
-
return {
|
|
28
|
-
name: "sesame_search",
|
|
29
|
-
description:
|
|
30
|
-
'Search past coding sessions by topic, concept, or keyword using BM25 full-text search. More effective than find_sessions for multi-word queries like "nix infrastructure simplify" or "carousel company website". Supports date and directory filters.',
|
|
31
|
-
parameters: Type.Object({
|
|
32
|
-
query: Type.String({
|
|
33
|
-
description: "Search query (words, concepts, or phrases)",
|
|
34
|
-
}),
|
|
35
|
-
cwd: Type.Optional(
|
|
36
|
-
Type.String({ description: "Filter by project directory path" }),
|
|
37
|
-
),
|
|
38
|
-
after: Type.Optional(
|
|
39
|
-
Type.String({
|
|
40
|
-
description:
|
|
41
|
-
"Filter sessions after date (7d, 2w, 1m, or ISO date)",
|
|
42
|
-
}),
|
|
43
|
-
),
|
|
44
|
-
before: Type.Optional(
|
|
45
|
-
Type.String({
|
|
46
|
-
description:
|
|
47
|
-
"Filter sessions before date (7d, 2w, 1m, or ISO date)",
|
|
48
|
-
}),
|
|
49
|
-
),
|
|
50
|
-
limit: Type.Optional(
|
|
51
|
-
Type.Number({ description: "Max results (default: 10)" }),
|
|
52
|
-
),
|
|
53
|
-
}),
|
|
54
|
-
|
|
55
|
-
async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
|
|
56
|
-
const args = ["search", params.query, "--json"];
|
|
57
|
-
if (params.cwd) args.push("--cwd", params.cwd);
|
|
58
|
-
if (params.after) args.push("--after", params.after);
|
|
59
|
-
if (params.before) args.push("--before", params.before);
|
|
60
|
-
if (params.limit) args.push("--limit", String(params.limit));
|
|
61
|
-
|
|
62
|
-
const result = await pi.exec("sesame", args, {
|
|
63
|
-
signal,
|
|
64
|
-
timeout: 30000,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (result.code !== 0) {
|
|
68
|
-
return {
|
|
69
|
-
output: `Sesame search failed: ${result.stderr || "unknown error"}`,
|
|
70
|
-
isError: true,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let data: SearchResponse;
|
|
75
|
-
try {
|
|
76
|
-
data = JSON.parse(result.stdout) as SearchResponse;
|
|
77
|
-
} catch {
|
|
78
|
-
return { output: result.stdout };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (data.resultCount === 0) {
|
|
82
|
-
return {
|
|
83
|
-
output: `No sessions found matching "${params.query}"`,
|
|
84
|
-
details: data,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let text = `Found ${data.resultCount} sessions matching "${params.query}"\n\n`;
|
|
89
|
-
for (const r of data.results) {
|
|
90
|
-
text += `[${r.score}] ${r.sessionId}`;
|
|
91
|
-
if (r.name) text += ` (${r.name})`;
|
|
92
|
-
text += ` - ${r.created?.split("T")[0] || "unknown date"}\n`;
|
|
93
|
-
if (r.cwd) text += ` cwd: ${r.cwd}\n`;
|
|
94
|
-
text += ` path: ${r.path}\n`;
|
|
95
|
-
text += ` "${r.matchedSnippet?.slice(0, 200) || ""}"\n\n`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
output: text,
|
|
100
|
-
details: data,
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
renderCall(params, theme) {
|
|
105
|
-
let text = theme.fg("toolTitle", theme.bold("sesame_search "));
|
|
106
|
-
text += theme.fg("muted", `"${params.query}"`);
|
|
107
|
-
if (params.cwd) text += theme.fg("dim", ` --cwd ${params.cwd}`);
|
|
108
|
-
if (params.after) text += theme.fg("dim", ` --after ${params.after}`);
|
|
109
|
-
if (params.before)
|
|
110
|
-
text += theme.fg("dim", ` --before ${params.before}`);
|
|
111
|
-
if (params.limit) text += theme.fg("dim", ` --limit ${params.limit}`);
|
|
112
|
-
return text;
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
renderResult(result, { isPartial }, theme) {
|
|
116
|
-
if (isPartial) {
|
|
117
|
-
return theme.fg("muted", "Searching...");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const data = result.details as SearchResponse | undefined;
|
|
121
|
-
if (!data) return undefined;
|
|
122
|
-
|
|
123
|
-
if (data.resultCount === 0) {
|
|
124
|
-
return theme.fg("warning", `No sessions found matching "${data.query}"`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const lines = [
|
|
128
|
-
theme.fg(
|
|
129
|
-
"success",
|
|
130
|
-
`Found ${data.resultCount} sessions matching "${data.query}"`,
|
|
131
|
-
),
|
|
132
|
-
];
|
|
133
|
-
for (const r of data.results) {
|
|
134
|
-
const name = r.name ? ` (${r.name})` : "";
|
|
135
|
-
const date = r.created?.split("T")[0] || "";
|
|
136
|
-
lines.push(
|
|
137
|
-
` ${theme.fg("accent", `[${r.score}]`)} ${r.sessionId.slice(0, 8)}${name} ${theme.fg("dim", date)}`,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return lines.join("\n");
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
}
|
package/skills/sesame/SKILL.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sesame
|
|
3
|
-
description: Search past coding sessions with Sesame BM25 search. Use for multi-word topic queries, tool-call searches, or listing recent sessions when find_sessions is too strict.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Sesame - Session Search
|
|
7
|
-
|
|
8
|
-
Sesame indexes coding agent sessions into SQLite FTS5 and ranks results with BM25.
|
|
9
|
-
|
|
10
|
-
## When to use
|
|
11
|
-
|
|
12
|
-
Use **sesame** when you need:
|
|
13
|
-
- Multi-word topic search (`"nix infra cleanup"`, `"publish workflow changesets"`)
|
|
14
|
-
- Tool-call oriented search (`--tools`, `--tool bash`, `--path package.json`)
|
|
15
|
-
- Session discovery / paging (`"*"` with filters and `--exclude`)
|
|
16
|
-
|
|
17
|
-
Use **find_sessions** for quick exact keyword lookups.
|
|
18
|
-
Use **read_session** after you identified the session to inspect.
|
|
19
|
-
|
|
20
|
-
## CLI
|
|
21
|
-
|
|
22
|
-
### Search
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
sesame search "query"
|
|
26
|
-
sesame search "query" --json
|
|
27
|
-
sesame search "query" --cwd /path/to/project
|
|
28
|
-
sesame search "query" --after 7d
|
|
29
|
-
sesame search "query" --before 2026-01-01
|
|
30
|
-
sesame search "query" --limit 5
|
|
31
|
-
sesame search "query" --tools
|
|
32
|
-
sesame search "query" --tool bash
|
|
33
|
-
sesame search "query" --path package.json
|
|
34
|
-
sesame search "query" --exclude <session-id> --exclude <session-id>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Special query to list sessions instead of full-text match:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
sesame search "*" --limit 20
|
|
41
|
-
sesame search "*" --cwd /path --after 2w --exclude <session-id>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Index / status / watch
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
sesame index
|
|
48
|
-
sesame index --full
|
|
49
|
-
sesame status
|
|
50
|
-
sesame watch
|
|
51
|
-
sesame watch --interval 30
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Practical workflow
|
|
55
|
-
|
|
56
|
-
1. Run `sesame search "query"`.
|
|
57
|
-
2. If results are empty or stale, run `sesame index`.
|
|
58
|
-
3. Narrow using `--cwd`, `--after`, `--before`, `--tools`, `--tool`, or `--path`.
|
|
59
|
-
4. Use `--exclude` to page through additional results across repeated searches.
|
|
60
|
-
5. Use `--json` when another tool/agent needs structured output.
|
|
61
|
-
|
|
62
|
-
## Date formats
|
|
63
|
-
|
|
64
|
-
- Relative: `7d`, `2w`, `1m`
|
|
65
|
-
- Absolute: `YYYY-MM-DD` (ISO date)
|
|
66
|
-
|
|
67
|
-
## Notes
|
|
68
|
-
|
|
69
|
-
- Scores are normalized to `0.00-1.00` for display. Higher is better.
|
|
70
|
-
- `sesame watch` runs an initial index pass, then re-indexes on change.
|
|
71
|
-
- The `sesame_search` pi extension tool exposes only: `query`, `cwd`, `after`, `before`, `limit`.
|