Repository navigation
fix(omp): keep path-scoped bash.patterns and run sessionStart on session_clear - #3984
Merged
Merged
Conversation
…ion_clear - Keep folder-scoped bash.patterns entries on generate, placed by their loosest rule so they never loosen a rulesync deny or prompt rule. - Carry a per-rule env list over to a regenerated rule with the same match and approval. - On import, fold scoped deny/prompt rules into global rules and skip scoped allow rules with a warning instead of widening them. - Subscribe sessionStart hooks to oh-my-pi's session_clear as well. Refs #3080 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…p-scoped-bash-patterns # Conflicts: # src/generated/docs-content.ts
- On import, a rule from a path-scoped entry no longer takes the first-match slot from a later unscoped rule for the same pattern; the stricter wins. - Warn only about scoped restrictions that changed the imported rules. - Warn when a kept scoped entry mixes allow and deny rules, or sits after a generated catch-all restriction, and document both. Refs #3080 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…p-scoped-bash-patterns # Conflicts: # src/generated/docs-content.ts
…p-scoped-bash-patterns # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR follows up on the 2026-11-19 re-check of #3080 (oh-my-pi v18.20.x to v19.0.0). Three things change:
bash.patternsentries.allowinto a global one.sessionStarthooks now also run after/clear.Upstream was checked against can1357/oh-my-pi@ce36c87:
docs/settings.md,docs/extensions.md, andpathScopePrefixes/resolvePathScopedObjectsinpackages/coding-agent/src/config/settings.ts.Changes
src/features/permissions/omp-permissions.ts)bash.patternsentries.path/paths/pathPrefix/pathPrefixesexactly as written. That covers both the inline{ path, match, approval }form and wrappers underpatterns/values/items.envlist of the existing entry with the same normalizedmatch, as long as its approval is unchanged.bash.allowedEnvVarsis a sibling key and was already kept. A test now covers it.deny/promptrules, nested ones included, are imported as globalbashrules.allowrules are skipped.toRulesyncPermissionsnow takes the logger.pi-extension-generator.ts)PiExtensionDialectgets anextraEventNamesmap. It is empty for Pi and{ sessionStart: ["session_clear"] }for oh-my-pi, so canonicalsessionStartcommands also subscribe tosession_clear.docs/reference/file-formats.mdnow cover:envlists andbash.allowedEnvVars--configlists being prepended to the global listsession_clearbeing awaited and unable to cancel the resetDesign decisions
Where kept scoped entries go (this differs from the triage plan, which put them first). oh-my-pi uses the first matching rule. If every scoped entry led the list, a folder-scoped
allowwould override a Rulesyncdeny/promptinside that folder. So each kept entry is placed by its most permissive rule:denyrules goes firstpromptgoes after Rulesync's deniesallowgoes after Rulesync's prompts, ahead of Rulesync's allowsA scoped rule therefore never loosens a Rulesync restriction, and a scoped restriction still beats a Rulesync allow. Entries are kept whole, never split, so the user's file structure is preserved.
What import does with scoped entries (refines the plan's "skip everything"). Skipping a scoped
denywould leave other targets more permissive inside that folder, for example a later globalgit *allow with nogit push*deny. Restrictions are therefore folded in as global rules, which is stricter than the scope, and only allows are skipped. Nothing scoped ever comes back as a broader allow. One side effect: an import followed by a generate adds a global copy of those restrictions next to the kept scoped entry.What counts as "scoped". This mirrors upstream
pathScopePrefixes: an entry counts as scoped only when a path key holds a string, or an array that contains strings. An entry such aspath: ~(YAML null) is unscoped upstream and applies everywhere, so Rulesync treats it as a normal owned entry.Import order (review round 1). A rule taken from a scoped entry never takes the first-match slot from a later unscoped rule for the same pattern. When both exist, the stricter one is imported (deny > ask). The import warning lists only the scoped restrictions that actually changed the imported rules.
Mixed scoped entries are kept whole, not split. Splitting would add a copy to the user's file, and that copy would multiply on every regenerate. So an entry that mixes allow and deny stays in the allow slot. Inside its scope, its deny loses to a matching Rulesync prompt rule and only prompts. This is documented and logs a warning. An entry that sits after a generated catch-all
*deny/prompt can never be reached; that also logs a warning and is documented.What
envcarry-over copies. Onlyenvis copied, and only on an exact normalizedmatchplusapprovalmatch. If the approval changes, the old allowlist is dropped.Skipped items (still open on #3080)
askrules totools.restrictedFolders(optional item 2 of 2026-10-27). A restricted folder is stricter than the canonical rule, so this needs a semantics decision first.notificationhook. Upstream still has noui_prompt_startequivalent.OMP_PROFILE/PI_CODING_AGENT_DIR/getAgentDir()). These need a cross-target design for env-dependent roots.Refs #3080
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4