Commit Graph

13 Commits

Author SHA1 Message Date
can1357 3f82589ec1 fix: fixed OAuth and profile-boundary regressions across CLI and env handling
- Fixed OAuth credentials to keep unknown fields in schema while preserving existing shape checks.
- Fixed MCP OAuth IDs to be profile-scoped and avoid deleting credentials from non-active profiles.
- Fixed string-flag parsing so PROFILE_BOOTSTRAP_BOUNDARY tokens are not consumed as values.
- Fixed active-profile directory resolution to refresh after env updates so profile .env overrides apply.
2026-06-15 03:20:45 +02:00
Ogrodev f9bc96e96c fix(coding-agent): harden profile auth shipping gaps 2026-06-14 20:30:50 -03:00
Ogrodev 7c6f77de0b fix(coding-agent): harden profile bootstrap and aliases 2026-06-04 23:55:15 -03:00
Ogrodev b99039ded2 fix(coding-agent): profile-scope native config discovery and load symlinked extension dirs
Native user-level config discovery (MCP, skills, rules, slash commands, prompts, instructions, hooks, tools, settings, extensions, and the top-level SYSTEM.md/RULES.md/AGENTS.md) now resolves the user scope through getAgentDir() in builtin.ts, omp-extension-roots.ts, and the discovery-layer getUserPath() helper. A named profile sees only its own ~/.omp/profiles/<name>/agent config instead of the default profile's ~/.omp/agent leaking into every profile, matching the /mcp config writer and getMCPConfigPath("user").

discoverExtensionModulePaths now detects top-level symlinked directories that the native glob skips (follow_links=false) and synthesizes their index/package.json entry-point matches, so an extension shared across profiles via a symlink loads like a real directory. Symlinked extension files were already handled.

cli: check --tiny-worker on the profile-flag-stripped resolvedArgv, matching the adjacent --smoke-test check and launch routing.
2026-06-04 15:07:55 -03:00
Ogrodev c5011661db fix(coding-agent): bootstrap profiles for acp 2026-06-02 22:30:23 -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 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 458482613b fix(profile-bootstrap): extract profile flags beyond subcommand-shaped tokens
- Allow parsing global profile flags after an early launch token is chosen
- Only the first residual token can terminate subcommand dispatch scanning
- Keep `--profile` parsing active when later argv contains subcommand-like words
- Add coverage for launch argv that include command names before/after profile args
2026-05-30 10:17:35 -03:00
Ogrodev 3a50761153 fix(coding-agent): handle -- boundary and subcommands in CLI parsing
- Add POSIX `--` end-of-options handling in argument parser
- Stop consuming flags after `--` and pass remaining tokens as messages
- Stop global `--profile`/alias extraction at first registered subcommand
- Add focused tests for parseArgs and profile bootstrap boundary behavior
2026-05-30 09:08:15 -03:00
Ogrodev efac908118 fix(coding-agent): restore empty-string resume handling
Refactored the optional-value flag handling so per-flag quirks live in
shared metadata instead of the args.ts dispatch loop. Added
OPTIONAL_FLAGS in cli/flag-tables.ts with rejectEmpty and
rejectAtPrefix controls, then updated both parseArgs and the profile
bootstrap to consult the same source of truth.

This restores the pre-refactor behavior for `--resume`, `-r`, and
`--session`: an empty-string argv token is treated as “no value
provided”, leaving resume=true and the empty string to fall through as a
positional message on the next iteration. `--list-models` intentionally
keeps its existing empty-string behavior.

Added regressions for parseArgs(["--resume", ""]), parseArgs(["-r",
""]), parseArgs(["--session", ""]), the preserved
`--list-models` empty-string behavior, and the bootstrap path where an
empty-string resume value precedes `--profile`.
2026-05-27 10:09:15 -03:00
Ogrodev 09cb4fe6d7 fix(coding-agent): added --approval-mode to bootstrap STRING_VALUE_FLAGS
`--approval-mode` is a string-valued flag in args.ts (`args[++i]` with
no `-` prefix check), but profile-bootstrap.ts did not list it in
STRING_VALUE_FLAGS. As a result `omp --approval-mode --profile foo`
was rewritten to `argv: ["--approval-mode"]` and silently activated
profile `foo` instead of passing `--profile` through as the invalid
approval-mode value — the exact corruption the pre-parser exists to
prevent for string-valued flags.

Caught in code review of PR #1435 after upstream merge brought in
`--approval-mode`. `--auto-approve`/`--yolo` are boolean and require
no entry. Added a regression test that mirrors the existing
`--system-prompt` coverage so future upstream merges that add
string-valued flags can be caught the same way.
2026-05-27 08:14:43 -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