Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .opencode/PAI/Tools/Banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ interface SystemStats {

function getStats(): SystemStats {
let name = "PAI";
let paiVersion = "4.0.3";
let paiVersion = "3.0.0"; // PAI-OpenCode version
let algorithmVersion = "3.7.0";
let catchphrase = "{name} here, ready to go";
let repoUrl = "github.com/danielmiessler/PAI";
let repoUrl = "github.com/Steffen025/pai-opencode"; // PAI-OpenCode repo
try {
const settings = JSON.parse(readFileSync(join(CLAUDE_DIR, "settings.json"), "utf-8"));
name = settings.daidentity?.displayName || settings.daidentity?.name || "PAI";
paiVersion = settings.pai?.version || "2.0";
paiVersion = settings.pai?.version || "3.0.0";
algorithmVersion = (settings.pai?.algorithmVersion || algorithmVersion).replace(/^v/i, '');
catchphrase = settings.daidentity?.startupCatchphrase || catchphrase;
repoUrl = settings.pai?.repoUrl || repoUrl;
Expand Down Expand Up @@ -163,10 +163,10 @@ function getStats(): SystemStats {
const platform = process.platform === "darwin" ? "macOS" : process.platform;
const arch = process.arch;

// Try to get Claude Code version
let ccVersion = "2.0";
// Try to get OpenCode version
let ccVersion = "";
try {
const result = spawnSync("claude", ["--version"], { encoding: "utf-8" });
const result = spawnSync("opencode", ["--version"], { encoding: "utf-8" });
if (result.stdout) {
const match = result.stdout.match(/(\d+\.\d+\.\d+)/);
if (match) ccVersion = match[1];
Expand Down Expand Up @@ -325,10 +325,10 @@ function createNavyBanner(stats: SystemStats, width: number): string {
lines.push(`${framePad}${topBorder}`);
lines.push("");

// Header: PAI (in logo colors) | Personal AI Infrastructure
// Header: PAI-OpenCode v3.0 | Personal AI Infrastructure
const paiColored = `${C.navy}P${RESET}${C.medBlue}A${RESET}${C.lightBlue}I${RESET}`;
const headerText = `${paiColored} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerLen = 33; // "PAI | Personal AI Infrastructure"
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerLen = 44; // "PAI-OpenCode v3.0.0 | Personal AI Infrastructure"
const headerPad = " ".repeat(Math.floor((width - headerLen) / 2));
lines.push(`${headerPad}${headerText}`);
Comment on lines +328 to 333
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

headerLen calculation appears slightly off.

The visible length of "PAI-OpenCode v3.0.0 | Personal AI Infrastructure" is 48 characters, but headerLen is set to 44. This will cause the header to be slightly off-center (~2 characters to the right).

Note: The length varies with version string (e.g., v10.0.0 would be 49 chars). Consider computing dynamically or adjusting to 48 for typical version strings.

Suggested fix
-  const headerLen = 44; // "PAI-OpenCode v3.0.0 | Personal AI Infrastructure"
+  const headerLen = 48; // "PAI-OpenCode v3.0.0 | Personal AI Infrastructure"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Header: PAI-OpenCode v3.0 | Personal AI Infrastructure
const paiColored = `${C.navy}P${RESET}${C.medBlue}A${RESET}${C.lightBlue}I${RESET}`;
const headerText = `${paiColored} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerLen = 33; // "PAI | Personal AI Infrastructure"
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerLen = 44; // "PAI-OpenCode v3.0.0 | Personal AI Infrastructure"
const headerPad = " ".repeat(Math.floor((width - headerLen) / 2));
lines.push(`${headerPad}${headerText}`);
// Header: PAI-OpenCode v3.0 | Personal AI Infrastructure
const paiColored = `${C.navy}P${RESET}${C.medBlue}A${RESET}${C.lightBlue}I${RESET}`;
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerLen = 48; // "PAI-OpenCode v3.0.0 | Personal AI Infrastructure"
const headerPad = " ".repeat(Math.floor((width - headerLen) / 2));
lines.push(`${headerPad}${headerText}`);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.opencode/PAI/Tools/Banner.ts around lines 328 - 333, The hardcoded
headerLen (44) is incorrect for the visible header length; instead compute the
visible length dynamically by stripping ANSI/color sequences from headerText
(e.g., remove /\x1b\[[0-9;]*m/g) and use that length to compute headerPad so
centering uses the actual visible character count; update the code around
headerLen/headerPad/headerText (and keep usage of stats.paiVersion, width,
headerPad, lines.push) to calculate visibleLength =
headerTextWithoutColors.length and then set headerPad = "
".repeat(Math.floor((width - visibleLength) / 2)).

lines.push(""); // Blank line between header and tagline
Expand All @@ -355,11 +355,16 @@ function createNavyBanner(stats: SystemStats, width: number): string {
lines.push("");
lines.push("");

// Footer: Unicode symbol + URL in medium blue (A color)
// Footer: repo URL + credit line
const urlLine = `${C.steel}\u2192${RESET} ${C.medBlue}${stats.repoUrl}${RESET}`;
const urlLen = stats.repoUrl.length + 3;
const urlPad = " ".repeat(Math.floor((width - urlLen) / 2));
lines.push(`${urlPad}${urlLine}`);

const creditLine = `${C.muted}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditLen = 61; // visible length
const creditPad = " ".repeat(Math.floor((width - creditLen) / 2));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
Comment on lines +363 to 368
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

creditLen calculation appears slightly off.

The visible length of "Built on PAI by Daniel Miessler · github.com/danielmiessler/PAI" is 63 characters, but creditLen is set to 61. This will cause slight off-center alignment.

Suggested fix
-  const creditLen = 61; // visible length
+  const creditLen = 63; // visible length
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const creditLine = `${C.muted}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditLen = 61; // visible length
const creditPad = " ".repeat(Math.floor((width - creditLen) / 2));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
const creditLine = `${C.muted}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditLen = 63; // visible length
const creditPad = " ".repeat(Math.floor((width - creditLen) / 2));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.opencode/PAI/Tools/Banner.ts around lines 363 - 368, The center alignment
is off because creditLen is hardcoded as 61 while the visible text is 63; update
the code around creditLine/creditLen/creditPad to compute the visible length
dynamically (e.g., define the plain text "Built on PAI by Daniel Miessler ·
github.com/danielmiessler/PAI" and set creditLen = visibleText.length) or simply
change creditLen to 63 so creditPad centers correctly before pushing the line
with lines.push(`${creditPad}${creditLine}`).


// Bottom border with full horizontal line and reticle corners
Expand Down Expand Up @@ -675,8 +680,8 @@ function createNavyMediumBanner(stats: SystemStats, width: number): string {

// Header (no border)
const paiColored = `${C.navy}P${RESET}${C.medBlue}A${RESET}${C.lightBlue}I${RESET}`;
const headerText = `${paiColored} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerPad = " ".repeat(Math.max(0, Math.floor((width - 33) / 2)));
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerPad = " ".repeat(Math.max(0, Math.floor((width - 44) / 2)));
lines.push(`${headerPad}${headerText}`);
lines.push("");
Comment on lines +683 to 686
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same headerLen discrepancy as the Navy banner.

The header width used for centering (44) should be 48 to match the actual visible text length.

Suggested fix
-  const headerPad = " ".repeat(Math.max(0, Math.floor((width - 44) / 2)));
+  const headerPad = " ".repeat(Math.max(0, Math.floor((width - 48) / 2)));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerPad = " ".repeat(Math.max(0, Math.floor((width - 44) / 2)));
lines.push(`${headerPad}${headerText}`);
lines.push("");
const headerText = `${paiColored}${C.slate}-OpenCode ${C.silver}v${stats.paiVersion}${RESET} ${C.steel}|${RESET} ${C.slate}Personal AI Infrastructure${RESET}`;
const headerPad = " ".repeat(Math.max(0, Math.floor((width - 48) / 2)));
lines.push(`${headerPad}${headerText}`);
lines.push("");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.opencode/PAI/Tools/Banner.ts around lines 683 - 686, The centering uses a
hardcoded 44 width causing misalignment; update the calculation in Banner.ts to
use the correct visible header length (48) by replacing the 44 in the headerPad
computation (the line that computes headerPad using " ".repeat(Math.max(0,
Math.floor((width - 44) / 2)))) with 48 (or compute the actual headerText length
dynamically) so headerText is centered correctly; adjust the same constant
wherever the Navy banner used 48 to keep behavior consistent.


Expand All @@ -697,6 +702,9 @@ function createNavyMediumBanner(stats: SystemStats, width: number): string {
const urlLine = `${C.steel}\u2192${RESET} ${C.medBlue}${stats.repoUrl}${RESET}`;
const urlPad = " ".repeat(Math.max(0, Math.floor((width - stats.repoUrl.length - 3) / 2)));
lines.push(`${urlPad}${urlLine}`);
const creditLine = `${C.steel}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditPad = " ".repeat(Math.max(0, Math.floor((width - 61) / 2)));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
Comment on lines +705 to 708
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same creditLen discrepancy as the Navy banner.

The credit width used for centering (61) should be 63 to match the actual visible text length.

Suggested fix
-  const creditPad = " ".repeat(Math.max(0, Math.floor((width - 61) / 2)));
+  const creditPad = " ".repeat(Math.max(0, Math.floor((width - 63) / 2)));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const creditLine = `${C.steel}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditPad = " ".repeat(Math.max(0, Math.floor((width - 61) / 2)));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
const creditLine = `${C.steel}Built on PAI by Daniel Miessler \u00b7 github.com/danielmiessler/PAI${RESET}`;
const creditPad = " ".repeat(Math.max(0, Math.floor((width - 63) / 2)));
lines.push(`${creditPad}${creditLine}`);
lines.push("");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.opencode/PAI/Tools/Banner.ts around lines 705 - 708, The credit centering
uses a hardcoded 61 width causing off-by-2 alignment; update the centering logic
in Banner.ts where creditLine and creditPad are computed (variables creditLine,
creditPad, and subsequent lines.push calls) to use the correct visible length
(change the hardcoded 61 to 63) or, better, compute the visible length
dynamically by stripping ANSI/color codes from creditLine and using that length
when calculating " ".repeat(Math.max(0, Math.floor((width - visibleLen) / 2)));
ensure the same approach is applied where the Navy banner had the same fix.


return lines.join("\n");
Expand Down
Loading