@aiderdesk/extensions 0.2.0 → 0.3.0

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +110 -72
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -58,6 +58,7 @@ For comprehensive documentation on creating and using extensions, see the [Exten
58
58
  | **[wakatime.ts](./extensions/wakatime.ts)** | Tracks coding activity by sending heartbeats to WakaTime via wakatime-cli | `onLoad`, `onPromptStarted`, `onPromptFinished`, `onToolFinished`, `onFilesAdded` |
59
59
  | **[redact-secrets/](./extensions/redact-secrets/)** | Redacts secret values from `.env*` files in file read results | `onLoad`, `onProjectOpen`, `onToolFinished` |
60
60
  | **[external-rules.ts](./extensions/external-rules.ts)** | Includes rule files from Cursor, Claude Code, and Roo Code configurations | `onLoad`, `onRuleFilesRetrieved` |
61
+ | **[lsp/](./extensions/lsp/)** | LSP integration for automatic error detection after file edits and code intelligence tools (find references) | `onLoad`, `onUnload`, `getTools`, `onProjectStarted`, `onProjectStopped`, `onToolFinished` |
61
62
  | **[ultrathink.ts](./extensions/ultrathink.ts)** | Detects prompts like "ultrathink" / "think hard" and increases OpenAI/OpenAI-compatible reasoning effort (`xhigh` for `-max` models, otherwise `high`) | `onLoad`, `onAgentStarted` |
62
63
 
63
64
  ## Quick Start
package/dist/cli.js CHANGED
@@ -4,10 +4,10 @@ import { createRequire } from "node:module";
4
4
  import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { homedir } from "node:os";
7
- import { existsSync, mkdirSync, cpSync, writeFileSync, rmSync } from "node:fs";
7
+ import { existsSync, mkdirSync, cpSync, writeFileSync, rmSync, readFileSync } from "node:fs";
8
8
  import { spawn } from "node:child_process";
9
9
  import { Command } from "commander";
10
- import { checkbox, confirm } from "@inquirer/prompts";
10
+ import { checkbox } from "@inquirer/prompts";
11
11
  import chalk from "chalk";
12
12
  import ora from "ora";
13
13
  var require2 = createRequire(import.meta.url);
@@ -16,11 +16,104 @@ var __dirname = dirname(__filename);
16
16
  var EXTENSIONS_JSON_PATH = join(__dirname, "..", "extensions.json");
17
17
  var EXTENSIONS_DIR = join(__dirname, "..", "extensions");
18
18
  var PACKAGE_VERSION = require2("../package.json").version;
19
- function loadExtensions() {
19
+ var CACHE_FILE = join(homedir(), ".aider-desk", "extension-cache.json");
20
+ var CACHE_TTL = 60 * 60 * 1e3;
21
+ var GITHUB_API_URL = "https://api.github.com/repos/hotovo/aider-desk/contents/packages/extensions/extensions";
22
+ function loadFromCache() {
23
+ try {
24
+ if (!existsSync(CACHE_FILE)) {
25
+ return null;
26
+ }
27
+ const cacheContent = readFileSync(CACHE_FILE, "utf-8");
28
+ const cache = JSON.parse(cacheContent);
29
+ if (Date.now() - cache.timestamp < CACHE_TTL) {
30
+ return cache;
31
+ }
32
+ return null;
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
37
+ function saveToCache(extensions) {
38
+ try {
39
+ const cacheDir = dirname(CACHE_FILE);
40
+ if (!existsSync(cacheDir)) {
41
+ mkdirSync(cacheDir, { recursive: true });
42
+ }
43
+ const cacheData = {
44
+ timestamp: Date.now(),
45
+ extensions
46
+ };
47
+ writeFileSync(CACHE_FILE, JSON.stringify(cacheData, null, 2), "utf-8");
48
+ } catch {
49
+ }
50
+ }
51
+ function loadLocalExtensionsMap() {
52
+ try {
53
+ const localConfig = require2(EXTENSIONS_JSON_PATH);
54
+ const map = /* @__PURE__ */ new Map();
55
+ localConfig.extensions.forEach((ext) => {
56
+ map.set(ext.id, ext);
57
+ });
58
+ return map;
59
+ } catch {
60
+ return /* @__PURE__ */ new Map();
61
+ }
62
+ }
63
+ async function fetchExtensions() {
64
+ try {
65
+ const response = await fetch(GITHUB_API_URL, {
66
+ headers: {
67
+ "User-Agent": "aiderdesk-extensions-cli"
68
+ }
69
+ });
70
+ if (!response.ok) {
71
+ return null;
72
+ }
73
+ const contents = await response.json();
74
+ const localExtensionsMap = loadLocalExtensionsMap();
75
+ const extensions = contents.filter((item) => item.type === "file" || item.type === "dir").filter((item) => {
76
+ if (item.type === "file") {
77
+ return item.name.endsWith(".ts") || item.name.endsWith(".js");
78
+ }
79
+ return true;
80
+ }).map((item) => {
81
+ const isFile = item.type === "file";
82
+ const id = isFile ? item.name.replace(/\.(ts|js)$/, "") : item.name;
83
+ const localExt = localExtensionsMap.get(id);
84
+ if (localExt) {
85
+ return localExt;
86
+ }
87
+ const name = id.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
88
+ return {
89
+ id,
90
+ name,
91
+ description: "",
92
+ type: isFile ? "single" : "folder",
93
+ file: isFile ? item.name : void 0,
94
+ folder: isFile ? void 0 : item.name,
95
+ capabilities: []
96
+ };
97
+ });
98
+ return extensions;
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+ async function loadExtensions() {
104
+ const dynamicExtensions = await fetchExtensions();
105
+ if (dynamicExtensions && dynamicExtensions.length > 0) {
106
+ saveToCache(dynamicExtensions);
107
+ return { extensions: dynamicExtensions };
108
+ }
109
+ const cachedData = loadFromCache();
110
+ if (cachedData && cachedData.extensions.length > 0) {
111
+ return { extensions: cachedData.extensions };
112
+ }
20
113
  try {
21
114
  return require2(EXTENSIONS_JSON_PATH);
22
115
  } catch {
23
- console.error(chalk.red("Error: Could not load extensions.json"));
116
+ console.error(chalk.red("Error: Could not load extensions from any source"));
24
117
  process.exit(1);
25
118
  }
26
119
  }
@@ -86,14 +179,8 @@ Installing ${ext.name} to: ${targetDir}
86
179
  const targetPath = join(targetDir, ext.folder);
87
180
  cpSync(localPath, targetPath, { recursive: true });
88
181
  spinner.succeed(chalk.green(`\u2713 Installed ${ext.name}`));
89
- if (ext.hasDependencies && existsSync(join(targetPath, "package.json"))) {
90
- const installDeps = await confirm({
91
- message: `${ext.name} has dependencies. Install them now?`,
92
- default: true
93
- });
94
- if (installDeps) {
95
- await installDependencies(targetPath);
96
- }
182
+ if (existsSync(join(targetPath, "package.json"))) {
183
+ await installDependencies(targetPath);
97
184
  }
98
185
  } else {
99
186
  spinner.text = `Downloading ${ext.name} from GitHub...`;
@@ -107,14 +194,8 @@ Installing ${ext.name} to: ${targetDir}
107
194
  }
108
195
  cpSync(sourceDir, targetPath, { recursive: true });
109
196
  spinner.succeed(chalk.green(`\u2713 Installed ${ext.name} from GitHub`));
110
- if (ext.hasDependencies && existsSync(join(targetPath, "package.json"))) {
111
- const installDeps = await confirm({
112
- message: `${ext.name} has dependencies. Install them now?`,
113
- default: true
114
- });
115
- if (installDeps) {
116
- await installDependencies(targetPath);
117
- }
197
+ if (existsSync(join(targetPath, "package.json"))) {
198
+ await installDependencies(targetPath);
118
199
  }
119
200
  } finally {
120
201
  if (existsSync(tempDir)) {
@@ -162,13 +243,7 @@ async function installFromUrl(url, targetDir) {
162
243
  cpSync(sourceDir, targetPath, { recursive: true });
163
244
  spinner.succeed(chalk.green(`\u2713 Installed ${extName} to ${targetDir}`));
164
245
  if (existsSync(join(targetPath, "package.json"))) {
165
- const installDeps = await confirm({
166
- message: "This extension has dependencies. Install them now?",
167
- default: true
168
- });
169
- if (installDeps) {
170
- await installDependencies(targetPath);
171
- }
246
+ await installDependencies(targetPath);
172
247
  }
173
248
  } else {
174
249
  throw new Error("Extension folder not found in repository");
@@ -190,7 +265,7 @@ async function installFromUrl(url, targetDir) {
190
265
  async function installFromExamples(extensions, targetDir) {
191
266
  console.log(chalk.cyan("\n\u{1F4E6} Available AiderDesk Extensions\n"));
192
267
  const choices = extensions.map((ext) => ({
193
- name: `${ext.name} - ${ext.description}`,
268
+ name: ext.description ? `${ext.name} - ${ext.description}` : ext.name,
194
269
  value: ext.id,
195
270
  disabled: false
196
271
  }));
@@ -210,47 +285,8 @@ async function installFromExamples(extensions, targetDir) {
210
285
  Installing to: ${targetDir}
211
286
  `));
212
287
  for (const extId of selectedIds) {
213
- const ext = extensions.find((e) => e.id === extId);
214
- if (!ext) {
215
- continue;
216
- }
217
- const spinner = ora(`Installing ${ext.name}...`).start();
218
- try {
219
- if (ext.type === "single" && ext.file) {
220
- const sourcePath = join(EXTENSIONS_DIR, ext.file);
221
- const targetPath = join(targetDir, ext.file);
222
- if (!existsSync(sourcePath)) {
223
- spinner.fail(chalk.yellow(`\u26A0 ${ext.name} source file not found, skipping`));
224
- continue;
225
- }
226
- cpSync(sourcePath, targetPath);
227
- spinner.succeed(chalk.green(`\u2713 Installed ${ext.name}`));
228
- } else if (ext.type === "folder" && ext.folder) {
229
- const sourcePath = join(EXTENSIONS_DIR, ext.folder);
230
- const targetPath = join(targetDir, ext.folder);
231
- if (!existsSync(sourcePath)) {
232
- spinner.fail(chalk.yellow(`\u26A0 ${ext.name} source folder not found, skipping`));
233
- continue;
234
- }
235
- cpSync(sourcePath, targetPath, { recursive: true });
236
- spinner.succeed(chalk.green(`\u2713 Installed ${ext.name}`));
237
- if (ext.hasDependencies && existsSync(join(targetPath, "package.json"))) {
238
- const installDeps = await confirm({
239
- message: `${ext.name} has dependencies. Install them now?`,
240
- default: true
241
- });
242
- if (installDeps) {
243
- await installDependencies(targetPath);
244
- }
245
- }
246
- }
247
- } catch (error) {
248
- spinner.fail(chalk.red(`\u2717 Failed to install ${ext.name}: ${error}`));
249
- }
288
+ await installExtensionById(extId, extensions, targetDir);
250
289
  }
251
- console.log(chalk.cyan("\n\u2728 Installation complete!\n"));
252
- console.log(chalk.gray("Extensions will be automatically loaded when you restart AiderDesk."));
253
- console.log(chalk.gray("Or they will hot-reload if AiderDesk is already running.\n"));
254
290
  }
255
291
  async function installDependencies(targetPath) {
256
292
  const spinner = ora("Installing dependencies...").start();
@@ -284,7 +320,7 @@ async function main() {
284
320
  program.name("aiderdesk-extensions").description("CLI tool for installing AiderDesk extensions").version(PACKAGE_VERSION);
285
321
  program.command("install [extension]").description("Install AiderDesk extensions interactively, by ID, or from a URL").option("-d, --directory <path>", "Custom installation directory").option("-g, --global", "Install to global directory (~/.aider-desk/extensions)").action(async (extension, options) => {
286
322
  const targetDir = getInstallDirectory(options);
287
- const examples = loadExtensions();
323
+ const examples = await loadExtensions();
288
324
  console.log(chalk.cyan.bold("\n\u{1F680} AiderDesk Extension Installer\n"));
289
325
  if (extension) {
290
326
  if (isUrl(extension)) {
@@ -296,12 +332,14 @@ async function main() {
296
332
  await installFromExamples(examples.extensions, targetDir);
297
333
  }
298
334
  });
299
- program.command("list").description("List all available example extensions").action(() => {
300
- const examples = loadExtensions();
335
+ program.command("list").description("List all available example extensions").action(async () => {
336
+ const examples = await loadExtensions();
301
337
  console.log(chalk.cyan.bold("\n\u{1F4E6} Available AiderDesk Extensions\n"));
302
338
  examples.extensions.forEach((ext) => {
303
339
  console.log(chalk.white.bold(` ${ext.name}`));
304
- console.log(chalk.gray(` ${ext.description}`));
340
+ if (ext.description) {
341
+ console.log(chalk.gray(` ${ext.description}`));
342
+ }
305
343
  console.log(chalk.gray(` Type: ${ext.type}`));
306
344
  if (ext.hasDependencies) {
307
345
  console.log(chalk.yellow(" \u26A0 Has dependencies"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiderdesk/extensions",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Type definitions and examples for AiderDesk extensions",
5
5
  "author": "Hotovo",
6
6
  "homepage": "https://aiderdesk.hotovo.com",