Unify and streamline profile system architecture (#853)

* move claude rules and commands to assets/claude

* update claude profile to copy assets/claude to .claude

* fix formatting

* feat(profiles): Implement unified profile system

- Convert Claude and Codex profiles to use createProfile() factory
- Remove simple vs complex profile distinction in rule transformer
- Unify convertAllRulesToProfileRules() to handle all profiles consistently
- Fix mcpConfigPath construction in base-profile.js for null mcpConfigName
- Update terminology from 'simpleProfiles' to 'assetOnlyProfiles' throughout
- Ensure Claude .claude directory copying works in both CLI and MCP contexts
- All profiles now follow same execution flow with proper lifecycle functions

Changes:
- src/profiles/claude.js: Convert to createProfile() factory pattern
- src/profiles/codex.js: Convert to createProfile() factory pattern
- src/utils/rule-transformer.js: Unified profile handling logic
- src/utils/profiles.js: Remove simple profile categorization
- src/profiles/base-profile.js: Fix mcpConfigPath construction
- scripts/modules/commands.js: Update variable naming
- tests/: Update all tests for unified system and terminology

Fixes Claude profile asset copying issue in MCP context.
All tests passing (617 passed, 11 skipped).

* re-checkin claude files

* fix formatting

* chore: clean up test Claude rules files

* chore: add changeset for unified profile system

* add claude files back

* add changeset

* restore proper gitignore

* remove claude agents file from root

* remove incorrect doc

* simplify profiles and update tests

* update changeset

* update changeset

* remove profile specific code

* streamline profiles with defaults and update tests

* update changeset

* add newline at end of gitignore

* restore changes

* streamline profiles with defaults; update tests and add vscode test

* update rule profile tests

* update wording for clearer profile management

* refactor and clarify terminology

* use original projectRoot var name

* revert param desc

* use updated claude assets from neno

* add "YOUR_" before api key here

* streamline codex profile

* add gemini profile

* update gemini profile

* update tests

* relocate function

* update rules interactive setup Gemini desc

* remove duplicative code

* add comma
This commit is contained in:
Joe Danziger
2025-07-09 07:22:11 -04:00
committed by GitHub
parent 5f009a5e1f
commit 95c299df64
82 changed files with 4827 additions and 720 deletions

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import { codexProfile } from '../../../src/profiles/codex.js';
describe('Codex Profile Initialization Functionality', () => {
let codexProfileContent;
@@ -9,46 +10,41 @@ describe('Codex Profile Initialization Functionality', () => {
codexProfileContent = fs.readFileSync(codexJsPath, 'utf8');
});
test('codex.js is a simple profile with correct configuration', () => {
expect(codexProfileContent).toContain("profileName: 'codex'");
test('codex.js has correct asset-only profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(codexProfileContent).toContain("name: 'codex'");
expect(codexProfileContent).toContain("displayName: 'Codex'");
expect(codexProfileContent).toContain("profileDir: '.'");
expect(codexProfileContent).toContain("rulesDir: '.'");
expect(codexProfileContent).toContain("profileDir: '.'"); // non-default
expect(codexProfileContent).toContain("rulesDir: '.'"); // non-default
expect(codexProfileContent).toContain('mcpConfig: false'); // non-default
expect(codexProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(codexProfileContent).toContain("'AGENTS.md': 'AGENTS.md'");
// Check the final computed properties on the profile object
expect(codexProfile.profileName).toBe('codex');
expect(codexProfile.displayName).toBe('Codex');
expect(codexProfile.profileDir).toBe('.');
expect(codexProfile.rulesDir).toBe('.');
expect(codexProfile.mcpConfig).toBe(false);
expect(codexProfile.mcpConfigName).toBe(null); // computed
expect(codexProfile.includeDefaultRules).toBe(false);
expect(codexProfile.fileMap['AGENTS.md']).toBe('AGENTS.md');
});
test('codex.js has no MCP configuration', () => {
expect(codexProfileContent).toContain('mcpConfig: false');
expect(codexProfileContent).toContain('mcpConfigName: null');
expect(codexProfileContent).toContain('mcpConfigPath: null');
test('codex.js has no lifecycle functions', () => {
// Codex has been simplified - no lifecycle functions
expect(codexProfileContent).not.toContain('function onAddRulesProfile');
expect(codexProfileContent).not.toContain('function onRemoveRulesProfile');
expect(codexProfileContent).not.toContain(
'function onPostConvertRulesProfile'
);
expect(codexProfileContent).not.toContain('log(');
});
test('codex.js has empty file map (simple profile)', () => {
expect(codexProfileContent).toContain('fileMap: {}');
expect(codexProfileContent).toContain('conversionConfig: {}');
expect(codexProfileContent).toContain('globalReplacements: []');
});
test('codex.js has lifecycle functions for file management', () => {
expect(codexProfileContent).toContain('function onAddRulesProfile');
expect(codexProfileContent).toContain('function onRemoveRulesProfile');
expect(codexProfileContent).toContain('function onPostConvertRulesProfile');
});
test('codex.js copies AGENTS.md to AGENTS.md (same filename)', () => {
expect(codexProfileContent).toContain("'AGENTS.md'");
expect(codexProfileContent).toContain('copyFileSync');
// Should copy to the same filename (AGENTS.md)
expect(codexProfileContent).toMatch(/destFile.*AGENTS\.md/);
});
test('codex.js has proper error handling', () => {
expect(codexProfileContent).toContain('try {');
expect(codexProfileContent).toContain('} catch (err) {');
expect(codexProfileContent).toContain("log('error'");
});
test('codex.js removes AGENTS.md on profile removal', () => {
expect(codexProfileContent).toContain('rmSync');
expect(codexProfileContent).toContain('force: true');
test('codex.js has minimal implementation', () => {
// Should just use createProfile factory
expect(codexProfileContent).toContain('createProfile({');
expect(codexProfileContent).toContain("name: 'codex'");
expect(codexProfileContent).toContain("'AGENTS.md': 'AGENTS.md'");
});
});