@bacnh85/pi-serena 0.1.2 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +14 -0
  2. package/index.ts +14 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -55,6 +55,20 @@ After install or update, restart Pi or run `/reload` in an existing Pi session.
55
55
 
56
56
  All tool outputs are truncated to 50KB / 2000 lines to match Pi-friendly output limits. Most tools accept optional `timeout_ms`.
57
57
 
58
+ ### Pattern search
59
+
60
+ Use the Pi-facing `pattern` field with `serena_search_for_pattern`:
61
+
62
+ ```json
63
+ {
64
+ "pattern": "USB_HOST_DEVICE_OBJ|USB_HOST_DEVICE_STATE_ERROR_HOLDING",
65
+ "relative_path": "AmazonFreeRTOS",
66
+ "paths_include_glob": "**/*.h"
67
+ }
68
+ ```
69
+
70
+ The extension maps `pattern` to Serena's backend `substring_pattern` parameter internally, so users do not need to call the Serena implementation detail directly.
71
+
58
72
  ## Commands
59
73
 
60
74
  - `/serena-status [project]`
package/index.ts CHANGED
@@ -104,6 +104,10 @@ const searchPatternSchema = Type.Object({
104
104
  relative_path: Type.Optional(Type.String({ description: "Optional file or directory restriction relative to the Serena project root." })),
105
105
  paths_include_glob: Type.Optional(Type.String({ description: "Optional glob for included paths." })),
106
106
  paths_exclude_glob: Type.Optional(Type.String({ description: "Optional glob for excluded paths." })),
107
+ context_lines_before: Type.Optional(Type.Number({ description: "Number of context lines before each match." })),
108
+ context_lines_after: Type.Optional(Type.Number({ description: "Number of context lines after each match." })),
109
+ restrict_search_to_code_files: Type.Optional(Type.Boolean({ description: "Restrict search to source/code files when supported by Serena." })),
110
+ multiline: Type.Optional(Type.Boolean({ description: "Treat the pattern as a multiline regular expression when supported by Serena." })),
107
111
  max_answer_chars: MAX_CHARS_PARAM,
108
112
  });
109
113
 
@@ -135,6 +139,15 @@ function stripControlParams(params: Record<string, unknown>): { project: string;
135
139
  return { project: normalizeProject(project), context: normalizeContext(context), timeoutMs: normalizeTimeoutMs(timeout_ms), params: toolParams };
136
140
  }
137
141
 
142
+ export function normalizeSearchPatternParams(params: Record<string, unknown>): Record<string, unknown> {
143
+ const normalized = { ...params };
144
+ if (normalized.substring_pattern === undefined && normalized.pattern !== undefined) {
145
+ normalized.substring_pattern = normalized.pattern;
146
+ }
147
+ delete normalized.pattern;
148
+ return normalized;
149
+ }
150
+
138
151
  function truncateText(text: string): string {
139
152
  const lines = text.split("\n");
140
153
  let output = lines.slice(0, OUTPUT_MAX_LINES).join("\n");
@@ -373,7 +386,7 @@ export default function serenaToolsExtension(pi: ExtensionAPI) {
373
386
  promptGuidelines: ["Use serena_search_for_pattern for project-scoped code searches when symbol lookup is not enough."],
374
387
  parameters: searchPatternSchema,
375
388
  async execute(_id, params, _signal, _onUpdate, ctx) {
376
- return callSerena(ctx, "search_for_pattern", params);
389
+ return callSerena(ctx, "search_for_pattern", normalizeSearchPatternParams(params));
377
390
  },
378
391
  });
379
392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-serena",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Pi extension that provides Serena semantic code tools through a persistent worker.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {