Skip to content
Open
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
48 changes: 48 additions & 0 deletions templates/echo-cli/.cursor/rules/echo_rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
description: Echo SDK guidelines for CLI tools — user-pays AI infrastructure
globs: **/*.ts,**/*.js
---

# Echo SDK Guidelines (CLI)

Echo lets CLI tools authenticate users and let them pay for their own AI usage.

## Authentication

Use Echo's auth functions for CLI login flow:

```typescript
import { loginWithEcho, logout, isAuthenticated } from '@/auth';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { loginWithEcho, logout, isAuthenticated } from '@/auth';
import { loginWithEcho, logout } from '@/auth';
import { isAuthenticated } from '@/utils';

Cursor rules documentation shows incorrect import path for isAuthenticated - it should be from @/utils, not @/auth.

Fix on Vercel


// Login
await loginWithEcho();

// Check auth
if (await isAuthenticated()) {
// proceed
}

// Logout
await logout();
```

## Wallet management

```typescript
import {
initLocalWallet,
loginWithWallet,
Comment on lines +32 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {
initLocalWallet,
loginWithWallet,
import { initLocalWallet, loginWithWallet } from '@/auth';
import {

Cursor rules documentation shows incorrect import path for wallet authentication functions initLocalWallet and loginWithWallet.

Fix on Vercel

showLocalWalletBalance,
showLocalWalletAddress,
exportPrivateKey,
fundWallet
} from '@/core';
```

## Key rules

- Use `@merit-systems/echo-sdk` for CLI applications
- Use `commander` for CLI argument parsing
- Use `@clack/prompts` for interactive prompts
- Handle `isCancel` from prompts to allow graceful exit
- Store auth tokens securely, never log them
89 changes: 89 additions & 0 deletions templates/next/.cursor/rules/echo_rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
description: Echo SDK guidelines for Next.js — user-pays AI infrastructure
globs: **/*.ts,**/*.tsx,**/*.js,**/*.jsx
---

# Echo SDK Guidelines (Next.js)

Echo lets users pay for their own AI usage — you never front API costs. Replace standard AI SDK imports with Echo and earn revenue via markup.

## Setup

### Server-side configuration
Create `src/echo/index.ts` and initialize Echo:

```typescript
import Echo from '@merit-systems/echo-next-sdk';

export const { handlers, isSignedIn, openai, anthropic } = Echo({
appId: process.env.ECHO_APP_ID!,
});
```

### Client-side provider
Wrap your app in `EchoProvider` in your layout or providers file:

```typescript
'use client';
import { EchoProvider } from '@merit-systems/echo-next-sdk/client';

export function Providers({ children }: { children: React.ReactNode }) {
return (
<EchoProvider config={{ appId: process.env.NEXT_PUBLIC_ECHO_APP_ID! }}>
{children}
</EchoProvider>
);
}
```

### Environment variables
- `ECHO_APP_ID` — Server-side app ID (from echo.merit.systems)
- `NEXT_PUBLIC_ECHO_APP_ID` — Client-side app ID (same value, must be prefixed with NEXT_PUBLIC_)

## Using Echo model providers

Import model providers from your Echo config instead of directly from the AI SDK:

```typescript
import { openai, anthropic } from '@/echo';
import { generateText } from 'ai';

const response = await generateText({
model: openai('gpt-4o'),
prompt: '...',
});
```

Do NOT hardcode API keys — Echo handles authentication and billing.

## UI components

### Token balance display
Use `EchoTokens` to show user balance and login:

```typescript
'use client';
import { EchoTokens } from '@merit-systems/echo-next-sdk/client';

export function EchoButton() {
return <EchoTokens />;
}
```

## API routes

Register the Echo auth handler in `src/app/api/echo/[...echo]/route.ts`:

```typescript
import { handlers } from '@/echo';
export const { GET, POST } = handlers;
```

## Key rules

- ALWAYS use `@merit-systems/echo-next-sdk` for Next.js apps (not the React or plain SDK)
- ALWAYS wrap the app in `EchoProvider` on the client side
- ALWAYS use the server-side Echo config for AI model providers
- NEVER hardcode API keys — Echo manages authentication
- Use `'use client'` directive for components importing from `echo-next-sdk/client`
- The `EchoTokens` component handles OAuth login flow and balance display
69 changes: 69 additions & 0 deletions templates/react/.cursor/rules/echo_rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
description: Echo SDK guidelines for React — user-pays AI infrastructure
globs: **/*.ts,**/*.tsx,**/*.js,**/*.jsx
---

# Echo SDK Guidelines (React)

Echo lets users pay for their own AI usage — you never front API costs. Replace standard AI SDK imports with Echo and earn revenue via markup.

## Setup

### Provider setup
Wrap your app in `EchoProvider` in `main.tsx`:

```typescript
import { EchoProvider } from '@merit-systems/echo-react-sdk';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<EchoProvider config={{ appId: import.meta.env.VITE_ECHO_APP_ID! }}>
<App />
</EchoProvider>
</StrictMode>
);
```

### Environment variables
- `VITE_ECHO_APP_ID` — App ID from echo.merit.systems (Vite requires VITE_ prefix)

## Using Echo model providers

```typescript
import { useEchoModelProviders } from '@merit-systems/echo-react-sdk';
import { generateText } from 'ai';

function MyComponent() {
const { openai } = useEchoModelProviders();

const handleGenerate = async () => {
const response = await generateText({
model: openai('gpt-4o'),
prompt: '...',
});
};
}
```

## UI components

```typescript
import { EchoTokens } from '@merit-systems/echo-react-sdk';

function App() {
return (
<>
<h1>My App</h1>
<EchoTokens />
</>
);
}
```

## Key rules

- ALWAYS use `@merit-systems/echo-react-sdk` for React apps (not the Next.js SDK)
- ALWAYS wrap the app in `EchoProvider` at the root
- Use `useEchoModelProviders()` hook to get AI model providers
- NEVER hardcode API keys — Echo manages authentication
- Use `EchoTokens` component for user balance and login UI