Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert project into monorepo #39

Merged
merged 5 commits into from
Nov 29, 2024
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
53 changes: 9 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ Cali is an AI agent that helps you build React Native apps. It takes all the uti

Thanks to that, an LLM can help you with your React Native app development, without the need to remember commands, spending time troubleshooting errors, and in the future, much more.

Under the hood, it uses [Vercel AI SDK](https://github.com/ai-sdk/ai), [@react-native-community/cli](https://github.com/react-native-community/cli).
## How can I use it?

The default model is `gpt-4o`.
You can use Cali in two ways:

> [!NOTE]
> You can change the default model by setting `AI_MODEL` env variable. We are currently
evaluating how different models perform, so we might change the default model in the future.
- [`cali`](./packages/cali/README.md) - AI agent that runs in your terminal. Ready to use out of the box.
- [`@cali/tools-react-native`](./packages/tools/README.md) - Collection of tools for building React Native apps with [Vercel AI SDK](https://github.com/ai-sdk/ai)
- [`@cali/mcp-server`](./packages/mcp-server/README.md) - (soon) [MCP server](http://modelcontextprotocol.io) for using Cali with Claude and other compatible environments

## Features
Under the hood, it uses [@react-native-community/cli](https://github.com/react-native-community/cli).

## What can it do?

Cali is still in the early stages of development, but it already supports:

Expand All @@ -39,13 +41,7 @@ Cali is still in the early stages of development, but it already supports:
- **Dependency Management**: Install and manage npm packages and CocoaPods dependencies.
- **React Native Library Search**: Searching and listing React Native libraries from [React Native Directory](https://reactnative.directory)

as well as various smaller utilities:

- **Port Forwarding**: Use ADB to forward ports for Android devices.
- **Ruby Gems Installation**: Install Ruby gems, including CocoaPods, for iOS projects.
- **Metro Bundler**: Automatically start Metro bundler for React Native projects.

We are actively working on expanding its capabilities. If you would like to request a feature, please open an issue.
You can learn more about available tools [here](./packages/tools/README.md).

## Examples

Expand All @@ -65,43 +61,12 @@ We are actively working on expanding its capabilities. If you would like to requ

[TBD]

## Prerequisites

In order to use Cali, you need to have an OpenAI API key. You can get one [here](https://platform.openai.com/api-keys). Once you have your key, you can set it as `OPENAI_API_KEY` env variable (either create a dotenv file or set it inline).

> [!NOTE]
> In the future, you will be able to change the provider from OpenAI to other, including local and self-hosted models. If you are interested in this feature, please open an issue so we can prioritize it and make sure it brings the best DX.

## Usage

Under the hood, Cali uses Vercel AI SDK. That means you can import all its tools into your existing project and use them for different purposes, without our interactive chat interface.

```ts
// import all tools
import { reactNativeTools, androidTools, iosTools } from "cali";

// use them in your project
import { generateText } from "ai";
await generateText({
// other options
tools: {
...reactNativeTools,
...androidTools,
...iosTools,
},
});
```

## Future requests

I like the idea of an AI agent for building React Native apps. I would like to play around with this idea in public, and see where it goes.

Feel free to open an issue or a discussion to suggest ideas or report bugs. Happy to hear from you! 👋

## Special thanks

Special thanks to [@jedirandy](https://github.com/jedirandy) for donating the name `cali` on `npm`!

## Made with ❤️ at Callstack

Cali is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Callstack](https://callstack.com) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi!
Expand Down
Binary file modified bun.lockb
Binary file not shown.
63 changes: 8 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
{
"name": "cali",
"version": "0.1.0",
"description": "AI agent that runs React Native apps",
"type": "module",
"main": "./dist/index.js",
"bin": {
"cali": "./dist/cli.js"
},
"name": "@cali/root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"prepare": "bun run build:tools && bun run build:cli",
"build:tools": "bun build ./src/index.ts --outdir ./dist --target node --packages external",
"build:cli": "bun build ./src/cli.ts --outdir ./dist --target node",
"build:tools": "bun build ./packages/tools/src/index.ts --outdir ./packages/tools/dist --target node --packages external",
"build:cli": "bun build ./packages/cali/src/cli.ts --outdir ./packages/cali/dist --target node",
"release": "release-it"
},
"dependencies": {
"@ai-sdk/openai": "^1.0.2",
"@clack/prompts": "^0.8.1",
"@react-native-community/cli": "^15.1.2",
"@react-native-community/cli-config": "^15.1.2",
"@react-native-community/cli-platform-android": "^15.1.2",
"@react-native-community/cli-platform-apple": "^15.1.2",
"@react-native-community/cli-platform-ios": "^15.1.2",
"ai": "^4.0.3",
"chalk": "^5.3.0",
"dedent": "^1.5.3",
"diff": "^7.0.0",
"dotenv": "^16.4.5",
"gradient-string": "^3.0.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@react-native-community/cli-types": "^15.1.2",
"@release-it-plugins/workspaces": "^4.2.0",
"@release-it/conventional-changelog": "^9.0.3",
"@types/diff": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"bun-types": "^1.1.33",
Expand All @@ -42,7 +21,6 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"glob": "^11.0.0",
"prettier": "^3.2.5",
"release-it": "^17.10.0",
"typescript": "^5.1.3",
Expand All @@ -51,31 +29,6 @@
"patchedDependencies": {
"ai@4.0.3": "patches/ai@4.0.3.patch"
},
"author": "Mike Grabowski <mike@callstack.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/callstackincubator/cali.git"
},
"contributors": [
"Oskar Kwasniewski <oskarkwasniewski@icloud.com> (https://github.com/okwasniewski)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/callstackincubator/cali/issues"
},
"homepage": "https://github.com/callstackincubator/cali/#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"keywords": [
"react-native",
"ai",
"agent",
"vercel ai",
"chatgpt"
],
"engines": {
"node": ">=22"
}
"version": "0.1.0"
}
17 changes: 17 additions & 0 deletions packages/cali/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cali

Cali is an AI agent that helps you build React Native apps. It takes all the utilities and functions of a React Native CLI and exposes them as tools to an LLM.

## Learn more

Learn more about Cali on [GitHub](https://github.com/callstackincubator/cali).

## Special thanks

Special thanks to [@jedirandy](https://github.com/jedirandy) for donating the name `cali` on `npm`!

## Made with ❤️ at Callstack

Cali is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Callstack](https://callstack.com) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi!

Like the project? ⚛️ [Join the team](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) who does amazing stuff for clients and drives React Native Open Source! 🔥
46 changes: 46 additions & 0 deletions packages/cali/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "cali",
"type": "module",
"bin": {
"cali": "./dist/cli.js"
},
"dependencies": {
"@ai-sdk/openai": "^1.0.2",
"@cali/tools-react-native": "workspace:*",
"@clack/prompts": "^0.8.1",
"ai": "^4.0.3",
"chalk": "^5.3.0",
"dedent": "^1.5.3",
"dotenv": "^16.4.5",
"gradient-string": "^3.0.0",
"zod": "^3.23.8"
},
"bugs": {
"url": "https://github.com/callstackincubator/cali/issues"
},
"homepage": "https://github.com/callstackincubator/cali/#readme",
"author": "Mike Grabowski <mike@callstack.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/callstackincubator/cali.git"
},
"contributors": [
"Oskar Kwasniewski <oskarkwasniewski@icloud.com> (https://github.com/okwasniewski)"
],
"keywords": [
"react-native",
"ai",
"agent",
"vercel ai"
],
"files": [
"dist",
"src",
"README.md"
],
"license": "MIT",
"version": "0.1.0",
"engines": {
"node": ">=22"
}
}
2 changes: 1 addition & 1 deletion src/cli.ts → packages/cali/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dotenv/config'
import { execSync } from 'node:child_process'

import { createOpenAI } from '@ai-sdk/openai'
import * as tools from '@cali/tools-react-native'
import { confirm, log, outro, select, spinner, text } from '@clack/prompts'
import { CoreMessage, generateText } from 'ai'
import chalk from 'chalk'
Expand All @@ -13,7 +14,6 @@ import { retro } from 'gradient-string'
import { z } from 'zod'

import { reactNativePrompt } from './prompt'
import * as tools from './tools'

const MessageSchema = z.union([
z.object({ type: z.literal('select'), content: z.string(), options: z.array(z.string()) }),
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/cali/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts"]
}
6 changes: 6 additions & 0 deletions packages/mcp-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @cali/mcp-server

> [!NOTE]
> This package is not yet released. It is a work in progress.

Model Context Protocol server that allows you to build and work with React Native apps. Under the hood it uses [@cali/tools](./tools/README.md).
6 changes: 6 additions & 0 deletions packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@cali/mcp-server",
"private": true,
"module": "src/index.ts",
"version": "0.1.0"
}
1 change: 1 addition & 0 deletions packages/mcp-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Cooming soon! (tm)')
4 changes: 4 additions & 0 deletions packages/mcp-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts"]
}
69 changes: 69 additions & 0 deletions packages/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# @callstack/cali

Collection of tools for building AI agents that work with React Native. Exported tools can be used with [ai](https://www.npmjs.com/package/ai) package.

## Usage

```ts
// First, import all tools
import * as tools from "@cali/tools-react-native";

import { generateText } from "ai";
await generateText({
prompt: {
role: 'system',
content: 'What is my React Native version?',
},
// Then, include them with the prompt
tools,
});
```

## List of tools

### Android
- **getAdbPath** - Returns path to ADB executable
- **getAndroidDevices** - Gets available Android devices and emulators with ID, name, type, and boot status
- **bootAndroidEmulator** - Boots a given Android emulator and returns its ID
- **buildAndroidApp** - Builds Android application and install it on a given device
- **runAdbReverse** - Runs "adb reverse" to forward given port to a specified Android device
- **launchAndroidAppOnDevice** - Launches a given Android application on a specified device

### Apple
- **getAppleSimulators** - Gets available simulators for iOS, tvOS, or visionOS
- **installRubyGems** - Install Ruby gems, including CocoaPods
- **bootAppleSimulator** - Boots iOS simulator with specified device ID
- **buildAppleAppWithoutStarting** - Build application for Apple platforms without running it
- **buildStartAppleApp** - Build and start Apple application on simulator or device
- **installPods** - Install CocoaPods dependencies
- **startAppleLogging** - Start Apple gathering logs from simulator or device

### React Native
- **startMetroDevServer** - Starts Metro development server on a given port or a different available port
- **getReactNativeConfig** - Get React Native configuration including root directory, path, version, platforms, and project configuration
- **listReactNativeLibraries** - List React Native libraries from reactnative.directory

### NPM
- **installNpmPackage** - Install a package from npm by name
- **unInstallNpmPackage** - Uninstall a package from npm by name

### File System
- **getFileTree** - Get user file tree, can be used to determine the package.json location, package manager, etc.
- **readFile** - Read file, can be used to read package.json, etc.

### Git
- **applyDiff** - Apply a diff/patch to a file

## Learn more

Learn more about Cali on [GitHub](https://github.com/callstackincubator/cali).

## Missing a tool?

Please open an issue or a discussion to suggest a new tool. We are happy to hear from you! 👋

## Made with ❤️ at Callstack

Cali is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Callstack](https://callstack.com) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi!

Like the project? ⚛️ [Join the team](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) who does amazing stuff for clients and drives React Native Open Source! 🔥
51 changes: 51 additions & 0 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@cali/tools-react-native",
"description": "Tools to build your own AI agent with React Native capabilities.",
"module": "src/index.ts",
"exports": {
"bun": "./src/index.ts",
"default": "./dist/index.js"
},
"type": "module",
"dependencies": {
"@ai-sdk/openai": "^1.0.2",
"@clack/prompts": "^0.8.1",
"@react-native-community/cli": "^15.1.2",
"@react-native-community/cli-config": "^15.1.2",
"@react-native-community/cli-platform-android": "^15.1.2",
"@react-native-community/cli-platform-apple": "^15.1.2",
"ai": "4.0.3",
"dedent": "^1.5.3",
"diff": "^7.0.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@react-native-community/cli-types": "^15.1.2",
"@types/diff": "^6.0.0"
},
"author": "Mike Grabowski <mike@callstack.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/callstackincubator/cali.git"
},
"contributors": [
"Oskar Kwasniewski <oskarkwasniewski@icloud.com> (https://github.com/okwasniewski)"
],
"keywords": [
"react-native",
"ai",
"tools",
"vercel ai"
],
"files": [
"dist",
"src",
"vendor",
"README.md"
],
"license": "MIT",
"version": "0.1.0",
"engines": {
"node": ">=22"
}
}
Loading