@contextai-core/cli 0.1.0 â 0.1.2
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 +5 -5
- package/package.json +1 -1
- package/src/actions/init.js +50 -55
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@ npm install -g @contextai-core/cli
|
|
|
12
12
|
## Features for Agents (The "Bridge")
|
|
13
13
|
This CLI includes an MCP-Compliant "Bridge" that enforces project protocols.
|
|
14
14
|
|
|
15
|
-
- **`contextai write`**: Writes files + Updates Changelog/Manifest.
|
|
16
|
-
- **`contextai read`**: Reads files + Injects Hook Context.
|
|
17
|
-
- **`contextai patch`**: Smart Search & Replace.
|
|
18
|
-
- **`contextai run`**: Safe Command Execution.
|
|
19
|
-
- **`contextai mcp`**: Launches a Native MCP Server (stdio) for Claude Desktop.
|
|
15
|
+
- **`npx @contextai-core/cli write`**: Writes files + Updates Changelog/Manifest.
|
|
16
|
+
- **`npx @contextai-core/cli read`**: Reads files + Injects Hook Context.
|
|
17
|
+
- **`npx @contextai-core/cli patch`**: Smart Search & Replace.
|
|
18
|
+
- **`npx @contextai-core/cli run`**: Safe Command Execution.
|
|
19
|
+
- **`npx @contextai-core/cli mcp`**: Launches a Native MCP Server (stdio) for Claude Desktop.
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
See `MCP_GUIDE.md` (included in this package) for detailed integration instructions for your IDE.
|
package/package.json
CHANGED
package/src/actions/init.js
CHANGED
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
1
|
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { installPackage } from "./install.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the ContextAI Shared Brain (.ai) by installing the Core UCP.
|
|
9
|
+
*/
|
|
10
|
+
export async function init() {
|
|
11
|
+
console.log(chalk.green('đ§ Initializing ContextAI Shared Brain...'));
|
|
7
12
|
const aiDir = path.join(process.cwd(), '.ai');
|
|
8
|
-
const ucpDir = path.join(aiDir, 'ucp');
|
|
9
|
-
const manifestPath = path.join(aiDir, 'context.json');
|
|
10
|
-
const bootPath = path.join(aiDir, 'boot.md');
|
|
11
|
-
|
|
12
|
-
if (fs.existsSync(aiDir)) {
|
|
13
|
-
// Check if it's legacy
|
|
14
|
-
if (!fs.existsSync(ucpDir) && fs.existsSync(path.join(aiDir, 'context'))) {
|
|
15
|
-
console.log(chalk.yellow('â ď¸ Legacy .ai/ structure detected. Migration is recommended but not yet auto-implemented.'));
|
|
16
|
-
console.log(chalk.yellow(' Please start fresh or manually move contents to .ai/ucp/'));
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
// 1. Create .ai directory if missing
|
|
15
|
+
if (!fs.existsSync(aiDir)) {
|
|
16
|
+
fs.mkdirSync(aiDir);
|
|
17
|
+
}
|
|
18
|
+
|
|
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;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.log(chalk.green('â
Successfully initialized Shared Brain (.ai/)!'));
|
|
59
|
-
console.log(chalk.gray(' - .ai/boot.md (Traffic Cop)'));
|
|
60
|
-
console.log(chalk.gray(' - .ai/context.json (Manifest)'));
|
|
61
|
-
console.log(chalk.gray(' - .ai/ucp/ (Core Protocol)'));
|
|
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
|
+
}
|
|
62
57
|
}
|