Skip to content
Merged
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
43 changes: 42 additions & 1 deletion src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function provisionMcporterConfig(opts: ProvisionOpts = {}): void {
}

/**
* Provision all bundle dependencies (skills + CLI tools + config).
* Provision all bundle dependencies (skills + CLI tools + config + extensions).
* Non-fatal — logs warnings on failure but never throws.
*/
export function provisionBundle(opts: ProvisionOpts = {}): void {
Expand All @@ -192,4 +192,45 @@ export function provisionBundle(opts: ProvisionOpts = {}): void {
provisionPlaywright(opts);
provisionUvx(opts);
provisionMcporterConfig(opts);
provisionExtensions(opts);
}

/**
* Ensure core extensions are listed in ~/.pi/agent/settings.json packages array.
*/
export function provisionExtensions(opts: ProvisionOpts = {}): void {
const { log = defaultLog } = opts;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a defined logger fallback in provisionExtensions

provisionExtensions destructures log with defaultLog, but defaultLog is not defined in this module. When /update calls provisionBundle() without opts (see src/commands/update.ts), this line throws a ReferenceError before entering the try block, so extension provisioning is skipped and the bundle step is reported as failed despite the function being documented as non-fatal.

Useful? React with 👍 / 👎.

const settingsPath = resolve(homedir(), ".pi", "agent", "settings.json");

const coreExtensions = [
"npm:@inceptionstack/pi-hard-no",
"npm:@inceptionstack/pi-branch-enforcer",
];

try {
let settings: Record<string, unknown> = {};
if (existsSync(settingsPath)) {
settings = JSON.parse(readFileSync(settingsPath, "utf8"));
}
if (!Array.isArray(settings.packages)) settings.packages = [];
const pkgs = settings.packages as string[];

let added = 0;
for (const ext of coreExtensions) {
if (!pkgs.includes(ext)) {
pkgs.push(ext);
added++;
}
}

if (added > 0) {
mkdirSync(dirname(settingsPath), { recursive: true });
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
log.ok(`${added} extension(s) added to settings.json`);
} else {
log.ok("extensions (already configured)");
}
} catch (err: any) {
log.warn(`extensions provisioning failed: ${err.message}`);
}
}
9 changes: 9 additions & 0 deletions src/cli/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ function resolveAgentForSetup(opts: SetupOptions): AgentDefinition {
const pkgs = settings.packages as string[];
if (!pkgs.includes(selfPkg)) pkgs.push(selfPkg);

// Add code review + branch protection extensions
const coreExtensions = [
"npm:@inceptionstack/pi-hard-no",
"npm:@inceptionstack/pi-branch-enforcer",
];
for (const ext of coreExtensions) {
if (!pkgs.includes(ext)) pkgs.push(ext);
}

// Add pi-psst if using psst
if (ctx.psst) {
const psstPkg = "npm:@miclivs/pi-psst";
Expand Down
12 changes: 12 additions & 0 deletions src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,18 @@ export class Gateway {
lines.push(`📝 Context: no usage data yet (${windowK}K window)`);
}

// Extensions
const extensions = Array.isArray(info.extensions) ? info.extensions as string[] : [];
if (extensions.length > 0) {
lines.push(``);
lines.push(`🧩 Extensions (${extensions.length}):`);
for (const ext of extensions) {
// Show short name: strip npm: prefix and path noise
const short = ext.replace(/^.*node_modules\//, "").replace(/\/index\.[tj]s$/, "");
lines.push(` • ${short}`);
}
}

await this.postWithFallback(thread, lines.join("\n"));
console.log(`[roundhouse] /status for thread=${thread.id} agentThread=${agentThreadId}`);
return;
Expand Down
Loading