@oh-my-pi/pi-utils 16.0.10 → 16.1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [16.0.11] - 2026-06-19
6
+
7
+ ### Removed
8
+
9
+ - Removed `getIndentation`, `setDefaultTabWidth`, and `getDefaultTabWidth` helpers
10
+
5
11
  ## [16.0.8] - 2026-06-18
6
12
 
7
13
  ### Changed
@@ -1,18 +1,12 @@
1
1
  export declare const MIN_TAB_WIDTH = 1;
2
2
  export declare const MAX_TAB_WIDTH = 16;
3
3
  export declare const DEFAULT_TAB_WIDTH = 3;
4
- export declare function getDefaultTabWidth(): number;
5
- export declare function setDefaultTabWidth(width: number): void;
6
- /**
7
- * Visible tab width in columns for `file` (from `.editorconfig` + default), or the default when `file` is omitted.
8
- */
9
- export declare function getIndentation(file?: string | null, projectDir?: string | null): number;
10
4
  /**
11
5
  * `.editorconfig`-derived formatting options for an LSP `textDocument/formatting` request.
12
6
  *
13
7
  * Both fields are absent when the resolved `.editorconfig` chain does not pin them, so callers
14
8
  * can layer their own fallbacks (content sniffing, project defaults) underneath. Returned values
15
- * are clamped to {@link MIN_TAB_WIDTH}..{@link MAX_TAB_WIDTH} for parity with {@link getIndentation}.
9
+ * are clamped to {@link MIN_TAB_WIDTH}..{@link MAX_TAB_WIDTH}.
16
10
  */
17
11
  export interface EditorConfigFormatting {
18
12
  /** Effective indent width in columns, from `indent_size` or `tab_width`. */
@@ -24,7 +18,7 @@ export interface EditorConfigFormatting {
24
18
  * Resolve `.editorconfig` formatting hints for `file` without falling back to any default.
25
19
  *
26
20
  * Used by the LSP format-on-write path so a missing `.editorconfig` declaration falls through
27
- * to caller-provided defaults instead of clobbering the file with the renderer's display
28
- * `defaultTabWidth` (issue #2329).
21
+ * to caller-provided defaults instead of clobbering the file with the renderer's
22
+ * display tab width (issue #2329).
29
23
  */
30
24
  export declare function getEditorConfigFormatting(file?: string | null, projectDir?: string | null): EditorConfigFormatting;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "16.0.10",
4
+ "version": "16.1.0",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -31,7 +31,7 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
- "@oh-my-pi/pi-natives": "16.0.10",
34
+ "@oh-my-pi/pi-natives": "16.1.0",
35
35
  "handlebars": "^4.7.9",
36
36
  "winston": "^3.19.0",
37
37
  "winston-daily-rotate-file": "^5.0.0"
@@ -20,11 +20,8 @@ const NAME_MAX_BYTES = 255;
20
20
 
21
21
  const EDITORCONFIG_NAME = ".editorconfig";
22
22
 
23
- let defaultTabWidth = DEFAULT_TAB_WIDTH;
24
-
25
23
  const editorConfigCache = new Map<string, ParsedEditorConfig | null>();
26
24
  const editorConfigChainCache = new Map<string, ChainEntry[]>();
27
- const indentationCache = new Map<string, number>();
28
25
 
29
26
  interface EditorConfigSection {
30
27
  pattern: string;
@@ -266,31 +263,6 @@ function resolveEditorConfigMatch(absoluteFile: string): EditorConfigMatch | und
266
263
  return match;
267
264
  }
268
265
 
269
- function resolveEditorConfigTabWidth(match: EditorConfigMatch | undefined, fallback: number): number | undefined {
270
- if (match === undefined) return undefined;
271
-
272
- if (match.indentSize?.kind === "spaces") {
273
- return match.indentSize.n;
274
- }
275
-
276
- if (match.indentSize?.kind === "tab") {
277
- if (match.tabWidth !== undefined) {
278
- return match.tabWidth;
279
- }
280
- return fallback;
281
- }
282
-
283
- if (match.tabWidth !== undefined) {
284
- return match.tabWidth;
285
- }
286
-
287
- if (match.indentStyle === IndentStyle.Tab) {
288
- return fallback;
289
- }
290
-
291
- return undefined;
292
- }
293
-
294
266
  function hasOverlongPathComponent(filePath: string): boolean {
295
267
  for (const part of filePath.split(/[\\/]/)) {
296
268
  if (part.length > 0 && Buffer.byteLength(part) > NAME_MAX_BYTES) {
@@ -300,53 +272,12 @@ function hasOverlongPathComponent(filePath: string): boolean {
300
272
  return false;
301
273
  }
302
274
 
303
- export function getDefaultTabWidth(): number {
304
- return defaultTabWidth;
305
- }
306
-
307
- export function setDefaultTabWidth(width: number): void {
308
- defaultTabWidth = clampTabWidth(width);
309
- }
310
-
311
- /**
312
- * Visible tab width in columns for `file` (from `.editorconfig` + default), or the default when `file` is omitted.
313
- */
314
- export function getIndentation(file?: string | null, projectDir?: string | null): number {
315
- const fallback = defaultTabWidth;
316
- if (file === undefined || file === null || file === "") {
317
- return fallback;
318
- }
319
-
320
- const cwd = projectDir ?? process.cwd();
321
- const absoluteFile = resolveFilePath(cwd, file);
322
-
323
- // Renderers can hand us arbitrary strings (e.g. a malformed edit tool
324
- // call whose `file_path` is gibberish). Reject paths whose normalized
325
- // absolute form still has any component longer than `NAME_MAX_BYTES` —
326
- // the editorconfig chain would only trip `ENAMETOOLONG` from
327
- // `readFileSync` and escape.
328
- if (hasOverlongPathComponent(absoluteFile)) {
329
- return fallback;
330
- }
331
- const absKey = absoluteFile;
332
- const cached = indentationCache.get(absKey);
333
- if (cached !== undefined) {
334
- return cached;
335
- }
336
-
337
- const editorMatch = resolveEditorConfigMatch(absoluteFile);
338
- const resolved = resolveEditorConfigTabWidth(editorMatch, fallback) ?? fallback;
339
- const clamped = clampTabWidth(resolved);
340
- indentationCache.set(absKey, clamped);
341
- return clamped;
342
- }
343
-
344
275
  /**
345
276
  * `.editorconfig`-derived formatting options for an LSP `textDocument/formatting` request.
346
277
  *
347
278
  * Both fields are absent when the resolved `.editorconfig` chain does not pin them, so callers
348
279
  * can layer their own fallbacks (content sniffing, project defaults) underneath. Returned values
349
- * are clamped to {@link MIN_TAB_WIDTH}..{@link MAX_TAB_WIDTH} for parity with {@link getIndentation}.
280
+ * are clamped to {@link MIN_TAB_WIDTH}..{@link MAX_TAB_WIDTH}.
350
281
  */
351
282
  export interface EditorConfigFormatting {
352
283
  /** Effective indent width in columns, from `indent_size` or `tab_width`. */
@@ -359,8 +290,8 @@ export interface EditorConfigFormatting {
359
290
  * Resolve `.editorconfig` formatting hints for `file` without falling back to any default.
360
291
  *
361
292
  * Used by the LSP format-on-write path so a missing `.editorconfig` declaration falls through
362
- * to caller-provided defaults instead of clobbering the file with the renderer's display
363
- * `defaultTabWidth` (issue #2329).
293
+ * to caller-provided defaults instead of clobbering the file with the renderer's
294
+ * display tab width (issue #2329).
364
295
  */
365
296
  export function getEditorConfigFormatting(file?: string | null, projectDir?: string | null): EditorConfigFormatting {
366
297
  if (file === undefined || file === null || file === "") {
@@ -370,7 +301,7 @@ export function getEditorConfigFormatting(file?: string | null, projectDir?: str
370
301
  const cwd = projectDir ?? process.cwd();
371
302
  const absoluteFile = resolveFilePath(cwd, file);
372
303
 
373
- // Same NAME_MAX guard as `getIndentation`: editorconfig discovery is
304
+ // NAME_MAX guard: editorconfig discovery is
374
305
  // best-effort and must never escape as `ENAMETOOLONG` from a renderer's
375
306
  // stray gibberish path.
376
307
  if (hasOverlongPathComponent(absoluteFile)) {