@contextai-core/cli 0.1.3 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextai-core/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Give your AI agents persistent memory. Install pre-built context packs for Cursor, Windsurf, Copilot & more.",
5
5
  "author": "ContextAI",
6
6
  "license": "ISC",
@@ -2,10 +2,10 @@
2
2
  import chalk from "chalk";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
- import { installPackage } from "./install.js";
6
5
 
7
6
  /**
8
- * Initializes the ContextAI Shared Brain (.ai) by installing the Core UCP.
7
+ * Initializes the ContextAI Shared Brain (.ai).
8
+ * Creates the directory structure but installs NO packs by default.
9
9
  */
10
10
  export async function init() {
11
11
  console.log(chalk.green('🧠 Initializing ContextAI Shared Brain...'));
@@ -14,44 +14,13 @@ export async function init() {
14
14
  // 1. Create .ai directory if missing
15
15
  if (!fs.existsSync(aiDir)) {
16
16
  fs.mkdirSync(aiDir);
17
+ console.log(chalk.blue(' Created .ai/ directory.'));
18
+ } else {
19
+ console.log(chalk.yellow(' .ai/ directory already exists.'));
17
20
  }
18
21
 
19
- // 2. Check overlap
20
- if (fs.existsSync(path.join(aiDir, 'ucp'))) {
21
- console.log(chalk.yellow('⚠️ .ai/ucp already exists. Skipping core installation.'));
22
- return;
23
- }
24
-
25
- try {
26
- // 3. Delegate to Install Action
27
- // "universal-context-protocol" should be the slug of the Core UCP in our DB.
28
- // For now, if that pack doesn't exist, we fallback to the "seed" method?
29
- // NO, we should enforce the "Git/Marketplace" model.
30
-
31
- console.log(chalk.blue('⬇️ Downloading Universal Context Protocol (Core OS)...'));
32
-
33
- // We call installPackage directly.
34
- // We assume "universal-context-protocol" is free and public.
35
- await installPackage("universal-context-protocol", {});
36
-
37
- // 4. Create Bootloader (Traffic Cop) if missing
38
- const bootPath = path.join(aiDir, 'boot.md');
39
- if (!fs.existsSync(bootPath)) {
40
- fs.writeFileSync(
41
- bootPath,
42
- `# AI Context Container\n\nThis project uses multiple context protocols.\n\n## Active Protocols\n1. **UCP** (Core OS): [Unified Context Protocol](./ucp/README.md)\n - Use for: General Project Context, Workflows.\n`
43
- );
44
- }
45
-
46
- console.log(chalk.green('\n✅ Initialization Complete!'));
47
- console.log(chalk.gray(' Your agent now has a brain in .ai/'));
48
-
49
- } catch (error) {
50
- console.error(chalk.red(`\n❌ Init Failed: ${error.message}`));
51
- console.error(chalk.yellow(' Ensure you have internet connection and the "universal-context-protocol" pack is live.'));
52
- // Fallback or exit?
53
- // For resilience, maybe write a minimal skeleton if download fails?
54
- // User asked to "download from live ucp template link".
55
- process.exit(1);
56
- }
22
+ console.log(chalk.green('\n✅ Initialization Complete!'));
23
+ console.log(chalk.white(' Your project is ready context.'));
24
+ console.log(chalk.cyan('\n Next Step: Install a Context Pack'));
25
+ console.log(chalk.gray(' $ npx contextai install @<username>/ucp'));
57
26
  }
@@ -33,7 +33,9 @@ export async function installPackage(packageSlug, options = {}) {
33
33
  // 1. Fetch pack from Supabase
34
34
  spinner.text = `Fetching pack info for ${packageSlug}...`;
35
35
 
36
- const { data: purchaseData, error: purchaseError } = await getSupabase()
36
+ const supabase = getSupabase();
37
+
38
+ const { data: pack, error } = await supabase
37
39
  .from('packs')
38
40
  .select('*')
39
41
  .eq('slug', packageSlug)
@@ -153,10 +155,13 @@ export async function installPackage(packageSlug, options = {}) {
153
155
  const tempDir = path.join(os.tmpdir(), `contextai-${Date.now()}`);
154
156
  zip.extractAllTo(tempDir, true);
155
157
 
156
- // Find actual root
157
- const items = fs.readdirSync(tempDir);
158
- const rootItem = items.find(i => fs.statSync(path.join(tempDir, i)).isDirectory());
159
- const sourceDir = rootItem ? path.join(tempDir, rootItem) : tempDir;
158
+ // Find actual root (only unwrap if it's a single folder)
159
+ const items = fs.readdirSync(tempDir).filter(i => !i.startsWith('.') && i !== '__MACOSX');
160
+ let sourceDir = tempDir;
161
+
162
+ if (items.length === 1 && fs.statSync(path.join(tempDir, items[0])).isDirectory()) {
163
+ sourceDir = path.join(tempDir, items[0]);
164
+ }
160
165
 
161
166
  spinner.text = 'Injecting Verified Context...';
162
167
  copyRecursiveSync(sourceDir, targetDir);