@oh-my-pi/pi-utils 14.9.9 → 15.0.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "14.9.9",
4
+ "version": "15.0.0",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/bun": "^1.3.13",
41
- "@oh-my-pi/pi-natives": "14.9.9"
41
+ "@oh-my-pi/pi-natives": "15.0.0"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.7"
package/src/dirs.ts CHANGED
@@ -324,6 +324,17 @@ export function getGpuCachePath(): string {
324
324
  return dirs.rootSubdir("gpu_cache.json", "cache");
325
325
  }
326
326
 
327
+ /**
328
+ * Get the GitHub view cache database path (~/.omp/cache/github-cache.db).
329
+ * Honors the `OMP_GITHUB_CACHE_DB` env var when set so tests can isolate the
330
+ * cache file without touching the rest of the config root.
331
+ */
332
+ export function getGithubCacheDbPath(): string {
333
+ const override = process.env.OMP_GITHUB_CACHE_DB;
334
+ if (override) return override;
335
+ return dirs.rootSubdir(path.join("cache", "github-cache.db"), "cache");
336
+ }
337
+
327
338
  /** Get the natives directory (~/.omp/natives). */
328
339
  export function getNativesDir(): string {
329
340
  return dirs.rootSubdir("natives", "cache");
package/src/prompt.ts CHANGED
@@ -8,7 +8,7 @@ export type PromptRenderPhase = "pre-render" | "post-render";
8
8
  export interface PromptFormatOptions {
9
9
  renderPhase?: PromptRenderPhase;
10
10
  replaceAsciiSymbols?: boolean;
11
- boldRfc2119Keywords?: boolean;
11
+ normalizeRfc2119?: boolean;
12
12
  }
13
13
 
14
14
  // Opening XML tag (not self-closing, not closing)
@@ -22,21 +22,27 @@ const TABLE_ROW = /^\|.*\|$/;
22
22
  // Table separator (|---|---|)
23
23
  const TABLE_SEP = /^\|[-:\s|]+\|$/;
24
24
 
25
- /** RFC 2119 keywords used in prompts. */
26
- const RFC2119_KEYWORDS = /\b(?:MUST NOT|SHOULD NOT|SHALL NOT|RECOMMENDED|REQUIRED|OPTIONAL|SHOULD|SHALL|MUST|MAY)\b/g;
27
-
28
- function boldRfc2119Keywords(line: string): string {
29
- return line.replace(RFC2119_KEYWORDS, (match, offset, source) => {
30
- const isAlreadyBold =
31
- source[offset - 2] === "*" &&
32
- source[offset - 1] === "*" &&
33
- source[offset + match.length] === "*" &&
34
- source[offset + match.length + 1] === "*";
35
- if (isAlreadyBold) {
36
- return match;
37
- }
38
- return `**${match}**`;
39
- });
25
+ /**
26
+ * RFC 2119 keywords (plus project aliases NEVER/AVOID) wrapped in markdown bold
27
+ * — `**MUST**`, `**MUST NOT**`, `**NEVER**`, etc.
28
+ */
29
+ const RFC2119_BOLD = /\*\*(MUST NOT|SHOULD NOT|RECOMMENDED|REQUIRED|OPTIONAL|SHOULD|MUST|MAY|NEVER|AVOID)\*\*/g;
30
+
31
+ /**
32
+ * Normalize RFC 2119 markers per project convention:
33
+ * - Strip `**KEYWORD**` bold (visual noise, no semantics).
34
+ * - Alias `MUST NOT` `NEVER` and `SHOULD NOT` → `AVOID` (single-token equivalents).
35
+ * Skips spans inside inline code (`` `…` ``) so alias definitions can be quoted literally.
36
+ */
37
+ function normalizeRfc2119(line: string): string {
38
+ const segments = line.split("`");
39
+ for (let i = 0; i < segments.length; i += 2) {
40
+ segments[i] = segments[i]
41
+ .replace(RFC2119_BOLD, "$1")
42
+ .replace(/\bMUST NOT\b/g, "NEVER")
43
+ .replace(/\bSHOULD NOT\b/g, "AVOID");
44
+ }
45
+ return segments.join("`");
40
46
  }
41
47
 
42
48
  /** Compact a table row by trimming cell padding */
@@ -75,7 +81,7 @@ export function format(content: string, options: PromptFormatOptions = {}): stri
75
81
  const {
76
82
  renderPhase = "post-render",
77
83
  replaceAsciiSymbols = false,
78
- boldRfc2119Keywords: shouldBoldRfc2119 = false,
84
+ normalizeRfc2119: shouldNormalizeRfc2119 = false,
79
85
  } = options;
80
86
  const isPreRender = renderPhase === "pre-render";
81
87
  const lines = content.split("\n");
@@ -125,8 +131,8 @@ export function format(content: string, options: PromptFormatOptions = {}): stri
125
131
  line = `${leadingWhitespace}${compactTableRow(trimmedStart)}`;
126
132
  }
127
133
 
128
- if (shouldBoldRfc2119) {
129
- line = boldRfc2119Keywords(line);
134
+ if (shouldNormalizeRfc2119) {
135
+ line = normalizeRfc2119(line);
130
136
  }
131
137
 
132
138
  if (trimmed === "") {