Welcome to the final chapter of the Plugins project!
In the previous chapter, Skill-to-Command Adaptation, we created a universal adapter that translates our fancy Plugin Skills into standard Commands the CLI can understand.
We now have all the pieces:
But there is one final problem: Who pushes the start button?
Imagine you bought a beautiful bookshelf from a furniture store.
However, if you just leave the box in your living room, you don't have a bookshelf. You have a box. You need an Assembly Stepβa specific moment where you take the parts out of the box and put them together.
This concept is called Initialization Scaffolding.
We want the git-helper plugin to be available the moment the user opens the CLI. We need a specific function where we write the line of code that says: "System, please load the Git Helper now."
This step is intentionally simple. It acts as a bridge between your static code files and the running application.
We define a single function, usually named initBuiltinPlugins.
Let's say you have defined a new plugin in a file called gitPlugin.ts. Now you need to "wire it up."
First, we need the tool to register plugins, and the plugin definition itself.
// src/bundled/index.ts
import { registerBuiltinPlugin } from '../builtinPlugins.js'
import { gitPluginDefinition } from '../skills/gitPlugin.js'
Inside our scaffolding function, we simply call the register function.
export function initBuiltinPlugins(): void {
// The application calls this once at startup.
// 1. Load the Git plugin
registerBuiltinPlugin(gitPluginDefinition)
// 2. Load the Calculator plugin
registerBuiltinPlugin(calculatorDefinition)
}
Explanation: This is the "Switchboard." If you want to add a new built-in feature, you add one line here. If you want to remove it, you delete the line. The rest of the application doesn't need to change.
What happens when the user types my-cli start? Let's visualize the sequence.
initBuiltinPlugins().Map (from Chapter 1).
Let's look at the actual file src/bundled/index.ts. Currently, it acts as a placeholder waiting for you to add features.
This file is the designated "Home" for built-in plugins.
// src/bundled/index.ts
/**
* Built-in Plugin Initialization
* Initializes plugins that ship with the CLI.
*/
// This is the function exported to the main app
export function initBuiltinPlugins(): void {
// Currently empty!
// This is where we will migrate hardcoded skills later.
}
Explanation: Right now, it does nothing. This is intentional. It is Scaffoldingβa structure put in place before the building is built. As developers migrate old, hardcoded features into this new system, they will add lines here.
You might notice the folder is named bundled, but the function talks about BuiltinPlugins.
Not every piece of code shipped with the app needs to be a "Plugin." Some things are just core system utilities. We only use this initBuiltinPlugins function for features we want the user to see, manage, and toggle on/off in their settings.
In this final chapter, we learned:
Congratulations! You have walked through the entire architecture of a modular Plugin System.
Let's review what we built:
Map) for our features.@builtin) that keeps them safe from conflicts.You now have a system that is modular, user-configurable, and ready to scale. Happy coding!
Generated by Code IQ