@hmawla/co-assistant 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -320,7 +320,10 @@ All configured via `.env` (the setup wizard handles this):
320
320
  | `co-assistant start -v` | Start with verbose logging |
321
321
  | `co-assistant model` | Show current AI model |
322
322
  | `co-assistant model <name>` | Switch AI model |
323
- | `co-assistant plugin list` | List discovered plugins |
323
+ | `co-assistant plugin list` | List discovered plugins in local `plugins/` |
324
+ | `co-assistant plugin available` | List bundled first-party plugins |
325
+ | `co-assistant plugin install <id>` | Install a bundled plugin into `plugins/` |
326
+ | `co-assistant plugin install --all` | Install all bundled plugins |
324
327
  | `co-assistant plugin enable <name>` | Enable a plugin |
325
328
  | `co-assistant plugin disable <name>` | Disable a plugin |
326
329
  | `co-assistant plugin configure <name>` | Set up plugin credentials |
@@ -385,6 +388,24 @@ Both files are injected as system-level context on every message:
385
388
  | **Gmail** | Search emails, read email, send email, send reply |
386
389
  | **Google Calendar** | List events, create event, update event, delete event |
387
390
 
391
+ ### Install Plugins
392
+
393
+ Co-Assistant ships with first-party plugins (Gmail, Google Calendar). If you installed via npm, they aren't in your working directory yet — install them with:
394
+
395
+ ```bash
396
+ # See what's available
397
+ co-assistant plugin available
398
+
399
+ # Install a specific plugin
400
+ co-assistant plugin install gmail
401
+
402
+ # Install all bundled plugins at once
403
+ co-assistant plugin install --all
404
+
405
+ # Overwrite an existing plugin (e.g. after an update)
406
+ co-assistant plugin install gmail --force
407
+ ```
408
+
388
409
  ### Enable a Plugin
389
410
 
390
411
  ```bash
package/dist/cli/index.js CHANGED
@@ -446,7 +446,13 @@ var init_client = __esm({
446
446
  }
447
447
  try {
448
448
  logger2.info("Starting Copilot client\u2026");
449
- this.client = new CopilotClient();
449
+ const opts = {};
450
+ const token = process.env.GITHUB_TOKEN;
451
+ if (token) {
452
+ opts.githubToken = token;
453
+ logger2.debug("Using GITHUB_TOKEN for SDK authentication");
454
+ }
455
+ this.client = new CopilotClient(opts);
450
456
  await this.client.start();
451
457
  this.isStarted = true;
452
458
  logger2.info("Copilot client started successfully");
@@ -3409,7 +3415,7 @@ ${question}`);
3409
3415
  }
3410
3416
  }
3411
3417
  async function promptFilePath(question) {
3412
- const { existsSync: existsSync9, readFileSync: readFileSync6 } = await import("fs");
3418
+ const { existsSync: existsSync9, readFileSync: readFileSync7 } = await import("fs");
3413
3419
  const { resolve } = await import("path");
3414
3420
  while (true) {
3415
3421
  const raw = await ask(`${question}: `);
@@ -3423,7 +3429,7 @@ async function promptFilePath(question) {
3423
3429
  continue;
3424
3430
  }
3425
3431
  try {
3426
- return readFileSync6(filePath, "utf-8");
3432
+ return readFileSync7(filePath, "utf-8");
3427
3433
  } catch {
3428
3434
  console.log(` \u26A0 Could not read file: ${filePath}`);
3429
3435
  }
@@ -3968,8 +3974,45 @@ Configuring plugin: ${manifest.id}`);
3968
3974
  }
3969
3975
 
3970
3976
  // src/cli/commands/plugin.ts
3971
- import { existsSync as existsSync7, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
3977
+ import {
3978
+ existsSync as existsSync7,
3979
+ mkdirSync as mkdirSync4,
3980
+ writeFileSync as writeFileSync5,
3981
+ readdirSync as readdirSync3,
3982
+ readFileSync as readFileSync6,
3983
+ cpSync
3984
+ } from "fs";
3972
3985
  import path4 from "path";
3986
+ import { fileURLToPath } from "url";
3987
+ function getPackagePluginsDir() {
3988
+ const thisFile = fileURLToPath(import.meta.url);
3989
+ const pkgRoot = path4.resolve(path4.dirname(thisFile), "..", "..", "..");
3990
+ const pluginsDir = path4.join(pkgRoot, "plugins");
3991
+ if (!existsSync7(pluginsDir)) {
3992
+ const altRoot = path4.resolve(path4.dirname(thisFile), "..", "..");
3993
+ const altDir = path4.join(altRoot, "plugins");
3994
+ if (existsSync7(altDir)) return altDir;
3995
+ }
3996
+ return pluginsDir;
3997
+ }
3998
+ function discoverBundledPlugins() {
3999
+ const pkgPluginsDir = getPackagePluginsDir();
4000
+ if (!existsSync7(pkgPluginsDir)) return [];
4001
+ const entries = readdirSync3(pkgPluginsDir, { withFileTypes: true });
4002
+ const results = [];
4003
+ for (const entry of entries) {
4004
+ if (!entry.isDirectory()) continue;
4005
+ const manifestPath = path4.join(pkgPluginsDir, entry.name, "plugin.json");
4006
+ if (!existsSync7(manifestPath)) continue;
4007
+ try {
4008
+ const raw = readFileSync6(manifestPath, "utf-8");
4009
+ const manifest = JSON.parse(raw);
4010
+ results.push({ ...manifest, sourcePath: path4.join(pkgPluginsDir, entry.name) });
4011
+ } catch {
4012
+ }
4013
+ }
4014
+ return results;
4015
+ }
3973
4016
  async function loadRegistry() {
3974
4017
  const registry = createPluginRegistry();
3975
4018
  const manifests = await registry.discoverPlugins();
@@ -4187,9 +4230,77 @@ Edit \`tools.ts\` to add or modify the tools this plugin exposes.
4187
4230
  writeFileSync5(path4.join(pluginDir, "README.md"), readmeContent, "utf-8");
4188
4231
  console.log(`\u2713 Plugin '${pluginId}' scaffolded at plugins/${pluginId}/`);
4189
4232
  }
4233
+ async function handleAvailable() {
4234
+ const bundled = discoverBundledPlugins();
4235
+ if (bundled.length === 0) {
4236
+ console.log("\n\u{1F4E6} No bundled first-party plugins found.\n");
4237
+ return;
4238
+ }
4239
+ const localPluginsDir = path4.join(process.cwd(), "plugins");
4240
+ console.log("\n\u{1F4E6} Available First-Party Plugins:\n");
4241
+ for (const plugin of bundled) {
4242
+ const localDir = path4.join(localPluginsDir, plugin.id);
4243
+ const installed = existsSync7(path4.join(localDir, "plugin.json"));
4244
+ const status = installed ? "\u2705 Installed" : "\u2B07\uFE0F Not installed";
4245
+ console.log(` ${plugin.id} (v${plugin.version}) \u2014 ${plugin.name}`);
4246
+ console.log(` ${plugin.description}`);
4247
+ console.log(` ${status}
4248
+ `);
4249
+ }
4250
+ console.log(" Install with: co-assistant plugin install <id>");
4251
+ console.log(" Install all: co-assistant plugin install --all\n");
4252
+ }
4253
+ async function handleInstall(pluginId, options) {
4254
+ const bundled = discoverBundledPlugins();
4255
+ if (bundled.length === 0) {
4256
+ console.error("\u2717 No bundled first-party plugins found in the package.");
4257
+ process.exit(1);
4258
+ }
4259
+ let toInstall;
4260
+ if (options.all) {
4261
+ toInstall = bundled;
4262
+ } else if (pluginId) {
4263
+ const match = bundled.find((p) => p.id === pluginId);
4264
+ if (!match) {
4265
+ console.error(`\u2717 Plugin '${pluginId}' is not a bundled first-party plugin.`);
4266
+ console.error(` Available: ${bundled.map((p) => p.id).join(", ")}`);
4267
+ process.exit(1);
4268
+ }
4269
+ toInstall = [match];
4270
+ } else {
4271
+ console.error("\u2717 Specify a plugin ID or use --all to install all plugins.");
4272
+ console.error(` Available: ${bundled.map((p) => p.id).join(", ")}`);
4273
+ process.exit(1);
4274
+ }
4275
+ const localPluginsDir = path4.join(process.cwd(), "plugins");
4276
+ mkdirSync4(localPluginsDir, { recursive: true });
4277
+ let installed = 0;
4278
+ let skipped = 0;
4279
+ for (const plugin of toInstall) {
4280
+ const destDir = path4.join(localPluginsDir, plugin.id);
4281
+ const alreadyExists = existsSync7(path4.join(destDir, "plugin.json"));
4282
+ if (alreadyExists && !options.force) {
4283
+ console.log(` \u23ED ${plugin.id} \u2014 already installed (use --force to overwrite)`);
4284
+ skipped++;
4285
+ continue;
4286
+ }
4287
+ cpSync(plugin.sourcePath, destDir, { recursive: true });
4288
+ console.log(` \u2705 ${plugin.id} \u2014 installed to plugins/${plugin.id}/`);
4289
+ installed++;
4290
+ }
4291
+ console.log(`
4292
+ \u2713 ${installed} installed, ${skipped} skipped`);
4293
+ if (installed > 0) {
4294
+ console.log("\nNext steps:");
4295
+ console.log(" co-assistant plugin configure <id> # Set up credentials");
4296
+ console.log(" co-assistant plugin enable <id> # Enable the plugin\n");
4297
+ }
4298
+ }
4190
4299
  function registerPluginCommand(program2) {
4191
4300
  const plugin = program2.command("plugin").description("Manage plugins");
4192
- plugin.command("list").description("List all available plugins").action(handleList);
4301
+ plugin.command("list").description("List all plugins in the local plugins/ directory").action(handleList);
4302
+ plugin.command("available").description("List bundled first-party plugins and their install status").action(handleAvailable);
4303
+ plugin.command("install").description("Install a first-party plugin from the package").argument("[id]", "Plugin ID to install (omit with --all)").option("--all", "Install all available first-party plugins").option("--force", "Overwrite existing plugins").action(handleInstall);
4193
4304
  plugin.command("enable").description("Enable a plugin").argument("<id>", "Plugin ID to enable").action(handleEnable);
4194
4305
  plugin.command("disable").description("Disable a plugin").argument("<id>", "Plugin ID to disable").action(handleDisable);
4195
4306
  plugin.command("info").description("Show detailed information about a plugin").argument("<id>", "Plugin ID to inspect").action(handleInfo);