@mariozechner/pi-coding-agent 0.12.3 → 0.12.5
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 +26 -1
- package/README.md +38 -1
- package/dist/changelog.d.ts +1 -1
- package/dist/changelog.d.ts.map +1 -1
- package/dist/changelog.js +1 -1
- package/dist/changelog.js.map +1 -1
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +109 -0
- package/dist/config.js.map +1 -0
- package/dist/export-html.d.ts.map +1 -1
- package/dist/export-html.js +1 -4
- package/dist/export-html.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +23 -27
- package/dist/main.js.map +1 -1
- package/dist/model-config.d.ts.map +1 -1
- package/dist/model-config.js +3 -4
- package/dist/model-config.js.map +1 -1
- package/dist/oauth/storage.d.ts.map +1 -1
- package/dist/oauth/storage.js +4 -12
- package/dist/oauth/storage.js.map +1 -1
- package/dist/session-manager.d.ts +2 -2
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/session-manager.js +2 -2
- package/dist/session-manager.js.map +1 -1
- package/dist/settings-manager.d.ts.map +1 -1
- package/dist/settings-manager.js +2 -2
- package/dist/settings-manager.js.map +1 -1
- package/dist/slash-commands.d.ts +2 -2
- package/dist/slash-commands.d.ts.map +1 -1
- package/dist/slash-commands.js +7 -8
- package/dist/slash-commands.js.map +1 -1
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +11 -15
- package/dist/theme/theme.js.map +1 -1
- package/dist/tools-manager.d.ts.map +1 -1
- package/dist/tools-manager.js +3 -2
- package/dist/tools-manager.js.map +1 -1
- package/dist/tui/model-selector.d.ts.map +1 -1
- package/dist/tui/model-selector.js +1 -1
- package/dist/tui/model-selector.js.map +1 -1
- package/dist/tui/tool-execution.d.ts.map +1 -1
- package/dist/tui/tool-execution.js +3 -2
- package/dist/tui/tool-execution.js.map +1 -1
- package/dist/tui/tui-renderer.d.ts +1 -0
- package/dist/tui/tui-renderer.d.ts.map +1 -1
- package/dist/tui/tui-renderer.js +40 -6
- package/dist/tui/tui-renderer.js.map +1 -1
- package/package.json +8 -4
- package/dist/paths.d.ts +0 -32
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -60
- package/dist/paths.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.12.5] - 2025-12-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Forking/Rebranding Support**: All branding (app name, config directory, environment variable names) is now configurable via `piConfig` in `package.json`. Forks can change `piConfig.name` and `piConfig.configDir` to rebrand the CLI without code changes. Affects CLI banner, help text, config paths, and error messages. ([#95](https://github.com/badlogic/pi-mono/pull/95))
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Bun Binary Detection**: Fixed Bun compiled binary failing to start after Bun updated its virtual filesystem path format from `%7EBUN` to `$bunfs`. ([#95](https://github.com/badlogic/pi-mono/pull/95))
|
|
14
|
+
|
|
15
|
+
## [0.12.4] - 2025-12-02
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`/debug` Command**: New slash command that writes debug information to `~/.pi/agent/pi-debug.log`, including terminal width and all rendered lines with their visible widths. Useful for diagnosing rendering issues.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **Windows Carriage Return Handling**: Fixed tool output containing stray `\r` characters on Windows, which could cause rendering issues. Carriage returns are now stripped from bash output.
|
|
24
|
+
|
|
5
25
|
## [0.12.3] - 2025-12-02
|
|
6
26
|
|
|
7
27
|
### Fixed
|
|
8
28
|
|
|
9
|
-
- **Windows Binary Path Resolution**: Fixed Bun compiled binary on Windows failing to find `package.json` and other assets. The binary was incorrectly using the Bun runtime's virtual filesystem path (`B:\~BUN\`) instead of the actual executable location. Now uses `process.execPath` which correctly points to the compiled binary, and updated detection to check for `%7EBUN` (URL-encoded `~BUN`) in `import.meta.url`.
|
|
10
29
|
- **Windows Terminal Truecolor Support**: Fixed theme colors appearing washed out in Windows Terminal. The color mode detection now checks for `WT_SESSION` environment variable to enable truecolor (24-bit RGB) support instead of falling back to 256-color mode.
|
|
11
30
|
|
|
31
|
+
## [0.12.2] - 2025-12-02
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **Windows Binary Path Resolution**: Fixed Bun compiled binary on Windows failing to find `package.json` and other assets. The binary was incorrectly using the Bun runtime's virtual filesystem path (`B:\~BUN\`) instead of the actual executable location. Now uses `process.execPath` which correctly points to the compiled binary, and updated detection to check for `%7EBUN` (URL-encoded `~BUN`) in `import.meta.url`.
|
|
36
|
+
|
|
12
37
|
## [0.12.1] - 2025-12-02
|
|
13
38
|
|
|
14
39
|
### Changed
|
package/README.md
CHANGED
|
@@ -637,7 +637,7 @@ Change queue mode with `/queue` command. Setting is saved in `~/.pi/agent/settin
|
|
|
637
637
|
|
|
638
638
|
**Editing:**
|
|
639
639
|
- **Enter**: Send message
|
|
640
|
-
- **Shift+Enter** / **Alt+Enter**: Insert new line (multi-line input)
|
|
640
|
+
- **Shift+Enter** / **Alt+Enter**: Insert new line (multi-line input). On WSL, use **Ctrl+Enter** instead.
|
|
641
641
|
- **Backspace**: Delete character backwards
|
|
642
642
|
- **Delete** (or **Fn+Backspace**): Delete character forwards
|
|
643
643
|
- **Ctrl+W** / **Option+Backspace**: Delete word backwards (stops at whitespace or punctuation)
|
|
@@ -1141,6 +1141,30 @@ Things that might happen eventually:
|
|
|
1141
1141
|
|
|
1142
1142
|
## Development
|
|
1143
1143
|
|
|
1144
|
+
### Forking / Rebranding
|
|
1145
|
+
|
|
1146
|
+
All branding (app name, config directory) is configurable via `package.json`:
|
|
1147
|
+
|
|
1148
|
+
```json
|
|
1149
|
+
{
|
|
1150
|
+
"piConfig": {
|
|
1151
|
+
"name": "pi",
|
|
1152
|
+
"configDir": ".pi"
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
To create a fork with different branding:
|
|
1158
|
+
1. Change `piConfig.name` to your app name (e.g., `"tau"`)
|
|
1159
|
+
2. Change `piConfig.configDir` to your config directory (e.g., `".tau"`)
|
|
1160
|
+
3. Change the `bin` field to your command name: `"bin": { "tau": "dist/cli.js" }`
|
|
1161
|
+
|
|
1162
|
+
This affects:
|
|
1163
|
+
- CLI banner and help text
|
|
1164
|
+
- Config directory (`~/.pi/agent/` → `~/.tau/agent/`)
|
|
1165
|
+
- Environment variable name (`PI_CODING_AGENT_DIR` → `TAU_CODING_AGENT_DIR`)
|
|
1166
|
+
- All user-facing paths in error messages and documentation
|
|
1167
|
+
|
|
1144
1168
|
### Path Resolution
|
|
1145
1169
|
|
|
1146
1170
|
The codebase supports three execution modes:
|
|
@@ -1156,6 +1180,19 @@ import { getPackageDir, getThemeDir, getPackageJsonPath, getReadmePath, getChang
|
|
|
1156
1180
|
|
|
1157
1181
|
**Never use `__dirname` directly** for resolving package assets. The `paths.ts` module handles the differences between execution modes automatically.
|
|
1158
1182
|
|
|
1183
|
+
### Debug Command
|
|
1184
|
+
|
|
1185
|
+
The `/debug` command is a hidden development feature (not shown in autocomplete) that writes all currently rendered lines with their visible widths and ANSI escape sequences to `~/.pi/agent/pi-debug.log`. This is useful for debugging TUI rendering issues, especially when lines don't extend to the terminal edge or contain unexpected invisible characters.
|
|
1186
|
+
|
|
1187
|
+
```
|
|
1188
|
+
/debug
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
The debug log includes:
|
|
1192
|
+
- Terminal width at time of capture
|
|
1193
|
+
- Total number of rendered lines
|
|
1194
|
+
- Each line with its index, visible width, and JSON-escaped content showing all ANSI codes
|
|
1195
|
+
|
|
1159
1196
|
## License
|
|
1160
1197
|
|
|
1161
1198
|
MIT
|
package/dist/changelog.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ export declare function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry):
|
|
|
17
17
|
* Get entries newer than lastVersion
|
|
18
18
|
*/
|
|
19
19
|
export declare function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[];
|
|
20
|
-
export { getChangelogPath } from "./
|
|
20
|
+
export { getChangelogPath } from "./config.js";
|
|
21
21
|
//# sourceMappingURL=changelog.d.ts.map
|
package/dist/changelog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE,CAyDtE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,GAAG,MAAM,CAI9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,EAAE,CAW9F;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE,CAyDtE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,GAAG,MAAM,CAI9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,EAAE,CAW9F;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface ChangelogEntry {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tcontent: string;\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: { major: number; minor: number; patch: number } | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push({\n\t\t\t\t\t\t...currentVersion,\n\t\t\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionMatch = line.match(/##\\s+\\[?(\\d+)\\.(\\d+)\\.(\\d+)\\]?/);\n\t\t\t\tif (versionMatch) {\n\t\t\t\t\tcurrentVersion = {\n\t\t\t\t\t\tmajor: Number.parseInt(versionMatch[1], 10),\n\t\t\t\t\t\tminor: Number.parseInt(versionMatch[2], 10),\n\t\t\t\t\t\tpatch: Number.parseInt(versionMatch[3], 10),\n\t\t\t\t\t};\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push({\n\t\t\t\t...currentVersion,\n\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t});\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\treturn v1.patch - v2.patch;\n}\n\n/**\n * Get entries newer than lastVersion\n */\nexport function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[] {\n\t// Parse lastVersion\n\tconst parts = lastVersion.split(\".\").map(Number);\n\tconst last: ChangelogEntry = {\n\t\tmajor: parts[0] || 0,\n\t\tminor: parts[1] || 0,\n\t\tpatch: parts[2] || 0,\n\t\tcontent: \"\",\n\t};\n\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"./config.js\";\n"]}
|
package/dist/changelog.js
CHANGED
|
@@ -83,5 +83,5 @@ export function getNewEntries(entries, lastVersion) {
|
|
|
83
83
|
return entries.filter((entry) => compareVersions(entry, last) > 0);
|
|
84
84
|
}
|
|
85
85
|
// Re-export getChangelogPath from paths.ts for convenience
|
|
86
|
-
export { getChangelogPath } from "./
|
|
86
|
+
export { getChangelogPath } from "./config.js";
|
|
87
87
|
//# sourceMappingURL=changelog.js.map
|
package/dist/changelog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAS9C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB,EAAoB;IACvE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,OAAO,GAAqB,EAAE,CAAC;QAErC,IAAI,YAAY,GAAa,EAAE,CAAC;QAChC,IAAI,cAAc,GAA2D,IAAI,CAAC;QAElF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,qDAAqD;YACrD,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,gCAAgC;gBAChC,IAAI,cAAc,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/C,OAAO,CAAC,IAAI,CAAC;wBACZ,GAAG,cAAc;wBACjB,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;qBACvC,CAAC,CAAC;gBACJ,CAAC;gBAED,sCAAsC;gBACtC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBAClE,IAAI,YAAY,EAAE,CAAC;oBAClB,cAAc,GAAG;wBAChB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;wBAC3C,KAAK,EAAE,MAAM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AChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,EAAE,CAAC;IACX,CAAC;AAAA,CACD;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAAkB,EAAE,EAAkB,EAAU;IAC/E,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;IACtD,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;IACtD,OAAO,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;AAAA,CAC3B;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAyB,EAAE,WAAmB,EAAoB;IAC/F,oBAAoB;IACpB,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,IAAI,GAAmB;QAC5B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,OAAO,EAAE,EAAE;KACX,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAAA,CACnE;AAED,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface ChangelogEntry {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tcontent: string;\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: { major: number; minor: number; patch: number } | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push({\n\t\t\t\t\t\t...currentVersion,\n\t\t\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionMatch = line.match(/##\\s+\\[?(\\d+)\\.(\\d+)\\.(\\d+)\\]?/);\n\t\t\t\tif (versionMatch) {\n\t\t\t\t\tcurrentVersion = {\n\t\t\t\t\t\tmajor: Number.parseInt(versionMatch[1], 10),\n\t\t\t\t\t\tminor: Number.parseInt(versionMatch[2], 10),\n\t\t\t\t\t\tpatch: Number.parseInt(versionMatch[3], 10),\n\t\t\t\t\t};\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push({\n\t\t\t\t...currentVersion,\n\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t});\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\treturn v1.patch - v2.patch;\n}\n\n/**\n * Get entries newer than lastVersion\n */\nexport function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[] {\n\t// Parse lastVersion\n\tconst parts = lastVersion.split(\".\").map(Number);\n\tconst last: ChangelogEntry = {\n\t\tmajor: parts[0] || 0,\n\t\tminor: parts[1] || 0,\n\t\tpatch: parts[2] || 0,\n\t\tcontent: \"\",\n\t};\n\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"./config.js\";\n"]}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect if we're running as a Bun compiled binary.
|
|
3
|
+
* Bun binaries have import.meta.url containing "$bunfs" (Bun's virtual filesystem path)
|
|
4
|
+
*/
|
|
5
|
+
export declare const isBunBinary: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).
|
|
8
|
+
* - For Bun binary: returns the directory containing the executable
|
|
9
|
+
* - For Node.js (dist/): returns __dirname (the dist/ directory)
|
|
10
|
+
* - For tsx (src/): returns parent directory (the package root)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPackageDir(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get path to built-in themes directory (shipped with package)
|
|
15
|
+
* - For Bun binary: theme/ next to executable
|
|
16
|
+
* - For Node.js (dist/): dist/theme/
|
|
17
|
+
* - For tsx (src/): src/theme/
|
|
18
|
+
*/
|
|
19
|
+
export declare function getThemesDir(): string;
|
|
20
|
+
/** Get path to package.json */
|
|
21
|
+
export declare function getPackageJsonPath(): string;
|
|
22
|
+
/** Get path to README.md */
|
|
23
|
+
export declare function getReadmePath(): string;
|
|
24
|
+
/** Get path to CHANGELOG.md */
|
|
25
|
+
export declare function getChangelogPath(): string;
|
|
26
|
+
export declare const APP_NAME: string;
|
|
27
|
+
export declare const CONFIG_DIR_NAME: string;
|
|
28
|
+
export declare const VERSION: string;
|
|
29
|
+
export declare const ENV_AGENT_DIR: string;
|
|
30
|
+
/** Get the agent config directory (e.g., ~/.pi/agent/) */
|
|
31
|
+
export declare function getAgentDir(): string;
|
|
32
|
+
/** Get path to user's custom themes directory */
|
|
33
|
+
export declare function getCustomThemesDir(): string;
|
|
34
|
+
/** Get path to models.json */
|
|
35
|
+
export declare function getModelsPath(): string;
|
|
36
|
+
/** Get path to oauth.json */
|
|
37
|
+
export declare function getOAuthPath(): string;
|
|
38
|
+
/** Get path to settings.json */
|
|
39
|
+
export declare function getSettingsPath(): string;
|
|
40
|
+
/** Get path to tools directory */
|
|
41
|
+
export declare function getToolsDir(): string;
|
|
42
|
+
/** Get path to slash commands directory */
|
|
43
|
+
export declare function getCommandsDir(): string;
|
|
44
|
+
/** Get path to sessions directory */
|
|
45
|
+
export declare function getSessionsDir(): string;
|
|
46
|
+
/** Get path to debug log file */
|
|
47
|
+
export declare function getDebugLogPath(): string;
|
|
48
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,WAAW,SAAqC,CAAC;AAM9D;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAWtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4BAA4B;AAC5B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,+BAA+B;AAC/B,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAQD,eAAO,MAAM,QAAQ,EAAE,MAAmC,CAAC;AAC3D,eAAO,MAAM,eAAe,EAAE,MAAyC,CAAC;AACxE,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAG3C,eAAO,MAAM,aAAa,QAA+C,CAAC;AAM1E,0DAA0D;AAC1D,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,6BAA6B;AAC7B,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,2CAA2C;AAC3C,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary = import.meta.url.includes(\"$bunfs\");\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: check if package.json exists in __dirname (dist/) or parent (src/ case)\n\tif (existsSync(join(__dirname, \"package.json\"))) {\n\t\treturn __dirname;\n\t}\n\t// Running from src/ via tsx - go up one level to package root\n\treturn dirname(__dirname);\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/theme/\n * - For tsx (src/): src/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// __dirname is either dist/ or src/ - theme is always a subdirectory\n\treturn join(__dirname, \"theme\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\treturn process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to oauth.json */\nexport function getOAuthPath(): string {\n\treturn join(getAgentDir(), \"oauth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to slash commands directory */\nexport function getCommandsDir(): string {\n\treturn join(getAgentDir(), \"commands\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { dirname, join, resolve } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Package Detection
|
|
7
|
+
// =============================================================================
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
/**
|
|
11
|
+
* Detect if we're running as a Bun compiled binary.
|
|
12
|
+
* Bun binaries have import.meta.url containing "$bunfs" (Bun's virtual filesystem path)
|
|
13
|
+
*/
|
|
14
|
+
export const isBunBinary = import.meta.url.includes("$bunfs");
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Package Asset Paths (shipped with executable)
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).
|
|
20
|
+
* - For Bun binary: returns the directory containing the executable
|
|
21
|
+
* - For Node.js (dist/): returns __dirname (the dist/ directory)
|
|
22
|
+
* - For tsx (src/): returns parent directory (the package root)
|
|
23
|
+
*/
|
|
24
|
+
export function getPackageDir() {
|
|
25
|
+
if (isBunBinary) {
|
|
26
|
+
// Bun binary: process.execPath points to the compiled executable
|
|
27
|
+
return dirname(process.execPath);
|
|
28
|
+
}
|
|
29
|
+
// Node.js: check if package.json exists in __dirname (dist/) or parent (src/ case)
|
|
30
|
+
if (existsSync(join(__dirname, "package.json"))) {
|
|
31
|
+
return __dirname;
|
|
32
|
+
}
|
|
33
|
+
// Running from src/ via tsx - go up one level to package root
|
|
34
|
+
return dirname(__dirname);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get path to built-in themes directory (shipped with package)
|
|
38
|
+
* - For Bun binary: theme/ next to executable
|
|
39
|
+
* - For Node.js (dist/): dist/theme/
|
|
40
|
+
* - For tsx (src/): src/theme/
|
|
41
|
+
*/
|
|
42
|
+
export function getThemesDir() {
|
|
43
|
+
if (isBunBinary) {
|
|
44
|
+
return join(dirname(process.execPath), "theme");
|
|
45
|
+
}
|
|
46
|
+
// __dirname is either dist/ or src/ - theme is always a subdirectory
|
|
47
|
+
return join(__dirname, "theme");
|
|
48
|
+
}
|
|
49
|
+
/** Get path to package.json */
|
|
50
|
+
export function getPackageJsonPath() {
|
|
51
|
+
return join(getPackageDir(), "package.json");
|
|
52
|
+
}
|
|
53
|
+
/** Get path to README.md */
|
|
54
|
+
export function getReadmePath() {
|
|
55
|
+
return resolve(join(getPackageDir(), "README.md"));
|
|
56
|
+
}
|
|
57
|
+
/** Get path to CHANGELOG.md */
|
|
58
|
+
export function getChangelogPath() {
|
|
59
|
+
return resolve(join(getPackageDir(), "CHANGELOG.md"));
|
|
60
|
+
}
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// App Config (from package.json piConfig)
|
|
63
|
+
// =============================================================================
|
|
64
|
+
const pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
65
|
+
export const APP_NAME = pkg.piConfig?.name || "pi";
|
|
66
|
+
export const CONFIG_DIR_NAME = pkg.piConfig?.configDir || ".pi";
|
|
67
|
+
export const VERSION = pkg.version;
|
|
68
|
+
// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR
|
|
69
|
+
export const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;
|
|
70
|
+
// =============================================================================
|
|
71
|
+
// User Config Paths (~/.pi/agent/*)
|
|
72
|
+
// =============================================================================
|
|
73
|
+
/** Get the agent config directory (e.g., ~/.pi/agent/) */
|
|
74
|
+
export function getAgentDir() {
|
|
75
|
+
return process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, "agent");
|
|
76
|
+
}
|
|
77
|
+
/** Get path to user's custom themes directory */
|
|
78
|
+
export function getCustomThemesDir() {
|
|
79
|
+
return join(getAgentDir(), "themes");
|
|
80
|
+
}
|
|
81
|
+
/** Get path to models.json */
|
|
82
|
+
export function getModelsPath() {
|
|
83
|
+
return join(getAgentDir(), "models.json");
|
|
84
|
+
}
|
|
85
|
+
/** Get path to oauth.json */
|
|
86
|
+
export function getOAuthPath() {
|
|
87
|
+
return join(getAgentDir(), "oauth.json");
|
|
88
|
+
}
|
|
89
|
+
/** Get path to settings.json */
|
|
90
|
+
export function getSettingsPath() {
|
|
91
|
+
return join(getAgentDir(), "settings.json");
|
|
92
|
+
}
|
|
93
|
+
/** Get path to tools directory */
|
|
94
|
+
export function getToolsDir() {
|
|
95
|
+
return join(getAgentDir(), "tools");
|
|
96
|
+
}
|
|
97
|
+
/** Get path to slash commands directory */
|
|
98
|
+
export function getCommandsDir() {
|
|
99
|
+
return join(getAgentDir(), "commands");
|
|
100
|
+
}
|
|
101
|
+
/** Get path to sessions directory */
|
|
102
|
+
export function getSessionsDir() {
|
|
103
|
+
return join(getAgentDir(), "sessions");
|
|
104
|
+
}
|
|
105
|
+
/** Get path to debug log file */
|
|
106
|
+
export function getDebugLogPath() {
|
|
107
|
+
return join(getAgentDir(), `${APP_NAME}-debug.log`);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAE9D,gFAAgF;AAChF,gDAAgD;AAChD,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,GAAW;IACvC,IAAI,WAAW,EAAE,CAAC;QACjB,iEAAiE;QACjE,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,mFAAmF;IACnF,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,8DAA8D;IAC9D,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAAA,CAC1B;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,GAAW;IACtC,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,IA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CAAC,CAAC;AAAA,CAC/E;AAED,iDAAiD;AACjD,MAAM,UAAU,kBAAkB,GAAW;IAC5C,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;AAAA,CACrC;AAED,8BAA8B;AAC9B,MAAM,UAAU,aAAa,GAAW;IACvC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AAAA,CAC1C;AAED,6BAA6B;AAC7B,MAAM,UAAU,YAAY,GAAW;IACtC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,YAAY,CAAC,CAAC;AAAA,CACzC;AAED,gCAAgC;AAChC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,CAAC;AAAA,CAC5C;AAED,kCAAkC;AAClC,MAAM,UAAU,WAAW,GAAW;IACrC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;AAAA,CACpC;AAED,2CAA2C;AAC3C,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,CACvC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,CACvC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAAA,CACpD","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary = import.meta.url.includes(\"$bunfs\");\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: check if package.json exists in __dirname (dist/) or parent (src/ case)\n\tif (existsSync(join(__dirname, \"package.json\"))) {\n\t\treturn __dirname;\n\t}\n\t// Running from src/ via tsx - go up one level to package root\n\treturn dirname(__dirname);\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/theme/\n * - For tsx (src/): src/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// __dirname is either dist/ or src/ - theme is always a subdirectory\n\treturn join(__dirname, \"theme\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\treturn process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to oauth.json */\nexport function getOAuthPath(): string {\n\treturn join(getAgentDir(), \"oauth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to slash commands directory */\nexport function getCommandsDir(): string {\n\treturn join(getAgentDir(), \"commands\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|