@huaqiu/dsh-tool-part-search 0.3.9 → 0.3.11

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/lib/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { getLogger } from "@huaqiu/dsh-plugin-log";
1
2
  import { createPartSearchService } from "@huaqiu/part-search";
2
3
  import { defineTool } from "@deepseek-ai/dsh-tools";
3
4
  //#region src/service.ts
@@ -255,8 +256,18 @@ function toPartIdentifier(args) {
255
256
  const name = "@huaqiu/dsh-tool-part-search";
256
257
  /** Cordis services this half depends on: the DSH node tool registry. */
257
258
  const inject = ["tools"];
258
- /** Console tag for filtering in logs. */
259
- const LOG_TAG = "[dsh-part-search]";
259
+ /**
260
+ * Lazy: a module-level `const log = getLogger(...)` would call `getLogger()` at
261
+ * import time, which on bootstrap touches `dshHomePath('logs')` (transitively
262
+ * via the unified-sink directory resolution). Tests that
263
+ * `vi.mock('@deepseek-ai/dsh-home-paths', …)` get their TMP constant in scope
264
+ * only after the mock factory, so defer the call until `apply()` runs.
265
+ */
266
+ let _log = null;
267
+ function log() {
268
+ if (_log === null) _log = getLogger("dsh-part-search");
269
+ return _log;
270
+ }
260
271
  /**
261
272
  * Host plugin body — register the four agent-visible part-search tools.
262
273
  *
@@ -270,7 +281,7 @@ const LOG_TAG = "[dsh-part-search]";
270
281
  function apply(ctx) {
271
282
  if (!ctx.tools || typeof ctx.tools.register !== "function") throw new Error("@huaqiu/dsh-tool-part-search requires the DSH `tools` service (ctx.tools.register).");
272
283
  const disposers = createPartSearchTools(createPartSearch()).map((tool) => ctx.tools.register(tool));
273
- console.log(LOG_TAG, "registered agent tools", { tools: disposers.length });
284
+ log().info("registered agent tools", { tools: disposers.length });
274
285
  return function dispose() {
275
286
  for (const disposeTool of disposers) try {
276
287
  disposeTool();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huaqiu/dsh-tool-part-search",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "main": "./lib/index.mjs",
6
6
  "types": "./lib/index.d.mts",
@@ -22,7 +22,8 @@
22
22
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.0"
23
23
  },
24
24
  "dependencies": {
25
- "@huaqiu/part-search": "^0.2.0"
25
+ "@huaqiu/part-search": "^0.2.0",
26
+ "@huaqiu/dsh-plugin-log": "0.3.11"
26
27
  },
27
28
  "files": [
28
29
  "lib",
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@
24
24
  */
25
25
 
26
26
  import type { Context } from '@deepseek-ai/cordis'
27
+ import { getLogger, type PluginLogger } from '@huaqiu/dsh-plugin-log'
27
28
  import { createPartSearch } from './service.js'
28
29
  import { createPartSearchTools } from './tools.js'
29
30
 
@@ -33,8 +34,18 @@ export const name = '@huaqiu/dsh-tool-part-search'
33
34
  /** Cordis services this half depends on: the DSH node tool registry. */
34
35
  export const inject = ['tools'] as const
35
36
 
36
- /** Console tag for filtering in logs. */
37
- const LOG_TAG = '[dsh-part-search]'
37
+ /**
38
+ * Lazy: a module-level `const log = getLogger(...)` would call `getLogger()` at
39
+ * import time, which on bootstrap touches `dshHomePath('logs')` (transitively
40
+ * via the unified-sink directory resolution). Tests that
41
+ * `vi.mock('@deepseek-ai/dsh-home-paths', …)` get their TMP constant in scope
42
+ * only after the mock factory, so defer the call until `apply()` runs.
43
+ */
44
+ let _log: PluginLogger | null = null
45
+ function log(): PluginLogger {
46
+ if (_log === null) _log = getLogger('dsh-part-search')
47
+ return _log
48
+ }
38
49
 
39
50
  /**
40
51
  * Host plugin body — register the four agent-visible part-search tools.
@@ -54,8 +65,7 @@ export function apply(ctx: Context): () => void {
54
65
  const service = createPartSearch()
55
66
  const disposers = createPartSearchTools(service).map((tool) => ctx.tools.register(tool))
56
67
 
57
- // eslint-disable-next-line no-console
58
- console.log(LOG_TAG, 'registered agent tools', { tools: disposers.length })
68
+ log().info('registered agent tools', { tools: disposers.length })
59
69
 
60
70
  return function dispose() {
61
71
  for (const disposeTool of disposers) {