Skip to content

Commit 99511c9

Browse files
jdillonclaude
andcommitted
refactor: complete forge→commando rename in lib/
- Rename Forge class to Commando in core.ts - Update cli.ts to use Commando, fix error messages for cmdo - Update all comments, variable names, log messages - Fix forgeCmd → commandoCmd parameter names - Update config-resolver.ts variable names - Update module-resolver.ts and auto-install.ts references - All 76 tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 43a7288 commit 99511c9

File tree

10 files changed

+59
-59
lines changed

10 files changed

+59
-59
lines changed

lib/auto-install.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const RESTART_EXIT_CODE = 42;
2626
/**
2727
* Sync dependencies and handle restart if needed
2828
*
29-
* @param config - Forge configuration
29+
* @param config - Commando configuration
3030
* @param commandoDir - Project .commando/ directory path
31-
* @param isRestarted - True if this is a restarted process (from --forge-restarted flag)
31+
* @param isRestarted - True if this is a restarted process (from --commando-restarted flag)
3232
* @returns True if process should exit for restart
3333
* @throws Error if dependencies missing on restarted process
3434
*/
@@ -130,7 +130,7 @@ export async function autoInstallDependencies(
130130
log.debug({ originalMessage: err.message }, 'Wrapping auto-install error');
131131
throw new Error(
132132
`Failed to install dependencies: ${err.message}\n\n` +
133-
`Try running: forge module install`,
133+
`Try running: cmdo module install`,
134134
);
135135
}
136136

lib/builtins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const version: CommandoCommand = {
3535
execute: async () => {
3636
const info = await getVersion();
3737

38-
console.log('Forge Version Information:');
38+
console.log('Commando Version Information:');
3939
console.log();
4040
console.log(` Version: ${info.version}`);
4141
console.log(` Full: ${info.semver}`);

lib/cli.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function main(): Promise<void> {
4444
if (cliArgs.includes('--version') || cliArgs.includes('-V')) {
4545
const { getVersionString } = await import('./version');
4646
const version = await getVersionString();
47-
console.log(`commando version ${version}`);
47+
console.log(`cmdo version ${version}`);
4848
process.exit(0);
4949
}
5050

@@ -191,11 +191,11 @@ async function buildCLI(config: CommandoConfig): Promise<Command> {
191191
exit(1);
192192
});
193193

194-
// Initialize Forge and register commands
195-
const { Forge } = await import("./core");
196-
const forge = new Forge(config);
197-
await forge.initialize(); // Throws ExitNotification if restart needed
198-
await forge.registerCommands(program);
194+
// Initialize Commando and register commands
195+
const { Commando } = await import("./core");
196+
const commando = new Commando(config);
197+
await commando.initialize(); // Throws ExitNotification if restart needed
198+
await commando.registerCommands(program);
199199

200200
return program;
201201
}
@@ -239,7 +239,7 @@ function handleError(err: any): never {
239239
if (unknownCmd) {
240240
showCommanderError(`unknown command '${unknownCmd}'`);
241241
} else {
242-
showCommanderError("unknown command. Run 'forge --help' to see available commands");
242+
showCommanderError("unknown command. Run 'cmdo --help' to see available commands");
243243
}
244244
}
245245

@@ -274,7 +274,7 @@ function handleError(err: any): never {
274274
function showCommanderError(message: string): never {
275275
const cleanMessage = message.replace(/^error:\s*/i, "");
276276
console.error(`ERROR: ${cleanMessage}`);
277-
console.error(`Try 'forge --help' for more information.`);
277+
console.error(`Try 'cmdo --help' for more information.`);
278278
runtimeExit(1);
279279
}
280280

lib/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type {
2626
} from './types';
2727

2828
// ============================================================================
29-
// Core API - Forge utilities
29+
// Core API - Commando utilities
3030
// ============================================================================
3131

3232
export { createLogger } from './logging/logger';

lib/commando-home.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export function getCommandoHomePath(): string {
3131
}
3232

3333
/**
34-
* Get the node_modules directory for Forge
35-
* This is where Forge looks for installed modules
34+
* Get the node_modules directory for Commando
35+
* This is where Commando looks for installed modules
3636
*
3737
* Derived from COMMANDO_HOME/node_modules
3838
*/
@@ -53,7 +53,7 @@ export async function ensureCommandoHome(): Promise<void> {
5353
log.debug({ commandoHome }, 'Creating commando home directory');
5454
mkdirSync(commandoHome, { recursive: true });
5555
} else {
56-
log.debug({ commandoHome }, 'Forge home already exists');
56+
log.debug({ commandoHome }, 'Commando home already exists');
5757
}
5858

5959
const pkgPath = join(commandoHome, 'package.json');
@@ -187,7 +187,7 @@ export async function syncDependencies(
187187
log.debug({ mode, missing }, 'Manual mode, not auto-installing');
188188
throw new Error(
189189
`Missing dependencies: ${missing.join(', ')}\n` +
190-
`Run: forge module install`,
190+
`Run: cmdo module install`,
191191
);
192192
}
193193

lib/config-resolver.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ async function findProjectRoot(options: {
163163
* 1. Discover project root (.commando directory)
164164
* 2. Load .commando/config.yml if project exists
165165
* 3. DEFERRED: Merge with user config (~/.commando/config) and defaults
166-
* 4. DEFERRED: Apply ENV var overrides beyond existing FORGE_* vars
166+
* 4. DEFERRED: Apply ENV var overrides beyond existing COMMANDO_* vars
167167
* 5. Return CommandoConfig
168168
*
169169
* @param bootstrapConfig - Bootstrap options from CLI args
170-
* @returns CommandoConfig with all data needed for Forge initialization
170+
* @returns CommandoConfig with all data needed for Commando initialization
171171
* @throws Error on critical failures (e.g., YAML parse error)
172172
*/
173173
export async function resolveConfig(
@@ -186,7 +186,7 @@ export async function resolveConfig(
186186
log.debug(`Project root: ${projectRoot || "(none)"}`);
187187

188188
// 2. Load project config if present
189-
let forgeConfig: Partial<CommandoConfig> = {};
189+
let commandoConfig: Partial<CommandoConfig> = {};
190190

191191
if (projectRoot) {
192192
try {
@@ -219,8 +219,8 @@ export async function resolveConfig(
219219
log.debug(`Config search completed in ${configLoadDuration}ms`);
220220

221221
if (result?.config) {
222-
forgeConfig = result.config;
223-
const configKeys = Object.keys(forgeConfig);
222+
commandoConfig = result.config;
223+
const configKeys = Object.keys(commandoConfig);
224224
log.debug(`Loaded config from ${result.filepath} (${configKeys.length} keys: ${configKeys.join(', ')})`);
225225
} else {
226226
log.debug(`No config file found in ${commandoDir} (using defaults)`);
@@ -241,15 +241,15 @@ export async function resolveConfig(
241241
// - User config (~/.commando/config)
242242
// - Project config (.commando/config)
243243
// - Local overrides (.commando/config.local)
244-
// - ENV vars (FORGE_*)
244+
// - ENV vars (COMMANDO_*)
245245
// For now: Just use .commando/config directly
246246

247247
// 4. DEFERRED: Extended ENV var support
248248
// TODO: Support ENV var overrides for config values
249-
// - FORGE_INSTALL_MODE=manual
250-
// - FORGE_OFFLINE=true
249+
// - COMMANDO_INSTALL_MODE=manual
250+
// - COMMANDO_OFFLINE=true
251251
// - etc.
252-
// Current: Only COMMANDO_PROJECT, FORGE_HOME supported
252+
// Current: Only COMMANDO_PROJECT, COMMANDO_HOME supported
253253

254254
// 5. Build CommandoConfig
255255
const config: CommandoConfig = {
@@ -268,12 +268,12 @@ export async function resolveConfig(
268268
colorMode: bootstrapConfig.colorMode,
269269
isRestarted: bootstrapConfig.isRestarted,
270270

271-
// Forge config (from .commando/config.yml)
272-
modules: forgeConfig.modules,
273-
dependencies: forgeConfig.dependencies,
274-
settings: forgeConfig.settings,
275-
installMode: forgeConfig.installMode,
276-
offline: forgeConfig.offline,
271+
// Commando config (from .commando/config.yml)
272+
modules: commandoConfig.modules,
273+
dependencies: commandoConfig.dependencies,
274+
settings: commandoConfig.settings,
275+
installMode: commandoConfig.installMode,
276+
offline: commandoConfig.offline,
277277
};
278278

279279
log.debug(`Config resolved: ${JSON.stringify(config, null, 2)}`);

lib/core.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ export function discoverCommands(
137137
*
138138
* Handles:
139139
* - Module resolution (local .commando/ or npm package)
140-
* - Symlink rewriting for correct forge instance
140+
* - Symlink rewriting for correct commando instance
141141
* - Command discovery via discoverCommands()
142142
*
143143
* @param modulePath - Module path (relative, absolute, or package name)
144-
* @param commandoDir - Forge directory for resolution
144+
* @param commandoDir - Commando directory for resolution
145145
* @returns Object with groupName, description, and discovered commands
146146
*/
147147
export async function loadModule(
@@ -160,7 +160,7 @@ export async function loadModule(
160160
log.debug({ durationMs: resolveDuration, fullPath }, 'Module path resolved');
161161

162162
// Rewrite path to go through symlink in node_modules
163-
// This ensures user commands import forge from the correct instance
163+
// This ensures user commands import commando from the correct instance
164164
// Requires bun --preserve-symlinks
165165
const symlinkStart = Date.now();
166166
const symlinkPath = await rewriteModulePath(fullPath, commandoDir);
@@ -190,9 +190,9 @@ export async function loadModule(
190190
// ============================================================================
191191

192192
/**
193-
* Main forge runner
193+
* Main commando runner
194194
*/
195-
export class Forge {
195+
export class Commando {
196196
public config: CommandoConfig; // Public so commands can access
197197
private log: Logger;
198198

@@ -209,7 +209,7 @@ export class Forge {
209209
public globalOptions: Record<string, any>;
210210

211211
constructor(config: CommandoConfig) {
212-
this.log = createLogger('forge');
212+
this.log = createLogger('commando');
213213
this.log.debug({ config });
214214

215215
this.config = config;
@@ -264,7 +264,7 @@ export class Forge {
264264
}
265265

266266
/**
267-
* Initialize Forge instance
267+
* Initialize Commando instance
268268
*
269269
* Handles:
270270
* - Loading builtin commands (always)
@@ -275,7 +275,7 @@ export class Forge {
275275
* @throws ExitNotification if restart needed after dependency installation
276276
*/
277277
async initialize(): Promise<void> {
278-
log.debug('Starting Forge initialization');
278+
log.debug('Starting Commando initialization');
279279

280280
// 1. Always load builtins (available everywhere)
281281
log.debug('Phase 1: Loading builtins');
@@ -372,12 +372,12 @@ export class Forge {
372372
const groupDetails = Object.fromEntries(
373373
Object.entries(this.commandGroups).map(([group, data]) => [group, Object.keys(data.commands)])
374374
);
375-
log.debug({ topLevel, groups, groupDetails }, 'Forge initialization complete');
375+
log.debug({ topLevel, groups, groupDetails }, 'Commando initialization complete');
376376
}
377377

378378
/**
379379
* Register all discovered commands with Commander program
380-
* This is the bridge between Forge and Commander
380+
* This is the bridge between Commando and Commander
381381
*/
382382
async registerCommands(program: Command): Promise<void> {
383383
log.debug(
@@ -386,8 +386,8 @@ export class Forge {
386386
);
387387

388388
// Register top-level commands first
389-
for (const [cmdName, forgeCmd] of Object.entries(this.topLevelCommands)) {
390-
const cmd = this.buildCommanderCommand(cmdName, forgeCmd);
389+
for (const [cmdName, commandoCmd] of Object.entries(this.topLevelCommands)) {
390+
const cmd = this.buildCommanderCommand(cmdName, commandoCmd);
391391
cmd.copyInheritedSettings(program); // Copy inherited settings from program
392392
program.addCommand(cmd);
393393
log.debug({ cmdName }, 'Registered top-level command');
@@ -405,8 +405,8 @@ export class Forge {
405405
}
406406

407407
// Add each command to the group
408-
for (const [cmdName, forgeCmd] of Object.entries(group.commands)) {
409-
const cmd = this.buildCommanderCommand(cmdName, forgeCmd, groupName);
408+
for (const [cmdName, commandoCmd] of Object.entries(group.commands)) {
409+
const cmd = this.buildCommanderCommand(cmdName, commandoCmd, groupName);
410410
cmd.copyInheritedSettings(groupCmd); // Copy from group command
411411
groupCmd.addCommand(cmd);
412412
}
@@ -420,25 +420,25 @@ export class Forge {
420420

421421
/**
422422
* Build a Commander Command from a CommandoCommand definition
423-
* Internal method - bridges Forge commands to Commander
423+
* Internal method - bridges Commando commands to Commander
424424
*/
425425
private buildCommanderCommand(
426426
name: string,
427-
forgeCmd: CommandoCommand,
427+
commandoCmd: CommandoCommand,
428428
groupName?: string
429429
): Command {
430430
// 1. Create Commander Command
431431
const cmd = new Command(name);
432-
cmd.description(forgeCmd.description);
432+
cmd.description(commandoCmd.description);
433433

434434
// 2. Let command customize Commander Command (if defined)
435-
if (forgeCmd.defineCommand) {
436-
forgeCmd.defineCommand(cmd);
435+
if (commandoCmd.defineCommand) {
436+
commandoCmd.defineCommand(cmd);
437437
} else {
438438
// No defineCommand - use simple model: usage string + allowUnknown
439-
if (forgeCmd.usage) {
439+
if (commandoCmd.usage) {
440440
// Add usage as argument definition (e.g., '<text...>' or '[options]')
441-
cmd.argument(forgeCmd.usage, '');
441+
cmd.argument(commandoCmd.usage, '');
442442
} else {
443443
// No usage specified - allow any arguments
444444
cmd.allowUnknownOption(true);
@@ -476,7 +476,7 @@ export class Forge {
476476
};
477477

478478
try {
479-
await forgeCmd.execute(options, positionalArgs, context);
479+
await commandoCmd.execute(options, positionalArgs, context);
480480
} catch (err) {
481481
die(`Command failed: ${name}\n${err}`);
482482
}

lib/logging/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
/**
17-
* Logging API for Forge
17+
* Logging API for Commando
1818
*
1919
* Public exports for the logging system
2020
*/

lib/logging/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export async function shutdownLogging(): Promise<void> {
142142
export function createLogger(name?: string): pino.Logger {
143143
ensureInitialized();
144144

145-
return rootLogger!.child({ name: name || 'forge' });
145+
return rootLogger!.child({ name: name || 'commando' });
146146
}
147147

148148
/**

lib/module-resolver.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ export async function resolveModule(
6262
}
6363

6464
// 2. Package modules (from node_modules)
65-
// Examples: "@jdillon/forge-standard/hello", "cowsay"
65+
// Examples: "@jdillon/commando-standard/hello", "cowsay"
6666
log.debug({ strategy: 'package', modulePath }, 'Using package module strategy');
6767
const nodeModules = getNodeModulesPath();
6868

69-
// For scoped packages with subpaths like "@jdillon/forge-standard/hello"
69+
// For scoped packages with subpaths like "@jdillon/commando-standard/hello"
7070
// we need to resolve the full path including the submodule
7171
const packagePath = join(nodeModules, modulePath);
7272
const attemptedPaths: string[] = [];
@@ -99,6 +99,6 @@ export async function resolveModule(
9999
`Attempted paths:\n ${attemptedPaths.join('\n ')}\n\n` +
100100
`Suggestions:\n` +
101101
` 1. Add to config.yml dependencies section\n` +
102-
` 2. Run: forge module install`,
102+
` 2. Run: cmdo module install`,
103103
);
104104
}

0 commit comments

Comments
 (0)