holohq 0.1.0 → 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 (33) hide show
  1. package/README.fr.md +10 -2
  2. package/README.md +10 -2
  3. package/dist/server/server/app.js +4 -0
  4. package/dist/server/server/claude/floor.js +408 -0
  5. package/dist/server/server/claude/history.js +268 -0
  6. package/dist/server/server/claude/prompt.js +8 -0
  7. package/dist/server/server/config.js +10 -4
  8. package/dist/server/server/demo/data.js +12 -1
  9. package/dist/server/server/demo/deps.js +14 -0
  10. package/dist/server/server/demo/floor.js +45 -0
  11. package/dist/server/server/demo/run.js +40 -3
  12. package/dist/server/server/domain/home.js +1 -1
  13. package/dist/server/server/domain/journal.js +3 -3
  14. package/dist/server/server/floor/attribute.js +74 -0
  15. package/dist/server/server/floor/evidence.js +39 -0
  16. package/dist/server/server/github/project.js +7 -5
  17. package/dist/server/server/launch.js +42 -20
  18. package/dist/server/server/routes/actions.js +1 -1
  19. package/dist/server/server/routes/conversations.js +21 -0
  20. package/dist/server/server/routes/floor.js +77 -0
  21. package/dist/server/server/routes/launch.js +42 -7
  22. package/dist/server/server/routes/projects.js +14 -2
  23. package/dist/server/server/start.js +7 -1
  24. package/dist/server/shared/errors.js +5 -1
  25. package/dist/server/shared/themes.js +2 -0
  26. package/dist/web/assets/Globe-ighOFp2V.js +4273 -0
  27. package/dist/web/assets/index-ByHbMQJl.js +11 -0
  28. package/dist/web/assets/index-DgR2KpYV.css +1 -0
  29. package/dist/web/index.html +2 -2
  30. package/package.json +1 -1
  31. package/dist/web/assets/Globe-BQOGOJCc.js +0 -4273
  32. package/dist/web/assets/index-BBiWQTd5.js +0 -11
  33. package/dist/web/assets/index-CoHzgpbC.css +0 -1
@@ -0,0 +1,39 @@
1
+ /** Champs d'un outil qui portent un chemin. */
2
+ const PATH_KEYS = ['file_path', 'path', 'notebook_path', 'cwd'];
3
+ /** Outils dont un texte peut citer des chemins, et les champs de ce texte. */
4
+ const TEXT_KEYS = {
5
+ Bash: ['command'], PowerShell: ['command'], Agent: ['prompt'], Task: ['prompt'], SendMessage: ['message', 'content', 'prompt'],
6
+ };
7
+ /** Texte lu au plus, et chemins retenus au plus, par outil. */
8
+ const TEXT_CHARS = 16_384;
9
+ const TOKENS_MAX = 40;
10
+ /** Chemin absolu entre guillemets : il peut contenir des espaces. */
11
+ const QUOTED = /(["'`])((?:[A-Za-z]:[\\/]|\/)[^"'`\r\n]*)\1/g;
12
+ /** Chemin absolu nu : `C:\…`, `C:/…` (aussi dans `--out=C:/…` et `file:///C:/…`) ou `/…` (ni une URL, ni un chemin relatif). */
13
+ const BARE = /(?<![A-Za-z0-9])[A-Za-z]:[\\/][^\s"'`|<>;&(),]*|(?<![\w.~:/\\$}*-])\/(?:\\ |[^\s"'`|<>;&(),\\])+/g;
14
+ /** Ponctuation finale d'une phrase ou d'un Markdown : retirée par la fin, en temps linéaire (une regex `…+$` serait quadratique). */
15
+ function trimEnd(token) {
16
+ let end = token.length;
17
+ while (end > 0 && '.,:!?*]}'.includes(token[end - 1]))
18
+ end--;
19
+ return token.slice(0, end);
20
+ }
21
+ /** Chemins absolus cités dans une commande ou une consigne, sans doublon. */
22
+ export function pathTokens(text) {
23
+ const out = new Set();
24
+ const rest = text.slice(0, TEXT_CHARS).replace(QUOTED, (_all, _quote, path) => {
25
+ out.add(path);
26
+ return ' ';
27
+ });
28
+ for (const [token] of rest.matchAll(BARE))
29
+ out.add(trimEnd(token.replace(/\\ /g, ' ')));
30
+ return [...out].slice(0, TOKENS_MAX);
31
+ }
32
+ /**
33
+ * Chemins qu'un tool_use désigne : ses champs de chemin, et les chemins absolus de sa commande ou de sa consigne.
34
+ * Ils servent seulement à trouver le projet d'un agent : ils ne quittent jamais le serveur.
35
+ */
36
+ export function evidenceOf(name, input) {
37
+ const strings = (keys) => keys.map((k) => input[k]).filter((v) => typeof v === 'string' && v !== '');
38
+ return [...strings(PATH_KEYS), ...strings(Object.hasOwn(TEXT_KEYS, name) ? TEXT_KEYS[name] : []).flatMap(pathTokens)];
39
+ }
@@ -7,8 +7,8 @@ const QUERY = `query($owner: String!, $name: String!) { repository(owner: $owner
7
7
  milestones(states: OPEN, first: 20) { nodes { number title dueOn createdAt open: issues(states: OPEN) { totalCount } closed: issues(states: CLOSED) { totalCount } } }
8
8
  ideas: issues(states: OPEN, labels: ["idée", "idea"], first: 100) { nodes { ${ISSUE} } }
9
9
  bugs: issues(states: OPEN, labels: ["bug"]) { totalCount }
10
- pullRequests(states: OPEN) { totalCount }
11
- journal: issues(states: OPEN, labels: ["journal"], first: 1) { nodes { number url comments(last: 1) { nodes { body url } } } }
10
+ pullRequests(states: OPEN, first: 5, orderBy: {field: CREATED_AT, direction: DESC}) { totalCount nodes { number title url isDraft author { login } } }
11
+ journal: issues(states: OPEN, labels: ["journal"], first: 1) { nodes { number url comments(last: 3) { nodes { body url createdAt } } } }
12
12
  label(name: "journal") { name }
13
13
  } }`;
14
14
  const SPRINT_QUERY = `query($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) {
@@ -27,7 +27,7 @@ export async function fetchProjectDetail(run, repo) {
27
27
  const data = await ghGraphql(run, QUERY, vars);
28
28
  const r = data.repository;
29
29
  if (!r)
30
- return { sprint: null, ideas: [], openBugs: 0, openPrs: 0, journal: null, hasConvention: false };
30
+ return { sprint: null, ideas: [], openBugs: 0, openPrs: 0, prs: [], journal: null, hasConvention: false };
31
31
  const milestones = r.milestones.nodes.map((m) => ({
32
32
  number: m.number,
33
33
  title: m.title,
@@ -44,13 +44,15 @@ export async function fetchProjectDetail(run, repo) {
44
44
  }
45
45
  const ideas = r.ideas.nodes.map((n) => classifyIdea(toIssue(n)));
46
46
  const j = r.journal.nodes[0];
47
- const lastComment = j?.comments.nodes[0];
47
+ // GitHub renvoie les commentaires du plus ancien au plus récent : on inverse.
48
+ const sessions = (j?.comments.nodes ?? []).map((c) => parseJournalComment(c.body, c.url, c.createdAt)).reverse();
48
49
  return {
49
50
  sprint,
50
51
  ideas,
51
52
  openBugs: r.bugs.totalCount,
52
53
  openPrs: r.pullRequests.totalCount,
53
- journal: j ? { number: j.number, url: j.url, last: lastComment ? parseJournalComment(lastComment.body, lastComment.url) : null } : null,
54
+ prs: r.pullRequests.nodes.map((n) => ({ number: n.number, title: n.title, url: n.url, isDraft: n.isDraft, author: n.author?.login ?? null })),
55
+ journal: j ? { number: j.number, url: j.url, sessions } : null,
54
56
  hasConvention: r.label !== null,
55
57
  };
56
58
  }
@@ -16,19 +16,39 @@ function checkPath(path) {
16
16
  function checkCmdPath(path) {
17
17
  return CMD_META.test(path) ? errorBody('pathCmdMeta') : null;
18
18
  }
19
- /** Lance `claude /<skill>` dans un nouveau terminal, dans le dossier du projet. Arguments séparés, jamais de chaîne shell (sauf l'AppleScript, échappé). */
20
- export function claudeLaunch(projectPath, skill, ctx) {
21
- if (!SKILL_NAME.test(skill))
22
- return errorBody('skillInvalid');
19
+ /** UUID strict d'une conversation Claude Code : jamais pris pour une option, ni un chemin. */
20
+ export const SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
21
+ /** Caractères refusés dans une consigne : métacaractères de cmd.exe, `;` (séparateur de Windows Terminal), `\`, retours à la ligne. */
22
+ const PROMPT_META = /[&|<>^%!";\\\r\n]/;
23
+ /** Lance `claude` dans un nouveau terminal, dans le dossier du projet. Arguments séparés, jamais de chaîne shell (sauf l'AppleScript, échappé). */
24
+ export function claudeLaunch(projectPath, what, ctx) {
25
+ let claudeArgs;
26
+ if ('skill' in what) {
27
+ if (!SKILL_NAME.test(what.skill))
28
+ return errorBody('skillInvalid');
29
+ claudeArgs = ['/' + what.skill];
30
+ }
31
+ else if ('resume' in what) {
32
+ if (!SESSION_ID.test(what.resume))
33
+ return errorBody('sessionIdInvalid');
34
+ claudeArgs = ['--resume', what.resume];
35
+ }
36
+ else if ('continue' in what) {
37
+ claudeArgs = ['--continue'];
38
+ }
39
+ else {
40
+ if (PROMPT_META.test(what.prompt))
41
+ return errorBody('promptInvalid');
42
+ claudeArgs = [what.prompt];
43
+ }
23
44
  const bad = checkPath(projectPath);
24
45
  if (bad)
25
46
  return bad;
26
- const slash = '/' + skill;
27
47
  if (ctx.platform === 'win32')
28
- return windows(projectPath, slash, ctx);
48
+ return windows(projectPath, claudeArgs, ctx);
29
49
  if (ctx.platform === 'darwin')
30
- return mac(projectPath, slash, ctx);
31
- return linux(projectPath, slash, ctx);
50
+ return mac(projectPath, claudeArgs, ctx);
51
+ return linux(projectPath, claudeArgs, ctx);
32
52
  }
33
53
  /**
34
54
  * cmd.exe cherche une commande dans le dossier courant (ici le projet) avant le PATH : un `claude.cmd` posé
@@ -36,29 +56,31 @@ export function claudeLaunch(projectPath, skill, ctx) {
36
56
  * sans valeur injectée (le `&&` collé évite une espace finale dans la valeur).
37
57
  */
38
58
  const NO_CWD_SEARCH = ['set', 'NoDefaultCurrentDirectoryInExePath=1&&'];
39
- function windows(path, slash, ctx) {
59
+ function windows(path, claudeArgs, ctx) {
40
60
  if (path.includes(';'))
41
61
  return errorBody('pathSemicolon');
42
62
  // wt.exe ne transmet pas l'environnement du serveur : la variable est posée dans la console elle-même.
43
63
  if (ctx.terminal === 'wt' || ctx.has('wt.exe'))
44
- return { cmd: 'wt.exe', args: ['-d', path, 'cmd.exe', '/k', ...NO_CWD_SEARCH, 'claude', slash] };
64
+ return { cmd: 'wt.exe', args: ['-d', path, 'cmd.exe', '/k', ...NO_CWD_SEARCH, 'claude', ...claudeArgs] };
45
65
  // Repli : `start` ouvre une nouvelle console ; ici le chemin est relu par cmd.exe. La variable est posée
46
66
  // avant `start` (sinon le `&&` serait lu par ce premier cmd) et héritée par la nouvelle console.
47
67
  const bad = checkCmdPath(path);
48
68
  if (bad)
49
69
  return bad;
50
- return { cmd: 'cmd.exe', args: ['/c', ...NO_CWD_SEARCH, 'start', '""', '/D', path, 'cmd.exe', '/k', 'claude', slash] };
70
+ return { cmd: 'cmd.exe', args: ['/c', ...NO_CWD_SEARCH, 'start', '""', '/D', path, 'cmd.exe', '/k', 'claude', ...claudeArgs] };
51
71
  }
52
72
  /** Protège pour sh : entre apostrophes, chaque `'` devient `'\''`. */
53
73
  const shellQuote = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
54
74
  /** Protège pour une chaîne AppleScript : `\` puis `"`. */
55
75
  const appleQuote = (s) => `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
56
- function mac(path, slash, ctx) {
76
+ /** Argument sans caractère spécial pour sh : laissé tel quel (`--resume`, `/skill`) ; sinon protégé par `shellQuote`. */
77
+ const shellArg = (s) => (/^[A-Za-z0-9_.\/:=-]+$/.test(s) ? s : shellQuote(s));
78
+ function mac(path, claudeArgs, ctx) {
57
79
  // La commande est tapée dans le shell de l'utilisateur ; sous fish, \' et \\ restent des échappements
58
80
  // entre apostrophes : une barre oblique inverse pourrait faire sortir le chemin de ses apostrophes.
59
81
  if (path.includes('\\'))
60
82
  return errorBody('pathBackslash');
61
- const command = appleQuote(`cd ${shellQuote(path)} && claude ${slash}`);
83
+ const command = appleQuote(`cd ${shellQuote(path)} && claude ${claudeArgs.map(shellArg).join(' ')}`);
62
84
  const script = ctx.terminal?.toLowerCase() === 'iterm'
63
85
  ? [
64
86
  'tell application "iTerm"',
@@ -71,7 +93,7 @@ function mac(path, slash, ctx) {
71
93
  return { cmd: 'osascript', args: ['-e', script] };
72
94
  }
73
95
  const LINUX_TERMINALS = ['x-terminal-emulator', 'gnome-terminal', 'konsole', 'xfce4-terminal', 'kitty', 'alacritty'];
74
- function linux(path, slash, ctx) {
96
+ function linux(path, claudeArgs, ctx) {
75
97
  // Terminal choisi dans les réglages mais absent : on le dit au lieu d'un lancement qui échoue sans bruit.
76
98
  if (ctx.terminal && !ctx.has(ctx.terminal))
77
99
  return errorBody('terminalNotFound', { terminal: ctx.terminal });
@@ -80,18 +102,18 @@ function linux(path, slash, ctx) {
80
102
  return errorBody('noTerminal');
81
103
  switch (posix.basename(term)) {
82
104
  case 'gnome-terminal':
83
- return { cmd: term, args: ['--working-directory', path, '--', 'claude', slash] };
105
+ return { cmd: term, args: ['--working-directory', path, '--', 'claude', ...claudeArgs] };
84
106
  case 'konsole':
85
- return { cmd: term, args: ['--workdir', path, '-e', 'claude', slash] };
107
+ return { cmd: term, args: ['--workdir', path, '-e', 'claude', ...claudeArgs] };
86
108
  case 'xfce4-terminal':
87
- return { cmd: term, args: ['--working-directory', path, '-x', 'claude', slash] };
109
+ return { cmd: term, args: ['--working-directory', path, '-x', 'claude', ...claudeArgs] };
88
110
  case 'kitty':
89
- return { cmd: term, args: ['--directory', path, 'claude', slash] };
111
+ return { cmd: term, args: ['--directory', path, 'claude', ...claudeArgs] };
90
112
  case 'alacritty':
91
- return { cmd: term, args: ['--working-directory', path, '-e', 'claude', slash] };
113
+ return { cmd: term, args: ['--working-directory', path, '-e', 'claude', ...claudeArgs] };
92
114
  default:
93
115
  // Le chemin est un argument positionnel ($1), jamais interpolé dans la chaîne -c.
94
- return { cmd: term, args: ['-e', 'sh', '-c', 'cd "$1" && exec claude "$2"', 'sh', path, slash] };
116
+ return { cmd: term, args: ['-e', 'sh', '-c', 'cd "$1" && shift && exec claude "$@"', 'sh', path, ...claudeArgs] };
95
117
  }
96
118
  }
97
119
  /**
@@ -76,7 +76,7 @@ export function register(app, deps) {
76
76
  const p = { id: projectId(path), name: b.name, path, repo, duplicates: [] };
77
77
  remember(p);
78
78
  // Le projet est créé même si le terminal ne peut pas s'ouvrir (chemin refusé, aucun terminal) : on le dit.
79
- const l = claudeLaunch(path, deps.config.skills.kickoff, launchCtx(deps));
79
+ const l = claudeLaunch(path, { skill: deps.config.skills.kickoff }, launchCtx(deps));
80
80
  if ('error' in l)
81
81
  return c.json({ ...p, launchError: l }, 201);
82
82
  deps.spawnDetached(l.cmd, l.args);
@@ -0,0 +1,21 @@
1
+ import { errorBody } from '../../shared/errors.js';
2
+ import { getProject } from './projects.js';
3
+ /** Conversations d'un projet ; toute erreur du lecteur (ou son absence de lecture) donne `{ readable: false }`. */
4
+ export async function conversationsOf(path, deps) {
5
+ if (!deps.conversations)
6
+ return { readable: true, items: [] };
7
+ try {
8
+ return await deps.conversations(path);
9
+ }
10
+ catch {
11
+ return { readable: false };
12
+ }
13
+ }
14
+ export function register(app, deps) {
15
+ app.get('/api/projects/:id/conversations', async (c) => {
16
+ const p = await getProject(c.req.param('id'), deps);
17
+ if (!p)
18
+ return c.json(errorBody('unknownProject'), 404);
19
+ return c.json(await conversationsOf(p.path, deps));
20
+ });
21
+ }
@@ -0,0 +1,77 @@
1
+ import { tierOf } from '../../shared/tiers.js';
2
+ import { cached } from '../cache.js';
3
+ import { attributeAll, parseWorktrees } from '../floor/attribute.js';
4
+ import { scanProjects } from '../projects/scan.js';
5
+ /** Projets, dates et worktrees ne sont relus qu'à cet intervalle : la page interroge la route toutes les 3 s. */
6
+ const PROJECTS_MS = 5 * 60_000;
7
+ /** `git` sans verrou facultatif : une lecture ne fait jamais échouer le `git add` d'un agent dans le même dépôt. */
8
+ const unlocked = (run) => (cmd, args, opts) => run(cmd, cmd === 'git' && args[0] === '-C' ? ['-C', args[1], '--no-optional-locks', ...args.slice(2)] : args, opts);
9
+ /** Sortie d'une commande git ; null si elle échoue. */
10
+ async function output(run, path, args) {
11
+ try {
12
+ const r = await run('git', ['-C', path, ...args]);
13
+ return r.code === 0 ? r.stdout : null;
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
19
+ /** Projets du scan (date du dernier commit) et leurs racines : chaque clone du dépôt et ses worktrees. */
20
+ function projectsOf(deps) {
21
+ return cached('floor:projects', PROJECTS_MS, deps.now, async () => {
22
+ const run = unlocked(deps.run);
23
+ const found = await Promise.all((await scanProjects({ ...deps, run })).map(async (p) => {
24
+ const clones = [p.path, ...p.duplicates];
25
+ const [date, ...worktrees] = await Promise.all([
26
+ output(run, p.path, ['log', '-1', '--format=%cI']),
27
+ ...clones.map((path) => output(run, path, ['worktree', 'list', '--porcelain'])),
28
+ ]);
29
+ const paths = [...clones, ...worktrees.flatMap((w) => (w ? parseWorktrees(w) : []))];
30
+ return {
31
+ project: { id: p.id, name: p.name, lastActivity: date?.trim() || null },
32
+ roots: paths.map((path) => ({ projectId: p.id, path })),
33
+ };
34
+ }));
35
+ return { projects: found.map((f) => f.project), roots: found.flatMap((f) => f.roots) };
36
+ });
37
+ }
38
+ export function register(app, deps) {
39
+ // Dernier projet de chaque agent présent : il n'en change que sur une nouvelle preuve.
40
+ const remembered = new Map();
41
+ app.get('/api/floor', async (c) => {
42
+ const platform = deps.launchHost?.platform ?? process.platform;
43
+ let read = { readable: true, agents: [] };
44
+ if (deps.floor) {
45
+ try {
46
+ read = await deps.floor();
47
+ }
48
+ catch {
49
+ read = { readable: false };
50
+ }
51
+ }
52
+ let known = [];
53
+ let roots = [];
54
+ try {
55
+ ;
56
+ ({ projects: known, roots } = await projectsOf(deps));
57
+ }
58
+ catch {
59
+ // Sans projets, les agents restent affichés, hors projet.
60
+ }
61
+ const now = deps.now();
62
+ let agents = [];
63
+ if (read.readable) {
64
+ const projectOf = attributeAll(read.agents, roots, platform, remembered);
65
+ // Dossier de travail et chemins cités ne quittent jamais le serveur.
66
+ agents = read.agents.map(({ cwd: _cwd, paths: _paths, ...a }) => ({ ...a, projectId: projectOf.get(a.id) ?? null }));
67
+ }
68
+ const data = {
69
+ generatedAt: now.toISOString(),
70
+ readable: read.readable,
71
+ // Même règle que l'accueil : le rang vient de l'âge du dernier commit.
72
+ projects: known.map((p) => ({ ...p, tier: tierOf(p.lastActivity, now) })),
73
+ agents,
74
+ };
75
+ return c.json(data);
76
+ });
77
+ }
@@ -1,7 +1,25 @@
1
1
  import { errorBody } from '../../shared/errors.js';
2
+ import { NEW_SKILL_PROMPT } from '../claude/prompt.js';
2
3
  import { claudeLaunch, editorLaunch, launchCtx } from '../launch.js';
3
4
  import { listSkills } from '../skills.js';
5
+ import { conversationsOf } from './conversations.js';
4
6
  import { getProject } from './projects.js';
7
+ /** Corps strict : un objet avec exactement une clé parmi les quatre, de la bonne forme ; sinon null. */
8
+ function parseLaunchBody(body) {
9
+ if (typeof body !== 'object' || body === null || Array.isArray(body))
10
+ return null;
11
+ const entries = Object.entries(body);
12
+ if (entries.length !== 1)
13
+ return null;
14
+ const [key, value] = entries[0];
15
+ if ((key === 'skill' || key === 'resume') && typeof value === 'string')
16
+ return key === 'skill' ? { skill: value } : { resume: value };
17
+ if (key === 'continue' && value === true)
18
+ return { continue: true };
19
+ if (key === 'newSkill' && value === true)
20
+ return { newSkill: true };
21
+ return null;
22
+ }
5
23
  export function register(app, deps) {
6
24
  app.get('/api/projects/:id/skills', async (c) => {
7
25
  const p = await getProject(c.req.param('id'), deps);
@@ -14,13 +32,30 @@ export function register(app, deps) {
14
32
  if (!p)
15
33
  return c.json(errorBody('unknownProject'), 404);
16
34
  const body = await c.req.json().catch(() => null);
17
- const skill = typeof body === 'object' && body !== null ? body.skill : undefined;
18
- if (typeof skill !== 'string')
19
- return c.json(errorBody('skillMissing'), 400);
20
- const known = await (deps.listSkills ?? listSkills)(p.path, deps.config);
21
- if (!known.some((s) => s.name === skill))
22
- return c.json(errorBody('skillUnknown'), 400);
23
- const l = claudeLaunch(p.path, skill, launchCtx(deps));
35
+ const req = parseLaunchBody(body);
36
+ if (!req)
37
+ return c.json(errorBody('launchBodyInvalid'), 400);
38
+ let what;
39
+ if ('skill' in req) {
40
+ const known = await (deps.listSkills ?? listSkills)(p.path, deps.config);
41
+ if (!known.some((s) => s.name === req.skill))
42
+ return c.json(errorBody('skillUnknown'), 400);
43
+ what = { skill: req.skill };
44
+ }
45
+ else if ('resume' in req) {
46
+ const r = await conversationsOf(p.path, deps);
47
+ if (!r.readable || !r.items.some((x) => x.id === req.resume))
48
+ return c.json(errorBody('conversationUnknown'), 400);
49
+ what = { resume: req.resume };
50
+ }
51
+ else if ('continue' in req) {
52
+ what = { continue: true };
53
+ }
54
+ else {
55
+ // La consigne vient du code (langue des réglages), jamais du corps de la requête.
56
+ what = { prompt: NEW_SKILL_PROMPT[deps.config.language] };
57
+ }
58
+ const l = claudeLaunch(p.path, what, launchCtx(deps));
24
59
  if ('error' in l)
25
60
  return c.json(l, 400);
26
61
  deps.spawnDetached(l.cmd, l.args);
@@ -27,6 +27,16 @@ export async function getProject(id, deps) {
27
27
  p = findProject(id);
28
28
  return p;
29
29
  }
30
+ /** Hash complets des commits sur aucune branche distante ; null si le dépôt n'a pas de remote (ou si git échoue). */
31
+ async function unpushedHashes(path, deps) {
32
+ const remote = await deps.run('git', ['-C', path, 'remote']);
33
+ if (remote.code !== 0 || !remote.stdout.trim())
34
+ return null;
35
+ const r = await deps.run('git', ['-C', path, 'rev-list', '--max-count=8', 'HEAD', '--not', '--remotes']);
36
+ if (r.code !== 0)
37
+ return null;
38
+ return r.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
39
+ }
30
40
  export function register(app, deps) {
31
41
  app.get('/api/projects', async (c) => {
32
42
  const projects = await scanProjects(deps);
@@ -47,7 +57,7 @@ export function register(app, deps) {
47
57
  const p = await getProject(c.req.param('id'), deps);
48
58
  if (!p)
49
59
  return c.json(errorBody('unknownProject'), 404);
50
- const r = await deps.run('git', ['-C', p.path, 'log', '-5', '--format=%h%x1f%cI%x1f%s']);
60
+ const r = await deps.run('git', ['-C', p.path, 'log', '-8', '--format=%h%x1f%cI%x1f%s']);
51
61
  if (r.code !== 0)
52
62
  return c.json([]);
53
63
  const commits = r.stdout
@@ -58,6 +68,8 @@ export function register(app, deps) {
58
68
  return { hash, date, subject: subject ?? '' };
59
69
  })
60
70
  .filter((x) => x.hash && x.date);
61
- return c.json(commits);
71
+ const unpushed = await unpushedHashes(p.path, deps);
72
+ const out = commits.map((x) => ({ ...x, unpushed: unpushed === null ? null : unpushed.some((h) => h.startsWith(x.hash)) }));
73
+ return c.json(out);
62
74
  });
63
75
  }
@@ -6,6 +6,8 @@ import { serve } from '@hono/node-server';
6
6
  import { realAutostartDeps, runAutostart } from './autostartRun.js';
7
7
  import { createApp } from './app.js';
8
8
  import { openBrowser } from './browser.js';
9
+ import { createFloorReader } from './claude/floor.js';
10
+ import { claudeProjectsRoot, createHistoryReader } from './claude/history.js';
9
11
  import { configPath, loadConfig, localeLang, portFromEnv } from './config.js';
10
12
  import { DEMO_PORT } from './demo/config.js';
11
13
  import { demoDeps } from './demo/deps.js';
@@ -63,11 +65,15 @@ function realDepsFor(opts, port) {
63
65
  });
64
66
  if (configError)
65
67
  log(`Unreadable config, using defaults : ${configError}`);
68
+ const now = () => new Date();
66
69
  return {
67
70
  config,
68
71
  setup: { file, firstRun, configError },
69
72
  run,
70
- now: () => new Date(),
73
+ now,
74
+ // Un seul lecteur par processus : il garde un cache par fichier.
75
+ conversations: createHistoryReader({ root: claudeProjectsRoot(process.env, homedir()), platform: process.platform, now }),
76
+ floor: createFloorReader({ root: claudeProjectsRoot(process.env, homedir()), now }),
71
77
  spawnDetached: (cmd, args, cwd) => {
72
78
  const child = spawn(cmd, args, { cwd, detached: true, stdio: 'ignore', windowsHide: false });
73
79
  child.on('error', (e) => log(`Launch failed (${cmd}): ${e.message}`));
@@ -6,7 +6,7 @@ export const ERROR_CODES = [
6
6
  'hostRefused', 'missingHeader', 'originRefused',
7
7
  'unknownProject', 'noRepo', 'noOwner',
8
8
  'invalidName', 'repoNameRequired',
9
- 'skillMissing', 'skillUnknown', 'skillInvalid',
9
+ 'skillMissing', 'skillUnknown', 'skillInvalid', 'sessionIdInvalid', 'promptInvalid', 'launchBodyInvalid', 'conversationUnknown',
10
10
  'editorNotFound', 'terminalNotFound', 'noTerminal',
11
11
  'pathRefused', 'pathControlChar', 'pathCmdMeta', 'pathSemicolon', 'pathBackslash',
12
12
  'noSprint', 'journalExists',
@@ -42,6 +42,10 @@ export const ERROR_EN = {
42
42
  skillMissing: 'Skill missing',
43
43
  skillUnknown: 'Unknown skill',
44
44
  skillInvalid: 'Invalid skill name: launch refused',
45
+ sessionIdInvalid: 'Invalid conversation id: launch refused',
46
+ promptInvalid: 'Prompt contains a forbidden character: launch refused',
47
+ launchBodyInvalid: 'Invalid launch request: expected exactly one of skill, resume, continue, newSkill',
48
+ conversationUnknown: 'Unknown conversation for this project',
45
49
  editorNotFound: 'Editor not found ({editor}): set it in Settings',
46
50
  terminalNotFound: 'Terminal not found ({terminal}): set it in Settings',
47
51
  noTerminal: 'No terminal found: set "terminal" in Settings',
@@ -1,4 +1,6 @@
1
1
  import { ensureContrast, mix, parseHex, toHex } from './color.js';
2
+ export const FLOOR_VIEWS = ['planets', 'tower', 'openspace'];
3
+ export const floorViewOf = (a) => a.floor ?? 'planets';
2
4
  export const THEME_IDS = ['holo', 'mars', 'terminal', 'nebula', 'day', 'custom'];
3
5
  export const DEFAULT_APPEARANCE = { theme: 'holo', effects: 'full' };
4
6
  /** Bordure : l'accent à un tiers d'opacité (comme `--line` de Holo). */