pi-readseek 0.2.1 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-readseek",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "Pi extension for readseek-backed hash-anchored read/edit/grep, structural code maps, structural search, and file exploration",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "node": ">=20.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@jarkkojs/readseek": "0.2.4",
42
+ "@jarkkojs/readseek": "^0.2.7",
43
43
  "diff": "^8.0.3",
44
44
  "ignore": "^7.0.5",
45
45
  "picomatch": "^4.0.4",
package/prompts/sg.md CHANGED
@@ -29,7 +29,7 @@ Patterns are parsed as code, not text. Formatting is mostly ignored, but syntax
29
29
 
30
30
  ## Languages
31
31
 
32
- Useful `lang` values include `typescript`, `tsx`, `javascript`, `jsx`, `rust`, `python`, `go`, `java`, `c`, `cpp`, `csharp`, `ruby`, `php`, `lua`, `bash`, `json`, `yaml`, `toml`, `markdown`, `dockerfile`, `nix`, and `zig`. readseek 0.2.3 also accepts languages such as `assembly`, `css`, `gdscript`, `html`, `just`, `kconfig`, `latex`, `make`, `meson`, `perl`, `puppet`, `riscv`, `sql`, `swift`, `typst`, `xml`, and `unknown`.
32
+ Useful `lang` values include `assembly`, `bash`, `c`, `cpp`, `csharp`, `css`, `dockerfile`, `gdscript`, `go`, `html`, `java`, `javascript`, `json`, `jsx`, `just`, `kconfig`, `latex`, `lua`, `make`, `markdown`, `meson`, `nix`, `perl`, `php`, `puppet`, `python`, `riscv`, `ruby`, `rust`, `sql`, `swift`, `toml`, `tsx`, `typescript`, `typst`, `xml`, `yaml`, `zig`, and `unknown`.
33
33
 
34
34
  `unknown` forces text-only handling and is not useful for parser-backed search.
35
35
 
@@ -5,7 +5,7 @@ import { THRESHOLDS } from "./constants.js";
5
5
  import type { FileMap, MapOptions } from "./types.js";
6
6
 
7
7
  export const READSEEK_MAPPER_NAME = "readseek";
8
- export const READSEEK_MAPPER_VERSION = 1;
8
+ export const READSEEK_MAPPER_VERSION = 2;
9
9
 
10
10
  export interface MapperIdentity {
11
11
  mapperName: string;
@@ -25,7 +25,7 @@ export interface ReadseekReadOutput {
25
25
  interface ReadseekSymbol {
26
26
  kind: string;
27
27
  name: string;
28
- address: string;
28
+ qualified_name: string;
29
29
  start_line: number;
30
30
  end_line: number;
31
31
  start_hash: string;
@@ -88,34 +88,41 @@ function normalizeKind(kind: string): FileSymbol["kind"] {
88
88
  return SymbolKind.Unknown;
89
89
  }
90
90
 
91
+ function parentQualifiedNameFor(qualifiedName: string): string {
92
+ const lastDot = qualifiedName.lastIndexOf(".");
93
+ return lastDot === -1 ? "" : qualifiedName.slice(0, lastDot);
94
+ }
95
+
91
96
  function symbolsFromReadseek(symbols: ReadseekSymbol[]): FileSymbol[] {
92
- const byAddress = new Map<string, FileSymbol[]>();
93
- const entries: Array<{ address: string; parentAddress: string; symbol: FileSymbol }> = [];
97
+ const symbolsByQualifiedName = new Map<string, FileSymbol[]>();
98
+ const entries: Array<{ parentQualifiedName: string; symbol: FileSymbol }> = [];
94
99
 
95
100
  for (const symbol of symbols) {
96
- const address = symbol.address || symbol.name;
97
- const parentAddress = address.includes(".") ? address.slice(0, address.lastIndexOf(".")) : "";
101
+ const parentQualifiedName = parentQualifiedNameFor(symbol.qualified_name);
98
102
  const fileSymbol: FileSymbol = {
99
103
  name: symbol.name,
100
104
  kind: normalizeKind(symbol.kind),
101
105
  startLine: symbol.start_line,
102
106
  endLine: symbol.end_line,
103
107
  };
104
- const bucket = byAddress.get(address);
108
+ const bucket = symbolsByQualifiedName.get(symbol.qualified_name);
105
109
  if (bucket) bucket.push(fileSymbol);
106
- else byAddress.set(address, [fileSymbol]);
107
- entries.push({ address, parentAddress, symbol: fileSymbol });
110
+ else symbolsByQualifiedName.set(symbol.qualified_name, [fileSymbol]);
111
+ entries.push({ parentQualifiedName, symbol: fileSymbol });
108
112
  }
109
113
 
110
114
  const roots: FileSymbol[] = [];
111
115
  for (const entry of entries) {
112
- const parent = entry.parentAddress ? byAddress.get(entry.parentAddress)?.[0] : undefined;
113
- if (parent) {
114
- parent.children ??= [];
115
- parent.children.push(entry.symbol);
116
- } else {
116
+ const parent = entry.parentQualifiedName
117
+ ? symbolsByQualifiedName.get(entry.parentQualifiedName)?.[0]
118
+ : undefined;
119
+ if (!parent) {
117
120
  roots.push(entry.symbol);
121
+ continue;
118
122
  }
123
+
124
+ parent.children ??= [];
125
+ parent.children.push(entry.symbol);
119
126
  }
120
127
 
121
128
  return roots;
@@ -258,7 +265,7 @@ function parseMapOutput(value: unknown): ReadseekMapOutput {
258
265
  return {
259
266
  kind: requireString(item.kind, "symbol.kind"),
260
267
  name: requireString(item.name, "symbol.name"),
261
- address: requireString(item.address, "symbol.address"),
268
+ qualified_name: requireString(item.qualified_name, "symbol.qualified_name"),
262
269
  start_line: requireNumber(item.start_line, "symbol.start_line"),
263
270
  end_line: requireNumber(item.end_line, "symbol.end_line"),
264
271
  start_hash: requireString(item.start_hash, "symbol.start_hash"),