Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions .beads/metadata.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"database": "dolt",
"backend": "dolt",
"dolt_mode": "server",
"dolt_server_host": "127.0.0.1",
"dolt_server_port": 3308,
"dolt_database": "beads_buddy-cli",
"dolt_mode": "embedded",
"dolt_database": "beads_buddy_cli",
"project_id": "8c1fd894-7662-4bbc-80fb-80bb8c683a61"
}
}
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ buddy <command> # Global (after self:install)
## Architecture

```
bin/buddy # Entry point
bin/buddy # Entry point (sh wrapper; unsets PHPRC, execs bin/buddy.php)
bin/buddy.php # PHP application bootstrap
src/
├── Application.php # Symfony Console application bootstrap
├── Commands/ # Command classes organized by resource
Expand Down
69 changes: 26 additions & 43 deletions bin/buddy
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

// Override script name for clean help output (e.g., "buddy help" instead of "/path/to/buddy help").
// Symfony Console reads $_SERVER['PHP_SELF'] directly in Command::getProcessedHelp() with no
// official API to customize it. This workaround is acknowledged by Symfony maintainers as
// "good enough" (see: https://github.com/symfony/symfony/issues/18524).
$_SERVER['PHP_SELF'] = 'buddy';
$_SERVER['argv'][0] = 'buddy';

// Find autoloader
$autoloadPaths = [
__DIR__ . '/../vendor/autoload.php', // Local development
__DIR__ . '/../../../autoload.php', // Installed as dependency
];

$autoloader = null;
foreach ($autoloadPaths as $path) {
if (file_exists($path)) {
$autoloader = $path;
break;
}
}

if ($autoloader === null) {
fwrite(STDERR, "Could not find autoloader. Run 'composer install' first.\n");
exit(1);
}

require $autoloader;

// Load .env files from current directory and all parent directories
$cwd = getcwd();
if ($cwd !== false) {
BuddyCli\Services\EnvLoader::loadRecursive($cwd);
}

use BuddyCli\Application;

$app = new Application();
$app->run();
#!/bin/sh
# buddy-cli launcher
#
# Unsets PHPRC before invoking PHP so that host-application php.ini files
# (notably LocalWP's per-site config, which pins openssl.cafile / curl.cainfo
# to a wp-includes ca-bundle.crt scoped to one WP install) cannot break our
# HTTPS requests with "cURL error 77: error setting certificate verify
# locations". buddy-cli has no reason to honor a host-app php.ini.
unset PHPRC

# Resolve symlinks to locate buddy.php next to the real launcher.
# Needed because `buddy self:install` and `composer global require` both
# install buddy as a symlink in a PATH dir; $0 then points at the symlink,
# not at the package's bin/ where buddy.php lives. macOS readlink lacks -f,
# so walk the symlink chain manually (POSIX).
self=$0
while [ -L "$self" ]; do
link=$(readlink "$self")
case "$link" in
/*) self=$link ;;
*) self=$(dirname "$self")/$link ;;
esac
done
dir=$(cd "$(dirname "$self")" && pwd)

exec php "$dir/buddy.php" "$@"
43 changes: 43 additions & 0 deletions bin/buddy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

// Override script name for clean help output (e.g., "buddy help" instead of "/path/to/buddy help").
// Symfony Console reads $_SERVER['PHP_SELF'] directly in Command::getProcessedHelp() with no
// official API to customize it. This workaround is acknowledged by Symfony maintainers as
// "good enough" (see: https://github.com/symfony/symfony/issues/18524).
$_SERVER['PHP_SELF'] = 'buddy';
$_SERVER['argv'][0] = 'buddy';

// Find autoloader
$autoloadPaths = [
__DIR__ . '/../vendor/autoload.php', // Local development
__DIR__ . '/../../../autoload.php', // Installed as dependency
];

$autoloader = null;
foreach ($autoloadPaths as $path) {
if (file_exists($path)) {
$autoloader = $path;
break;
}
}

if ($autoloader === null) {
fwrite(STDERR, "Could not find autoloader. Run 'composer install' first.\n");
exit(1);
}

require $autoloader;

// Load .env files from current directory and all parent directories
$cwd = getcwd();
if ($cwd !== false) {
BuddyCli\Services\EnvLoader::loadRecursive($cwd);
}

use BuddyCli\Application;

$app = new Application();
$app->run();
8 changes: 4 additions & 4 deletions tests/Integration/Commands/AuthCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testLoginNoBrowserOutputsUrl(): void
// Run login in background process and capture initial output
$port = 18090 + rand(0, 100);
$cmd = sprintf(
'cd %s && timeout 2 php bin/buddy login --client-id=test-id --client-secret=test-secret --no-browser --port=%d 2>&1 || true',
'cd %s && timeout 2 php bin/buddy.php login --client-id=test-id --client-secret=test-secret --no-browser --port=%d 2>&1 || true',
escapeshellarg(dirname(__DIR__, 3)),
$port
);
Expand All @@ -86,7 +86,7 @@ public function testLoginTestModeStartsServer(): void
// Run login --test in background
$port = 18190 + rand(0, 100);
$cmd = sprintf(
'cd %s && timeout 2 php bin/buddy login --test --port=%d 2>&1 || true',
'cd %s && timeout 2 php bin/buddy.php login --test --port=%d 2>&1 || true',
escapeshellarg(dirname(__DIR__, 3)),
$port
);
Expand All @@ -110,7 +110,7 @@ public function testLoginTestModeHandlesCallback(): void
];

$cmd = sprintf(
'cd %s && php bin/buddy login --test --port=%d',
'cd %s && php bin/buddy.php login --test --port=%d',
escapeshellarg(dirname(__DIR__, 3)),
$port
);
Expand Down Expand Up @@ -148,7 +148,7 @@ public function testLoginPortUnavailable(): void
try {
// Try to run login on same port
$cmd = sprintf(
'cd %s && php bin/buddy login --client-id=test-id --client-secret=test-secret --port=%d 2>&1',
'cd %s && php bin/buddy.php login --client-id=test-id --client-secret=test-secret --port=%d 2>&1',
escapeshellarg(dirname(__DIR__, 3)),
$port
);
Expand Down
Loading