claude-code-session-manager 0.8.6 → 0.10.1

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 (54) hide show
  1. package/README.md +95 -65
  2. package/dist/assets/{cssMode-DBg6nxUL.js → cssMode-AMMSQWRU.js} +1 -1
  3. package/dist/assets/{freemarker2-CyjUGY3f.js → freemarker2-B7HmOKy0.js} +1 -1
  4. package/dist/assets/{handlebars-lhtCWqlB.js → handlebars-DMhLYNJA.js} +1 -1
  5. package/dist/assets/{html-egptHwbZ.js → html-DIfRfeTv.js} +1 -1
  6. package/dist/assets/htmlMode-DBqG7xl_.js +1 -0
  7. package/dist/assets/{index-DjeqNwqn.js → index-BqL_4JKo.js} +1120 -1086
  8. package/dist/assets/{index-DnLtSCQS.css → index-CxncC9a0.css} +1 -1
  9. package/dist/assets/{javascript-tZbiID3O.js → javascript-Bsn1K6_V.js} +1 -1
  10. package/dist/assets/{jsonMode-BGtPN-L-.js → jsonMode-DVLHW2S3.js} +1 -1
  11. package/dist/assets/{liquid-DvTeXhev.js → liquid-9zGHPTSW.js} +1 -1
  12. package/dist/assets/{lspLanguageFeatures-D9xoxVlV.js → lspLanguageFeatures-BaqyiCFJ.js} +2 -2
  13. package/dist/assets/{mdx-BQ3Ja4wM.js → mdx-DhU2NoOP.js} +1 -1
  14. package/dist/assets/{ort-wasm-simd-threaded.asyncify-CtKKja6V.wasm → ort-wasm-simd-threaded.asyncify-DMmc6YqF.wasm} +0 -0
  15. package/dist/assets/{python-C71RWXaP.js → python-WMVORwGT.js} +1 -1
  16. package/dist/assets/{razor-w__Mkyns.js → razor-C13iUMo9.js} +1 -1
  17. package/dist/assets/{tsMode-DOQLQDB3.js → tsMode-B7lSY5y7.js} +1 -1
  18. package/dist/assets/{typescript-DEiub2Jt.js → typescript-BbjzsO4g.js} +1 -1
  19. package/dist/assets/{whisperWorker-QfIS0sPF.js → whisperWorker-CcsPqZUS.js} +19 -19
  20. package/dist/assets/{xml-RXkLQscS.js → xml-BH6qG4pe.js} +1 -1
  21. package/dist/assets/{yaml-C8HIpJku.js → yaml-B4r3z4qP.js} +1 -1
  22. package/dist/index.html +2 -2
  23. package/package.json +19 -10
  24. package/screenshots/.gitkeep +0 -0
  25. package/screenshots/README-screenshots.md +13 -0
  26. package/src/main/config.cjs +47 -9
  27. package/src/main/historyAggregator.cjs +10 -5
  28. package/src/main/index.cjs +186 -14
  29. package/src/main/ipcSchemas.cjs +165 -3
  30. package/src/main/lib/claudeBin.cjs +39 -0
  31. package/src/main/lib/encodeCwd.cjs +19 -0
  32. package/src/main/lib/fileTail.cjs +35 -0
  33. package/src/main/lib/insideHome.cjs +38 -0
  34. package/src/main/lib/prdFrontmatter.cjs +51 -0
  35. package/src/main/lib/sendToRenderer.cjs +21 -0
  36. package/src/main/memoryTool.cjs +203 -0
  37. package/src/main/otelSettings.cjs +2 -7
  38. package/src/main/pluginInstall.cjs +129 -0
  39. package/src/main/pty.cjs +13 -29
  40. package/src/main/queueOps.cjs +404 -0
  41. package/src/main/scheduler/prdParser.cjs +135 -0
  42. package/src/main/scheduler.cjs +296 -255
  43. package/src/main/sessionsStore.cjs +2 -6
  44. package/src/main/supervisor.cjs +3 -35
  45. package/src/main/teams.cjs +95 -0
  46. package/src/main/transcripts.cjs +5 -7
  47. package/src/main/usage.cjs +8 -0
  48. package/src/main/voiceHotkey.cjs +13 -9
  49. package/src/main/voiceSettings.cjs +2 -9
  50. package/src/main/voiceWizard.cjs +4 -11
  51. package/src/main/watchers.cjs +18 -42
  52. package/src/preload/api.d.ts +153 -1
  53. package/src/preload/index.cjs +29 -0
  54. package/dist/assets/htmlMode-tPDeHGOB.js +0 -1
@@ -0,0 +1,135 @@
1
+ /**
2
+ * scheduler/prdParser.cjs — PRD file parsing + dir-mtime cache.
3
+ *
4
+ * Extracted from scheduler.cjs to keep the main scheduler module focused on
5
+ * its state machine + executor. No mutable scheduler state lives here; the
6
+ * cache is module-private and keyed by absolute file path.
7
+ *
8
+ * Two-level cache for reconcile():
9
+ * - dirCache: keyed by PRDS_DIR mtimeMs — invalidated when files added/removed.
10
+ * - fileCache: per-PRD parse keyed by individual file mtimeMs — survives across
11
+ * dir-cache invalidations so adding ONE new PRD doesn't re-parse the other 197.
12
+ * Both layers also bound by ino so a rename + re-create can't alias.
13
+ */
14
+ 'use strict';
15
+
16
+ const fs = require('node:fs');
17
+ const fsp = require('node:fs/promises');
18
+ const path = require('node:path');
19
+ const { splitFrontmatter } = require('../lib/prdFrontmatter.cjs');
20
+
21
+ // Hard cap to keep one malformed PRD (e.g. a binary blob accidentally renamed
22
+ // .md) from wedging the main thread. PRDs are PRDs, not media files; 1 MB is
23
+ // already ~25k lines and well beyond any legitimate authored doc.
24
+ const PRD_READ_MAX_BYTES = 1024 * 1024;
25
+
26
+ let prdDirMtime = -1;
27
+ let prdDirFiles = null; // sorted absolute paths
28
+ const prdFileCache = new Map(); // path -> { mtimeMs, ino, parsed }
29
+
30
+ /**
31
+ * Parse a PRD file from disk without any caching. Reads bytes once, decodes
32
+ * frontmatter, and folds in the parallel-group number from the filename when
33
+ * frontmatter doesn't specify one.
34
+ */
35
+ async function parsePrdRaw(filePath) {
36
+ const text = await fsp.readFile(filePath, 'utf8');
37
+ const { fm, body } = splitFrontmatter(text);
38
+
39
+ const base = path.basename(filePath, '.md');
40
+ const groupFromName = (() => {
41
+ const m = base.match(/^(\d+)-/);
42
+ return m ? Number(m[1]) : null;
43
+ })();
44
+
45
+ return {
46
+ slug: base,
47
+ path: filePath,
48
+ title: fm.title || base,
49
+ cwd: fm.cwd || null,
50
+ estimateMinutes: fm.estimateMinutes ? Number(fm.estimateMinutes) || null : null,
51
+ parallelGroup: (fm.parallelGroup ? Number(fm.parallelGroup) || null : null) ?? groupFromName ?? 99,
52
+ body: body.trim(),
53
+ };
54
+ }
55
+
56
+ /**
57
+ * List `.md` PRD files under the given dir. Caches the result keyed by the
58
+ * directory mtime so repeated reconcile() calls don't re-stat every entry.
59
+ * Pass `prdsDir` so the scheduler can keep ownership of its PRDS_DIR path
60
+ * without this module needing to know it.
61
+ */
62
+ async function listPrdFiles(prdsDir) {
63
+ let dirMtime;
64
+ try {
65
+ dirMtime = (await fsp.stat(prdsDir)).mtimeMs;
66
+ } catch {
67
+ dirMtime = -1;
68
+ }
69
+ if (dirMtime === prdDirMtime && prdDirFiles) return prdDirFiles;
70
+ let entries;
71
+ try {
72
+ entries = await fsp.readdir(prdsDir);
73
+ } catch {
74
+ entries = [];
75
+ }
76
+ const files = entries
77
+ .filter((f) => f.endsWith('.md') && !f.startsWith('.'))
78
+ .map((f) => path.join(prdsDir, f))
79
+ .sort();
80
+ // Drop file-cache entries whose path is no longer on disk so the map
81
+ // doesn't accumulate ghosts after archives/deletes.
82
+ if (prdFileCache.size > 0) {
83
+ const live = new Set(files);
84
+ for (const k of prdFileCache.keys()) {
85
+ if (!live.has(k)) prdFileCache.delete(k);
86
+ }
87
+ }
88
+ prdDirMtime = dirMtime;
89
+ prdDirFiles = files;
90
+ return files;
91
+ }
92
+
93
+ /**
94
+ * Parse a PRD with mtime-aware cache. Returns the cached object when the
95
+ * file's mtime + inode are unchanged. Throws if the file exceeds the size cap.
96
+ */
97
+ async function parsePrd(filePath) {
98
+ let st;
99
+ try {
100
+ st = await fsp.stat(filePath);
101
+ } catch {
102
+ // fall back to direct parse (will throw the original ENOENT to caller)
103
+ return parsePrdRaw(filePath);
104
+ }
105
+ if (st.size > PRD_READ_MAX_BYTES) {
106
+ // Evict any stale cached entry so callers see this as a parse miss.
107
+ prdFileCache.delete(filePath);
108
+ throw new Error(`PRD too large (${st.size}B > ${PRD_READ_MAX_BYTES}B): ${filePath}`);
109
+ }
110
+ const cached = prdFileCache.get(filePath);
111
+ if (cached && cached.mtimeMs === st.mtimeMs && cached.ino === st.ino) {
112
+ return cached.parsed;
113
+ }
114
+ // Evict BEFORE re-parsing so a parse exception leaves the cache empty
115
+ // rather than holding a stale-good entry for the new mtime.
116
+ prdFileCache.delete(filePath);
117
+ const parsed = await parsePrdRaw(filePath);
118
+ prdFileCache.set(filePath, { mtimeMs: st.mtimeMs, ino: st.ino, parsed });
119
+ return parsed;
120
+ }
121
+
122
+ /** Test-only: drop both cache layers so successive runs see fresh disk state. */
123
+ function _resetCache() {
124
+ prdDirMtime = -1;
125
+ prdDirFiles = null;
126
+ prdFileCache.clear();
127
+ }
128
+
129
+ module.exports = {
130
+ parsePrdRaw,
131
+ parsePrd,
132
+ listPrdFiles,
133
+ PRD_READ_MAX_BYTES,
134
+ _resetCache,
135
+ };