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
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "lab-cli"
name = "jdg-cli"
version = "0.1.0"
edition = "2024"
description = "LAB (Lazy Accounting Buddy): agent-friendly accounting reconciliation CLI and MCP server"
Expand Down
30 changes: 17 additions & 13 deletions README.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion scripts/install-launchd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ SCRIPT="$ROOT/scripts/lab-automation.sh"
# needs node/npm for the Saldeo re-login and Homebrew tools (poppler).
BASE_PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

# Explicit LAB_BIN wins; else ~/.local/bin/lab, else the legacy ~/.local/bin/lab-cli.
# Explicit LAB_BIN wins; else ~/.local/bin/lab, else ~/.local/bin/jdg-cli, else the legacy ~/.local/bin/lab-cli.
resolve_lab_bin() {
if [[ -n "${LAB_BIN_OVERRIDE:-}" ]]; then
printf '%s\n' "$LAB_BIN_OVERRIDE"
elif [[ ! -e "$HOME/.local/bin/lab" && -x "$HOME/.local/bin/jdg-cli" ]]; then
printf '%s\n' "$HOME/.local/bin/jdg-cli"
elif [[ ! -e "$HOME/.local/bin/lab" && -x "$HOME/.local/bin/lab-cli" ]]; then
printf '%s\n' "$HOME/.local/bin/lab-cli"
else
Expand Down
4 changes: 3 additions & 1 deletion scripts/lab-automation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ LOG_KEEP=3
# Error text the binary prints (with LAB_NONINTERACTIVE=1) instead of opening a login window.
SESSION_EXPIRED_PHRASE="Saldeo session expired"

# Explicit LAB_BIN wins; else ~/.local/bin/lab, else the legacy ~/.local/bin/lab-cli.
# Explicit LAB_BIN wins; else ~/.local/bin/lab, else ~/.local/bin/jdg-cli, else the legacy ~/.local/bin/lab-cli.
resolve_lab_bin() {
if [[ -n "${LAB_BIN:-}" ]]; then
printf '%s\n' "$LAB_BIN"
elif [[ ! -e "$HOME/.local/bin/lab" && -x "$HOME/.local/bin/jdg-cli" ]]; then
printf '%s\n' "$HOME/.local/bin/jdg-cli"
elif [[ ! -e "$HOME/.local/bin/lab" && -x "$HOME/.local/bin/lab-cli" ]]; then
printf '%s\n' "$HOME/.local/bin/lab-cli"
else
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) fn default_year() -> i32 {
}

#[derive(Parser, Debug)]
#[command(name = "lab-cli")]
#[command(name = "jdg-cli")]
#[command(about = "LAB — Lazy Accounting Buddy", long_about = None)]
pub(crate) struct Cli {
/// Dedykowana baza SQLite na rekordy, przebiegi i dopasowania.
Expand Down
6 changes: 3 additions & 3 deletions src/commands/cli_policy_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl TempDir {
fn new(tag: &str) -> Self {
static NEXT: AtomicUsize = AtomicUsize::new(0);
let path = std::env::temp_dir().join(format!(
"lab-cli-policy-{tag}-{}-{}-{}",
"jdg-cli-policy-{tag}-{}-{}-{}",
std::process::id(),
Utc::now().timestamp_nanos_opt().unwrap(),
NEXT.fetch_add(1, Ordering::Relaxed)
Expand Down Expand Up @@ -195,7 +195,7 @@ fn approve_require_mail_env_values() {
}

fn parse_cli(args: &[&str]) -> Cli {
Cli::try_parse_from(std::iter::once("lab-cli").chain(args.iter().copied())).unwrap()
Cli::try_parse_from(std::iter::once("jdg-cli").chain(args.iter().copied())).unwrap()
}

#[test]
Expand Down Expand Up @@ -232,7 +232,7 @@ fn cli_approve_and_upload_parse_cap_and_require_mail() {
other => panic!("unexpected {other:?}"),
}
assert!(
Cli::try_parse_from(["lab-cli", "approve", "--max-approve", "-1"]).is_err(),
Cli::try_parse_from(["jdg-cli", "approve", "--max-approve", "-1"]).is_err(),
"negative cap must be rejected"
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ pub(crate) fn cwd_is_lab_package(cwd: &Path) -> bool {
return false;
}
let package_header = Regex::new(r"^\[package\]\s*(?:#.*)?$").unwrap();
let package_name = Regex::new(r#"^(?:"lab-cli"|'lab-cli')\s*(?:#.*)?$"#).unwrap();
// `jdg-cli`, albo `lab-cli` — nazwa pakietu sprzed zmiany nazwy repo.
let package_name =
Regex::new(r#"^(?:"(?:jdg|lab)-cli"|'(?:jdg|lab)-cli')\s*(?:#.*)?$"#).unwrap();
let mut in_package = false;
let mut seen_package = false;
let mut name_matches = None;
Expand Down
28 changes: 17 additions & 11 deletions src/credentials_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,29 @@ fn dotenv_path_unrelated_rust_project_uses_home() {
let fixture = DotenvPathFixture::new("unrelated-cli", true);
fs::write(
fixture.cwd.join("Cargo.toml"),
"# name = \"lab-cli\"\n[package]\nname = \"unrelated-cli\"\n[package.metadata]\nname = \"lab-cli\"\n",
"# name = \"jdg-cli\"\n[package]\nname = \"unrelated-cli\"\n[package.metadata]\nname = \"jdg-cli\"\n",
)
.unwrap();
assert_eq!(fixture.selected(None), fixture.fallback());
}

#[test]
fn dotenv_path_lab_checkout_not_ignored_uses_home() {
let fixture = DotenvPathFixture::new("lab-cli", false);
let fixture = DotenvPathFixture::new("jdg-cli", false);
assert_eq!(fixture.selected(None), fixture.fallback());
}

#[test]
fn dotenv_path_tracked_env_uses_home_even_when_ignored() {
let fixture = DotenvPathFixture::new("lab-cli", true);
let fixture = DotenvPathFixture::new("jdg-cli", true);
fs::write(fixture.cwd.join(".env"), "").unwrap();
fixture.git(&["add", "--force", "--", ".env"]);
assert_eq!(fixture.selected(None), fixture.fallback());
}

#[test]
fn dotenv_path_ignored_lab_checkout_uses_cwd() {
let fixture = DotenvPathFixture::new("lab-cli", true);
let fixture = DotenvPathFixture::new("jdg-cli", true);
assert_eq!(fixture.selected(None), fixture.cwd.join(".env"));
assert!(!fixture.cwd.join(".env").exists());
}
Expand All @@ -154,28 +154,34 @@ fn dotenv_path_explicit_override_is_preserved() {

#[test]
fn dotenv_path_lab_without_git_uses_home() {
let fixture = DotenvPathFixture::new("lab-cli", true);
let fixture = DotenvPathFixture::new("jdg-cli", true);
fs::remove_dir_all(fixture.cwd.join(".git")).unwrap();
assert_eq!(fixture.selected(None), fixture.fallback());
}

#[test]
fn dotenv_path_lab_package_accepts_literal_name_and_comments() {
let fixture = DotenvPathFixture::new("lab-cli", true);
let fixture = DotenvPathFixture::new("jdg-cli", true);
fs::write(
fixture.cwd.join("Cargo.toml"),
"[package] # package table\nname = 'lab-cli' # package name\n[package.metadata]\nname = 'other'\n",
"[package] # package table\nname = 'jdg-cli' # package name\n[package.metadata]\nname = 'other'\n",
)
.unwrap();
assert_eq!(fixture.selected(None), fixture.cwd.join(".env"));
}

#[test]
fn dotenv_path_legacy_lab_cli_package_uses_cwd() {
let fixture = DotenvPathFixture::new("lab-cli", true);
assert_eq!(fixture.selected(None), fixture.cwd.join(".env"));
}

#[test]
fn dotenv_path_fake_package_in_multiline_string_uses_home() {
let fixture = DotenvPathFixture::new("unrelated-cli", true);
fs::write(
fixture.cwd.join("Cargo.toml"),
"[package]\nname = 'unrelated-cli'\ndescription = '''\n[package]\nname = 'lab-cli'\n'''\n",
"[package]\nname = 'unrelated-cli'\ndescription = '''\n[package]\nname = 'jdg-cli'\n'''\n",
)
.unwrap();
assert_eq!(fixture.selected(None), fixture.fallback());
Expand Down Expand Up @@ -1310,7 +1316,7 @@ fn write_lab_manifest(dir: &Path) {
fs::create_dir_all(dir).unwrap();
fs::write(
dir.join("Cargo.toml"),
"[package]\nname = \"lab-cli\"\nversion = \"0.1.0\"\n",
"[package]\nname = \"jdg-cli\"\nversion = \"0.1.0\"\n",
)
.unwrap();
}
Expand All @@ -1328,13 +1334,13 @@ fn planted_script_in_cwd_ancestor_is_ignored() {
find_saldeo_auth_script_in(None, None, Some(&cwd), uid).unwrap(),
None
);
// Nawet gdy przodek wygląda jak pakiet lab-cli: liczy się tylko sam cwd.
// Nawet gdy przodek wygląda jak pakiet jdg-cli: liczy się tylko sam cwd.
write_lab_manifest(&root);
assert_eq!(
find_saldeo_auth_script_in(None, None, Some(&cwd), uid).unwrap(),
None
);
// Sam katalog pakietu lab-cli jest zaufanym miejscem.
// Sam katalog pakietu jdg-cli jest zaufanym miejscem.
let found = find_saldeo_auth_script_in(None, None, Some(&root), uid).unwrap();
assert_eq!(
found,
Expand Down
4 changes: 2 additions & 2 deletions src/lab_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) enum LabRootSource {
/// `LAB_ROOT` z pliku konfiguracji: ustawiony ręcznie albo zapamiętany przy pierwszym
/// uruchomieniu w katalogu z danymi.
Config,
/// Bieżący katalog z `lab.sqlite`, `data/` albo checkout pakietu `lab-cli`.
/// Bieżący katalog z `lab.sqlite`, `data/` albo checkout pakietu `jdg-cli` (albo dawnego `lab-cli`).
Cwd,
/// `~/.local/share/lab`.
Home,
Expand Down Expand Up @@ -102,7 +102,7 @@ fn lab_root_value_path(value: &str, inputs: &LabRootInputs<'_>) -> Option<PathBu
})
}

/// Katalog, w którym LAB już pracował (`lab.sqlite`, `data/`) albo checkout `lab-cli`.
/// Katalog, w którym LAB już pracował (`lab.sqlite`, `data/`) albo checkout `jdg-cli` (dawniej `lab-cli`).
pub(crate) fn cwd_holds_lab_state(cwd: &Path) -> bool {
cwd.join("lab.sqlite").is_file()
|| cwd.join("data").is_dir()
Expand Down
12 changes: 6 additions & 6 deletions src/lab_root/lab_root_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ fn cwd_with_data_directory_is_the_root() {
}

#[test]
fn cwd_lab_cli_checkout_is_the_root() {
fn cwd_jdg_cli_checkout_is_the_root() {
let tmp = TempDir::new("cwd-pkg");
let cwd = tmp.dir("cwd");
fs::write(
cwd.join("Cargo.toml"),
"[package]\nname = \"lab-cli\"\nversion = \"0.1.0\"\n",
"[package]\nname = \"jdg-cli\"\nversion = \"0.1.0\"\n",
)
.unwrap();
assert_eq!(
Expand Down Expand Up @@ -202,12 +202,12 @@ fn notice_only_for_remembered_or_home_root() {
fn remember_lab_root_writes_once_and_keeps_the_first_value() {
let tmp = TempDir::new("remember");
let (_store, _guard) = install(tmp.dir("config"), &[], StoreMode::Unavailable);
assert!(remember_lab_root(Path::new("/work/lab-cli")).unwrap());
assert!(remember_lab_root(Path::new("/work/jdg-cli")).unwrap());
assert!(!remember_lab_root(Path::new("/other")).unwrap());
let vars = read_lab_env_file().unwrap();
assert_eq!(
vars.get(LAB_ROOT_KEY).map(String::as_str),
Some("/work/lab-cli")
Some("/work/jdg-cli")
);
}

Expand All @@ -218,12 +218,12 @@ fn remember_lab_root_keeps_other_config_values() {
let mut vars = HashMap::new();
vars.insert("LAB_LLM_MODEL".to_string(), "gemma".to_string());
write_lab_env_file(&vars).unwrap();
assert!(remember_lab_root(Path::new("/work/lab-cli")).unwrap());
assert!(remember_lab_root(Path::new("/work/jdg-cli")).unwrap());
let vars = read_lab_env_file().unwrap();
assert_eq!(vars.get("LAB_LLM_MODEL").map(String::as_str), Some("gemma"));
assert_eq!(
vars.get(LAB_ROOT_KEY).map(String::as_str),
Some("/work/lab-cli")
Some("/work/jdg-cli")
);
}

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub(crate) use parser::*;
pub(crate) use scoring::*;
pub(crate) use sync::*;

/// Celowo dawna nazwa pakietu: zmiana osierociłaby sekrety już zapisane w Keychain.
pub(crate) const KEYCHAIN_SERVICE: &str = "lab-cli";
const DEFAULT_PRODUCTMESH_NIP: &str = "5242920020";

Expand Down
2 changes: 1 addition & 1 deletion src/mcp/mcp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ fn shared_review_score_default_and_range() {
}

fn parse_cli(args: &[&str]) -> std::result::Result<Cli, clap::Error> {
Cli::try_parse_from(std::iter::once("lab-cli").chain(args.iter().copied()))
Cli::try_parse_from(std::iter::once("jdg-cli").chain(args.iter().copied()))
}

fn cli_year_and_score(args: &[&str]) -> (i32, Option<u8>) {
Expand Down
2 changes: 1 addition & 1 deletion src/onboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ pub(crate) fn npm_install_playwright_command(prefix: &Path, version: &str) -> Co

/// Skrypt `saldeo-auth.sh` tylko z zaufanych miejsc: `SALDEO_AUTH_SCRIPT` (ścieżka
/// bezwzględna), drzewo katalogów uruchomionego pliku (po rozwinięciu dowiązań) albo
/// bieżący katalog, gdy jest pakietem `lab-cli`. Nigdy przodkowie bieżącego katalogu.
/// bieżący katalog, gdy jest pakietem `jdg-cli` (albo dawnym `lab-cli`). Nigdy przodkowie bieżącego katalogu.
pub(crate) fn find_saldeo_auth_script() -> Result<Option<PathBuf>> {
let explicit = std::env::var_os("SALDEO_AUTH_SCRIPT").filter(|value| !value.is_empty());
let exe = std::env::current_exe().ok();
Expand Down
2 changes: 1 addition & 1 deletion src/openrouter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub(crate) fn openrouter_extract_invoice_fields(
.post(OPENROUTER_CHAT_URL)
.header("Authorization", format!("Bearer {api_key}"))
.header("Content-Type", "application/json")
.header("HTTP-Referer", "https://github.com/wydrox/lab")
.header("HTTP-Referer", "https://github.com/wydrox/jdg-cli")
.header("X-Title", "LAB")
.json(&body)
.send()
Expand Down
Loading