@oh-my-pi/pi-coding-agent 14.0.2 → 14.0.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.
@@ -0,0 +1,239 @@
1
+ import * as path from "node:path";
2
+
3
+ /**
4
+ * Extension segment → [highlight language id, LSP language id].
5
+ * Highlight ids match tree-sitter / native highlighter; LSP ids match Language Server Protocol.
6
+ */
7
+ const EXTENSION_LANG: Record<string, readonly [string, string]> = {
8
+ // TypeScript / JavaScript
9
+ ts: ["typescript", "typescript"],
10
+ cts: ["typescript", "typescript"],
11
+ mts: ["typescript", "typescript"],
12
+ tsx: ["tsx", "typescriptreact"],
13
+ js: ["javascript", "javascript"],
14
+ jsx: ["javascript", "javascriptreact"],
15
+ mjs: ["javascript", "javascript"],
16
+ cjs: ["javascript", "javascript"],
17
+
18
+ // Systems
19
+ rs: ["rust", "rust"],
20
+ go: ["go", "go"],
21
+ c: ["c", "c"],
22
+ h: ["c", "c"],
23
+ cpp: ["cpp", "cpp"],
24
+ cc: ["cpp", "cpp"],
25
+ cxx: ["cpp", "cpp"],
26
+ hh: ["cpp", "cpp"],
27
+ hpp: ["cpp", "cpp"],
28
+ hxx: ["cpp", "cpp"],
29
+ cu: ["cpp", "cpp"],
30
+ ino: ["cpp", "cpp"],
31
+ zig: ["zig", "zig"],
32
+
33
+ // Scripting
34
+ py: ["python", "python"],
35
+ pyi: ["python", "python"],
36
+ rb: ["ruby", "ruby"],
37
+ rbw: ["ruby", "ruby"],
38
+ gemspec: ["ruby", "ruby"],
39
+ lua: ["lua", "lua"],
40
+ sh: ["bash", "shellscript"],
41
+ bash: ["bash", "shellscript"],
42
+ zsh: ["bash", "shellscript"],
43
+ ksh: ["bash", "shellscript"],
44
+ bats: ["bash", "shellscript"],
45
+ tmux: ["bash", "shellscript"],
46
+ cgi: ["bash", "shellscript"],
47
+ fcgi: ["bash", "shellscript"],
48
+ command: ["bash", "shellscript"],
49
+ tool: ["bash", "shellscript"],
50
+ fish: ["fish", "fish"],
51
+ pl: ["perl", "perl"],
52
+ pm: ["perl", "perl"],
53
+ perl: ["perl", "perl"],
54
+ php: ["php", "php"],
55
+
56
+ // JVM
57
+ java: ["java", "java"],
58
+ kt: ["kotlin", "kotlin"],
59
+ ktm: ["kotlin", "kotlin"],
60
+ kts: ["kotlin", "kotlin"],
61
+ scala: ["scala", "scala"],
62
+ sc: ["scala", "scala"],
63
+ sbt: ["scala", "scala"],
64
+ groovy: ["groovy", "groovy"],
65
+ clj: ["clojure", "clojure"],
66
+ cljc: ["clojure", "clojure"],
67
+ cljs: ["clojure", "clojure"],
68
+ edn: ["clojure", "clojure"],
69
+
70
+ // .NET
71
+ cs: ["csharp", "csharp"],
72
+ fs: ["fsharp", "fsharp"],
73
+ vb: ["vb", "vb"],
74
+
75
+ // Web
76
+ html: ["html", "html"],
77
+ htm: ["html", "html"],
78
+ xhtml: ["html", "html"],
79
+ css: ["css", "css"],
80
+ scss: ["scss", "scss"],
81
+ sass: ["sass", "sass"],
82
+ less: ["less", "less"],
83
+ vue: ["vue", "vue"],
84
+ svelte: ["svelte", "svelte"],
85
+ astro: ["astro", "astro"],
86
+
87
+ // Data
88
+ json: ["json", "json"],
89
+ jsonc: ["jsonc", "jsonc"],
90
+ yaml: ["yaml", "yaml"],
91
+ yml: ["yaml", "yaml"],
92
+ toml: ["toml", "toml"],
93
+ xml: ["xml", "xml"],
94
+ xsl: ["xml", "xml"],
95
+ xslt: ["xml", "xml"],
96
+ svg: ["xml", "xml"],
97
+ plist: ["xml", "xml"],
98
+ ini: ["ini", "ini"],
99
+
100
+ // Docs
101
+ md: ["markdown", "markdown"],
102
+ markdown: ["markdown", "markdown"],
103
+ mdx: ["markdown", "markdown"],
104
+ rst: ["restructuredtext", "restructuredtext"],
105
+ adoc: ["asciidoc", "asciidoc"],
106
+ tex: ["latex", "latex"],
107
+
108
+ // Other languages
109
+ sql: ["sql", "sql"],
110
+ graphql: ["graphql", "graphql"],
111
+ gql: ["graphql", "graphql"],
112
+ proto: ["protobuf", "protobuf"],
113
+ dockerfile: ["dockerfile", "dockerfile"],
114
+ containerfile: ["dockerfile", "dockerfile"],
115
+ tf: ["hcl", "terraform"],
116
+ hcl: ["hcl", "hcl"],
117
+ tfvars: ["hcl", "hcl"],
118
+ nix: ["nix", "nix"],
119
+ ex: ["elixir", "elixir"],
120
+ exs: ["elixir", "elixir"],
121
+ erl: ["erlang", "erlang"],
122
+ hrl: ["erlang", "erlang"],
123
+ hs: ["haskell", "haskell"],
124
+ ml: ["ocaml", "ocaml"],
125
+ mli: ["ocaml", "ocaml"],
126
+ swift: ["swift", "swift"],
127
+ r: ["r", "r"],
128
+ jl: ["julia", "julia"],
129
+ dart: ["dart", "dart"],
130
+ elm: ["elm", "elm"],
131
+ v: ["verilog", "v"],
132
+ nim: ["nim", "nim"],
133
+ cr: ["crystal", "crystal"],
134
+ d: ["d", "d"],
135
+ pas: ["pascal", "pascal"],
136
+ pp: ["pascal", "pascal"],
137
+ lisp: ["lisp", "lisp"],
138
+ lsp: ["lisp", "lisp"],
139
+ rkt: ["racket", "racket"],
140
+ scm: ["scheme", "scheme"],
141
+ ps1: ["powershell", "powershell"],
142
+ psm1: ["powershell", "powershell"],
143
+ bat: ["bat", "bat"],
144
+ cmd: ["bat", "bat"],
145
+ tla: ["tlaplus", "tlaplus"],
146
+ tlaplus: ["tlaplus", "tlaplus"],
147
+ m: ["objc", "plaintext"],
148
+ mm: ["objc", "plaintext"],
149
+ sol: ["solidity", "plaintext"],
150
+ odin: ["odin", "plaintext"],
151
+ star: ["starlark", "plaintext"],
152
+ bzl: ["starlark", "plaintext"],
153
+ sv: ["verilog", "plaintext"],
154
+ svh: ["verilog", "plaintext"],
155
+ vh: ["verilog", "plaintext"],
156
+ vim: ["vim", "plaintext"],
157
+ ipynb: ["ipynb", "plaintext"],
158
+ hbs: ["handlebars", "plaintext"],
159
+ hsb: ["handlebars", "plaintext"],
160
+ handlebars: ["handlebars", "plaintext"],
161
+ diff: ["diff", "plaintext"],
162
+ patch: ["diff", "plaintext"],
163
+ makefile: ["make", "plaintext"],
164
+ mk: ["make", "plaintext"],
165
+ mak: ["make", "plaintext"],
166
+ cmake: ["cmake", "cmake"],
167
+ justfile: ["just", "plaintext"],
168
+ txt: ["text", "plaintext"],
169
+ text: ["text", "plaintext"],
170
+ log: ["log", "plaintext"],
171
+ csv: ["csv", "plaintext"],
172
+ tsv: ["tsv", "plaintext"],
173
+ cfg: ["conf", "plaintext"],
174
+ conf: ["conf", "plaintext"],
175
+ config: ["conf", "plaintext"],
176
+ properties: ["conf", "plaintext"],
177
+ env: ["env", "plaintext"],
178
+ gitignore: ["conf", "plaintext"],
179
+ gitattributes: ["conf", "plaintext"],
180
+ gitmodules: ["conf", "plaintext"],
181
+ editorconfig: ["conf", "plaintext"],
182
+ npmrc: ["conf", "plaintext"],
183
+ prettierrc: ["conf", "plaintext"],
184
+ eslintrc: ["conf", "plaintext"],
185
+ prettierignore: ["conf", "plaintext"],
186
+ eslintignore: ["conf", "plaintext"],
187
+ };
188
+
189
+ /** Final segment after the last `.` in the full path (prior theme behavior). */
190
+ function themeExtensionKey(filePath: string): string {
191
+ const extBeg = filePath.lastIndexOf(".");
192
+ return extBeg !== -1 ? filePath.slice(extBeg + 1).toLowerCase() : filePath.toLowerCase();
193
+ }
194
+
195
+ function lspExtensionKey(filePath: string): string {
196
+ const ext = path.extname(filePath).toLowerCase();
197
+ return ext.startsWith(".") ? ext.slice(1) : "";
198
+ }
199
+
200
+ /**
201
+ * Language id for syntax highlighting and UI (icons, read tool), or undefined if unknown.
202
+ */
203
+ export function getLanguageFromPath(filePath: string): string | undefined {
204
+ const pair = EXTENSION_LANG[themeExtensionKey(filePath)];
205
+ if (pair) return pair[0];
206
+
207
+ const baseName = path.basename(filePath).toLowerCase();
208
+ if (baseName.startsWith(".env.")) return "env";
209
+ if (baseName === "dockerfile" || baseName.startsWith("dockerfile.") || baseName === "containerfile") {
210
+ return "dockerfile";
211
+ }
212
+ if (baseName === "justfile") return "just";
213
+ if (baseName === "cmakelists.txt") return "cmake";
214
+
215
+ return undefined;
216
+ }
217
+
218
+ /**
219
+ * LSP language identifier; falls back to `plaintext`.
220
+ */
221
+ export function detectLanguageId(filePath: string): string {
222
+ const baseName = path.basename(filePath).toLowerCase();
223
+ if (baseName === "dockerfile" || baseName.startsWith("dockerfile.") || baseName === "containerfile") {
224
+ return "dockerfile";
225
+ }
226
+ if (baseName === "makefile" || baseName === "gnumakefile") {
227
+ return "makefile";
228
+ }
229
+ if (baseName === "justfile") {
230
+ return "just";
231
+ }
232
+
233
+ const lspExt = lspExtensionKey(filePath);
234
+ if (baseName === "cmakelists.txt" || lspExt === "cmake") {
235
+ return "cmake";
236
+ }
237
+
238
+ return EXTENSION_LANG[lspExt]?.[1] ?? "plaintext";
239
+ }
@@ -1,4 +1,4 @@
1
- import { $env } from "@oh-my-pi/pi-utils";
1
+ import { $env, $flag } from "@oh-my-pi/pi-utils";
2
2
 
3
3
  const SIXEL_START_REGEX = /\x1bP(?:[0-9;]*)q/u;
4
4
  const SIXEL_END_SEQUENCE = "\x1b\\";
@@ -15,7 +15,7 @@ const SIXEL_PLACEHOLDER_PREFIX = "__OMP_SIXEL_SEQUENCE_";
15
15
  */
16
16
  export function isSixelPassthroughEnabled(): boolean {
17
17
  const forcedProtocol = $env.PI_FORCE_IMAGE_PROTOCOL?.trim().toLowerCase();
18
- return forcedProtocol === "sixel" && $env.PI_ALLOW_SIXEL_PASSTHROUGH === "1";
18
+ return forcedProtocol === "sixel" && $flag("PI_ALLOW_SIXEL_PASSTHROUGH");
19
19
  }
20
20
  /** Returns true when the text contains a SIXEL start sequence. */
21
21
  export function containsSixelSequence(text: string): boolean {