holohq 0.0.0-stage → 0.1.0

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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.fr.md +137 -0
  3. package/README.md +136 -2
  4. package/bin/holohq.js +12 -0
  5. package/dist/server/server/actions/clone.js +36 -0
  6. package/dist/server/server/actions/newProject.js +40 -0
  7. package/dist/server/server/actions/publish.js +22 -0
  8. package/dist/server/server/app.js +42 -0
  9. package/dist/server/server/autostart.js +127 -0
  10. package/dist/server/server/autostartRun.js +96 -0
  11. package/dist/server/server/browser.js +24 -0
  12. package/dist/server/server/cache.js +24 -0
  13. package/dist/server/server/cli/autostart.js +21 -0
  14. package/dist/server/server/cli/config.js +45 -0
  15. package/dist/server/server/cli/convention.js +51 -0
  16. package/dist/server/server/cli/io.js +1 -0
  17. package/dist/server/server/cli/main.js +129 -0
  18. package/dist/server/server/config.js +305 -0
  19. package/dist/server/server/demo/config.js +19 -0
  20. package/dist/server/server/demo/data.js +306 -0
  21. package/dist/server/server/demo/deps.js +22 -0
  22. package/dist/server/server/demo/run.js +278 -0
  23. package/dist/server/server/demo/scan.js +21 -0
  24. package/dist/server/server/domain/home.js +85 -0
  25. package/dist/server/server/domain/journal.js +33 -0
  26. package/dist/server/server/domain/sprint.js +9 -0
  27. package/dist/server/server/exec.js +12 -0
  28. package/dist/server/server/git/status.js +45 -0
  29. package/dist/server/server/github/gh.js +27 -0
  30. package/dist/server/server/github/labels.js +65 -0
  31. package/dist/server/server/github/project.js +56 -0
  32. package/dist/server/server/github/repos.js +17 -0
  33. package/dist/server/server/github/write.js +91 -0
  34. package/dist/server/server/guard.js +18 -0
  35. package/dist/server/server/index.js +9 -0
  36. package/dist/server/server/launch.js +146 -0
  37. package/dist/server/server/paths.js +26 -0
  38. package/dist/server/server/preload.js +30 -0
  39. package/dist/server/server/projects/remote.js +13 -0
  40. package/dist/server/server/projects/scan.js +79 -0
  41. package/dist/server/server/routes/actions.js +89 -0
  42. package/dist/server/server/routes/autostart.js +21 -0
  43. package/dist/server/server/routes/detail.js +24 -0
  44. package/dist/server/server/routes/home.js +64 -0
  45. package/dist/server/server/routes/launch.js +44 -0
  46. package/dist/server/server/routes/projects.js +63 -0
  47. package/dist/server/server/routes/remotes.js +30 -0
  48. package/dist/server/server/routes/setup.js +114 -0
  49. package/dist/server/server/routes/write.js +129 -0
  50. package/dist/server/server/setup/tools.js +37 -0
  51. package/dist/server/server/skills.js +69 -0
  52. package/dist/server/server/start.js +160 -0
  53. package/dist/server/server/static.js +49 -0
  54. package/dist/server/shared/color.js +59 -0
  55. package/dist/server/shared/errors.js +84 -0
  56. package/dist/server/shared/ideas.js +36 -0
  57. package/dist/server/shared/labels.js +36 -0
  58. package/dist/server/shared/repoName.js +13 -0
  59. package/dist/server/shared/themes.js +118 -0
  60. package/dist/server/shared/tiers.js +15 -0
  61. package/dist/server/shared/types.js +1 -0
  62. package/dist/web/assets/Globe-BQOGOJCc.js +4273 -0
  63. package/dist/web/assets/index-BBiWQTd5.js +11 -0
  64. package/dist/web/assets/index-CoHzgpbC.css +1 -0
  65. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  66. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  67. package/dist/web/assets/jetbrains-mono-cyrillic-600-normal-8K4wrrwR.woff +0 -0
  68. package/dist/web/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
  69. package/dist/web/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  70. package/dist/web/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  71. package/dist/web/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
  72. package/dist/web/assets/jetbrains-mono-greek-600-normal-mc2nkWzM.woff +0 -0
  73. package/dist/web/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  74. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  75. package/dist/web/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
  76. package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  77. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  78. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  79. package/dist/web/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
  80. package/dist/web/assets/jetbrains-mono-latin-ext-600-normal-DObL3zCW.woff +0 -0
  81. package/dist/web/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  82. package/dist/web/assets/jetbrains-mono-vietnamese-600-normal-OWROknRo.woff +0 -0
  83. package/dist/web/assets/rajdhani-devanagari-500-normal-BPH8g_s8.woff +0 -0
  84. package/dist/web/assets/rajdhani-devanagari-500-normal-B_DH_jja.woff2 +0 -0
  85. package/dist/web/assets/rajdhani-devanagari-600-normal-BtY48IV_.woff +0 -0
  86. package/dist/web/assets/rajdhani-devanagari-600-normal-DhS7ScYx.woff2 +0 -0
  87. package/dist/web/assets/rajdhani-devanagari-700-normal-BQQOj9BB.woff2 +0 -0
  88. package/dist/web/assets/rajdhani-devanagari-700-normal-DBRwWuxA.woff +0 -0
  89. package/dist/web/assets/rajdhani-latin-500-normal-ByNUCHrt.woff2 +0 -0
  90. package/dist/web/assets/rajdhani-latin-500-normal-DfvNI-Td.woff +0 -0
  91. package/dist/web/assets/rajdhani-latin-600-normal-CXCVEoA9.woff2 +0 -0
  92. package/dist/web/assets/rajdhani-latin-600-normal-Dx02qI2_.woff +0 -0
  93. package/dist/web/assets/rajdhani-latin-700-normal-BPDUZo87.woff2 +0 -0
  94. package/dist/web/assets/rajdhani-latin-700-normal-e0Uj8ZlN.woff +0 -0
  95. package/dist/web/assets/rajdhani-latin-ext-500-normal-CyRWJZ5B.woff +0 -0
  96. package/dist/web/assets/rajdhani-latin-ext-500-normal-DiyUS11w.woff2 +0 -0
  97. package/dist/web/assets/rajdhani-latin-ext-600-normal-BleIgkPp.woff +0 -0
  98. package/dist/web/assets/rajdhani-latin-ext-600-normal-C9ZjJQAt.woff2 +0 -0
  99. package/dist/web/assets/rajdhani-latin-ext-700-normal-BPaQ7tlD.woff +0 -0
  100. package/dist/web/assets/rajdhani-latin-ext-700-normal-S6aYESQK.woff2 +0 -0
  101. package/dist/web/index.html +13 -0
  102. package/package.json +74 -4
  103. package/scripts/autostart.ps1 +28 -0
  104. package/scripts/start-hidden.vbs +12 -0
  105. package/templates/en/CLAUDE.md +18 -0
  106. package/templates/en/README.md +3 -0
  107. package/templates/fr/CLAUDE.md +18 -0
  108. package/templates/fr/README.md +3 -0
@@ -0,0 +1,96 @@
1
+ import { dirname } from 'node:path';
2
+ import { autostartPlan, forSystemd } from './autostart.js';
3
+ /** Active (`on`) ou retire (`off`) le démarrage automatique ; `steps` est le journal anglais (utilisé par le CLI). */
4
+ export async function runAutostart(mode, deps) {
5
+ const steps = [];
6
+ const written = [];
7
+ const runCmd = async (c) => {
8
+ steps.push(`> ${[c.cmd, ...c.args].join(' ')}`);
9
+ const { stdout } = await deps.exec(c.cmd, c.args);
10
+ if (stdout.trim())
11
+ steps.push(stdout.trim());
12
+ };
13
+ if (mode === 'on' && deps.pkg.split(/[\\/]/).includes('_npx')) {
14
+ return { ok: false, code: 'autostartFailed', detail: 'holohq is running from the npx cache, which is temporary. Run "npm i -g holohq" first, then "holohq autostart on".', steps };
15
+ }
16
+ try {
17
+ const { platform } = deps;
18
+ let plan = autostartPlan(platform, { node: deps.node, entry: deps.entry, home: deps.home, env: deps.env, pkg: deps.pkg });
19
+ if (platform !== 'win32' && platform !== 'darwin')
20
+ plan = forSystemd(plan, deps.has('systemctl'));
21
+ if (mode === 'on') {
22
+ for (const f of plan.files) {
23
+ steps.push(`Writing ${f.path}`);
24
+ await deps.fs.mkdir(dirname(f.path));
25
+ await deps.fs.writeFile(f.path, f.content);
26
+ written.push(f.path);
27
+ }
28
+ for (const c of plan.commands)
29
+ await runCmd(c);
30
+ // Le démarrage est enregistré : un échec du lancement immédiat ne l'annule pas.
31
+ for (const c of plan.start) {
32
+ try {
33
+ await runCmd(c);
34
+ }
35
+ catch (e) {
36
+ steps.push(`Could not start HoloHQ now (${e instanceof Error ? e.message : String(e)}); it will start at next logon.`);
37
+ }
38
+ }
39
+ steps.push('Autostart enabled.');
40
+ }
41
+ else {
42
+ for (const c of plan.remove.commands) {
43
+ try {
44
+ await runCmd(c);
45
+ }
46
+ catch (e) {
47
+ steps.push(`Ignored: ${e instanceof Error ? e.message : String(e)}`);
48
+ }
49
+ }
50
+ for (const p of plan.remove.files) {
51
+ steps.push(`Removing ${p}`);
52
+ await deps.fs.rm(p);
53
+ }
54
+ steps.push('Autostart disabled.');
55
+ }
56
+ return { ok: true, steps };
57
+ }
58
+ catch (e) {
59
+ // Échec de `on` : on retire ce qu'on a écrit, pour qu'un démarrage « raté » ne se charge pas à la prochaine ouverture de session.
60
+ if (mode === 'on')
61
+ for (const p of written)
62
+ await deps.fs.rm(p).catch(() => { });
63
+ return { ok: false, code: 'autostartFailed', detail: e instanceof Error ? e.message : String(e), steps };
64
+ }
65
+ }
66
+ /** execFile sans shell, sans fenêtre console, avec délai maximal (la requête ne reste jamais suspendue). */
67
+ export function makeExec(execFileFn) {
68
+ return (cmd, args) => new Promise((resolve, reject) => {
69
+ execFileFn(cmd, args, { windowsHide: true, timeout: 30000 }, (err, stdout) => (err ? reject(err) : resolve({ stdout: String(stdout) })));
70
+ });
71
+ }
72
+ /** Dépendances réelles (le CLI et le serveur) : execFile sans shell, vrai système de fichiers. */
73
+ export async function realAutostartDeps() {
74
+ const [{ execFile }, { mkdir, rm, writeFile }, { homedir }, { pathLookup }, { pkgPath, pkgRoot }] = await Promise.all([
75
+ import('node:child_process'),
76
+ import('node:fs/promises'),
77
+ import('node:os'),
78
+ import('./launch.js'),
79
+ import('./paths.js'),
80
+ ]);
81
+ return {
82
+ platform: process.platform,
83
+ env: process.env,
84
+ home: homedir(),
85
+ node: process.execPath,
86
+ entry: pkgPath('dist/server/server/index.js'),
87
+ pkg: pkgRoot(),
88
+ exec: makeExec(execFile),
89
+ fs: {
90
+ mkdir: async (p) => void (await mkdir(p, { recursive: true })),
91
+ writeFile: (p, c) => writeFile(p, c, 'utf8'),
92
+ rm: (p) => rm(p, { force: true }),
93
+ },
94
+ has: pathLookup(process.env, process.platform),
95
+ };
96
+ }
@@ -0,0 +1,24 @@
1
+ import { spawn } from 'node:child_process';
2
+ const URL_RE = /^http:\/\/localhost:\d{1,5}\/$/;
3
+ /** Commande d'ouverture du navigateur par défaut. L'URL doit être exactement http://localhost:<port>/ (aucun métacaractère possible). */
4
+ export function browserCommand(platform, url) {
5
+ if (!URL_RE.test(url))
6
+ throw new Error(`Refusing to open unexpected URL: ${url}`);
7
+ if (platform === 'win32')
8
+ return { cmd: 'cmd.exe', args: ['/c', 'start', '""', url] };
9
+ if (platform === 'darwin')
10
+ return { cmd: 'open', args: [url] };
11
+ return { cmd: 'xdg-open', args: [url] };
12
+ }
13
+ /** Ouvre l'URL dans le navigateur, détaché ; best-effort (un échec n'arrête pas le serveur). */
14
+ export function openBrowser(url, onError = () => { }) {
15
+ try {
16
+ const { cmd, args } = browserCommand(process.platform, url);
17
+ const child = spawn(cmd, args, { detached: true, stdio: 'ignore', windowsHide: true });
18
+ child.on('error', (e) => onError(`Could not open the browser (${cmd}): ${e.message}`));
19
+ child.unref();
20
+ }
21
+ catch (e) {
22
+ onError(e instanceof Error ? e.message : String(e));
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ // Cache GitHub mémoire (TTL en ms, horloge injectée).
2
+ const store = new Map();
3
+ export async function cached(key, ttlMs, now, load) {
4
+ const t = now().getTime();
5
+ const hit = store.get(key);
6
+ if (hit && t - hit.at < ttlMs)
7
+ return hit.value;
8
+ const value = load();
9
+ store.set(key, { at: t, value });
10
+ try {
11
+ return await value;
12
+ }
13
+ catch (e) {
14
+ if (store.get(key)?.value === value)
15
+ store.delete(key);
16
+ throw e;
17
+ }
18
+ }
19
+ export function clearCaches() {
20
+ store.clear();
21
+ }
22
+ export function forgetCached(key) {
23
+ store.delete(key);
24
+ }
@@ -0,0 +1,21 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { realAutostartDeps, runAutostart } from '../autostartRun.js';
3
+ export async function autostartCommand(args, io) {
4
+ const mode = args[0];
5
+ if (mode !== 'on' && mode !== 'off') {
6
+ io.err('Usage: holohq autostart on|off');
7
+ return 1;
8
+ }
9
+ const r = await runAutostart(mode, await realAutostartDeps());
10
+ for (const s of r.steps)
11
+ io.out(s);
12
+ if (!r.ok) {
13
+ io.err(r.detail);
14
+ return 1;
15
+ }
16
+ return 0;
17
+ }
18
+ // Enveloppe `npm run autostart` (exécution directe uniquement).
19
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
20
+ process.exit(await autostartCommand(process.argv.slice(2), { out: console.log, err: console.error }));
21
+ }
@@ -0,0 +1,45 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { configPath, defaultConfig, saveConfig, storedPort, validateConfigInput } from '../config.js';
5
+ const USAGE = 'Usage: holohq config path | import <file.json>';
6
+ export async function configCommand(args, io) {
7
+ const [mode, input] = args;
8
+ const file = configPath(process.env, process.platform, homedir());
9
+ if (mode === 'path') {
10
+ io.out(file);
11
+ return 0;
12
+ }
13
+ if (mode === 'import' && input) {
14
+ let body;
15
+ try {
16
+ body = JSON.parse(readFileSync(input, 'utf8'));
17
+ }
18
+ catch (e) {
19
+ io.err(`${input}: ${e instanceof Error ? e.message : String(e)}`);
20
+ return 1;
21
+ }
22
+ const checked = validateConfigInput(body);
23
+ if (!checked.ok) {
24
+ io.err(`${input}: ${checked.error}`);
25
+ return 1;
26
+ }
27
+ const defaults = defaultConfig(homedir(), existsSync, Intl.DateTimeFormat().resolvedOptions().locale);
28
+ const cfg = {
29
+ ...defaults,
30
+ ...checked.value,
31
+ port: storedPort(file),
32
+ skills: { ...defaults.skills, ...(checked.value.skills ?? {}) },
33
+ };
34
+ // L'ancien fichier, s'il existe, est conservé en .bak.
35
+ await saveConfig(file, cfg, true);
36
+ io.out(`Config imported to ${file}`);
37
+ return 0;
38
+ }
39
+ io.err(USAGE);
40
+ return 1;
41
+ }
42
+ // Enveloppe `npm run config` (exécution directe uniquement).
43
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
44
+ process.exit(await configCommand(process.argv.slice(2), { out: console.log, err: console.error }));
45
+ }
@@ -0,0 +1,51 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { configPath, loadConfig } from '../config.js';
5
+ import { run } from '../exec.js';
6
+ import { repoLabelSet } from '../github/labels.js';
7
+ import { ensureConvention } from '../github/write.js';
8
+ const USAGE = 'Usage: holohq convention <owner>/<repo> [--lang en|fr]';
9
+ export async function conventionCommand(args, io) {
10
+ let lang = null;
11
+ const rest = [];
12
+ for (let i = 0; i < args.length; i++) {
13
+ if (args[i] === '--lang') {
14
+ const v = args[++i];
15
+ if (v !== 'en' && v !== 'fr') {
16
+ io.err(USAGE);
17
+ return 1;
18
+ }
19
+ lang = v;
20
+ }
21
+ else
22
+ rest.push(args[i]);
23
+ }
24
+ const arg = rest[0] ?? '';
25
+ const m = rest.length === 1 ? arg.match(/^([A-Za-z0-9][A-Za-z0-9-]*)\/([A-Za-z0-9._-]+)$/) : null;
26
+ if (!m) {
27
+ io.err(USAGE);
28
+ return 1;
29
+ }
30
+ try {
31
+ const repo = { owner: m[1], name: m[2] };
32
+ const fallback = lang ?? loadConfig(configPath(process.env, process.platform, homedir()), {
33
+ home: homedir(),
34
+ exists: existsSync,
35
+ locale: Intl.DateTimeFormat().resolvedOptions().locale,
36
+ }).config.labelSet;
37
+ // Le jeu déjà présent dans le dépôt prime (jamais de second jeu) ; --lang ou la config ne servent que de repli.
38
+ const set = await repoLabelSet(run, repo, fallback);
39
+ const r = await ensureConvention(run, repo, set);
40
+ io.out(`Convention in place on ${arg} (labels ${set.lang})${r.journalCreated ? ' (journal created and pinned)' : ' (journal already present)'}.`);
41
+ return 0;
42
+ }
43
+ catch (e) {
44
+ io.err(e instanceof Error ? e.message : String(e));
45
+ return 1;
46
+ }
47
+ }
48
+ // Enveloppe `npm run convention` (exécution directe uniquement).
49
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
50
+ process.exit(await conventionCommand(process.argv.slice(2), { out: console.log, err: console.error }));
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,129 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { pkgPath } from '../paths.js';
3
+ import { startServer } from '../start.js';
4
+ import { autostartCommand } from './autostart.js';
5
+ import { configCommand } from './config.js';
6
+ import { conventionCommand } from './convention.js';
7
+ export const HELP = `HoloHQ - a holographic HUD cockpit for your GitHub projects.
8
+
9
+ Usage:
10
+ holohq [start] [--demo] [--no-open] [--port <n>] [--lang en|fr]
11
+ holohq autostart on|off
12
+ holohq convention <owner>/<repo> [--lang en|fr]
13
+ holohq config path | import <file.json>
14
+ holohq --version | -v
15
+ holohq --help | -h
16
+
17
+ Commands:
18
+ start Start HoloHQ and open it in your browser (default)
19
+ autostart Start HoloHQ automatically at login (on) or stop doing so (off)
20
+ convention Set up the label convention and journal issue on a repository
21
+ config Print the config file path, or import a config file
22
+
23
+ Options:
24
+ --demo Run on built-in sample data (default port 4243, nothing is read or written)
25
+ --no-open Do not open the browser
26
+ --port <n> Listen on this port (default: the configured port)
27
+ --lang en|fr Language of the demo data
28
+ --version Print the version
29
+ --help Print this help
30
+ `;
31
+ export function parseArgs(argv) {
32
+ const [first, ...tail] = argv;
33
+ switch (first) {
34
+ case '--version':
35
+ case '-v':
36
+ return { kind: 'version' };
37
+ case '--help':
38
+ case '-h':
39
+ return { kind: 'help' };
40
+ case 'autostart':
41
+ return tail.length === 1 && (tail[0] === 'on' || tail[0] === 'off')
42
+ ? { kind: 'autostart', mode: tail[0] }
43
+ : { kind: 'error', message: 'Usage: holohq autostart on|off' };
44
+ case 'convention':
45
+ return { kind: 'convention', args: tail };
46
+ case 'config':
47
+ return { kind: 'config', args: tail };
48
+ }
49
+ const rest = first === 'start' ? tail : argv;
50
+ const cmd = { kind: 'start', demo: false, open: true, port: null, lang: null };
51
+ for (let i = 0; i < rest.length; i++) {
52
+ const a = rest[i];
53
+ if (a === '--demo')
54
+ cmd.demo = true;
55
+ else if (a === '--no-open')
56
+ cmd.open = false;
57
+ else if (a === '--port') {
58
+ const v = rest[++i];
59
+ const n = Number(v);
60
+ if (v === undefined || !/^\d+$/.test(v) || n < 1 || n > 65535) {
61
+ return { kind: 'error', message: `Invalid port: ${v ?? '(missing)'}. Expected a number from 1 to 65535.` };
62
+ }
63
+ cmd.port = n;
64
+ }
65
+ else if (a === '--lang') {
66
+ const v = rest[++i];
67
+ if (v !== 'en' && v !== 'fr')
68
+ return { kind: 'error', message: `Invalid language: ${v ?? '(missing)'}. Expected en or fr.` };
69
+ cmd.lang = v;
70
+ }
71
+ else if (a === '--version' || a === '-v')
72
+ return { kind: 'version' };
73
+ else if (a === '--help' || a === '-h')
74
+ return { kind: 'help' };
75
+ else
76
+ return { kind: 'error', message: `Unknown command or option: ${a}` };
77
+ }
78
+ if (cmd.lang !== null && !cmd.demo)
79
+ return { kind: 'error', message: '--lang only applies to --demo' };
80
+ return cmd;
81
+ }
82
+ export async function main(argv, io) {
83
+ const cmd = parseArgs(argv);
84
+ try {
85
+ switch (cmd.kind) {
86
+ case 'version':
87
+ io.out(io.version());
88
+ return 0;
89
+ case 'help':
90
+ io.out(HELP);
91
+ return 0;
92
+ case 'autostart':
93
+ return await io.autostart([cmd.mode]);
94
+ case 'convention':
95
+ return await io.convention(cmd.args);
96
+ case 'config':
97
+ return await io.config(cmd.args);
98
+ case 'error':
99
+ io.err(cmd.message);
100
+ io.err('Run "holohq --help" for usage.'); // erreurs d'usage seulement
101
+ return 1;
102
+ case 'start':
103
+ await io.start({ demo: cmd.demo, open: cmd.open, port: cmd.port, lang: cmd.lang, dev: false });
104
+ return await new Promise(() => { }); // le serveur tourne jusqu'à Ctrl+C
105
+ }
106
+ }
107
+ catch (e) {
108
+ io.err(e instanceof Error ? e.message : String(e));
109
+ return 1;
110
+ }
111
+ }
112
+ export function realIo() {
113
+ const base = { out: (s) => console.log(s), err: (s) => console.error(s) };
114
+ return {
115
+ ...base,
116
+ start: async (opts) => {
117
+ const r = await startServer(opts);
118
+ if (r.reused) {
119
+ base.out(`HoloHQ is already running at ${r.url}`);
120
+ process.exit(0);
121
+ }
122
+ base.out(`HoloHQ is running at ${r.url} (Ctrl+C to stop)`);
123
+ },
124
+ version: () => JSON.parse(readFileSync(pkgPath('package.json'), 'utf8')).version,
125
+ autostart: (a) => autostartCommand(a, base),
126
+ convention: (a) => conventionCommand(a, base),
127
+ config: (a) => configCommand(a, base),
128
+ };
129
+ }