Commit Graph

13 Commits

Author SHA1 Message Date
roboomp 133e42e34b fix(cli): handled standalone profile aliases
Detected Bun-compiled entry points before preserving source invocations. Added a regression for the virtual bunfs argv shape and documented the fix.

Fixes #8233
2026-08-11 09:19:01 +00:00
can1357 ca31872f29 test(cli): cover backslash runtime-path normalization in profile-alias POSIX fields 2026-06-24 18:23:49 +02:00
oldschoola 1f8e923f8b fix: preserve UNC path roots in POSIX shell config paths
Address codex P2 review: Windows UNC paths like \\server\share\me
become //server/share/me after toPosix, but path.posix.join collapses
leading // to /, producing /server/share/me/.bashrc — a local Unix path
instead of the UNC location.

Add posixJoinUnc() that restores leading // after path.posix.join when
any input segment starts with //. Add regression test for UNC homeDir.
2026-06-23 15:24:38 -07:00
oldschoola 2ce25f2dc2 fix: normalize backslashes in all POSIX path components for profile-alias
Address codex review feedback on PR #3346:
- path.posix.join only adds / separators but preserves existing backslashes
  in input segments (homeDir, ZDOTDIR, XDG_CONFIG_HOME), producing mixed
  paths like C:\Users\me/.bashrc on Windows.
- Add toPosix() helper to normalize backslashes to forward slashes before
  path.posix.join, applied to all POSIX-shell path components.
- PowerShell paths remain platform-native (path.join) as before.
- Add 3 regression tests: bash homeDir, zsh ZDOTDIR, fish XDG_CONFIG_HOME
  all with Windows backslash paths.
2026-06-23 13:55:51 -07:00
oldschoola f423cc5c95 fix(cli): profile-alias installer produces correct paths for POSIX shells on Windows
The profile-alias installer used path.join unconditionally, which produces
backslash-separated paths on Windows. For bash/zsh/fish config files, this
is wrong — POSIX shells can't resolve backslash paths, even on Windows
(Git Bash, WSL).

Fix:
- resolveShellConfigPath: use path.posix.join for non-Windows platforms,
  path.join for Windows (PowerShell profiles need native Windows paths)
- resolveProfileAliasCommandFromProcess: normalize script path to forward
  slashes for the display/posix/fish fields (POSIX shells), keep native
  path for the powerShell field

Updated 12 test assertions to compute expected paths dynamically using
path.join/path.resolve, so they match the platform's path separator.
All 17 profile-alias tests now pass on Windows (was 5 pass / 12 fail).
2026-06-23 12:24:41 -07:00
Ogrodev 7c6f77de0b fix(coding-agent): harden profile bootstrap and aliases 2026-06-04 23:55:15 -03:00
Ogrodev f6d520df87 fix(coding-agent): hardened profile bootstrap and alias installation edge cases
Bootstrap: an unknown (extension) long flag now only protects a value-like
successor (mirroring parseArgs in args.ts), so a trailing global --profile/--alias
after a value-less extension flag is still extracted (omp --some-ext-flag --profile
work); a -- successor falls through to end-of-options instead of being swallowed.

Alias installer: on Windows the PowerShell edition is inferred from PSModulePath
(separator-anchored so WindowsPowerShell does not match pwsh), falling back to
POWERSHELL_DISTRIBUTION_CHANNEL, when $SHELL is unset; the fish alias path honors
$XDG_CONFIG_HOME. Env is threaded through install options for testability.

Also de-duplicated a stale 'Mnemosyne' changelog line left by the mnemosyne->mnemopi
rename and moved the profile-bootstrap edge-case note to [Unreleased].
2026-06-02 12:24:44 -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 2e4f258050 fix(profiles): harden alias upsert, env precedence, and bootstrap flag handling
- profile-alias: refuse to rewrite a managed block whose start marker lacks a
  matching end marker instead of appending, which on the next install would
  splice from the stale start through the new end and delete intervening user
  shell config (data loss in dotfiles).
- dirs/cli: add resolveProfileEnv so OMP_PROFILE takes precedence and an
  explicitly-empty OMP_PROFILE selects the default profile instead of falling
  through to PI_PROFILE; share the rule across both env-read sites.
- dirs: reject uppercase profile names so profile identity/isolation is stable
  across case-sensitive and case-insensitive filesystems.
- profile-bootstrap: treat an unclassified bare long option as a possible
  extension string flag and forward its successor untouched (never as a global
  --profile/--alias), while exempting known value-less launch flags via
  VALUELESS_FLAGS so 'omp --print --profile work' still selects a profile.
- tests: cover all four contracts.
2026-05-30 11:05:30 -03:00
Ogrodev c41bb8c170 fix(profile-alias): align alias install handling for edge cases
- Reject /bin/sh as unsupported shell instead of mapping it to bash
- Make alias-shadow check for `omp` case-insensitive
- Preserve non-ENOENT read failures when loading shell config
- Treat missing shell config file as empty for fresh installs
- Add targeted tests for case-insensitive alias rejection, sh rejection, and read error behavior
2026-05-30 10:17:34 -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 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