@hsingjui/contextweaver 0.0.2 → 0.0.3

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getIndexer,
3
3
  getVectorStore
4
- } from "./chunk-UWQSUTEL.js";
4
+ } from "./chunk-RU4OUBZS.js";
5
5
  import {
6
6
  initDb,
7
7
  isChunksFtsInitialized,
@@ -11,11 +11,11 @@ import {
11
11
  searchChunksFts,
12
12
  searchFilesFts,
13
13
  segmentQuery
14
- } from "./chunk-NHKBCYHN.js";
14
+ } from "./chunk-AVBQ77MN.js";
15
15
  import {
16
16
  getEmbeddingConfig,
17
17
  getRerankerConfig
18
- } from "./chunk-2HG4HNNX.js";
18
+ } from "./chunk-ESTPBFCW.js";
19
19
 
20
20
  // src/api/reranker.ts
21
21
  var RerankerClient = class {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generateProjectId,
3
3
  logger
4
- } from "./chunk-NHKBCYHN.js";
4
+ } from "./chunk-AVBQ77MN.js";
5
5
 
6
6
  // src/mcp/tools/codebaseRetrieval.ts
7
7
  import { z } from "zod";
@@ -61,7 +61,7 @@ function isProjectIndexed(projectId) {
61
61
  }
62
62
  async function ensureIndexed(repoPath, projectId) {
63
63
  const wasIndexed = isProjectIndexed(projectId);
64
- const { scan } = await import("./scanner-E52TXHEM.js");
64
+ const { scan } = await import("./scanner-CXUYLK56.js");
65
65
  if (!wasIndexed) {
66
66
  logger.info({ repoPath, projectId: projectId.slice(0, 10) }, "\u4EE3\u7801\u5E93\u672A\u521D\u59CB\u5316\uFF0C\u5F00\u59CB\u9996\u6B21\u7D22\u5F15...");
67
67
  } else {
@@ -88,7 +88,7 @@ async function handleCodebaseRetrieval(args, configOverride = ZEN_CONFIG_OVERRID
88
88
  information_request,
89
89
  technical_terms
90
90
  }, "MCP codebase-retrieval \u8C03\u7528\u5F00\u59CB");
91
- const { checkEmbeddingEnv, checkRerankerEnv } = await import("./config-BVORFWIO.js");
91
+ const { checkEmbeddingEnv, checkRerankerEnv } = await import("./config-BQCFTZVY.js");
92
92
  const embeddingCheck = checkEmbeddingEnv();
93
93
  const rerankerCheck = checkRerankerEnv();
94
94
  const allMissingVars = [...embeddingCheck.missingVars, ...rerankerCheck.missingVars];
@@ -108,7 +108,7 @@ async function handleCodebaseRetrieval(args, configOverride = ZEN_CONFIG_OVERRID
108
108
  query,
109
109
  zenConfig: configOverride
110
110
  }, "MCP \u67E5\u8BE2\u6784\u5EFA");
111
- const { SearchService } = await import("./SearchService-NM6J3XHC.js");
111
+ const { SearchService } = await import("./SearchService-CMHVTNSM.js");
112
112
  const service = new SearchService(projectId, repo_path, configOverride);
113
113
  await service.init();
114
114
  logger.debug("SearchService \u521D\u59CB\u5316\u5B8C\u6210");
@@ -1,6 +1,7 @@
1
1
  import {
2
- isDev
3
- } from "./chunk-2HG4HNNX.js";
2
+ isDev,
3
+ isMcpMode
4
+ } from "./chunk-ESTPBFCW.js";
4
5
 
5
6
  // src/utils/logger.ts
6
7
  import pino from "pino";
@@ -54,7 +55,7 @@ function cleanupOldLogs(dir) {
54
55
  const filePath = path.join(dir, file);
55
56
  try {
56
57
  fs.unlinkSync(filePath);
57
- console.log(`[Logger] \u6E05\u7406\u8FC7\u671F\u65E5\u5FD7: ${file}`);
58
+ console.error(`[Logger] \u6E05\u7406\u8FC7\u671F\u65E5\u5FD7: ${file}`);
58
59
  } catch {
59
60
  }
60
61
  }
@@ -133,7 +134,8 @@ function createDevLogger() {
133
134
  level: logLevel,
134
135
  name: "contextweaver"
135
136
  },
136
- pino.multistream([
137
+ // MCP 模式下禁用控制台输出,避免污染 STDIO 协议流
138
+ isMcpMode ? logStream : pino.multistream([
137
139
  { stream: logStream, level: logLevel },
138
140
  { stream: consoleStream, level: logLevel }
139
141
  ])
@@ -150,7 +152,8 @@ function createProdLogger() {
150
152
  level: logLevel,
151
153
  name: "contextweaver"
152
154
  },
153
- pino.multistream([
155
+ // MCP 模式下禁用控制台输出,避免污染 STDIO 协议流
156
+ isMcpMode ? logStream : pino.multistream([
154
157
  { stream: logStream, level: logLevel },
155
158
  { stream: consoleStream, level: logLevel }
156
159
  ])
@@ -4,6 +4,7 @@ import path from "path";
4
4
  import os from "os";
5
5
  import fs from "fs";
6
6
  var isDev = process.env.NODE_ENV === "dev";
7
+ var isMcpMode = process.argv.includes("mcp");
7
8
  function loadEnv() {
8
9
  const candidates = isDev ? [
9
10
  path.join(process.cwd(), ".env"),
@@ -152,6 +153,7 @@ function getExcludePatterns() {
152
153
 
153
154
  export {
154
155
  isDev,
156
+ isMcpMode,
155
157
  checkEmbeddingEnv,
156
158
  checkRerankerEnv,
157
159
  getEmbeddingConfig,
@@ -2,7 +2,7 @@ import {
2
2
  closeAllIndexers,
3
3
  closeAllVectorStores,
4
4
  getIndexer
5
- } from "./chunk-UWQSUTEL.js";
5
+ } from "./chunk-RU4OUBZS.js";
6
6
  import {
7
7
  batchDelete,
8
8
  batchUpdateMtime,
@@ -17,11 +17,11 @@ import {
17
17
  initDb,
18
18
  logger,
19
19
  setStoredEmbeddingDimensions
20
- } from "./chunk-NHKBCYHN.js";
20
+ } from "./chunk-AVBQ77MN.js";
21
21
  import {
22
22
  getEmbeddingConfig,
23
23
  getExcludePatterns
24
- } from "./chunk-2HG4HNNX.js";
24
+ } from "./chunk-ESTPBFCW.js";
25
25
 
26
26
  // src/scanner/crawler.ts
27
27
  import { fdir } from "fdir";
@@ -5,10 +5,10 @@ import {
5
5
  clearVectorIndexHash,
6
6
  isChunksFtsInitialized,
7
7
  logger
8
- } from "./chunk-NHKBCYHN.js";
8
+ } from "./chunk-AVBQ77MN.js";
9
9
  import {
10
10
  getEmbeddingConfig
11
- } from "./chunk-2HG4HNNX.js";
11
+ } from "./chunk-ESTPBFCW.js";
12
12
 
13
13
  // src/vectorStore/index.ts
14
14
  import * as lancedb from "@lancedb/lancedb";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  codebaseRetrievalSchema,
3
3
  handleCodebaseRetrieval
4
- } from "./chunk-C7PBP6HL.js";
5
- import "./chunk-NHKBCYHN.js";
6
- import "./chunk-2HG4HNNX.js";
4
+ } from "./chunk-4XOWK7YZ.js";
5
+ import "./chunk-AVBQ77MN.js";
6
+ import "./chunk-ESTPBFCW.js";
7
7
  export {
8
8
  codebaseRetrievalSchema,
9
9
  handleCodebaseRetrieval
@@ -5,8 +5,9 @@ import {
5
5
  getEmbeddingConfig,
6
6
  getExcludePatterns,
7
7
  getRerankerConfig,
8
- isDev
9
- } from "./chunk-2HG4HNNX.js";
8
+ isDev,
9
+ isMcpMode
10
+ } from "./chunk-ESTPBFCW.js";
10
11
  export {
11
12
  DEFAULT_EXCLUDE_PATTERNS,
12
13
  checkEmbeddingEnv,
@@ -14,5 +15,6 @@ export {
14
15
  getEmbeddingConfig,
15
16
  getExcludePatterns,
16
17
  getRerankerConfig,
17
- isDev
18
+ isDev,
19
+ isMcpMode
18
20
  };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scan
4
- } from "./chunk-JNMCEE3A.js";
5
- import "./chunk-UWQSUTEL.js";
4
+ } from "./chunk-NHQE2IOY.js";
5
+ import "./chunk-RU4OUBZS.js";
6
6
  import {
7
7
  generateProjectId,
8
8
  logger
9
- } from "./chunk-NHKBCYHN.js";
10
- import "./chunk-2HG4HNNX.js";
9
+ } from "./chunk-AVBQ77MN.js";
10
+ import "./chunk-ESTPBFCW.js";
11
11
 
12
12
  // src/index.ts
13
13
  import cac from "cac";
@@ -100,7 +100,7 @@ cli.command("index [path]", "\u626B\u63CF\u4EE3\u7801\u5E93\u5E76\u5EFA\u7ACB\u7
100
100
  }
101
101
  });
102
102
  cli.command("mcp", "\u542F\u52A8 MCP \u670D\u52A1\u5668").action(async () => {
103
- const { startMcpServer } = await import("./server-Y4GFTGLG.js");
103
+ const { startMcpServer } = await import("./server-LC4NWEGV.js");
104
104
  try {
105
105
  await startMcpServer();
106
106
  } catch (error) {
@@ -117,7 +117,7 @@ cli.command("search", "\u672C\u5730\u68C0\u7D22\uFF08\u53C2\u6570\u5BF9\u9F50 MC
117
117
  }
118
118
  const technicalTerms = (options.technicalTerms || "").split(",").map((t) => t.trim()).filter(Boolean);
119
119
  const useZen = options.zen !== false;
120
- const { handleCodebaseRetrieval } = await import("./codebaseRetrieval-GPSIAFSZ.js");
120
+ const { handleCodebaseRetrieval } = await import("./codebaseRetrieval-NLSYDBF4.js");
121
121
  const response = await handleCodebaseRetrieval({
122
122
  repo_path: repoPath,
123
123
  information_request: informationRequest,
@@ -0,0 +1,9 @@
1
+ import {
2
+ scan
3
+ } from "./chunk-NHQE2IOY.js";
4
+ import "./chunk-RU4OUBZS.js";
5
+ import "./chunk-AVBQ77MN.js";
6
+ import "./chunk-ESTPBFCW.js";
7
+ export {
8
+ scan
9
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  codebaseRetrievalSchema,
3
3
  handleCodebaseRetrieval
4
- } from "./chunk-C7PBP6HL.js";
4
+ } from "./chunk-4XOWK7YZ.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-NHKBCYHN.js";
8
- import "./chunk-2HG4HNNX.js";
7
+ } from "./chunk-AVBQ77MN.js";
8
+ import "./chunk-ESTPBFCW.js";
9
9
 
10
10
  // src/mcp/server.ts
11
11
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsingjui/contextweaver",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A context weaving tool for LLMs",
5
5
  "license": "MIT",
6
6
  "author": "hsingjui",
@@ -1,9 +0,0 @@
1
- import {
2
- scan
3
- } from "./chunk-JNMCEE3A.js";
4
- import "./chunk-UWQSUTEL.js";
5
- import "./chunk-NHKBCYHN.js";
6
- import "./chunk-2HG4HNNX.js";
7
- export {
8
- scan
9
- };