paris-immersion 0.1.8 → 0.1.9

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.
@@ -38,9 +38,19 @@ export interface ServeHandle {
38
38
  close: () => void;
39
39
  }
40
40
  /**
41
- * Spawn the coached pty (`claude '/tostudy'` inside the provisioned workspace).
42
- * Shared by the local ws server and the relay agent. Throws if node-pty can't
43
- * load/spawn — callers report it on their channel.
41
+ * Descobre o slash-command do tutor pra injetar no kickoff. O `@tostudy-ai/cli`
42
+ * instala o comando com nome ESPECÍFICO do curso (`.claude/commands/tostudy-<slug>.md`),
43
+ * NÃO `/tostudy` — então cravar `/tostudy` dava "Unknown command: /tostudy" e o
44
+ * curso não iniciava. Aqui varremos `.claude/commands/tostudy*.md` e usamos o
45
+ * comando real; com vários cursos, casamos com o `slug` ativo do
46
+ * `.tostudy/workspace.json`. Override explícito via PARIS_COACH_KICKOFF.
47
+ * Fallback `/tostudy` (legado / antes do `tostudy` instalar o comando).
48
+ */
49
+ export declare function resolveKickoff(cwd: string): string;
50
+ /**
51
+ * Spawn the coached pty (`claude '/tostudy-<curso>'` inside the provisioned
52
+ * workspace). Shared by the local ws server and the relay agent. Throws if
53
+ * node-pty can't load/spawn — callers report it on their channel.
44
54
  */
45
55
  export declare function spawnCoachPty(cwd: string): IPty;
46
56
  /**
@@ -1,6 +1,6 @@
1
1
  import { WebSocketServer } from 'ws';
2
2
  import { createRequire } from 'node:module';
3
- import { promises as fs, chmodSync, existsSync, statSync } from 'node:fs';
3
+ import { promises as fs, chmodSync, existsSync, statSync, readdirSync, readFileSync } from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { readCredentials } from '../lib/credentials.js';
6
6
  import { ensureWorkspace } from './install.js';
@@ -69,20 +69,60 @@ const DEFAULT_ALLOWED_ORIGINS = [
69
69
  // `/tostudy` roda o curso real direto. Override com PARIS_COACH_KICKOFF se uma
70
70
  // turma precisar de outro entrypoint (ex.: o tutor-paris `get_course` como
71
71
  // fallback quando não há curso ToStudy configurado).
72
- const COACH_KICKOFF = process.env.PARIS_COACH_KICKOFF || '/tostudy';
73
72
  /**
74
- * Spawn the coached pty (`claude '/tostudy'` inside the provisioned workspace).
75
- * Shared by the local ws server and the relay agent. Throws if node-pty can't
76
- * load/spawn — callers report it on their channel.
73
+ * Descobre o slash-command do tutor pra injetar no kickoff. O `@tostudy-ai/cli`
74
+ * instala o comando com nome ESPECÍFICO do curso (`.claude/commands/tostudy-<slug>.md`),
75
+ * NÃO `/tostudy` — então cravar `/tostudy` dava "Unknown command: /tostudy" e o
76
+ * curso não iniciava. Aqui varremos `.claude/commands/tostudy*.md` e usamos o
77
+ * comando real; com vários cursos, casamos com o `slug` ativo do
78
+ * `.tostudy/workspace.json`. Override explícito via PARIS_COACH_KICKOFF.
79
+ * Fallback `/tostudy` (legado / antes do `tostudy` instalar o comando).
80
+ */
81
+ export function resolveKickoff(cwd) {
82
+ const override = process.env.PARIS_COACH_KICKOFF;
83
+ if (override)
84
+ return override;
85
+ try {
86
+ const cmdDir = path.join(cwd, '.claude', 'commands');
87
+ const files = readdirSync(cmdDir).filter((f) => /^tostudy.*\.md$/i.test(f));
88
+ if (files.length === 0)
89
+ return '/tostudy';
90
+ let chosen = files.sort()[0];
91
+ if (files.length > 1) {
92
+ try {
93
+ const ws = JSON.parse(readFileSync(path.join(cwd, '.tostudy', 'workspace.json'), 'utf8'));
94
+ const slug = ws.slug?.toLowerCase();
95
+ if (slug) {
96
+ const match = files.find((f) => f.toLowerCase() === `tostudy-${slug}.md`) ??
97
+ files.find((f) => f.toLowerCase().includes(slug));
98
+ if (match)
99
+ chosen = match;
100
+ }
101
+ }
102
+ catch {
103
+ /* sem workspace.json legível — usa o primeiro */
104
+ }
105
+ }
106
+ return '/' + chosen.replace(/\.md$/i, '');
107
+ }
108
+ catch {
109
+ return '/tostudy';
110
+ }
111
+ }
112
+ /**
113
+ * Spawn the coached pty (`claude '/tostudy-<curso>'` inside the provisioned
114
+ * workspace). Shared by the local ws server and the relay agent. Throws if
115
+ * node-pty can't load/spawn — callers report it on their channel.
77
116
  */
78
117
  export function spawnCoachPty(cwd) {
79
118
  const req = createRequire(import.meta.url);
80
119
  ensureSpawnHelperExecutable(req);
81
120
  const ptyMod = req('node-pty');
121
+ const kickoff = resolveKickoff(cwd);
82
122
  const shell = process.env.SHELL || (process.platform === 'win32' ? 'powershell.exe' : 'bash');
83
123
  const shellArgs = process.platform === 'win32'
84
- ? ['-NoLogo', '-Command', `claude "${COACH_KICKOFF.replace(/"/g, '`"')}"`]
85
- : ['-l', '-c', `claude '${COACH_KICKOFF.replace(/'/g, `'\\''`)}'`];
124
+ ? ['-NoLogo', '-Command', `claude "${kickoff.replace(/"/g, '`"')}"`]
125
+ : ['-l', '-c', `claude '${kickoff.replace(/'/g, `'\\''`)}'`];
86
126
  return ptyMod.spawn(shell, shellArgs, {
87
127
  name: 'xterm-color',
88
128
  cols: 80,
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { daemonCommand } from './commands/daemon.js';
13
13
  const program = new Command()
14
14
  .name('paris')
15
15
  .description('Paris Immersion — CLI do aluno (login, workspace, tarefas)')
16
- .version('0.1.8');
16
+ .version('0.1.9');
17
17
  program
18
18
  .command('login')
19
19
  .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.8",
3
+ "version": "0.1.9",
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": {