Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/src/content/docs/docs/reference/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,44 @@ retains modified, shared, failed, or uncorroborated resources for inspection
and retry. There is intentionally no `allagents profile update`; use repeatable
`allagents update --profile <name>`.

#### profile rename

```bash
allagents profile rename <old> <new> [--yes] [--dry-run]
```

`rename` changes the declaration key and keeps any configured launcher names.
The command previews the changes and asks for confirmation. Pass `--yes` in
scripts and JSON mode. `--dry-run` prints the plan without changing files.
Rename can move complete file-only installations for Claude Code on Linux or
Windows, Codex, and OpenCode. It moves isolated client files, session data, and
file-based credentials. Shared OpenCode data stays in its original location.
Uninstalled declarations can be renamed regardless of client.

Close clients using the profile before applying. Rename stops on a destination
collision, native plugin data, a symbolic link in the profile tree, a modified
launcher, or generated settings that embed a profile selector or the old root.
Codex session databases contain absolute paths, and Claude Code on macOS uses
Keychain credentials. These cases require a separate migration, as do installed
Copilot, Pi, and OMP profiles and installations with partial state. External
references, including T3 provider config or home paths and custom scripts, need
to be updated separately.

If rename is interrupted after it starts moving files, rerun the same
`allagents profile rename <old> <new> --yes` command to resume. Keep the recovery
record beside `workspace.yaml` and wait until rename completes before editing
the workspace or either profile directory, or starting the affected clients.
Run workspace writers from the same host and PID namespace when they share a
workspace.

If the destination already exists, move it aside before retrying. This includes
an empty directory left by an interruption before the reservation was recorded.
If the command has published a replacement and reports a preserved edit, move
the reported capture file out of its recovery path, resume the rename, and then
reconcile the saved edit with the published file. If `workspace.yaml` is missing
and its capture contains a pending workspace edit, move the capture back to
`workspace.yaml` before retrying.

### status

Show the sync status of all configured plugins and skills.
Expand Down
85 changes: 84 additions & 1 deletion src/cli/commands/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ import {
profileInstallMeta,
profileListMeta,
profileRemoveMeta,
profileRenameMeta,
profileStatusMeta,
} from '../metadata/profile.js';
import { terminalSafe } from '../terminal-output.js';
import { applyProfileRename, planProfileRename } from '../../core/profile/rename.js';

export interface ProfileCommandDependencies {
readonly planProfileOperation: (
Expand Down Expand Up @@ -331,6 +333,66 @@ async function executeList(
return success ? 0 : 1;
}

async function executeRename(
args: { profile: string; newProfile: string; yes: boolean; dryRun: boolean },
runtime: ProfileCommandRuntime,
): Promise<number> {
const plan = await planProfileRename(args.profile, args.newProfile, runtimeOptions(args));
const command = 'profile rename';
if (!runtime.isJson()) {
const action = plan.recovering ? 'Resume renaming' : 'Rename';
runtime.print(`${action} profile '${plan.profile}' to '${plan.newProfile}'`);
const labels = {
root: 'Move profile data',
settings: 'Move client settings',
launcher: 'Retarget launcher',
state: 'Transfer installation state',
workspace: 'Update workspace declaration',
};
for (const { kind, from, to } of plan.steps) {
runtime.print(` ${labels[kind]}: ${terminalSafe(from)}`);
if (from !== to) runtime.print(` → ${terminalSafe(to)}`);
}
for (const warning of plan.warnings) runtime.print(warning);
}
if (args.dryRun) {
if (runtime.isJson()) runtime.printJson({ success: true, command, data: { ...plan } });
else runtime.print('Dry run; no changes applied.');
return 0;
}
if (!args.yes) {
if (!runtime.isInteractive() || runtime.isJson()) {
throw new ProfileCommandError(
'profile rename requires confirmation; rerun with --yes in non-interactive and JSON modes',
2,
{ ...plan, status: 'failed', plan },
);
}
const confirmed = await runtime.confirm({
message: `Rename profile '${plan.profile}' to '${plan.newProfile}' using this plan?`,
});
if (confirmed !== true) {
runtime.print('Profile rename cancelled.');
return 0;
}
}
try {
await applyProfileRename(plan);
} catch (error) {
throw new ProfileCommandError(
error instanceof Error ? error.message : String(error),
1,
{ ...plan, status: 'failed', plan },
);
}
if (runtime.isJson()) {
runtime.printJson({ success: true, command, data: { ...plan, status: 'renamed', plan } });
} else {
runtime.print(`Renamed profile '${plan.profile}' to '${plan.newProfile}'.`);
}
return 0;
}

async function executeStatus(
name: string | undefined,
dependencies: ProfileCommandDependencies,
Expand Down Expand Up @@ -458,14 +520,35 @@ export function createProfileCommand(
),
});

const renameCmd = command({
name: 'rename',
description: buildDescription(profileRenameMeta),
args: {
profile: positional({ type: string, displayName: 'old' }),
newProfile: positional({ type: string, displayName: 'new' }),
yes: flag({
long: 'yes',
short: 'y',
description: 'Apply without asking for confirmation',
}),
dryRun: flag({
long: 'dry-run',
description: 'Display the plan without making changes',
}),
},
handler: (args) =>
handleCommand('profile rename', runtime, () => executeRename(args, runtime)),
});

return conciseSubcommands({
name: 'profile',
description: 'Manage global Pi and OMP profiles',
description: 'Manage global agent profiles',
cmds: {
install: installCmd,
list: listCmd,
status: statusCmd,
remove: removeCmd,
rename: renameCmd,
},
});
}
Expand Down
36 changes: 36 additions & 0 deletions src/cli/metadata/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,39 @@ export const profileRemoveMeta: AgentCommandMeta = {
},
jsonFields: profileMutationJsonFields,
};

const profileRenamePlanOutput = {
profile: 'string',
newProfile: 'string',
operation: 'rename',
status: 'planned',
installed: 'boolean',
recovering: 'boolean',
steps: [{ kind: 'workspace | root | settings | launcher | state', from: 'string', to: 'string' }],
warnings: ['string'],
};

export const profileRenameMeta: AgentCommandMeta = {
command: 'profile rename',
description: 'Rename a declared profile and relocate a supported installation',
whenToUse: 'When you want to change a global profile name while keeping its launcher names and session data',
examples: [
'allagents profile rename work office --dry-run',
'allagents --json profile rename work office --yes',
],
expectedOutput: 'Shows the declaration, client directory, settings, state, and launcher changes before confirmation.',
positionals: [
{ name: 'old', type: 'string', required: true, description: 'Current declared profile name.' },
{ name: 'new', type: 'string', required: true, description: 'New profile name.' },
],
options: mutationOptions.slice(0, 2),
Comment thread
christso marked this conversation as resolved.
Resolved
interaction: 'conditional',
outputSchema: {
...profileRenamePlanOutput,
status: 'planned | renamed | failed',
plan: profileRenamePlanOutput,
error: 'string?',
},
jsonFields: ['profile', 'newProfile', 'operation', 'status', 'installed', 'recovering', 'plan', 'steps', 'warnings', 'error'],
skipUpdateCheck: true,
};
2 changes: 2 additions & 0 deletions src/cli/structured-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
profileInstallMeta,
profileListMeta,
profileRemoveMeta,
profileRenameMeta,
profileStatusMeta,
} from './metadata/profile.js';
import { updateMeta } from './metadata/self.js';
Expand Down Expand Up @@ -119,6 +120,7 @@ const registeredCommands: RegisteredCommand[] = [
{ command: 'profile list', meta: profileListMeta },
{ command: 'profile status', meta: profileStatusMeta },
{ command: 'profile remove', meta: profileRemoveMeta },
{ command: 'profile rename', meta: profileRenameMeta },
];

const groupDescriptions: Readonly<Record<string, string>> = {
Expand Down
27 changes: 21 additions & 6 deletions src/core/marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
resolvePluginSourcePath,
} from '../utils/marketplace-manifest-parser.js';
import { normalizeGitRef } from '../utils/git-source.js';
import { withWorkspaceConfigMutation } from '../utils/workspace-config-lock.js';
import {
isFilesystemRoot,
parseGitHubUrl,
Expand Down Expand Up @@ -1103,6 +1104,13 @@ async function removeMarketplaceRegistration(
}
}

interface MarketplaceRemovalOptions {
cascade?: boolean;
scope?: MarketplaceScope | 'all';
workspacePath?: string;
userRegistryPath?: string;
}

/**
* Remove a marketplace from the registry and delete its files.
*
Expand All @@ -1118,12 +1126,7 @@ async function removeMarketplaceRegistration(
*/
export async function removeMarketplace(
name: string,
options: {
cascade?: boolean;
scope?: MarketplaceScope | 'all';
workspacePath?: string;
userRegistryPath?: string;
} = {},
options: MarketplaceRemovalOptions = {},
deps: Partial<MarketplaceRemovalDeps> = {},
): Promise<MarketplaceResult> {
const scope = options.scope ?? 'all';
Expand All @@ -1143,6 +1146,18 @@ export async function removeMarketplace(
// scope === 'all' without workspacePath: fall back to user-only removal
}

const remove = () => removeRegisteredMarketplace(name, scope, options, deps);
if (!options.cascade) return remove();
const { getUserWorkspaceConfigPath } = await import('./user-workspace.js');
return withWorkspaceConfigMutation(getUserWorkspaceConfigPath(), remove);
}

async function removeRegisteredMarketplace(
name: string,
scope: MarketplaceScope | 'all',
options: MarketplaceRemovalOptions,
deps: Partial<MarketplaceRemovalDeps>,
): Promise<MarketplaceResult> {
const userRegPath = options.userRegistryPath ?? getRegistryPath();
let removedEntry: MarketplaceEntry | undefined;
const warnings: string[] = [];
Expand Down
Loading