@neetru/cli 2.12.20 → 2.12.22

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.
@@ -316,106 +316,106 @@ async function scaffoldNextjs(dir, name, write) {
316
316
  },
317
317
  }, null, 2));
318
318
  // next.config.mjs
319
- await write(path.join(dir, 'next.config.mjs'), `/** @type {import('next').NextConfig} */
320
- const nextConfig = {};
321
- export default nextConfig;
319
+ await write(path.join(dir, 'next.config.mjs'), `/** @type {import('next').NextConfig} */
320
+ const nextConfig = {};
321
+ export default nextConfig;
322
322
  `);
323
323
  // Layout raiz
324
- await write(path.join(dir, 'src', 'app', 'layout.tsx'), `import type { Metadata } from 'next';
325
-
326
- export const metadata: Metadata = {
327
- title: '${name}',
328
- };
329
-
330
- export default function RootLayout({ children }: { children: React.ReactNode }) {
331
- return (
332
- <html lang="pt-BR">
333
- <body>{children}</body>
334
- </html>
335
- );
336
- }
324
+ await write(path.join(dir, 'src', 'app', 'layout.tsx'), `import type { Metadata } from 'next';
325
+
326
+ export const metadata: Metadata = {
327
+ title: '${name}',
328
+ };
329
+
330
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
331
+ return (
332
+ <html lang="pt-BR">
333
+ <body>{children}</body>
334
+ </html>
335
+ );
336
+ }
337
337
  `);
338
338
  // Página inicial com auth gate via SDK 1.1
339
- await write(path.join(dir, 'src', 'app', 'page.tsx'), `// Produto Neetru — gerado por neetru init
340
- // Auth via @neetru/sdk client (createNeetruClient + auth namespace)
341
-
342
- 'use client';
343
-
344
- import { createNeetruClient } from '@neetru/sdk';
345
- import { useEffect, useState } from 'react';
346
- import type { NeetruUser } from '@neetru/sdk';
347
-
348
- // [C1] Falha rápido se NEXT_PUBLIC_NEETRU_ENV não estiver configurada —
349
- // nunca defaulta silenciosamente pra 'dev' em produção.
350
- const _neetruEnv = process.env.NEXT_PUBLIC_NEETRU_ENV;
351
- if (!_neetruEnv) {
352
- throw new Error(
353
- 'NEXT_PUBLIC_NEETRU_ENV não está definida. ' +
354
- 'Defina como "prod" no ambiente de produção e "dev" no ambiente de desenvolvimento. ' +
355
- 'Exemplo: NEXT_PUBLIC_NEETRU_ENV=prod',
356
- );
357
- }
358
- const neetru = createNeetruClient({
359
- apiKey: process.env.NEXT_PUBLIC_NEETRU_API_KEY,
360
- env: _neetruEnv as 'dev' | 'prod',
361
- });
362
-
363
- export default function HomePage() {
364
- const [user, setUser] = useState<NeetruUser | null>(null);
365
- const [loading, setLoading] = useState(true);
366
-
367
- useEffect(() => {
368
- let unsub: (() => void) | undefined;
369
- neetru.auth.getUser().then((u) => {
370
- setUser(u);
371
- setLoading(false);
372
- });
373
- unsub = neetru.auth.onAuthStateChanged((u) => setUser(u));
374
- return () => unsub?.();
375
- }, []);
376
-
377
- if (loading) return <main><p>Carregando...</p></main>;
378
- if (!user) {
379
- return (
380
- <main>
381
- <h1>${name}</h1>
382
- <button onClick={() => neetru.auth.signIn()}>Entrar com Neetru</button>
383
- </main>
384
- );
385
- }
386
- return (
387
- <main>
388
- <h1>Bem-vindo, {user.email}</h1>
389
- <p>UID: {user.uid}</p>
390
- <button onClick={() => neetru.auth.signOut()}>Sair</button>
391
- </main>
392
- );
393
- }
339
+ await write(path.join(dir, 'src', 'app', 'page.tsx'), `// Produto Neetru — gerado por neetru init
340
+ // Auth via @neetru/sdk client (createNeetruClient + auth namespace)
341
+
342
+ 'use client';
343
+
344
+ import { createNeetruClient } from '@neetru/sdk';
345
+ import { useEffect, useState } from 'react';
346
+ import type { NeetruUser } from '@neetru/sdk';
347
+
348
+ // [C1] Falha rápido se NEXT_PUBLIC_NEETRU_ENV não estiver configurada —
349
+ // nunca defaulta silenciosamente pra 'dev' em produção.
350
+ const _neetruEnv = process.env.NEXT_PUBLIC_NEETRU_ENV;
351
+ if (!_neetruEnv) {
352
+ throw new Error(
353
+ 'NEXT_PUBLIC_NEETRU_ENV não está definida. ' +
354
+ 'Defina como "prod" no ambiente de produção e "dev" no ambiente de desenvolvimento. ' +
355
+ 'Exemplo: NEXT_PUBLIC_NEETRU_ENV=prod',
356
+ );
357
+ }
358
+ const neetru = createNeetruClient({
359
+ apiKey: process.env.NEXT_PUBLIC_NEETRU_API_KEY,
360
+ env: _neetruEnv as 'dev' | 'prod',
361
+ });
362
+
363
+ export default function HomePage() {
364
+ const [user, setUser] = useState<NeetruUser | null>(null);
365
+ const [loading, setLoading] = useState(true);
366
+
367
+ useEffect(() => {
368
+ let unsub: (() => void) | undefined;
369
+ neetru.auth.getUser().then((u) => {
370
+ setUser(u);
371
+ setLoading(false);
372
+ });
373
+ unsub = neetru.auth.onAuthStateChanged((u) => setUser(u));
374
+ return () => unsub?.();
375
+ }, []);
376
+
377
+ if (loading) return <main><p>Carregando...</p></main>;
378
+ if (!user) {
379
+ return (
380
+ <main>
381
+ <h1>${name}</h1>
382
+ <button onClick={() => neetru.auth.signIn()}>Entrar com Neetru</button>
383
+ </main>
384
+ );
385
+ }
386
+ return (
387
+ <main>
388
+ <h1>Bem-vindo, {user.email}</h1>
389
+ <p>UID: {user.uid}</p>
390
+ <button onClick={() => neetru.auth.signOut()}>Sair</button>
391
+ </main>
392
+ );
393
+ }
394
394
  `);
395
395
  // Middleware Next.js — gate de cookie de sessão em rotas privadas
396
- await write(path.join(dir, 'src', 'middleware.ts'), `import { NextRequest, NextResponse } from 'next/server';
397
-
398
- const PUBLIC_PATHS = ['/login', '/api/auth', '/_next', '/favicon.ico'];
399
-
400
- export function middleware(request: NextRequest) {
401
- const { pathname } = request.nextUrl;
402
- if (PUBLIC_PATHS.some((p) => pathname.startsWith(p))) {
403
- return NextResponse.next();
404
- }
405
-
406
- const hasSession = request.cookies.has('__session');
407
- if (!hasSession) {
408
- const url = request.nextUrl.clone();
409
- url.pathname = '/login';
410
- return NextResponse.redirect(url);
411
- }
412
-
413
- return NextResponse.next();
414
- }
415
-
416
- export const config = {
417
- matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
418
- };
396
+ await write(path.join(dir, 'src', 'middleware.ts'), `import { NextRequest, NextResponse } from 'next/server';
397
+
398
+ const PUBLIC_PATHS = ['/login', '/api/auth', '/_next', '/favicon.ico'];
399
+
400
+ export function middleware(request: NextRequest) {
401
+ const { pathname } = request.nextUrl;
402
+ if (PUBLIC_PATHS.some((p) => pathname.startsWith(p))) {
403
+ return NextResponse.next();
404
+ }
405
+
406
+ const hasSession = request.cookies.has('__session');
407
+ if (!hasSession) {
408
+ const url = request.nextUrl.clone();
409
+ url.pathname = '/login';
410
+ return NextResponse.redirect(url);
411
+ }
412
+
413
+ return NextResponse.next();
414
+ }
415
+
416
+ export const config = {
417
+ matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
418
+ };
419
419
  `);
420
420
  // tsconfig.json
421
421
  await write(path.join(dir, 'tsconfig.json'), JSON.stringify({
@@ -461,59 +461,59 @@ async function scaffoldNodeApi(dir, name, write) {
461
461
  '@types/node': '^22.0.0',
462
462
  },
463
463
  }, null, 2));
464
- await write(path.join(dir, 'src', 'index.ts'), `import Fastify from 'fastify';
465
- import { createNeetruClient } from '@neetru/sdk';
466
-
467
- // Padrão @neetru/sdk@1.1 — namespaces server-side: entitlements/usage/telemetry.
468
- // [C1] Falha rápido se NEETRU_ENV não estiver configurada.
469
- const _neetruEnv = process.env.NEETRU_ENV;
470
- if (!_neetruEnv) {
471
- throw new Error(
472
- 'NEETRU_ENV não está definida. ' +
473
- 'Defina como "prod" no ambiente de produção e "dev" no ambiente de desenvolvimento. ' +
474
- 'Exemplo: NEETRU_ENV=prod',
475
- );
476
- }
477
- // [C2] NEETRU_API_KEY é obrigatória — falha rápido com mensagem clara.
478
- const apiKey = process.env.NEETRU_API_KEY;
479
- if (!apiKey) {
480
- throw new Error(
481
- 'NEETRU_API_KEY é obrigatória. Configure a variável de ambiente antes de iniciar o servidor.',
482
- );
483
- }
484
- const neetru = createNeetruClient({
485
- apiKey,
486
- env: _neetruEnv as 'dev' | 'prod',
487
- });
488
-
489
- const PRODUCT_SLUG = process.env.NEETRU_PRODUCT_SLUG ?? '${name}';
490
-
491
- const app = Fastify({ logger: true });
492
-
493
- function requireEntitlement(feature: string) {
494
- return async (
495
- _request: import('fastify').FastifyRequest,
496
- reply: import('fastify').FastifyReply,
497
- ) => {
498
- const allowed = await neetru.entitlements.check(PRODUCT_SLUG, feature);
499
- if (!allowed) {
500
- return reply.code(403).send({ error: 'entitlement_denied', feature });
501
- }
502
- };
503
- }
504
-
505
- app.get('/health', async () => ({ status: 'ok' }));
506
-
507
- app.get(
508
- '/api/data',
509
- { preHandler: requireEntitlement('api-access') },
510
- async () => {
511
- await neetru.usage.report('api_call', 1, { productId: PRODUCT_SLUG });
512
- return { data: [] };
513
- },
514
- );
515
-
516
- await app.listen({ port: 3000, host: '0.0.0.0' });
464
+ await write(path.join(dir, 'src', 'index.ts'), `import Fastify from 'fastify';
465
+ import { createNeetruClient } from '@neetru/sdk';
466
+
467
+ // Padrão @neetru/sdk@1.1 — namespaces server-side: entitlements/usage/telemetry.
468
+ // [C1] Falha rápido se NEETRU_ENV não estiver configurada.
469
+ const _neetruEnv = process.env.NEETRU_ENV;
470
+ if (!_neetruEnv) {
471
+ throw new Error(
472
+ 'NEETRU_ENV não está definida. ' +
473
+ 'Defina como "prod" no ambiente de produção e "dev" no ambiente de desenvolvimento. ' +
474
+ 'Exemplo: NEETRU_ENV=prod',
475
+ );
476
+ }
477
+ // [C2] NEETRU_API_KEY é obrigatória — falha rápido com mensagem clara.
478
+ const apiKey = process.env.NEETRU_API_KEY;
479
+ if (!apiKey) {
480
+ throw new Error(
481
+ 'NEETRU_API_KEY é obrigatória. Configure a variável de ambiente antes de iniciar o servidor.',
482
+ );
483
+ }
484
+ const neetru = createNeetruClient({
485
+ apiKey,
486
+ env: _neetruEnv as 'dev' | 'prod',
487
+ });
488
+
489
+ const PRODUCT_SLUG = process.env.NEETRU_PRODUCT_SLUG ?? '${name}';
490
+
491
+ const app = Fastify({ logger: true });
492
+
493
+ function requireEntitlement(feature: string) {
494
+ return async (
495
+ _request: import('fastify').FastifyRequest,
496
+ reply: import('fastify').FastifyReply,
497
+ ) => {
498
+ const allowed = await neetru.entitlements.check(PRODUCT_SLUG, feature);
499
+ if (!allowed) {
500
+ return reply.code(403).send({ error: 'entitlement_denied', feature });
501
+ }
502
+ };
503
+ }
504
+
505
+ app.get('/health', async () => ({ status: 'ok' }));
506
+
507
+ app.get(
508
+ '/api/data',
509
+ { preHandler: requireEntitlement('api-access') },
510
+ async () => {
511
+ await neetru.usage.report('api_call', 1, { productId: PRODUCT_SLUG });
512
+ return { data: [] };
513
+ },
514
+ );
515
+
516
+ await app.listen({ port: 3000, host: '0.0.0.0' });
517
517
  `);
518
518
  }
519
519
  //# sourceMappingURL=init.js.map
@@ -0,0 +1,36 @@
1
+ export declare function getCacheDir(): string;
2
+ /**
3
+ * Resolve o diretorio fonte das skills no cache local.
4
+ *
5
+ * Suporta 2 estruturas no repo neetru-libs/claude-skills/:
6
+ *
7
+ * 1. Marketplace estruturado (atual): plugins/PLUGIN/skills/SKILL/SKILL.md
8
+ * - descobre todos os plugins/PLUGIN/skills/ e retorna o primeiro.
9
+ * 2. Plugin direto (legado): skills/SKILL/SKILL.md
10
+ * - retorna single path.
11
+ *
12
+ * Pra simplicidade, esta funcao devolve UMA root virtual:
13
+ * - Se existir claude-skills/plugins/PLUGIN/skills/, retorna a primeira (assume 1 plugin).
14
+ * - Senao, fallback pra claude-skills/skills/ (estrutura legada).
15
+ */
16
+ export declare function getSkillsSourceDir(): string;
17
+ export declare function getClaudeSkillsDir(): string;
18
+ export interface SkillInfo {
19
+ name: string;
20
+ description: string;
21
+ version: string;
22
+ installed: boolean;
23
+ }
24
+ export declare function listAvailableSkills(): Promise<SkillInfo[]>;
25
+ export declare function runSkillsInstall(): Promise<void>;
26
+ export declare function runSkillsUpdate(): Promise<void>;
27
+ export declare function runSkillsList(): Promise<void>;
28
+ export declare function runSkillsUninstall(opts?: {
29
+ yes?: boolean;
30
+ }): Promise<void>;
31
+ export declare function runSdkInit(): Promise<void>;
32
+ export declare function runSdkTemplates(): Promise<void>;
33
+ export declare function runSdkAddTemplate(template: string, opts?: {
34
+ force?: boolean;
35
+ }): Promise<void>;
36
+ export declare function runMarketplaceBrowse(): Promise<void>;