reasonix 0.19.0 → 0.21.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.
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  CODE_SYSTEM_PROMPT,
4
4
  codeSystemPrompt
5
- } from "./chunk-RTVI2CLX.js";
5
+ } from "./chunk-R2L5YEEF.js";
6
6
  export {
7
7
  CODE_SYSTEM_PROMPT,
8
8
  codeSystemPrompt
9
9
  };
10
- //# sourceMappingURL=prompt-P54FIQAH.js.map
10
+ //# sourceMappingURL=prompt-YUL7CYKY.js.map
package/dist/index.d.ts CHANGED
@@ -1631,6 +1631,13 @@ declare class StreamableHttpTransport implements McpTransport {
1631
1631
  private pushMessage;
1632
1632
  }
1633
1633
 
1634
+ /** Per-server ring-buffered latency tracker; emits a "slow" event on threshold cross only. */
1635
+ interface SlowEvent {
1636
+ serverName: string;
1637
+ p95Ms: number;
1638
+ sampleSize: number;
1639
+ }
1640
+
1634
1641
  interface BridgeOptions {
1635
1642
  /** Prefix for tool names — disambiguates collisions when bridging multiple servers. */
1636
1643
  namePrefix?: string;
@@ -1647,6 +1654,12 @@ interface BridgeOptions {
1647
1654
  total?: number;
1648
1655
  message?: string;
1649
1656
  }) => void;
1657
+ /** Server name used to tag latency samples + slow events. Falls through to namePrefix without trailing `_`. */
1658
+ serverName?: string;
1659
+ /** p95 cutoff in ms before a slow event fires — defaults to 4000. */
1660
+ slowThresholdMs?: number;
1661
+ /** Fired exactly when the per-server p95 transitions over `slowThresholdMs`. */
1662
+ onSlow?: (ev: SlowEvent) => void;
1650
1663
  }
1651
1664
  declare const DEFAULT_MAX_RESULT_CHARS = 32000;
1652
1665
  /** ~6% of DeepSeek V3 context. Char cap alone fails on CJK (~1 char/token). */
@@ -1772,6 +1785,12 @@ interface CodeSystemPromptOptions {
1772
1785
  * explicit routing fragment so the model picks it for intent-style
1773
1786
  * queries instead of defaulting to grep. */
1774
1787
  hasSemanticSearch?: boolean;
1788
+ /** Inline string appended after the generated code system prompt.
1789
+ * Preserves the default prompt — this is append-only, not a replacement. */
1790
+ systemAppend?: string;
1791
+ /** UTF-8 file contents appended after the generated code system prompt.
1792
+ * Preserves the default prompt — this is append-only, not a replacement. */
1793
+ systemAppendFile?: string;
1775
1794
  }
1776
1795
  declare function codeSystemPrompt(rootDir: string, opts?: CodeSystemPromptOptions): string;
1777
1796
 
@@ -1801,6 +1820,8 @@ interface ReasonixConfig {
1801
1820
  reasoningEffort?: ReasoningEffort;
1802
1821
  /** Stored as `--mcp`-format strings so one parser handles both flag and config. */
1803
1822
  mcp?: string[];
1823
+ /** Names of servers in `mcp` to skip on bridge — see `/mcp disable <name>`. */
1824
+ mcpDisabled?: string[];
1804
1825
  session?: string | null;
1805
1826
  setupCompleted?: boolean;
1806
1827
  search?: boolean;
@@ -1960,4 +1981,4 @@ declare function aggregateUsage(records: UsageRecord[], opts?: AggregateOptions)
1960
1981
  /** File-size helper for the stats header — "1.2 MB" etc. Returns "" if missing. */
1961
1982
  declare function formatLogSize(path?: string): string;
1962
1983
 
1963
- 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, type ChoiceOption, ChoiceRequestedError, type ChoiceToolOptions, 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, PlanCheckpointError, PlanProposedError, PlanRevisionProposedError, type PlanStep, type PlanStepRisk, 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, type StepCompletion, StormBreaker, type StreamChunk, type StreamableHttpMcpSpec, StreamableHttpTransport, type StreamableHttpTransportOptions, 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, listFilesWithStatsAsync, 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, registerChoiceTool, 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 };
1984
+ 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, type ChoiceOption, ChoiceRequestedError, type ChoiceToolOptions, type CodeSystemPromptOptions, 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, PlanCheckpointError, PlanProposedError, PlanRevisionProposedError, type PlanStep, type PlanStepRisk, 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, type StepCompletion, StormBreaker, type StreamChunk, type StreamableHttpMcpSpec, StreamableHttpTransport, type StreamableHttpTransportOptions, 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, listFilesWithStatsAsync, 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, registerChoiceTool, 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
@@ -1029,6 +1029,39 @@ function hasDotKey(obj) {
1029
1029
  return false;
1030
1030
  }
1031
1031
 
1032
+ // src/mcp/latency.ts
1033
+ var SAMPLE_SIZE = 5;
1034
+ var DEFAULT_THRESHOLD_MS = 4e3;
1035
+ var LatencyTracker = class {
1036
+ constructor(serverName, opts = {}) {
1037
+ this.serverName = serverName;
1038
+ this.thresholdMs = opts.thresholdMs ?? DEFAULT_THRESHOLD_MS;
1039
+ this.onSlow = opts.onSlow;
1040
+ }
1041
+ serverName;
1042
+ samples = [];
1043
+ wasOverThreshold = false;
1044
+ thresholdMs;
1045
+ onSlow;
1046
+ record(elapsedMs) {
1047
+ this.samples.push(elapsedMs);
1048
+ if (this.samples.length > SAMPLE_SIZE) this.samples.shift();
1049
+ if (this.samples.length < SAMPLE_SIZE) return;
1050
+ const p95 = computeP95(this.samples);
1051
+ const nowOver = p95 > this.thresholdMs;
1052
+ if (nowOver && !this.wasOverThreshold) {
1053
+ this.onSlow?.({ serverName: this.serverName, p95Ms: p95, sampleSize: this.samples.length });
1054
+ }
1055
+ this.wasOverThreshold = nowOver;
1056
+ }
1057
+ };
1058
+ function computeP95(samples) {
1059
+ if (samples.length === 0) return 0;
1060
+ const sorted = [...samples].sort((a, b) => a - b);
1061
+ const idx = Math.min(sorted.length - 1, Math.floor(sorted.length * 0.95));
1062
+ return sorted[idx] ?? 0;
1063
+ }
1064
+
1032
1065
  // src/mcp/registry.ts
1033
1066
  var DEFAULT_MAX_RESULT_CHARS = 32e3;
1034
1067
  var DEFAULT_MAX_RESULT_TOKENS = 8e3;
@@ -1037,6 +1070,8 @@ async function bridgeMcpTools(client, opts = {}) {
1037
1070
  const prefix = opts.namePrefix ?? "";
1038
1071
  const maxResultChars = opts.maxResultChars ?? DEFAULT_MAX_RESULT_CHARS;
1039
1072
  const result = { registry, registeredNames: [], skipped: [] };
1073
+ const serverName = opts.serverName ?? prefix.replace(/_$/, "") ?? "anon";
1074
+ const tracker = opts.onSlow ? new LatencyTracker(serverName, { thresholdMs: opts.slowThresholdMs, onSlow: opts.onSlow }) : null;
1040
1075
  const listed = await client.listTools();
1041
1076
  for (const mcpTool of listed.tools) {
1042
1077
  if (!mcpTool.name) {
@@ -1049,6 +1084,7 @@ async function bridgeMcpTools(client, opts = {}) {
1049
1084
  description: mcpTool.description ?? "",
1050
1085
  parameters: mcpTool.inputSchema,
1051
1086
  fn: async (args, ctx) => {
1087
+ const t0 = tracker ? Date.now() : 0;
1052
1088
  const toolResult = await client.callTool(mcpTool.name, args, {
1053
1089
  // Forward server-side progress frames to the bridge caller,
1054
1090
  // tagged with the registered name so multi-server UIs can
@@ -1062,6 +1098,7 @@ async function bridgeMcpTools(client, opts = {}) {
1062
1098
  // pending promise immediately, no "wait for subprocess".
1063
1099
  signal: ctx?.signal
1064
1100
  });
1101
+ if (tracker) tracker.record(Date.now() - t0);
1065
1102
  return flattenMcpResult(toolResult, { maxChars: maxResultChars });
1066
1103
  }
1067
1104
  });
@@ -7610,7 +7647,7 @@ function shellSplit(input) {
7610
7647
  }
7611
7648
 
7612
7649
  // src/mcp/spec.ts
7613
- var NAME_PREFIX = /^([a-zA-Z_][a-zA-Z0-9_]*)=(.*)$/;
7650
+ var NAME_PREFIX = /^([a-zA-Z_][a-zA-Z0-9_-]*)=(.*)$/;
7614
7651
  var HTTP_URL = /^https?:\/\//i;
7615
7652
  var STREAMABLE_PREFIX = /^streamable\+(https?:\/\/.+)$/i;
7616
7653
  function parseMcpSpec(input) {
@@ -8001,17 +8038,18 @@ function codeSystemPrompt(rootDir, opts = {}) {
8001
8038
  const base = opts.hasSemanticSearch ? `${CODE_SYSTEM_PROMPT}${SEMANTIC_SEARCH_ROUTING}` : CODE_SYSTEM_PROMPT;
8002
8039
  const withMemory = applyMemoryStack(base, rootDir);
8003
8040
  const gitignorePath = join10(rootDir, ".gitignore");
8004
- if (!existsSync11(gitignorePath)) return withMemory;
8005
- let content;
8006
- try {
8007
- content = readFileSync12(gitignorePath, "utf8");
8008
- } catch {
8009
- return withMemory;
8010
- }
8011
- const MAX = 2e3;
8012
- const truncated = content.length > MAX ? `${content.slice(0, MAX)}
8041
+ let result = withMemory;
8042
+ if (existsSync11(gitignorePath)) {
8043
+ let content;
8044
+ try {
8045
+ content = readFileSync12(gitignorePath, "utf8");
8046
+ } catch {
8047
+ }
8048
+ if (content !== void 0) {
8049
+ const MAX = 2e3;
8050
+ const truncated = content.length > MAX ? `${content.slice(0, MAX)}
8013
8051
  \u2026 (truncated ${content.length - MAX} chars)` : content;
8014
- return `${withMemory}
8052
+ result = `${result}
8015
8053
 
8016
8054
  # Project .gitignore
8017
8055
 
@@ -8021,6 +8059,17 @@ The user's repo ships this .gitignore \u2014 treat every pattern as "don't trave
8021
8059
  ${truncated}
8022
8060
  \`\`\`
8023
8061
  `;
8062
+ }
8063
+ }
8064
+ const appendParts = [opts.systemAppend, opts.systemAppendFile].filter(Boolean);
8065
+ if (appendParts.length > 0) {
8066
+ result = `${result}
8067
+
8068
+ # User System Append
8069
+
8070
+ ${appendParts.join("\n\n")}`;
8071
+ }
8072
+ return result;
8024
8073
  }
8025
8074
 
8026
8075
  // src/config.ts