oh-pi 0.1.8 → 0.1.10

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.
@@ -1,4 +1,4 @@
1
- import { writeFileSync, mkdirSync, readFileSync, copyFileSync, existsSync, readdirSync, statSync } from "node:fs";
1
+ import { writeFileSync, mkdirSync, readFileSync, copyFileSync, existsSync, readdirSync, statSync, rmSync } from "node:fs";
2
2
  import { join, dirname } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { homedir } from "node:os";
@@ -8,6 +8,12 @@ const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
8
8
  function ensureDir(dir) {
9
9
  mkdirSync(dir, { recursive: true });
10
10
  }
11
+ /** Remove and recreate a directory */
12
+ function cleanDir(dir) {
13
+ if (existsSync(dir))
14
+ rmSync(dir, { recursive: true });
15
+ ensureDir(dir);
16
+ }
11
17
  /** Recursively copy a directory */
12
18
  function copyDir(src, dest) {
13
19
  ensureDir(dest);
@@ -115,7 +121,7 @@ export function applyConfig(config) {
115
121
  catch { /* template not found, skip */ }
116
122
  // 6. Copy extensions (single file .ts or directory with index.ts)
117
123
  const extDir = join(agentDir, "extensions");
118
- ensureDir(extDir);
124
+ cleanDir(extDir);
119
125
  for (const ext of config.extensions) {
120
126
  const dirSrc = join(PKG_ROOT, "pi-package", "extensions", ext);
121
127
  const fileSrc = join(PKG_ROOT, "pi-package", "extensions", `${ext}.ts`);
@@ -131,7 +137,7 @@ export function applyConfig(config) {
131
137
  }
132
138
  // 7. Copy prompts
133
139
  const promptDir = join(agentDir, "prompts");
134
- ensureDir(promptDir);
140
+ cleanDir(promptDir);
135
141
  for (const p of config.prompts) {
136
142
  const src = join(PKG_ROOT, "pi-package", "prompts", `${p}.md`);
137
143
  try {
@@ -141,7 +147,7 @@ export function applyConfig(config) {
141
147
  }
142
148
  // 8. Copy skills
143
149
  const skillDir = join(agentDir, "skills");
144
- ensureDir(skillDir);
150
+ cleanDir(skillDir);
145
151
  for (const s of config.skills) {
146
152
  const srcDir = join(PKG_ROOT, "pi-package", "skills", s);
147
153
  const destDir = join(skillDir, s);
@@ -153,7 +159,7 @@ export function applyConfig(config) {
153
159
  }
154
160
  // 9. Copy themes (only custom ones)
155
161
  const themeDir = join(agentDir, "themes");
156
- ensureDir(themeDir);
162
+ cleanDir(themeDir);
157
163
  const themeSrc = join(PKG_ROOT, "pi-package", "themes", `${config.theme}.json`);
158
164
  try {
159
165
  copyFileSync(themeSrc, join(themeDir, `${config.theme}.json`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-pi",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "One-click setup for pi-coding-agent. Like oh-my-zsh for pi.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -95,8 +95,15 @@ export default function (pi: ExtensionAPI) {
95
95
  if (branchStr) leftParts.push(branchStr);
96
96
  const left = leftParts.join(sep);
97
97
 
98
- const pad = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(sep) - visibleWidth(right)));
99
- return [truncateToWidth(left + pad + right, width)];
98
+ const leftW = visibleWidth(left);
99
+ const rightW = visibleWidth(right);
100
+ const gap = width - leftW - rightW;
101
+ if (gap >= 2) {
102
+ const pad = " ".repeat(gap);
103
+ return [truncateToWidth(left + pad + right, width)];
104
+ }
105
+ // Not enough space for right side — just show left truncated
106
+ return [truncateToWidth(left, width)];
100
107
  },
101
108
  };
102
109
  });
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { AssistantMessage } from "@mariozechner/pi-ai";
8
8
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
9
+ import { truncateToWidth } from "@mariozechner/pi-tui";
9
10
 
10
11
  export default function (pi: ExtensionAPI) {
11
12
  pi.on("session_start", async (_event, ctx) => {
@@ -43,8 +44,8 @@ export default function (pi: ExtensionAPI) {
43
44
  const line = `⚡ ${modelStr}${thinkStr}${ctxStr}${costStr} │ 📂 ${cwd}${gitStr} │ 📋 ${sessionName}`;
44
45
 
45
46
  ctx.ui.setHeader((_tui, theme) => ({
46
- render(_width: number): string[] {
47
- return ["", theme.fg("accent", line), ""];
47
+ render(width: number): string[] {
48
+ return ["", truncateToWidth(theme.fg("accent", line), width), ""];
48
49
  },
49
50
  invalidate() {},
50
51
  }));