@chimerai/cli 0.2.99 → 0.2.100
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/dist/commands/create.js
CHANGED
|
@@ -1255,7 +1255,7 @@ async function getServerSessionWithPermissions() {
|
|
|
1255
1255
|
if (features.includes('ai-chat')) {
|
|
1256
1256
|
// Modular chat components (useChat hook + individual components)
|
|
1257
1257
|
await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'components/chat'));
|
|
1258
|
-
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'components/chat/use-chat.ts'), templates.generateUseChatHook());
|
|
1258
|
+
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'components/chat/use-chat.ts'), templates.generateUseChatHook(features.includes('billing')));
|
|
1259
1259
|
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'components/chat/chat-message.tsx'), templates.generateChatMessage());
|
|
1260
1260
|
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'components/chat/chat-input.tsx'), templates.generateChatInput());
|
|
1261
1261
|
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'components/chat/chat-sidebar.tsx'), templates.generateChatSidebar());
|
|
@@ -1286,17 +1286,6 @@ async function getServerSessionWithPermissions() {
|
|
|
1286
1286
|
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/v1/models/route.ts'), templates.generateV1ModelsRoute());
|
|
1287
1287
|
}
|
|
1288
1288
|
// ── Billing / Stripe (when selected) ────────────────────────────
|
|
1289
|
-
// Always generate /api/billing/credits — chat hook calls it unconditionally.
|
|
1290
|
-
// Without billing: return a stub so the client gets a clean 200 instead of 404.
|
|
1291
|
-
await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'app/api/billing/credits'));
|
|
1292
|
-
if (!features.includes('billing')) {
|
|
1293
|
-
await fs_extra_1.default.writeFile(path_1.default.join(targetDir, 'app/api/billing/credits/route.ts'), `import { NextResponse } from 'next/server';
|
|
1294
|
-
// Billing feature not enabled — return stub so the client doesn't get a 404
|
|
1295
|
-
export async function GET() {
|
|
1296
|
-
return NextResponse.json({ balance: null, enabled: false });
|
|
1297
|
-
}
|
|
1298
|
-
`);
|
|
1299
|
-
}
|
|
1300
1289
|
if (features.includes('billing')) {
|
|
1301
1290
|
const stripeLib = templates.generateStripeLib();
|
|
1302
1291
|
await fs_extra_1.default.ensureDir(path_1.default.join(targetDir, 'lib'));
|
package/dist/templates/chat.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function generateConversationsRoute(): string;
|
|
|
27
27
|
* Based on apps/frontend/components/chat/use-chat.ts
|
|
28
28
|
* @returns TypeScript content for components/chat/use-chat.ts
|
|
29
29
|
*/
|
|
30
|
-
export declare function generateUseChatHook(): string;
|
|
30
|
+
export declare function generateUseChatHook(hasBilling?: boolean): string;
|
|
31
31
|
/**
|
|
32
32
|
* Generates the ChatMessage component with Markdown rendering, copy, edit, delete
|
|
33
33
|
* Based on apps/frontend/components/chat/chat-message.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/templates/chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAqI/C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAuLzC;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAwa/D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAwEnD;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/templates/chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAqI/C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAuLzC;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAwa/D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAwEnD;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,UAAQ,GAAG,MAAM,CAob9D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAuQ5C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAwH1C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CA+O5C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CA+D9C;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAyGxD"}
|
package/dist/templates/chat.js
CHANGED
|
@@ -854,7 +854,7 @@ export async function POST(request: NextRequest) {
|
|
|
854
854
|
* Based on apps/frontend/components/chat/use-chat.ts
|
|
855
855
|
* @returns TypeScript content for components/chat/use-chat.ts
|
|
856
856
|
*/
|
|
857
|
-
function generateUseChatHook() {
|
|
857
|
+
function generateUseChatHook(hasBilling = false) {
|
|
858
858
|
return `// @chimerai component=UseChatHook version=2.0
|
|
859
859
|
'use client';
|
|
860
860
|
|
|
@@ -990,7 +990,7 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
|
|
990
990
|
}
|
|
991
991
|
}, [selectedModelId]);
|
|
992
992
|
|
|
993
|
-
|
|
993
|
+
${hasBilling ? `// --- Fetch Credit Balance ---
|
|
994
994
|
const fetchCreditBalance = useCallback(async () => {
|
|
995
995
|
try {
|
|
996
996
|
const res = await fetch('/api/billing/credits');
|
|
@@ -1001,13 +1001,13 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
|
|
1001
1001
|
} catch {
|
|
1002
1002
|
// Credits endpoint may not exist — that's ok
|
|
1003
1003
|
}
|
|
1004
|
-
}, [])
|
|
1004
|
+
}, []);` : ''}
|
|
1005
1005
|
|
|
1006
1006
|
// Load on mount
|
|
1007
1007
|
useEffect(() => {
|
|
1008
1008
|
refreshConversations();
|
|
1009
1009
|
fetchModels();
|
|
1010
|
-
fetchCreditBalance();
|
|
1010
|
+
${hasBilling ? 'fetchCreditBalance();' : '// billing not enabled'}
|
|
1011
1011
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1012
1012
|
}, []);
|
|
1013
1013
|
|
package/package.json
CHANGED