Skip to content

feat(permissions): export Codex CLI bash rules as .rules files#1499

Merged
dyoshikawa merged 2 commits intomainfrom
codex/fix-issue-1492-in-rulesync
Apr 17, 2026
Merged

feat(permissions): export Codex CLI bash rules as .rules files#1499
dyoshikawa merged 2 commits intomainfrom
codex/fix-issue-1492-in-rulesync

Conversation

@dyoshikawa
Copy link
Copy Markdown
Owner

Motivation

  • Add support for exporting permission.bash entries to Codex CLI prefix_rule(...) rules because Codex accepts command approval rules via .codex/rules/*.rules and Rulesync previously only wrote .codex/config.toml profiles.

Description

  • Generate a .codex/rules/rulesync.rules file from .rulesync/permissions.json permission.bash entries with prefix_rule(...) blocks and map actions: allowallow, askprompt, denyforbidden.
  • Added CodexcliRulesFile and createCodexcliBashRulesFile() in src/features/permissions/codexcli-permissions.ts to build serialized .rules content from PermissionsConfig.
  • Updated PermissionsProcessor (src/features/permissions/permissions-processor.ts) to return both the existing .codex/config.toml (CodexcliPermissions) and the new .codex/rules/rulesync.rules for the codexcli target.
  • Added unit tests covering .rules generation and processor output and updated documentation (docs/reference/file-formats.md and skills/rulesync/file-formats.md) to describe the new bash.codex/rules mapping and behavior.

Testing

  • Ran targeted unit tests: pnpm vitest run src/features/permissions/codexcli-permissions.test.ts src/features/permissions/permissions-processor.test.ts, and both test files passed.
  • Ran full CI checks: pnpm cicheck, and the full test suite and content checks completed successfully (all tests passed and content checks passed).

Closes #1492


Codex Task

Copilot AI review requested due to automatic review settings April 16, 2026 06:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Codex CLI support for exporting permission.bash rules into Codex’s .codex/rules/*.rules format, complementing the existing .codex/config.toml permissions profile export.

Changes:

  • Generate .codex/rules/rulesync.rules from .rulesync/permissions.json permission.bash entries via prefix_rule(...) blocks.
  • Update PermissionsProcessor to emit both Codex CLI outputs (config.toml + rulesync.rules) for the codexcli target.
  • Add/extend unit tests and update file format documentation to describe the new mapping.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/features/permissions/permissions-processor.ts Returns an additional Codex CLI .rules ToolFile during permissions generation.
src/features/permissions/permissions-processor.test.ts Adds test asserting both Codex outputs are generated.
src/features/permissions/codexcli-permissions.ts Introduces CodexcliRulesFile + .rules content builder for bash permissions.
src/features/permissions/codexcli-permissions.test.ts Adds unit test for .rules content generation.
skills/rulesync/file-formats.md Documents Codex CLI bash.codex/rules/rulesync.rules mapping.
docs/reference/file-formats.md Same documentation update for the main docs site.

Comment on lines +196 to +204
if (this.toolTarget !== "codexcli") {
return [toolPermissions];
}

return [toolPermissions];
const bashRulesFile = createCodexcliBashRulesFile({
baseDir: this.baseDir,
config: rulesyncPermissions.getJson(),
});
return [toolPermissions, bashRulesFile];
});

const content = rulesFile.getFileContent();
expect(rulesFile.getRelativeDirPath()).toBe(".codex/rules");

const ruleFile = toolFiles.find((file) => file.getRelativeFilePath() === "rulesync.rules");
expect(ruleFile).toBeDefined();
expect(ruleFile?.getRelativeDirPath()).toBe(".codex/rules");
@dyoshikawa dyoshikawa merged commit 277916f into main Apr 17, 2026
9 checks passed
@dyoshikawa dyoshikawa deleted the codex/fix-issue-1492-in-rulesync branch April 17, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Codex CLI bash permission

2 participants