Skip to content

Commit a6ae682

Browse files
committed
nitpicks
1 parent 15f28dd commit a6ae682

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

packages/cli/src/commands/plugins/actions/install.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,26 @@ async function updateCharacterFiles(pluginName: string, opts: AddPluginOptions):
129129

130130
const characterPaths = resolveCharacterPaths(opts.character);
131131

132+
let hasFailures = false;
133+
132134
for (const characterPath of characterPaths) {
133135
try {
134136
const characterFile = await loadCharacterFile(characterPath);
135137
await updateCharacterFile(characterFile, pluginName, 'add');
136138
logger.info(`✅ Added plugin '${pluginName}' to character '${characterFile.character.name}'`);
137139
} catch (error) {
138140
logger.error(`Failed to update character file ${characterPath}:`, error);
139-
process.exit(1);
141+
logger.warn('Plugin was installed but character file update failed.');
142+
logger.info('You can manually add the plugin to your character file.');
143+
hasFailures = true;
144+
// Continue with other character files instead of exiting
140145
}
141146
}
147+
148+
if (hasFailures) {
149+
logger.warn('Some character files could not be updated. Plugin installation was successful.');
150+
logger.info(`To manually add the plugin, add "${pluginName}" to the "plugins" array in your character file(s).`);
151+
}
142152
}
143153

144154
/**

packages/cli/src/commands/plugins/actions/installed-plugins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export async function showInstalledPlugins(characterPaths?: string[]): Promise<v
3333
const characterFilePaths = await findCharactersFromPaths(parsedPaths);
3434

3535
if (characterFilePaths.size === 0) {
36-
console.log('No valid character files found.');
36+
console.log('No valid character files found for the specified paths.');
37+
console.log('Please check your character paths and try again.');
3738
return;
3839
}
3940

@@ -86,7 +87,6 @@ export async function showInstalledPlugins(characterPaths?: string[]): Promise<v
8687
characterPluginMap.set(characterName, plugins);
8788
} catch (error) {
8889
// Skip files that can't be loaded
89-
continue;
9090
}
9191
}
9292

packages/cli/src/utils/character-finder.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,8 @@ export async function findCharactersFromPaths(
311311
* @throws Error if file cannot be read or parsed
312312
*/
313313
export async function loadCharacterQuietly(filePath: string): Promise<any> {
314-
try {
315-
const content = fs.readFileSync(filePath, 'utf-8');
316-
return JSON.parse(content);
317-
} catch (error) {
318-
throw error;
319-
}
314+
const content = fs.readFileSync(filePath, 'utf-8');
315+
return JSON.parse(content);
320316
}
321317

322318
/**
@@ -359,26 +355,26 @@ export function getTsCharacterName(filePath: string): string | null {
359355
// First, try to find a character object
360356
// Look for character: { ... name: "..." ... }
361357
const characterMatch = content.match(/character\s*:\s*{[^}]*name\s*:\s*["'`]([^"'`]+)["'`]/);
362-
if (characterMatch && characterMatch[1]) {
358+
if (characterMatch?.[1]) {
363359
return characterMatch[1];
364360
}
365361

366362
// Look for agents array with character
367363
const agentsMatch = content.match(/agents\s*:\s*\[[^\]]*character\s*:\s*{[^}]*name\s*:\s*["'`]([^"'`]+)["'`]/);
368-
if (agentsMatch && agentsMatch[1]) {
364+
if (agentsMatch?.[1]) {
369365
return agentsMatch[1];
370366
}
371367

372368
// Look for const characterName: Character = { name: "..." }
373369
const typedCharMatch = content.match(/const\s+\w+\s*:\s*Character\s*=\s*{[^}]*name\s*:\s*["'`]([^"'`]+)["'`]/);
374-
if (typedCharMatch && typedCharMatch[1]) {
370+
if (typedCharMatch?.[1]) {
375371
return typedCharMatch[1];
376372
}
377373

378374
// Fallback to simple patterns
379375
for (const pattern of patterns) {
380376
const match = content.match(pattern);
381-
if (match && match[1]) {
377+
if (match?.[1]) {
382378
return match[1];
383379
}
384380
}

0 commit comments

Comments
 (0)