paris-immersion 0.1.20 → 0.1.21

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.
@@ -2,7 +2,32 @@ import { hostname, platform } from 'node:os';
2
2
  import { setTimeout as delay } from 'node:timers/promises';
3
3
  import { apiFetch, ApiError, defaultApiUrl } from '../lib/api.js';
4
4
  import { writeCredentials } from '../lib/credentials.js';
5
+ import { daemonStatus, restartDaemon } from '../lib/daemon.js';
5
6
  import { c } from '../lib/colors.js';
7
+ /**
8
+ * Após um login bem-sucedido, religa o daemon do `paris serve` SE ele já estiver
9
+ * instalado. Sem isto, o daemon em execução segue com o loginToken ANTIGO em
10
+ * memória (capturado no boot — `relay-agent.ts` nunca relê o disco): `paris login`
11
+ * gravava as credenciais novas mas o agente vivo não as via, então um re-login NÃO
12
+ * alcançava o terminal embutido (ficava "Esperando o agente" pra sempre, mesmo o
13
+ * aluno tendo relogado — bug real, a tela escalada manda exatamente `paris login`).
14
+ * Reiniciar faz o launchd/systemd subir um processo NOVO que lê o token fresco e
15
+ * reconecta ao relay. Best-effort (nunca derruba o login). Guard por daemonStatus()
16
+ * pra não auto-instalar serviço em quem só roda `paris login` fora do onboarding —
17
+ * e pra ser no-op no 1º install (o daemon ainda nem existe; o `paris daemon install`
18
+ * do instalador cuida disso logo depois).
19
+ */
20
+ async function refreshDaemonAfterLogin() {
21
+ try {
22
+ if (!(await daemonStatus()))
23
+ return;
24
+ const { mechanism } = await restartDaemon();
25
+ console.log(c.dim(` Agente do terminal embutido religado (${mechanism}).`));
26
+ }
27
+ catch {
28
+ /* best-effort — o token já está no disco; o daemon religa no próximo boot/restart */
29
+ }
30
+ }
6
31
  export async function loginCommand(opts) {
7
32
  const apiUrl = opts.apiUrl ?? defaultApiUrl();
8
33
  // --token: skip device-code flow. Usado pelo installer (PARIS_ONBOARDING_TOKEN
@@ -25,6 +50,7 @@ export async function loginCommand(opts) {
25
50
  });
26
51
  console.log(c.green(`✓ Autenticado como ${me.email}.`));
27
52
  console.log(c.dim(' Token salvo em ~/.paris/credentials.'));
53
+ await refreshDaemonAfterLogin();
28
54
  return;
29
55
  }
30
56
  catch (err) {
@@ -74,6 +100,7 @@ export async function loginCommand(opts) {
74
100
  });
75
101
  console.log(c.green(`✓ Autenticado como ${poll.user.email}.`));
76
102
  console.log(c.dim(` Token salvo em ~/.paris/credentials.`));
103
+ await refreshDaemonAfterLogin();
77
104
  return;
78
105
  }
79
106
  if (poll.status === 'authorization_pending') {
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { tostudyLoginCommand } from './commands/tostudy-login.js';
14
14
  const program = new Command()
15
15
  .name('paris')
16
16
  .description('Paris Immersion — CLI do aluno (login, workspace, tarefas)')
17
- .version('0.1.20');
17
+ .version('0.1.21');
18
18
  program
19
19
  .command('login')
20
20
  .description('Autenticar com sua conta Paris (device-code OR --token direto)')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paris-immersion",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Paris Immersion CLI — login, install workspace, status, task control. Para alunos das imersões da Paris Group.",
5
5
  "homepage": "https://parisgroup.ai",
6
6
  "repository": {