@threadbase-sh/streamer 1.46.2 → 1.47.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.
- package/dist/cli.cjs +11410 -10660
- package/dist/cli.cjs.map +1 -1
- package/dist/ensure-demo-project-dirs.cjs +105 -0
- package/dist/ensure-demo-project-dirs.cjs.map +1 -0
- package/dist/index.cjs +936 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -4
- package/dist/index.d.ts +100 -4
- package/dist/index.js +937 -195
- package/dist/index.js.map +1 -1
- package/dist/merge-server-yaml.cjs +97 -0
- package/dist/merge-server-yaml.cjs.map +1 -0
- package/dist/migrations/015_drop_projects_message_count.sql +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/docker/ensureDemoProjectDirs.ts
|
|
22
|
+
var ensureDemoProjectDirs_exports = {};
|
|
23
|
+
__export(ensureDemoProjectDirs_exports, {
|
|
24
|
+
ensureDemoProjectDirs: () => ensureDemoProjectDirs,
|
|
25
|
+
extractDemoCwds: () => extractDemoCwds,
|
|
26
|
+
listJsonlFiles: () => listJsonlFiles
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(ensureDemoProjectDirs_exports);
|
|
29
|
+
var import_node_fs = require("fs");
|
|
30
|
+
var import_node_path = require("path");
|
|
31
|
+
function listJsonlFiles(root) {
|
|
32
|
+
const out = [];
|
|
33
|
+
const stack = [root];
|
|
34
|
+
while (stack.length > 0) {
|
|
35
|
+
const dir = stack.pop();
|
|
36
|
+
if (dir === void 0) break;
|
|
37
|
+
let entries;
|
|
38
|
+
try {
|
|
39
|
+
entries = (0, import_node_fs.readdirSync)(dir);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (err.code === "ENOENT") return out;
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
for (const name of entries) {
|
|
45
|
+
const full = (0, import_node_path.join)(dir, name);
|
|
46
|
+
try {
|
|
47
|
+
const st = (0, import_node_fs.statSync)(full);
|
|
48
|
+
if (st.isDirectory()) stack.push(full);
|
|
49
|
+
else if (st.isFile() && name.endsWith(".jsonl")) out.push(full);
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function extractDemoCwds(projectsRoot) {
|
|
57
|
+
const cwds = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const file of listJsonlFiles(projectsRoot)) {
|
|
59
|
+
const text = (0, import_node_fs.readFileSync)(file, "utf8");
|
|
60
|
+
for (const line of text.split("\n")) {
|
|
61
|
+
if (!line.trim()) continue;
|
|
62
|
+
try {
|
|
63
|
+
const obj = JSON.parse(line);
|
|
64
|
+
if (typeof obj.cwd === "string" && obj.cwd.length > 0 && obj.cwd.startsWith("/")) {
|
|
65
|
+
cwds.add(obj.cwd);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return [...cwds].sort();
|
|
72
|
+
}
|
|
73
|
+
function ensureDemoProjectDirs(projectsRoot) {
|
|
74
|
+
const cwds = extractDemoCwds(projectsRoot);
|
|
75
|
+
for (const cwd of cwds) {
|
|
76
|
+
(0, import_node_fs.mkdirSync)(cwd, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
return cwds;
|
|
79
|
+
}
|
|
80
|
+
function main() {
|
|
81
|
+
const projectsRoot = process.env.DEMO_PROJECTS_ROOT ?? process.argv[2];
|
|
82
|
+
if (!projectsRoot) {
|
|
83
|
+
console.error("[entrypoint] ensure-demo-project-dirs: DEMO_PROJECTS_ROOT or argv[2] required");
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const cwds = ensureDemoProjectDirs(projectsRoot);
|
|
88
|
+
for (const cwd of cwds) {
|
|
89
|
+
console.log(cwd);
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error(`[entrypoint] ${err.message}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (require.main === module) {
|
|
97
|
+
main();
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
ensureDemoProjectDirs,
|
|
102
|
+
extractDemoCwds,
|
|
103
|
+
listJsonlFiles
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=ensure-demo-project-dirs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/docker/ensureDemoProjectDirs.ts"],"sourcesContent":["// Walk a Claude projects tree (…/.claude/projects/**/*.jsonl), collect every\n// unique `cwd` value, and mkdir -p each one. Demo seed JSONLs reference paths\n// like /home/demo/projects/threadbase-mobile; when PTYManager resumes a\n// session it chdirs there, and a missing directory fails the spawn with\n// \"chdir(2) failed\". Deriving the list from the corpus removes the hardcoded\n// mkdir block in entrypoint.sh that drifted whenever a new seed was added.\n//\n// Compiled by tsup to dist/ensure-demo-project-dirs.cjs.\nimport { mkdirSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/** Recursively list *.jsonl files under `root`. */\nexport function listJsonlFiles(root: string): string[] {\n const out: string[] = [];\n const stack: string[] = [root];\n while (stack.length > 0) {\n const dir = stack.pop();\n if (dir === undefined) break;\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return out;\n throw err;\n }\n for (const name of entries) {\n const full = join(dir, name);\n try {\n const st = statSync(full);\n if (st.isDirectory()) stack.push(full);\n else if (st.isFile() && name.endsWith(\".jsonl\")) out.push(full);\n } catch {\n // Skip unreadable entries (races / permissions).\n }\n }\n }\n return out;\n}\n\n/**\n * Parse JSONL files under `projectsRoot` and return sorted unique absolute\n * `cwd` strings. Malformed lines and missing `cwd` are skipped.\n */\nexport function extractDemoCwds(projectsRoot: string): string[] {\n const cwds = new Set<string>();\n for (const file of listJsonlFiles(projectsRoot)) {\n const text = readFileSync(file, \"utf8\");\n for (const line of text.split(\"\\n\")) {\n if (!line.trim()) continue;\n try {\n const obj = JSON.parse(line) as { cwd?: unknown };\n if (typeof obj.cwd === \"string\" && obj.cwd.length > 0 && obj.cwd.startsWith(\"/\")) {\n cwds.add(obj.cwd);\n }\n } catch {\n // Skip corrupt lines — same tolerance the scanner uses.\n }\n }\n }\n return [...cwds].sort();\n}\n\n/** Extract cwds from `projectsRoot` and create each directory. Returns the list. */\nexport function ensureDemoProjectDirs(projectsRoot: string): string[] {\n const cwds = extractDemoCwds(projectsRoot);\n for (const cwd of cwds) {\n mkdirSync(cwd, { recursive: true });\n }\n return cwds;\n}\n\nfunction main(): void {\n const projectsRoot = process.env.DEMO_PROJECTS_ROOT ?? process.argv[2];\n if (!projectsRoot) {\n console.error(\"[entrypoint] ensure-demo-project-dirs: DEMO_PROJECTS_ROOT or argv[2] required\");\n process.exit(1);\n }\n try {\n const cwds = ensureDemoProjectDirs(projectsRoot);\n for (const cwd of cwds) {\n console.log(cwd);\n }\n } catch (err) {\n console.error(`[entrypoint] ${(err as Error).message}`);\n process.exit(1);\n }\n}\n\nif (require.main === module) {\n main();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAA+D;AAC/D,uBAAqB;AAGd,SAAS,eAAe,MAAwB;AACrD,QAAM,MAAgB,CAAC;AACvB,QAAM,QAAkB,CAAC,IAAI;AAC7B,SAAO,MAAM,SAAS,GAAG;AACvB,UAAM,MAAM,MAAM,IAAI;AACtB,QAAI,QAAQ,OAAW;AACvB,QAAI;AACJ,QAAI;AACF,oBAAU,4BAAY,GAAG;AAAA,IAC3B,SAAS,KAAK;AACZ,UAAK,IAA8B,SAAS,SAAU,QAAO;AAC7D,YAAM;AAAA,IACR;AACA,eAAW,QAAQ,SAAS;AAC1B,YAAM,WAAO,uBAAK,KAAK,IAAI;AAC3B,UAAI;AACF,cAAM,SAAK,yBAAS,IAAI;AACxB,YAAI,GAAG,YAAY,EAAG,OAAM,KAAK,IAAI;AAAA,iBAC5B,GAAG,OAAO,KAAK,KAAK,SAAS,QAAQ,EAAG,KAAI,KAAK,IAAI;AAAA,MAChE,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,gBAAgB,cAAgC;AAC9D,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,QAAQ,eAAe,YAAY,GAAG;AAC/C,UAAM,WAAO,6BAAa,MAAM,MAAM;AACtC,eAAW,QAAQ,KAAK,MAAM,IAAI,GAAG;AACnC,UAAI,CAAC,KAAK,KAAK,EAAG;AAClB,UAAI;AACF,cAAM,MAAM,KAAK,MAAM,IAAI;AAC3B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