holohq 0.0.0-stage → 0.2.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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.fr.md +145 -0
  3. package/README.md +144 -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 +46 -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/claude/floor.js +408 -0
  14. package/dist/server/server/claude/history.js +268 -0
  15. package/dist/server/server/claude/prompt.js +8 -0
  16. package/dist/server/server/cli/autostart.js +21 -0
  17. package/dist/server/server/cli/config.js +45 -0
  18. package/dist/server/server/cli/convention.js +51 -0
  19. package/dist/server/server/cli/io.js +1 -0
  20. package/dist/server/server/cli/main.js +129 -0
  21. package/dist/server/server/config.js +311 -0
  22. package/dist/server/server/demo/config.js +19 -0
  23. package/dist/server/server/demo/data.js +317 -0
  24. package/dist/server/server/demo/deps.js +36 -0
  25. package/dist/server/server/demo/floor.js +45 -0
  26. package/dist/server/server/demo/run.js +315 -0
  27. package/dist/server/server/demo/scan.js +21 -0
  28. package/dist/server/server/domain/home.js +85 -0
  29. package/dist/server/server/domain/journal.js +33 -0
  30. package/dist/server/server/domain/sprint.js +9 -0
  31. package/dist/server/server/exec.js +12 -0
  32. package/dist/server/server/floor/attribute.js +74 -0
  33. package/dist/server/server/floor/evidence.js +39 -0
  34. package/dist/server/server/git/status.js +45 -0
  35. package/dist/server/server/github/gh.js +27 -0
  36. package/dist/server/server/github/labels.js +65 -0
  37. package/dist/server/server/github/project.js +58 -0
  38. package/dist/server/server/github/repos.js +17 -0
  39. package/dist/server/server/github/write.js +91 -0
  40. package/dist/server/server/guard.js +18 -0
  41. package/dist/server/server/index.js +9 -0
  42. package/dist/server/server/launch.js +168 -0
  43. package/dist/server/server/paths.js +26 -0
  44. package/dist/server/server/preload.js +30 -0
  45. package/dist/server/server/projects/remote.js +13 -0
  46. package/dist/server/server/projects/scan.js +79 -0
  47. package/dist/server/server/routes/actions.js +89 -0
  48. package/dist/server/server/routes/autostart.js +21 -0
  49. package/dist/server/server/routes/conversations.js +21 -0
  50. package/dist/server/server/routes/detail.js +24 -0
  51. package/dist/server/server/routes/floor.js +77 -0
  52. package/dist/server/server/routes/home.js +64 -0
  53. package/dist/server/server/routes/launch.js +79 -0
  54. package/dist/server/server/routes/projects.js +75 -0
  55. package/dist/server/server/routes/remotes.js +30 -0
  56. package/dist/server/server/routes/setup.js +114 -0
  57. package/dist/server/server/routes/write.js +129 -0
  58. package/dist/server/server/setup/tools.js +37 -0
  59. package/dist/server/server/skills.js +69 -0
  60. package/dist/server/server/start.js +166 -0
  61. package/dist/server/server/static.js +49 -0
  62. package/dist/server/shared/color.js +59 -0
  63. package/dist/server/shared/errors.js +88 -0
  64. package/dist/server/shared/ideas.js +36 -0
  65. package/dist/server/shared/labels.js +36 -0
  66. package/dist/server/shared/repoName.js +13 -0
  67. package/dist/server/shared/themes.js +120 -0
  68. package/dist/server/shared/tiers.js +15 -0
  69. package/dist/server/shared/types.js +1 -0
  70. package/dist/web/assets/Globe-ighOFp2V.js +4273 -0
  71. package/dist/web/assets/index-ByHbMQJl.js +11 -0
  72. package/dist/web/assets/index-DgR2KpYV.css +1 -0
  73. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  74. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  75. package/dist/web/assets/jetbrains-mono-cyrillic-600-normal-8K4wrrwR.woff +0 -0
  76. package/dist/web/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
  77. package/dist/web/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  78. package/dist/web/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  79. package/dist/web/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
  80. package/dist/web/assets/jetbrains-mono-greek-600-normal-mc2nkWzM.woff +0 -0
  81. package/dist/web/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  82. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  83. package/dist/web/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
  84. package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  85. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  86. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  87. package/dist/web/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
  88. package/dist/web/assets/jetbrains-mono-latin-ext-600-normal-DObL3zCW.woff +0 -0
  89. package/dist/web/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  90. package/dist/web/assets/jetbrains-mono-vietnamese-600-normal-OWROknRo.woff +0 -0
  91. package/dist/web/assets/rajdhani-devanagari-500-normal-BPH8g_s8.woff +0 -0
  92. package/dist/web/assets/rajdhani-devanagari-500-normal-B_DH_jja.woff2 +0 -0
  93. package/dist/web/assets/rajdhani-devanagari-600-normal-BtY48IV_.woff +0 -0
  94. package/dist/web/assets/rajdhani-devanagari-600-normal-DhS7ScYx.woff2 +0 -0
  95. package/dist/web/assets/rajdhani-devanagari-700-normal-BQQOj9BB.woff2 +0 -0
  96. package/dist/web/assets/rajdhani-devanagari-700-normal-DBRwWuxA.woff +0 -0
  97. package/dist/web/assets/rajdhani-latin-500-normal-ByNUCHrt.woff2 +0 -0
  98. package/dist/web/assets/rajdhani-latin-500-normal-DfvNI-Td.woff +0 -0
  99. package/dist/web/assets/rajdhani-latin-600-normal-CXCVEoA9.woff2 +0 -0
  100. package/dist/web/assets/rajdhani-latin-600-normal-Dx02qI2_.woff +0 -0
  101. package/dist/web/assets/rajdhani-latin-700-normal-BPDUZo87.woff2 +0 -0
  102. package/dist/web/assets/rajdhani-latin-700-normal-e0Uj8ZlN.woff +0 -0
  103. package/dist/web/assets/rajdhani-latin-ext-500-normal-CyRWJZ5B.woff +0 -0
  104. package/dist/web/assets/rajdhani-latin-ext-500-normal-DiyUS11w.woff2 +0 -0
  105. package/dist/web/assets/rajdhani-latin-ext-600-normal-BleIgkPp.woff +0 -0
  106. package/dist/web/assets/rajdhani-latin-ext-600-normal-C9ZjJQAt.woff2 +0 -0
  107. package/dist/web/assets/rajdhani-latin-ext-700-normal-BPaQ7tlD.woff +0 -0
  108. package/dist/web/assets/rajdhani-latin-ext-700-normal-S6aYESQK.woff2 +0 -0
  109. package/dist/web/index.html +13 -0
  110. package/package.json +74 -4
  111. package/scripts/autostart.ps1 +28 -0
  112. package/scripts/start-hidden.vbs +12 -0
  113. package/templates/en/CLAUDE.md +18 -0
  114. package/templates/en/README.md +3 -0
  115. package/templates/fr/CLAUDE.md +18 -0
  116. package/templates/fr/README.md +3 -0
@@ -0,0 +1,311 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { copyFile, mkdir, writeFile } from 'node:fs/promises';
3
+ import { dirname, posix, win32 } from 'node:path';
4
+ import { errorBody } from '../shared/errors.js';
5
+ import { parseHex } from '../shared/color.js';
6
+ import { DEFAULT_APPEARANCE, THEME_IDS, FLOOR_VIEWS } from '../shared/themes.js';
7
+ import { SKILL_NAME } from './skills.js';
8
+ /** Chemin du fichier de config de l'utilisateur, selon l'OS. */
9
+ export function configPath(env, platform, home) {
10
+ if (env.HOLOHQ_CONFIG)
11
+ return env.HOLOHQ_CONFIG;
12
+ if (platform === 'win32')
13
+ return win32.join(env.APPDATA || win32.join(home, 'AppData', 'Roaming'), 'holohq', 'config.json');
14
+ if (platform === 'darwin')
15
+ return posix.join(home, 'Library', 'Application Support', 'holohq', 'config.json');
16
+ return posix.join(env.XDG_CONFIG_HOME || posix.join(home, '.config'), 'holohq', 'config.json');
17
+ }
18
+ /** Langue tirée de la locale du système : français si elle commence par « fr », anglais sinon. */
19
+ export const localeLang = (locale) => (locale.toLowerCase().startsWith('fr') ? 'fr' : 'en');
20
+ /** Valeurs par défaut génériques, calculées pour la machine de l'utilisateur. */
21
+ export function defaultConfig(home, exists, locale) {
22
+ const p = home.includes('\\') ? win32 : posix;
23
+ const candidates = ['Projects', 'projects', 'code', 'dev', 'src'].map((n) => p.join(home, n));
24
+ const projectsRoot = candidates.find((c) => exists(c)) ?? candidates[0];
25
+ const lang = localeLang(locale);
26
+ return {
27
+ port: 4242,
28
+ owner: null,
29
+ projectsRoot,
30
+ roots: [projectsRoot],
31
+ exclude: [],
32
+ language: lang,
33
+ labelSet: lang,
34
+ editorCommand: 'code',
35
+ terminal: null,
36
+ globalSkillsDir: p.join(home, '.claude', 'skills'),
37
+ skills: { resume: 'holohq:catch-up', wrapUp: 'holohq:wrap-up', kickoff: 'holohq:kickoff' },
38
+ appearance: { ...DEFAULT_APPEARANCE },
39
+ };
40
+ }
41
+ const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
42
+ const isThemeId = (v) => typeof v === 'string' && THEME_IDS.includes(v);
43
+ const isEffects = (v) => v === 'full' || v === 'subtle';
44
+ const isFloor = (v) => FLOOR_VIEWS.includes(v);
45
+ /** Couleur `#rrggbb` normalisée en minuscules ; null sinon. */
46
+ const hexColor = (v) => (typeof v === 'string' && parseHex(v) ? v.toLowerCase() : null);
47
+ function customColors(v) {
48
+ if (!isObj(v))
49
+ return null;
50
+ const accent = hexColor(v.accent);
51
+ const accent2 = hexColor(v.accent2);
52
+ return accent && accent2 && (v.mode === 'dark' || v.mode === 'light') ? { accent, accent2, mode: v.mode } : null;
53
+ }
54
+ /**
55
+ * Apparence saisie : thème connu, couleurs `#rrggbb`, effets full/subtle, rendu de l'étage connu s'il est donné ; null si un champ est invalide.
56
+ * Perso exige ses deux couleurs (sinon l'interface afficherait Holo en croyant Perso choisi).
57
+ */
58
+ function appearanceInput(v) {
59
+ if (!isObj(v) || !isThemeId(v.theme) || !isEffects(v.effects))
60
+ return null;
61
+ if (v.floor !== undefined && !isFloor(v.floor))
62
+ return null;
63
+ const floor = v.floor === undefined ? {} : { floor: v.floor };
64
+ if (v.custom === undefined)
65
+ return v.theme === 'custom' ? null : { theme: v.theme, effects: v.effects, ...floor };
66
+ const custom = customColors(v.custom);
67
+ return custom ? { theme: v.theme, custom, effects: v.effects, ...floor } : null;
68
+ }
69
+ /** Apparence lue dans le fichier : chaque champ invalide revient au défaut (Perso invalide écarté, Perso sans couleurs → Holo). */
70
+ function appearanceFromFile(v) {
71
+ const a = isObj(v) ? v : {};
72
+ const custom = customColors(a.custom);
73
+ const theme = isThemeId(a.theme) && !(a.theme === 'custom' && !custom) ? a.theme : DEFAULT_APPEARANCE.theme;
74
+ const out = { theme, effects: isEffects(a.effects) ? a.effects : DEFAULT_APPEARANCE.effects };
75
+ if (custom)
76
+ out.custom = custom;
77
+ if (isFloor(a.floor))
78
+ out.floor = a.floor;
79
+ return out;
80
+ }
81
+ const OWNER_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
82
+ const isLang = (v) => v === 'en' || v === 'fr';
83
+ const bad = (field, reason) => ({ ok: false, ...errorBody('configInvalid', { field, reason }) });
84
+ /** Raison précise d'un refus : un tiret initial ou un caractère de contrôle se distinguent du motif général. */
85
+ function why(v, fallback) {
86
+ if (typeof v !== 'string')
87
+ return fallback;
88
+ const t = v.trim();
89
+ if (/[\0\r\n]/.test(t))
90
+ return 'controlChar';
91
+ return t.startsWith('-') ? 'leadingDash' : fallback;
92
+ }
93
+ /** Chaîne propre : non vide après trim, sans NUL ni saut de ligne, ne commençant pas par « - » (jamais prise pour une option). */
94
+ function cleanStr(v) {
95
+ if (typeof v !== 'string')
96
+ return null;
97
+ const t = v.trim();
98
+ return t === '' || t.startsWith('-') || /[\0\r\n]/.test(t) ? null : t;
99
+ }
100
+ const isAbs = (p, platform) => (platform === 'win32' ? win32 : posix).isAbsolute(p);
101
+ /** Sous Windows, la casse et le séparateur final ne comptent pas ; ailleurs, comparaison exacte. */
102
+ function samePath(a, b, platform) {
103
+ if (platform !== 'win32')
104
+ return a === b;
105
+ const norm = (p) => p.replace(/[\\/]+$/, '').toLowerCase();
106
+ return norm(a) === norm(b);
107
+ }
108
+ function absPath(v, platform) {
109
+ const t = cleanStr(v);
110
+ return t !== null && isAbs(t, platform) ? t : null;
111
+ }
112
+ /**
113
+ * Exécutable (éditeur, terminal) : nom ou chemin sans espace ni métacaractère shell.
114
+ * C'est toujours un exécutable lancé via execFile, jamais une chaîne shell.
115
+ */
116
+ const EXECUTABLE_RE = /^[A-Za-z0-9._\\/:+-]+$/;
117
+ function executable(v) {
118
+ const t = cleanStr(v);
119
+ return t !== null && EXECUTABLE_RE.test(t) ? t : null;
120
+ }
121
+ /**
122
+ * Valide une saisie de réglages (POST /api/config) ; ne garde que les champs connus, nettoyés (trim, doublons retirés).
123
+ * Les dossiers sont des chemins absolus (selon `platform`) ; `exclude` accepte aussi un simple nom de dossier.
124
+ */
125
+ export function validateConfigInput(body, platform = process.platform) {
126
+ if (body === null || typeof body !== 'object' || Array.isArray(body))
127
+ return { ok: false, ...errorBody('invalidJson') };
128
+ const b = body;
129
+ const value = {};
130
+ const projectsRoot = absPath(b.projectsRoot, platform);
131
+ if (projectsRoot === null)
132
+ return bad('projectsRoot', why(b.projectsRoot, 'absolutePath'));
133
+ value.projectsRoot = projectsRoot;
134
+ if (!Array.isArray(b.roots))
135
+ return bad('roots', 'absolutePath');
136
+ const roots = b.roots.map((r) => absPath(r, platform));
137
+ if (roots.some((r) => r === null))
138
+ return bad('roots', why(b.roots.find((r, i) => roots[i] === null), 'absolutePath'));
139
+ value.roots = [...new Set(roots)];
140
+ if (!value.roots.some((r) => samePath(r, projectsRoot, platform)))
141
+ return bad('projectsRoot', 'projectsRootNotInRoots');
142
+ if (!isLang(b.language))
143
+ return bad('language', 'language');
144
+ value.language = b.language;
145
+ if (b.exclude !== undefined) {
146
+ if (!Array.isArray(b.exclude))
147
+ return bad('exclude', 'excludeEntry');
148
+ const ex = b.exclude.map((e) => {
149
+ const t = cleanStr(e);
150
+ return t !== null && (isAbs(t, platform) || !/[\\/]/.test(t)) ? t : null;
151
+ });
152
+ if (ex.some((e) => e === null))
153
+ return bad('exclude', why(b.exclude.find((e, i) => ex[i] === null), 'excludeEntry'));
154
+ value.exclude = [...new Set(ex)];
155
+ }
156
+ if (b.labelSet !== undefined) {
157
+ if (!isLang(b.labelSet))
158
+ return bad('labelSet', 'language');
159
+ value.labelSet = b.labelSet;
160
+ }
161
+ if (b.editorCommand !== undefined) {
162
+ const e = executable(b.editorCommand);
163
+ if (e === null)
164
+ return bad('editorCommand', why(b.editorCommand, 'executable'));
165
+ value.editorCommand = e;
166
+ }
167
+ if (b.terminal !== undefined) {
168
+ if (b.terminal === null)
169
+ value.terminal = null;
170
+ else {
171
+ const t = executable(b.terminal);
172
+ if (t === null)
173
+ return bad('terminal', why(b.terminal, 'executable'));
174
+ value.terminal = t;
175
+ }
176
+ }
177
+ if (b.owner !== undefined) {
178
+ if (typeof b.owner !== 'string' || !OWNER_RE.test(b.owner))
179
+ return bad('owner', 'owner');
180
+ value.owner = b.owner;
181
+ }
182
+ if (b.skills !== undefined) {
183
+ const sk = b.skills;
184
+ if (sk === null || typeof sk !== 'object' || Array.isArray(sk))
185
+ return bad('skills', 'skill');
186
+ const out = {};
187
+ for (const [k, v] of Object.entries(sk)) {
188
+ if (k !== 'resume' && k !== 'wrapUp' && k !== 'kickoff')
189
+ return bad(`skills.${k}`, 'skill');
190
+ if (typeof v !== 'string' || !SKILL_NAME.test(v))
191
+ return bad(`skills.${k}`, 'skill');
192
+ out[k] = v;
193
+ }
194
+ value.skills = out;
195
+ }
196
+ if (b.appearance !== undefined) {
197
+ const a = appearanceInput(b.appearance);
198
+ if (a === null)
199
+ return bad('appearance', 'appearance');
200
+ value.appearance = a;
201
+ }
202
+ return { ok: true, value };
203
+ }
204
+ /** Port forcé par HOLOHQ_PORT (tests, second exemplaire) ; null si absent ou invalide. */
205
+ export function portFromEnv(env) {
206
+ const n = Number(env.HOLOHQ_PORT);
207
+ return Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
208
+ }
209
+ /** Écarte les champs du fichier dont la valeur est invalide (retour au défaut pour ce champ) ; garde la valeur nettoyée. */
210
+ function sanitizeUser(user, defaults) {
211
+ const need = { projectsRoot: defaults.projectsRoot, roots: defaults.roots, language: defaults.language };
212
+ const out = {};
213
+ const checked = (input) => {
214
+ const r = validateConfigInput({ ...need, ...input });
215
+ return r.ok ? r.value : null;
216
+ };
217
+ for (const [k, v] of Object.entries(user)) {
218
+ if (k === 'port') {
219
+ if (typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 65535)
220
+ out.port = v;
221
+ }
222
+ else if (k === 'owner') {
223
+ if (v === null || (typeof v === 'string' && OWNER_RE.test(v)))
224
+ out.owner = v;
225
+ }
226
+ else if (k === 'globalSkillsDir') {
227
+ const g = cleanStr(v);
228
+ if (g !== null)
229
+ out.globalSkillsDir = g;
230
+ }
231
+ else if (k === 'skills') {
232
+ // Une clé invalide n'invalide pas les autres.
233
+ if (v !== null && typeof v === 'object' && !Array.isArray(v)) {
234
+ const good = {};
235
+ for (const [sk, sv] of Object.entries(v)) {
236
+ const r = checked({ skills: { [sk]: sv } });
237
+ if (r)
238
+ Object.assign(good, r.skills);
239
+ }
240
+ out.skills = good;
241
+ }
242
+ }
243
+ else if (k === 'appearance') {
244
+ out.appearance = appearanceFromFile(v);
245
+ }
246
+ else if (k === 'projectsRoot') {
247
+ // Champ lu seul : on le valide avec lui-même comme dossier scanné (l'appartenance est vérifiée à l'enregistrement).
248
+ const r = checked({ projectsRoot: v, roots: [v] });
249
+ if (r)
250
+ out.projectsRoot = r.projectsRoot;
251
+ }
252
+ else if (k === 'roots') {
253
+ const r = checked({ roots: v, projectsRoot: Array.isArray(v) ? v[0] : undefined });
254
+ if (r)
255
+ out.roots = r.roots;
256
+ }
257
+ else if (['language', 'exclude', 'labelSet', 'editorCommand', 'terminal'].includes(k)) {
258
+ const r = checked({ [k]: v });
259
+ if (r)
260
+ out[k] = r[k];
261
+ }
262
+ }
263
+ return out;
264
+ }
265
+ /** Port enregistré dans le fichier (4242 si absent, illisible ou invalide) : jamais l'override HOLOHQ_PORT. */
266
+ export function storedPort(file) {
267
+ try {
268
+ const p = JSON.parse(readFileSync(file, 'utf8')).port;
269
+ if (typeof p === 'number' && Number.isInteger(p) && p >= 1 && p <= 65535)
270
+ return p;
271
+ }
272
+ catch {
273
+ // fichier absent ou illisible
274
+ }
275
+ return 4242;
276
+ }
277
+ export function loadConfig(file, opts) {
278
+ const defaults = defaultConfig(opts.home, opts.exists, opts.locale);
279
+ let user = {};
280
+ let firstRun = false;
281
+ let configError = null;
282
+ if (!existsSync(file)) {
283
+ firstRun = true;
284
+ }
285
+ else {
286
+ try {
287
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
288
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
289
+ throw new Error('the file must contain a JSON object');
290
+ user = sanitizeUser(parsed, defaults);
291
+ }
292
+ catch (e) {
293
+ firstRun = true;
294
+ configError = `${file} : ${e instanceof Error ? e.message : String(e)}`;
295
+ }
296
+ }
297
+ const merged = { ...defaults, ...user, skills: { ...defaults.skills, ...(user.skills ?? {}) } };
298
+ if (opts.port)
299
+ merged.port = opts.port;
300
+ const allowedOrigins = [`http://localhost:${merged.port}`, `http://127.0.0.1:${merged.port}`];
301
+ if (opts.dev)
302
+ allowedOrigins.push('http://localhost:5173');
303
+ return { config: { ...merged, allowedOrigins }, firstRun, configError };
304
+ }
305
+ /** Enregistre la config ; si l'ancien fichier était illisible, il est d'abord conservé en `.bak`. */
306
+ export async function saveConfig(file, cfg, hadError) {
307
+ await mkdir(dirname(file), { recursive: true });
308
+ if (hadError && existsSync(file))
309
+ await copyFile(file, `${file}.bak`);
310
+ await writeFile(file, JSON.stringify(cfg, null, 2) + '\n', 'utf8');
311
+ }
@@ -0,0 +1,19 @@
1
+ import { defaultConfig } from '../config.js';
2
+ import { DEMO_OWNER, DEMO_ROOT } from './data.js';
3
+ export const DEMO_PORT = 4243;
4
+ /** `port` : celui où la démo écoute (4243 par défaut, ou --port) ; la garde Host/Origin en dépend. */
5
+ export function demoConfig(lang, port = DEMO_PORT) {
6
+ // Valeurs par défaut génériques (skills holohq:*, éditeur, apparence), calculées pour un dossier fictif.
7
+ const base = defaultConfig(DEMO_ROOT, () => false, lang);
8
+ return {
9
+ ...base,
10
+ port,
11
+ owner: DEMO_OWNER,
12
+ projectsRoot: DEMO_ROOT,
13
+ roots: [DEMO_ROOT],
14
+ exclude: [],
15
+ language: lang,
16
+ labelSet: lang,
17
+ allowedOrigins: [`http://localhost:${port}`, `http://127.0.0.1:${port}`],
18
+ };
19
+ }
@@ -0,0 +1,317 @@
1
+ export const DEMO_OWNER = 'holohq-demo';
2
+ export const DEMO_ROOT = '/demo';
3
+ const DAY_MS = 86_400_000;
4
+ /** Date ISO située `daysAgo` jours avant `now` (négatif : dans le futur). */
5
+ export const daysAgoIso = (now, daysAgo) => new Date(now.getTime() - daysAgo * DAY_MS).toISOString();
6
+ /** Chemin fictif d'un projet ; toujours avec des « / », quel que soit l'OS. */
7
+ export const demoPath = (name) => `${DEMO_ROOT}/${name}`;
8
+ export const DEMO_PROJECTS = [
9
+ {
10
+ name: 'orbit-notes',
11
+ github: true,
12
+ branch: 'feat/offline-sync',
13
+ modified: 2,
14
+ untracked: 1,
15
+ ahead: 1,
16
+ conversations: [
17
+ { id: '3f1c9a52-7d4e-4b8a-9c21-5e6d0a1b7f30', title: 'Sync queue design', daysAgo: 2.5, branch: 'feat/offline-sync', lastPrompt: 'How should the queue replay failed writes?' },
18
+ { id: 'b7e4d608-12a9-4c35-8f7b-0d93a6c2e514', title: 'Fix note ordering', daysAgo: 6, branch: 'main', lastPrompt: 'Notes jump around after a sync, why?' },
19
+ ],
20
+ commits: [
21
+ [0.08, 'feat: persist the offline queue in IndexedDB'],
22
+ [0.9, 'feat: conflict banner on reconnect'],
23
+ [1.7, 'refactor: extract the sync worker'],
24
+ [2.6, 'fix: keep the cursor position after a remote edit'],
25
+ [4.1, 'feat: queue edits while offline'],
26
+ ],
27
+ openPrs: 2,
28
+ bugs: 1,
29
+ sprint: {
30
+ title: 'Sprint 4: Offline mode',
31
+ dueInDays: 5,
32
+ createdDaysAgo: 9,
33
+ issues: [
34
+ { title: 'Queue edits while offline', closed: true, labels: ['theme:sync'] },
35
+ { title: 'Conflict banner on reconnect', closed: true, labels: ['theme:sync'] },
36
+ { title: 'Persist the queue in IndexedDB', closed: true, labels: ['theme:sync'] },
37
+ { title: 'Retry with exponential backoff', closed: false, labels: ['theme:sync', 'effort:S'] },
38
+ { title: 'Offline indicator in the header', closed: false, labels: ['theme:editor'] },
39
+ { title: 'Docs: how sync works', closed: false, labels: ['documentation'] },
40
+ ],
41
+ },
42
+ ideas: [
43
+ { title: 'Keyboard shortcut to pin a note', theme: 'editor', effort: 'S', impact: 'high' },
44
+ { title: 'Word count in the status bar', theme: 'editor', effort: 'S', impact: 'medium' },
45
+ { title: 'End-to-end encrypted sync', theme: 'sync', effort: 'L', impact: 'high' },
46
+ { title: 'Plugin API for custom note types', theme: 'platform', effort: 'M', impact: 'high' },
47
+ { title: 'Confetti when a checklist is done', theme: 'fun', effort: 'S', impact: 'low' },
48
+ { title: 'Rewrite the parser in another language', theme: 'platform', effort: 'L', impact: 'low' },
49
+ { title: 'Import a folder of Markdown files', theme: 'import' },
50
+ { title: 'Share a read-only link to a note' },
51
+ ],
52
+ journal: {
53
+ daysAgo: 0.1,
54
+ done: 'Offline queue persisted in IndexedDB; conflict banner wired to the sync status.',
55
+ left: 'Retry with backoff, offline indicator, sync docs.',
56
+ next: 'Implement exponential backoff in the sync worker (#5).',
57
+ },
58
+ skills: [{ name: 'release-notes', description: 'Draft the release notes from the merged pull requests.' }],
59
+ },
60
+ {
61
+ name: 'pixel-forge',
62
+ github: true,
63
+ branch: 'main',
64
+ modified: 0,
65
+ untracked: 0,
66
+ // Projet de la capture `docs/assets/project.png` : conversations, un commit non poussé et des PR ouvertes.
67
+ ahead: 1,
68
+ conversations: [
69
+ { id: '8a2d5c17-4e9b-4f06-b3a1-6c7e9d0f2b48', title: 'GIF export pipeline', daysAgo: 0.4, branch: 'main', lastPrompt: 'Can the GIF encoder reuse the sprite sheet palette?' },
70
+ { id: 'c94e1f03-5b2a-4d78-8e6c-1a0b3d7f9e25', title: 'Crash on empty frames', daysAgo: 1.6, branch: 'main', lastPrompt: 'Export fails when a frame has no pixels, find why' },
71
+ { id: '5d7b0e29-a1c4-4f83-9d52-e8f61b3c0a97', title: 'Onion skin opacity', daysAgo: 3.1, branch: 'main', lastPrompt: 'Make the previous frame fade to 30 percent' },
72
+ ],
73
+ commits: [
74
+ [1.5, 'feat: export sprites as a sheet'],
75
+ [2.2, 'feat: onion skin for the previous frame'],
76
+ [3.9, 'fix: palette swap ignored transparent pixels'],
77
+ [5.3, 'chore: bump the canvas library'],
78
+ [8.0, 'feat: frame timeline'],
79
+ ],
80
+ openPrs: 2,
81
+ bugs: 2,
82
+ sprint: {
83
+ title: 'v0.9: Export',
84
+ dueInDays: 9,
85
+ createdDaysAgo: 12,
86
+ issues: [
87
+ { title: 'Export as PNG sprite sheet', closed: true, labels: ['theme:export'] },
88
+ { title: 'Export as animated GIF', closed: false, labels: ['theme:export', 'effort:M'] },
89
+ { title: 'Remember the last export folder', closed: false },
90
+ { title: 'Crash when exporting an empty frame', closed: false, labels: ['bug'] },
91
+ ],
92
+ },
93
+ ideas: [
94
+ { title: 'Tile mode preview', theme: 'canvas', effort: 'S', impact: 'high' },
95
+ { title: 'Collaborative editing', theme: 'canvas', effort: 'L', impact: 'medium' },
96
+ { title: 'Retro CRT filter', theme: 'fun', effort: 'S', impact: 'low' },
97
+ ],
98
+ journal: {
99
+ daysAgo: 1.5,
100
+ done: 'Sprite sheet export with padding options.',
101
+ left: 'GIF export, empty-frame crash.',
102
+ next: 'Fix the crash on empty frames before starting the GIF export.',
103
+ },
104
+ },
105
+ {
106
+ name: 'tide-planner',
107
+ github: true,
108
+ isPrivate: true,
109
+ branch: 'main',
110
+ modified: 3,
111
+ untracked: 0,
112
+ ahead: 0,
113
+ commits: [
114
+ [3.2, 'feat: tide table for the next 7 days'],
115
+ [3.4, 'feat: harbour search'],
116
+ [6.5, 'chore: project skeleton'],
117
+ [6.6, 'chore: initial commit'],
118
+ ],
119
+ ideas: [
120
+ { title: 'Moon phase next to each day', theme: 'forecast', effort: 'S', impact: 'medium' },
121
+ { title: 'Offline maps of the coast', theme: 'maps', effort: 'L', impact: 'low' },
122
+ ],
123
+ },
124
+ {
125
+ name: 'lumen-cli',
126
+ github: false,
127
+ branch: 'main',
128
+ modified: 0,
129
+ untracked: 1,
130
+ ahead: null,
131
+ commits: [
132
+ [5.8, 'feat: --watch rebuilds on change'],
133
+ [7.5, 'feat: colour themes for the output'],
134
+ [12.0, 'chore: initial commit'],
135
+ ],
136
+ skills: [{ name: 'bench', description: 'Run the benchmark suite and compare with the last run.' }],
137
+ },
138
+ {
139
+ name: 'kiln',
140
+ github: true,
141
+ branch: 'main',
142
+ modified: 0,
143
+ untracked: 0,
144
+ ahead: 0,
145
+ commits: [
146
+ [9.3, 'feat: firing schedule presets'],
147
+ [11.0, 'fix: temperature graph off by one hour'],
148
+ [15.4, 'feat: cone chart'],
149
+ [19.0, 'docs: wiring diagram'],
150
+ [26.0, 'feat: read the thermocouple'],
151
+ ],
152
+ sprint: {
153
+ title: 'Glaze log',
154
+ dueInDays: null,
155
+ createdDaysAgo: 20,
156
+ issues: [
157
+ { title: 'Log each firing with photos', closed: true },
158
+ { title: 'Search past firings by glaze', closed: false, labels: ['effort:M'] },
159
+ ],
160
+ },
161
+ ideas: [
162
+ { title: 'Alert when the kiln cools below 100°C', theme: 'alerts', effort: 'S', impact: 'high' },
163
+ { title: 'Share schedules with other potters', theme: 'community', effort: 'M', impact: 'low' },
164
+ ],
165
+ journal: {
166
+ daysAgo: 9.3,
167
+ done: 'Firing schedule presets for bisque and glaze.',
168
+ left: 'Search past firings.',
169
+ next: 'Index firings by glaze name.',
170
+ },
171
+ },
172
+ {
173
+ name: 'quartz-blog',
174
+ github: true,
175
+ branch: 'draft/winter-post',
176
+ modified: 1,
177
+ untracked: 0,
178
+ ahead: 0,
179
+ commits: [
180
+ [14.2, 'post: draft of the winter notes'],
181
+ [16.0, 'feat: reading time on each post'],
182
+ [22.5, 'fix: RSS dates in UTC'],
183
+ [40.0, 'post: building a tiny static site generator'],
184
+ [61.0, 'feat: tag pages'],
185
+ ],
186
+ ideas: [
187
+ { title: 'Webmentions under each post', theme: 'social', effort: 'M', impact: 'medium' },
188
+ { title: 'Series navigation', theme: 'reading', effort: 'S', impact: 'medium' },
189
+ ],
190
+ journal: {
191
+ daysAgo: 14.2,
192
+ done: 'First draft of the winter post.',
193
+ left: 'Photos and proofreading.',
194
+ next: 'Pick the photos for the winter post.',
195
+ },
196
+ },
197
+ {
198
+ name: 'relay-bot',
199
+ github: false,
200
+ branch: 'main',
201
+ modified: 0,
202
+ untracked: 0,
203
+ ahead: null,
204
+ commits: [
205
+ [21.0, 'feat: forward messages between two channels'],
206
+ [23.0, 'feat: rate limit'],
207
+ [25.0, 'chore: initial commit'],
208
+ ],
209
+ },
210
+ {
211
+ name: 'ember-ui',
212
+ github: true,
213
+ branch: 'main',
214
+ modified: 0,
215
+ untracked: 0,
216
+ ahead: 2,
217
+ commits: [
218
+ [27.0, 'feat: tooltip component'],
219
+ [27.2, 'docs: button variants'],
220
+ [33.0, 'fix: focus ring hidden in high-contrast mode'],
221
+ [44.0, 'feat: dialog component'],
222
+ [58.0, 'chore: storybook setup'],
223
+ ],
224
+ openPrs: 1,
225
+ bugs: 1,
226
+ ideas: [
227
+ { title: 'Dark mode tokens', theme: 'theming', effort: 'M', impact: 'high' },
228
+ { title: 'Date picker', theme: 'components', effort: 'L', impact: 'medium' },
229
+ { title: 'Animated toast stack', theme: 'components', effort: 'S', impact: 'low' },
230
+ ],
231
+ journal: {
232
+ daysAgo: 27.0,
233
+ done: 'Tooltip component with keyboard support.',
234
+ left: 'Review the dialog pull request.',
235
+ next: 'Merge the dialog focus-trap pull request.',
236
+ },
237
+ },
238
+ {
239
+ name: 'atlas-maps',
240
+ github: true,
241
+ branch: 'main',
242
+ modified: 0,
243
+ untracked: 0,
244
+ ahead: 0,
245
+ commits: [
246
+ [45.0, 'feat: hillshade layer'],
247
+ [52.0, 'feat: GPX import'],
248
+ [70.0, 'fix: tiles flicker when zooming'],
249
+ [90.0, 'feat: offline tile cache'],
250
+ [120.0, 'chore: initial commit'],
251
+ ],
252
+ ideas: [
253
+ { title: 'Elevation profile of a track', theme: 'tracks', effort: 'M', impact: 'high' },
254
+ { title: '3D terrain view', theme: 'render', effort: 'L', impact: 'low' },
255
+ ],
256
+ journal: {
257
+ daysAgo: 45.0,
258
+ done: 'Hillshade layer.',
259
+ left: 'Elevation profile.',
260
+ next: 'Sample the elevation along a GPX track.',
261
+ },
262
+ },
263
+ {
264
+ name: 'nimbus-sync',
265
+ github: true,
266
+ isPrivate: true,
267
+ branch: 'main',
268
+ modified: 0,
269
+ untracked: 0,
270
+ ahead: 0,
271
+ commits: [
272
+ [80.0, 'fix: resume interrupted uploads'],
273
+ [95.0, 'feat: selective sync'],
274
+ [130.0, 'feat: watch folders'],
275
+ [160.0, 'chore: initial commit'],
276
+ ],
277
+ },
278
+ {
279
+ name: 'fable-cards',
280
+ github: false,
281
+ branch: 'main',
282
+ modified: 0,
283
+ untracked: 0,
284
+ ahead: null,
285
+ commits: [
286
+ [120.0, 'feat: shuffle and deal'],
287
+ [140.0, 'feat: card templates'],
288
+ [150.0, 'chore: initial commit'],
289
+ ],
290
+ },
291
+ {
292
+ name: 'vector-garden',
293
+ github: true,
294
+ branch: 'master',
295
+ modified: 0,
296
+ untracked: 0,
297
+ ahead: 0,
298
+ commits: [
299
+ [200.0, 'feat: L-system trees'],
300
+ [230.0, 'feat: wind animation'],
301
+ [260.0, 'feat: SVG export'],
302
+ [300.0, 'chore: initial commit'],
303
+ ],
304
+ ideas: [{ title: 'Seasons: leaves change colour', theme: 'render', effort: 'M', impact: 'medium' }],
305
+ journal: {
306
+ daysAgo: 200.0,
307
+ done: 'L-system trees with three presets.',
308
+ left: 'Seasons.',
309
+ next: 'Try a colour ramp for autumn leaves.',
310
+ },
311
+ },
312
+ ];
313
+ /** Dépôts GitHub sans copie locale (proposés au clonage dans la barre latérale). */
314
+ export const DEMO_REMOTE_ONLY = [
315
+ { name: 'comet-docs', pushedDaysAgo: 18, isPrivate: false, isFork: false, isArchived: false },
316
+ { name: 'legacy-site', pushedDaysAgo: 400, isPrivate: false, isFork: false, isArchived: true },
317
+ ];
@@ -0,0 +1,36 @@
1
+ import { demoConfig, DEMO_PORT } from './config.js';
2
+ import { DEMO_PROJECTS, daysAgoIso, demoPath } from './data.js';
3
+ import { demoFloor } from './floor.js';
4
+ import { demoRun } from './run.js';
5
+ import { demoScan, demoSkills } from './scan.js';
6
+ /** Repère affiché à la place du chemin du fichier de config : la démo n'en a pas. */
7
+ export const DEMO_CONFIG_FILE = '(demo: in-memory config)';
8
+ export function demoDeps(opts) {
9
+ const now = opts.now ?? (() => new Date());
10
+ const config = demoConfig(opts.lang, opts.port ?? DEMO_PORT);
11
+ if (opts.dev)
12
+ config.allowedOrigins.push('http://localhost:5173');
13
+ return {
14
+ demo: true,
15
+ config,
16
+ setup: { file: DEMO_CONFIG_FILE, firstRun: false, configError: null },
17
+ run: demoRun(now),
18
+ now,
19
+ scan: demoScan,
20
+ listSkills: demoSkills,
21
+ conversations: async (path) => ({
22
+ readable: true,
23
+ items: (DEMO_PROJECTS.find((p) => demoPath(p.name) === path)?.conversations ?? []).map((c) => ({
24
+ id: c.id,
25
+ title: c.title,
26
+ updatedAt: daysAgoIso(now(), c.daysAgo),
27
+ branch: c.branch,
28
+ lastPrompt: c.lastPrompt,
29
+ active: false,
30
+ })),
31
+ }),
32
+ floor: async () => ({ readable: true, agents: demoFloor(now()) }),
33
+ // Jamais atteint : toute écriture (lancement, éditeur, nouveau projet) est refusée avant (middleware demoMode).
34
+ spawnDetached: () => { },
35
+ };
36
+ }