Commit Graph

8 Commits

Author SHA1 Message Date
oldschoola a2854ba768 fix: migrate coding-agent tests from fs.rm to removeWithRetries
Migrate 203 test files (356 call sites) from fs.rm/fs.rmSync to
removeWithRetries/removeSyncWithRetries to reduce EBUSY test failures
on Windows. removeWithRetries is now exported from @oh-my-pi/pi-utils.

The migration uses a regex-based approach that:
- Replaces fs.rm(path, { recursive, force }) → removeWithRetries(path)
- Replaces fs.rmSync(path, { recursive, force }) → removeSyncWithRetries(path)
- Replaces fs.rm(path) → removeWithRetries(path) (no options)
- Skips fs.rm/fs.rmSync inside template literals (bun --eval scripts)
- Adds imports to existing @oh-my-pi/pi-utils import or creates new one
- Removes unused fs imports where fs.rm was the only fs usage (4 files)
2026-06-23 15:28:05 -07:00
Ogrodev c5011661db fix(coding-agent): bootstrap profiles for acp 2026-06-02 22:30:23 -03:00
Ogrodev 575d06d8d3 Fix profile alias bootstrap 2026-05-31 13:29:43 -03:00
Ogrodev 1f67c58034 Merge branch 'main' of https://github.com/can1357/oh-my-pi into feat/profiles-and-alias
# Conflicts:
#	packages/coding-agent/src/cli.ts
#	packages/coding-agent/src/cli/args.ts
#	packages/coding-agent/src/main.ts
#	packages/utils/src/dirs.ts
2026-05-31 12:00:00 -03:00
Ogrodev 8b1466270c test(coding-agent): add profile alias validation regression tests
- Add test ensuring malicious profile values are rejected before writing alias files
- Add assertions that no profile alias file is written on invalid profile input
- Restore OMP_PROFILE and PI_PROFILE env vars in profile CLI test setup/teardown
2026-05-30 09:39:27 -03:00
Ogrodev db8e090f91 fix(coding-agent): surface invalid inherited profile env as clean CLI error
- Revalidate OMP/PI profile env in runCli when no explicit --profile is passed
- Convert module-load profile parse failures into CLI error reporting path
- Preserve successful execution flow for valid profile selection paths
- Add integration test ensuring invalid env emits clear error and non-zero exit
2026-05-30 09:08:16 -03:00
Ogrodev 71f2616943 test(coding-agent): add regression test for profile .env precedence
- Add stream-reading helper for validating spawned subprocess output in tests.
- Create temporary profiles/default agent dirs with distinct .env sentinels and run CLI in child process.
- Assert profile-specific .env is loaded (work) instead of default when --profile is provided.
2026-05-29 22:33:30 -03:00
Ogrodev 680917f02a feat: added isolated profiles with --profile and --alias
Added named OMP profiles that isolate agent state (auth credentials,
sessions, settings, model cache, history, memories, blobs, plus
config root subdirs) under `~/.omp/profiles/<name>/agent/`. Activated
via `--profile <name>` or `OMP_PROFILE=<name>`; `default` maps back to
the regular `~/.omp/agent/` tree.

Added `--alias <command>` to generate a shell shortcut (e.g.
`omp-work`) that forwards `omp --profile <name>`. Detects the active
shell (bash, zsh, fish, PowerShell, pwsh), writes a wrapper into the
correct rc file, and preserves subcommands like `update`, `--version`,
and `--model` because the wrapper passes through argv unchanged.

The `--profile`/`--alias` bootstrap pre-parser lives in
`packages/coding-agent/src/cli/profile-bootstrap.ts` and runs before
any module that touches `getAgentDir()` (notably `@oh-my-pi/pi-utils/env`,
which eagerly loads `.env` from the agent directory at its own import
time). The pre-parser mirrors `parseArgs` value-consumption rules and
honors `--`, so commands like `omp --system-prompt --profile foo` pass
the literal `--profile` through as the prompt body instead of silently
activating profile `foo`.

XDG resolution for named profiles is keyed on the profile-specific
XDG path (`$XDG_*_HOME/omp/profiles/<name>`), never the base app root,
so a profile's location is decided once at first activation and stays
stable even after `omp config init-xdg` materializes the base later.
The default profile keeps its existing base-app-root check.

`setProfile(undefined)` (and `setProfile("default")`) restores the
pre-profile `PI_CODING_AGENT_DIR` snapshot taken at first activation
instead of unconditionally deleting it. `setAgentDir` refreshes the
snapshot since that call is the user explicitly redefining the
baseline.

Validation rejects profile names that match `.`/`..`, fail
`/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/`, or hit a Windows reserved
device name (`CON`, `PRN`, `AUX`, `NUL`, `COM0-9`, `LPT0-9`, including
dotted variants like `CON.txt`) — those would let `setProfile` accept
the input only for directory creation to fail later with confusing
errors on Windows.
2026-05-27 07:50:45 -03:00