reasonix 0.5.8 → 0.5.13
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/cli/index.js +454 -122
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +44 -6
- package/dist/index.js +44 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1085,6 +1085,22 @@ interface ListFilesOptions {
|
|
|
1085
1085
|
* - entries the walker can't read (permission errors, broken links).
|
|
1086
1086
|
*/
|
|
1087
1087
|
declare function listFilesSync(root: string, opts?: ListFilesOptions): string[];
|
|
1088
|
+
interface FileWithStats {
|
|
1089
|
+
/** Relative path with forward-slash separator. */
|
|
1090
|
+
path: string;
|
|
1091
|
+
/** Modification time (Date.getTime() / ms since epoch). 0 when stat failed. */
|
|
1092
|
+
mtimeMs: number;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Same walk as {@link listFilesSync} but also statS each file for
|
|
1096
|
+
* modification time. Used by the `@` picker to surface recently-
|
|
1097
|
+
* edited files first — matches VS Code Quick Open / similar UX.
|
|
1098
|
+
*
|
|
1099
|
+
* Stat failures don't throw: the entry is kept with `mtimeMs: 0` so
|
|
1100
|
+
* it still appears in the picker (just sinks to the bottom of the
|
|
1101
|
+
* recency sort).
|
|
1102
|
+
*/
|
|
1103
|
+
declare function listFilesWithStatsSync(root: string, opts?: ListFilesOptions): FileWithStats[];
|
|
1088
1104
|
/**
|
|
1089
1105
|
* Prefix pattern used by the `@` picker to detect an IN-PROGRESS
|
|
1090
1106
|
* mention at the END of the input buffer. Captures the partial path
|
|
@@ -1106,14 +1122,36 @@ declare function detectAtPicker(input: string): {
|
|
|
1106
1122
|
query: string;
|
|
1107
1123
|
atOffset: number;
|
|
1108
1124
|
} | null;
|
|
1125
|
+
/** A candidate accepted by the picker ranker — either a bare path or a path with mtime. */
|
|
1126
|
+
type PickerCandidate = string | FileWithStats;
|
|
1127
|
+
interface RankPickerOptions {
|
|
1128
|
+
/** Upper bound on returned entries. Default 40. */
|
|
1129
|
+
limit?: number;
|
|
1130
|
+
/**
|
|
1131
|
+
* Paths the user or model has touched recently (via tool calls like
|
|
1132
|
+
* `read_file` / `edit_file`). Matching paths get a recency boost so
|
|
1133
|
+
* the picker surfaces "stuff I just looked at" near the top.
|
|
1134
|
+
*/
|
|
1135
|
+
recentlyUsed?: readonly string[];
|
|
1136
|
+
}
|
|
1109
1137
|
/**
|
|
1110
1138
|
* Filter and rank candidate files against the picker's partial query.
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1139
|
+
*
|
|
1140
|
+
* Empty query:
|
|
1141
|
+
* - Sort by "recently used" bucket first (if provided), then mtime
|
|
1142
|
+
* descending (newer first), then path alpha.
|
|
1143
|
+
* - Pure-string input (no mtime data) falls back to alpha since
|
|
1144
|
+
* recency info isn't available.
|
|
1145
|
+
*
|
|
1146
|
+
* Non-empty query:
|
|
1147
|
+
* - Case-insensitive substring match, with a basename-prefix boost
|
|
1148
|
+
* so `lo` floats `loop.ts`-shaped paths to the top.
|
|
1149
|
+
* - Ties broken first by recently-used membership, then mtime.
|
|
1150
|
+
*
|
|
1151
|
+
* Back-compat: passes `string[]` through the same logic (mtime = 0,
|
|
1152
|
+
* recently-used still honored).
|
|
1115
1153
|
*/
|
|
1116
|
-
declare function rankPickerCandidates(files: readonly
|
|
1154
|
+
declare function rankPickerCandidates(files: readonly PickerCandidate[], query: string, limitOrOpts?: number | RankPickerOptions): string[];
|
|
1117
1155
|
/**
|
|
1118
1156
|
* Matches `@` at a word boundary (start-of-string or preceded by
|
|
1119
1157
|
* whitespace) followed by a path-like token. Deliberately rejects `@`
|
|
@@ -3107,4 +3145,4 @@ declare function aggregateUsage(records: UsageRecord[], opts?: AggregateOptions)
|
|
|
3107
3145
|
/** File-size helper for the stats header — "1.2 MB" etc. Returns "" if missing. */
|
|
3108
3146
|
declare function formatLogSize(path?: string): string;
|
|
3109
3147
|
|
|
3110
|
-
export { AT_MENTION_PATTERN, AT_PICKER_PREFIX, type AggregateOptions, AppendOnlyLog, type AppendUsageInput, type ApplyResult, type ApplyStatus, type AtMentionExpansion, type AtMentionOptions, type BranchOptions, type BranchProgress, type BranchResult, type BranchSample, type BranchSelector, type BranchSummary, type BridgeOptions, type BridgeResult, CODE_SYSTEM_PROMPT, CacheFirstLoop, type CacheFirstLoopOptions, type CallToolResult, type ChatMessage, type ChatResponse, DEFAULT_AT_MENTION_MAX_BYTES, DEFAULT_MAX_RESULT_CHARS, DEFAULT_MAX_RESULT_TOKENS, DEFAULT_PICKER_IGNORE_DIRS, DeepSeekClient, type DeepSeekClientOptions, type RenderOptions as DiffRenderOptions, type DiffReport, type DiffSide, type EditBlock, type EditSnapshot, type EventRole, type FilesystemToolsOptions, type FlattenDecision, type FlattenOptions, type GetLatestVersionOptions, type GetPromptResult, HOOK_EVENTS, HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME, type HarvestOptions, type HookConfig, type HookEvent, type HookOutcome, type HookPayload, type HookReport, type HookScope, type HookSettings, type HookSpawnInput, type HookSpawnResult, type HookSpawner, ImmutablePrefix, type ImmutablePrefixOptions, type InitializeResult, type InspectionReport, type JSONSchema, type JsonRpcMessage, type JsonRpcRequest, type JsonRpcResponse, LATEST_CACHE_TTL_MS, LATEST_FETCH_TIMEOUT_MS, type ListFilesOptions, type ListPromptsResult, type ListResourcesResult, type ListToolsResult, type LoadHookSettingsOptions, type LoopEvent, MCP_PROTOCOL_VERSION, MEMORY_INDEX_FILE, MEMORY_INDEX_MAX_CHARS, McpClient, type McpClientOptions, type McpContentBlock, type McpProgressHandler, type McpProgressInfo, type McpPrompt, type McpPromptArgument, type McpPromptMessage, type McpPromptResourceBlock, type McpResource, type McpResourceContents, type McpResourceContentsBlob, type McpResourceContentsText, type McpSpec, type McpTool, type McpToolSchema, type McpTransport, type MemoryEntry, type MemoryScope, MemoryStore, type MemoryStoreOptions, type MemoryToolsOptions, type MemoryType, type WriteInput as MemoryWriteInput, NeedsConfirmationError, PROJECT_MEMORY_FILE, PROJECT_MEMORY_MAX_CHARS, type PageContent, PlanProposedError, type PlanToolOptions, type ProgressNotificationParams, type ProjectMemory, type ReadResourceResult, type ReadTranscriptResult, type ReasonixConfig, type ReconfigurableOptions, type RepairReport, type ReplayStats, type ResolvedHook, type RetryInfo, type RetryOptions, type Role, type RunCommandResult, type RunHooksOptions, type ScavengeOptions, type ScavengeResult, type SearchResult, type SectionResult, type SessionInfo, SessionStats, type SessionSummary, type ShellToolsOptions, type SseMcpSpec, SseTransport, type SseTransportOptions, type StdioMcpSpec, StdioTransport, type StdioTransportOptions, StormBreaker, type StreamChunk, type SubagentEvent, type SubagentSink, type SubagentToolOptions, type ToolCall, type ToolCallContext, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TranscriptMeta, type TranscriptRecord, type TruncationRepairResult, type TurnPair, type TurnStats, type TypedPlanState, USER_MEMORY_DIR, Usage, type UsageAggregate, type UsageBucket, type UsageRecord, VERSION, VolatileScratch, type WebFetchOptions, type WebSearchOptions, type WebToolsOptions, aggregateBranchUsage, aggregateUsage, analyzeSchema, appendSessionMessage, appendUsage, applyEditBlock, applyEditBlocks, applyMemoryStack, applyProjectMemory, applyUserMemory, bridgeMcpTools, bucketCacheHitRatio, bucketSavingsFraction, claudeEquivalentCost, codeSystemPrompt, compareVersions, computeReplayStats, costUsd, decideOutcome, defaultConfigPath, defaultSelector, defaultUsageLogPath, deleteSession, detectAtPicker, detectShellOperator, diffTranscripts, emptyPlanState, expandAtMentions, fetchWithRetry, fixToolCallPairing, flattenMcpResult, flattenSchema, forkRegistryExcluding, formatCommandResult, formatHookOutcomeMessage, formatLogSize, formatLoopError, formatSearchResults, getLatestVersion, globalSettingsPath, harvest, healLoadedMessages, healLoadedMessagesByTokens, htmlToText, injectPowerShellUtf8, inputCostUsd, inspectMcpServer, isAllowed, isJsonRpcError, isNpxInstall, isPlanStateEmpty, isPlausibleKey, listFilesSync, listSessions, loadApiKey, loadDotenv, loadHooks, loadSessionMessages, matchesTool, memoryEnabled, nestArguments, openTranscriptFile, outputCostUsd, parseEditBlocks, parseMcpSpec, parseMojeekResults, parseTranscript, prepareSpawn, projectHash, projectSettingsPath, quoteForCmdExe, rankPickerCandidates, readConfig, readProjectMemory, readTranscript, readUsageLog, recordFromLoopEvent, redactKey, registerFilesystemTools, registerMemoryTools, registerPlanTool, registerShellTools, registerSubagentTool, registerWebTools, renderMarkdown as renderDiffMarkdown, renderSummaryTable as renderDiffSummary, repairTruncatedJson, replayFromFile, resolveExecutable, restoreSnapshots, runBranches, runCommand, runHooks, sanitizeMemoryName, sanitizeName as sanitizeSessionName, saveApiKey, scavengeToolCalls, sessionPath, sessionsDir, similarity, snapshotBeforeEdits, stripHallucinatedToolMarkup, tokenizeCommand, truncateForModel, truncateForModelByTokens, webFetch, webSearch, withUtf8Codepage, writeConfig, writeMeta, writeRecord };
|
|
3148
|
+
export { AT_MENTION_PATTERN, AT_PICKER_PREFIX, type AggregateOptions, AppendOnlyLog, type AppendUsageInput, type ApplyResult, type ApplyStatus, type AtMentionExpansion, type AtMentionOptions, type BranchOptions, type BranchProgress, type BranchResult, type BranchSample, type BranchSelector, type BranchSummary, type BridgeOptions, type BridgeResult, CODE_SYSTEM_PROMPT, CacheFirstLoop, type CacheFirstLoopOptions, type CallToolResult, type ChatMessage, type ChatResponse, DEFAULT_AT_MENTION_MAX_BYTES, DEFAULT_MAX_RESULT_CHARS, DEFAULT_MAX_RESULT_TOKENS, DEFAULT_PICKER_IGNORE_DIRS, DeepSeekClient, type DeepSeekClientOptions, type RenderOptions as DiffRenderOptions, type DiffReport, type DiffSide, type EditBlock, type EditSnapshot, type EventRole, type FileWithStats, type FilesystemToolsOptions, type FlattenDecision, type FlattenOptions, type GetLatestVersionOptions, type GetPromptResult, HOOK_EVENTS, HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME, type HarvestOptions, type HookConfig, type HookEvent, type HookOutcome, type HookPayload, type HookReport, type HookScope, type HookSettings, type HookSpawnInput, type HookSpawnResult, type HookSpawner, ImmutablePrefix, type ImmutablePrefixOptions, type InitializeResult, type InspectionReport, type JSONSchema, type JsonRpcMessage, type JsonRpcRequest, type JsonRpcResponse, LATEST_CACHE_TTL_MS, LATEST_FETCH_TIMEOUT_MS, type ListFilesOptions, type ListPromptsResult, type ListResourcesResult, type ListToolsResult, type LoadHookSettingsOptions, type LoopEvent, MCP_PROTOCOL_VERSION, MEMORY_INDEX_FILE, MEMORY_INDEX_MAX_CHARS, McpClient, type McpClientOptions, type McpContentBlock, type McpProgressHandler, type McpProgressInfo, type McpPrompt, type McpPromptArgument, type McpPromptMessage, type McpPromptResourceBlock, type McpResource, type McpResourceContents, type McpResourceContentsBlob, type McpResourceContentsText, type McpSpec, type McpTool, type McpToolSchema, type McpTransport, type MemoryEntry, type MemoryScope, MemoryStore, type MemoryStoreOptions, type MemoryToolsOptions, type MemoryType, type WriteInput as MemoryWriteInput, NeedsConfirmationError, PROJECT_MEMORY_FILE, PROJECT_MEMORY_MAX_CHARS, type PageContent, type PickerCandidate, PlanProposedError, type PlanToolOptions, type ProgressNotificationParams, type ProjectMemory, type RankPickerOptions, type ReadResourceResult, type ReadTranscriptResult, type ReasonixConfig, type ReconfigurableOptions, type RepairReport, type ReplayStats, type ResolvedHook, type RetryInfo, type RetryOptions, type Role, type RunCommandResult, type RunHooksOptions, type ScavengeOptions, type ScavengeResult, type SearchResult, type SectionResult, type SessionInfo, SessionStats, type SessionSummary, type ShellToolsOptions, type SseMcpSpec, SseTransport, type SseTransportOptions, type StdioMcpSpec, StdioTransport, type StdioTransportOptions, StormBreaker, type StreamChunk, type SubagentEvent, type SubagentSink, type SubagentToolOptions, type ToolCall, type ToolCallContext, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TranscriptMeta, type TranscriptRecord, type TruncationRepairResult, type TurnPair, type TurnStats, type TypedPlanState, USER_MEMORY_DIR, Usage, type UsageAggregate, type UsageBucket, type UsageRecord, VERSION, VolatileScratch, type WebFetchOptions, type WebSearchOptions, type WebToolsOptions, aggregateBranchUsage, aggregateUsage, analyzeSchema, appendSessionMessage, appendUsage, applyEditBlock, applyEditBlocks, applyMemoryStack, applyProjectMemory, applyUserMemory, bridgeMcpTools, bucketCacheHitRatio, bucketSavingsFraction, claudeEquivalentCost, codeSystemPrompt, compareVersions, computeReplayStats, costUsd, decideOutcome, defaultConfigPath, defaultSelector, defaultUsageLogPath, deleteSession, detectAtPicker, detectShellOperator, diffTranscripts, emptyPlanState, expandAtMentions, fetchWithRetry, fixToolCallPairing, flattenMcpResult, flattenSchema, forkRegistryExcluding, formatCommandResult, formatHookOutcomeMessage, formatLogSize, formatLoopError, formatSearchResults, getLatestVersion, globalSettingsPath, harvest, healLoadedMessages, healLoadedMessagesByTokens, htmlToText, injectPowerShellUtf8, inputCostUsd, inspectMcpServer, isAllowed, isJsonRpcError, isNpxInstall, isPlanStateEmpty, isPlausibleKey, listFilesSync, listFilesWithStatsSync, listSessions, loadApiKey, loadDotenv, loadHooks, loadSessionMessages, matchesTool, memoryEnabled, nestArguments, openTranscriptFile, outputCostUsd, parseEditBlocks, parseMcpSpec, parseMojeekResults, parseTranscript, prepareSpawn, projectHash, projectSettingsPath, quoteForCmdExe, rankPickerCandidates, readConfig, readProjectMemory, readTranscript, readUsageLog, recordFromLoopEvent, redactKey, registerFilesystemTools, registerMemoryTools, registerPlanTool, registerShellTools, registerSubagentTool, registerWebTools, renderMarkdown as renderDiffMarkdown, renderSummaryTable as renderDiffSummary, repairTruncatedJson, replayFromFile, resolveExecutable, restoreSnapshots, runBranches, runCommand, runHooks, sanitizeMemoryName, sanitizeName as sanitizeSessionName, saveApiKey, scavengeToolCalls, sessionPath, sessionsDir, similarity, snapshotBeforeEdits, stripHallucinatedToolMarkup, tokenizeCommand, truncateForModel, truncateForModelByTokens, webFetch, webSearch, withUtf8Codepage, writeConfig, writeMeta, writeRecord };
|
package/dist/index.js
CHANGED
|
@@ -2511,6 +2511,9 @@ var DEFAULT_PICKER_IGNORE_DIRS = [
|
|
|
2511
2511
|
"__pycache__"
|
|
2512
2512
|
];
|
|
2513
2513
|
function listFilesSync(root, opts = {}) {
|
|
2514
|
+
return listFilesWithStatsSync(root, opts).map((e) => e.path);
|
|
2515
|
+
}
|
|
2516
|
+
function listFilesWithStatsSync(root, opts = {}) {
|
|
2514
2517
|
const maxResults = Math.max(1, opts.maxResults ?? 500);
|
|
2515
2518
|
const ignore = new Set(opts.ignoreDirs ?? DEFAULT_PICKER_IGNORE_DIRS);
|
|
2516
2519
|
const rootAbs = resolve(root);
|
|
@@ -2531,7 +2534,12 @@ function listFilesSync(root, opts = {}) {
|
|
|
2531
2534
|
if (ent.name.startsWith(".") || ignore.has(ent.name)) continue;
|
|
2532
2535
|
walk2(join4(dirAbs, ent.name), relPath);
|
|
2533
2536
|
} else if (ent.isFile()) {
|
|
2534
|
-
|
|
2537
|
+
let mtimeMs = 0;
|
|
2538
|
+
try {
|
|
2539
|
+
mtimeMs = statSync2(join4(dirAbs, ent.name)).mtimeMs;
|
|
2540
|
+
} catch {
|
|
2541
|
+
}
|
|
2542
|
+
out.push({ path: relPath, mtimeMs });
|
|
2535
2543
|
}
|
|
2536
2544
|
}
|
|
2537
2545
|
};
|
|
@@ -2546,12 +2554,31 @@ function detectAtPicker(input) {
|
|
|
2546
2554
|
const atOffset = input.length - query.length - 1;
|
|
2547
2555
|
return { query, atOffset };
|
|
2548
2556
|
}
|
|
2549
|
-
function rankPickerCandidates(files, query,
|
|
2550
|
-
|
|
2557
|
+
function rankPickerCandidates(files, query, limitOrOpts) {
|
|
2558
|
+
const opts = typeof limitOrOpts === "number" ? { limit: limitOrOpts } : limitOrOpts ?? {};
|
|
2559
|
+
const limit = opts.limit ?? 40;
|
|
2560
|
+
const recent = new Set(opts.recentlyUsed ?? []);
|
|
2561
|
+
const entries = files.map(
|
|
2562
|
+
(f) => typeof f === "string" ? { path: f, mtimeMs: 0 } : f
|
|
2563
|
+
);
|
|
2564
|
+
if (!query) {
|
|
2565
|
+
const anyMtime = entries.some((e) => e.mtimeMs > 0);
|
|
2566
|
+
if (!anyMtime && recent.size === 0) {
|
|
2567
|
+
return entries.slice(0, limit).map((e) => e.path);
|
|
2568
|
+
}
|
|
2569
|
+
const sorted = [...entries].sort((a, b) => {
|
|
2570
|
+
const aRecent = recent.has(a.path) ? 1 : 0;
|
|
2571
|
+
const bRecent = recent.has(b.path) ? 1 : 0;
|
|
2572
|
+
if (aRecent !== bRecent) return bRecent - aRecent;
|
|
2573
|
+
if (a.mtimeMs !== b.mtimeMs) return b.mtimeMs - a.mtimeMs;
|
|
2574
|
+
return a.path.localeCompare(b.path);
|
|
2575
|
+
});
|
|
2576
|
+
return sorted.slice(0, limit).map((e) => e.path);
|
|
2577
|
+
}
|
|
2551
2578
|
const needle = query.toLowerCase();
|
|
2552
2579
|
const scored = [];
|
|
2553
|
-
for (const
|
|
2554
|
-
const lower =
|
|
2580
|
+
for (const e of entries) {
|
|
2581
|
+
const lower = e.path.toLowerCase();
|
|
2555
2582
|
const hit = lower.indexOf(needle);
|
|
2556
2583
|
if (hit < 0) continue;
|
|
2557
2584
|
const slash = lower.lastIndexOf("/");
|
|
@@ -2559,9 +2586,18 @@ function rankPickerCandidates(files, query, limit = 40) {
|
|
|
2559
2586
|
let score = 2;
|
|
2560
2587
|
if (base.startsWith(needle)) score = 0;
|
|
2561
2588
|
else if (lower.startsWith(needle)) score = 1;
|
|
2562
|
-
scored.push({
|
|
2589
|
+
scored.push({
|
|
2590
|
+
path: e.path,
|
|
2591
|
+
score: score * 1e4 + hit,
|
|
2592
|
+
mtimeMs: e.mtimeMs,
|
|
2593
|
+
recent: recent.has(e.path)
|
|
2594
|
+
});
|
|
2563
2595
|
}
|
|
2564
|
-
scored.sort((a, b) =>
|
|
2596
|
+
scored.sort((a, b) => {
|
|
2597
|
+
if (a.score !== b.score) return a.score - b.score;
|
|
2598
|
+
if (a.recent !== b.recent) return a.recent ? -1 : 1;
|
|
2599
|
+
return b.mtimeMs - a.mtimeMs;
|
|
2600
|
+
});
|
|
2565
2601
|
return scored.slice(0, limit).map((s) => s.path);
|
|
2566
2602
|
}
|
|
2567
2603
|
var AT_MENTION_PATTERN = /(?<=^|\s)@([a-zA-Z0-9_./\\-]+)/g;
|
|
@@ -6404,6 +6440,7 @@ export {
|
|
|
6404
6440
|
isPlanStateEmpty,
|
|
6405
6441
|
isPlausibleKey,
|
|
6406
6442
|
listFilesSync,
|
|
6443
|
+
listFilesWithStatsSync,
|
|
6407
6444
|
listSessions,
|
|
6408
6445
|
loadApiKey,
|
|
6409
6446
|
loadDotenv,
|