@ggterm/core 0.3.3 → 0.3.5
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-plot.js +53 -27
- package/dist/init.d.ts.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli-plot.js
CHANGED
|
@@ -14599,7 +14599,7 @@ var exports_serve = {};
|
|
|
14599
14599
|
__export(exports_serve, {
|
|
14600
14600
|
handleServe: () => handleServe
|
|
14601
14601
|
});
|
|
14602
|
-
import { watch, writeFileSync as writeFileSync3, unlinkSync } from "fs";
|
|
14602
|
+
import { watch, readFileSync as readFileSync3, writeFileSync as writeFileSync3, unlinkSync, existsSync as existsSync3 } from "fs";
|
|
14603
14603
|
import { join as join3 } from "path";
|
|
14604
14604
|
import { createServer } from "http";
|
|
14605
14605
|
import { spawn } from "child_process";
|
|
@@ -14629,6 +14629,18 @@ function handleServe(port) {
|
|
|
14629
14629
|
ensureHistoryDirs();
|
|
14630
14630
|
const clients = new Set;
|
|
14631
14631
|
let debounceTimer = null;
|
|
14632
|
+
function broadcast(payload) {
|
|
14633
|
+
const sseData = `data: ${payload}
|
|
14634
|
+
|
|
14635
|
+
`;
|
|
14636
|
+
for (const client of clients) {
|
|
14637
|
+
try {
|
|
14638
|
+
client.write(sseData);
|
|
14639
|
+
} catch {
|
|
14640
|
+
clients.delete(client);
|
|
14641
|
+
}
|
|
14642
|
+
}
|
|
14643
|
+
}
|
|
14632
14644
|
const plotsDir = getPlotsDir();
|
|
14633
14645
|
watch(plotsDir, (_event, filename) => {
|
|
14634
14646
|
if (!filename || !filename.endsWith(".json"))
|
|
@@ -14637,20 +14649,28 @@ function handleServe(port) {
|
|
|
14637
14649
|
clearTimeout(debounceTimer);
|
|
14638
14650
|
debounceTimer = setTimeout(() => {
|
|
14639
14651
|
const payload = getLatestPayload();
|
|
14640
|
-
if (
|
|
14641
|
-
|
|
14642
|
-
const sseData = `data: ${payload}
|
|
14643
|
-
|
|
14644
|
-
`;
|
|
14645
|
-
for (const client of clients) {
|
|
14646
|
-
try {
|
|
14647
|
-
client.write(sseData);
|
|
14648
|
-
} catch {
|
|
14649
|
-
clients.delete(client);
|
|
14650
|
-
}
|
|
14651
|
-
}
|
|
14652
|
+
if (payload)
|
|
14653
|
+
broadcast(payload);
|
|
14652
14654
|
}, 150);
|
|
14653
14655
|
});
|
|
14656
|
+
const vegaLitePath = join3(getGGTermDir(), "last-plot-vegalite.json");
|
|
14657
|
+
let styleDebounce = null;
|
|
14658
|
+
watch(getGGTermDir(), (_event, filename) => {
|
|
14659
|
+
if (filename !== "last-plot-vegalite.json")
|
|
14660
|
+
return;
|
|
14661
|
+
if (styleDebounce)
|
|
14662
|
+
clearTimeout(styleDebounce);
|
|
14663
|
+
styleDebounce = setTimeout(() => {
|
|
14664
|
+
if (!existsSync3(vegaLitePath))
|
|
14665
|
+
return;
|
|
14666
|
+
try {
|
|
14667
|
+
const spec = JSON.parse(readFileSync3(vegaLitePath, "utf-8"));
|
|
14668
|
+
const latestId = getLatestPlotId();
|
|
14669
|
+
const provenance = latestId ? { id: latestId, description: "Styled plot", timestamp: new Date().toISOString(), geomTypes: [] } : { id: "styled", description: "Styled plot", timestamp: new Date().toISOString(), geomTypes: [] };
|
|
14670
|
+
broadcast(JSON.stringify({ type: "plot", spec, provenance }));
|
|
14671
|
+
} catch {}
|
|
14672
|
+
}, 200);
|
|
14673
|
+
});
|
|
14654
14674
|
const server = createServer((req, res) => {
|
|
14655
14675
|
const url = new URL(req.url || "/", `http://localhost:${p}`);
|
|
14656
14676
|
if (url.pathname === "/events") {
|
|
@@ -15186,13 +15206,13 @@ var init_serve = __esm(() => {
|
|
|
15186
15206
|
// src/cli-plot.ts
|
|
15187
15207
|
init_src();
|
|
15188
15208
|
init_history();
|
|
15189
|
-
import { readFileSync as
|
|
15209
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, existsSync as existsSync4 } from "fs";
|
|
15190
15210
|
import { join as join4 } from "path";
|
|
15191
15211
|
|
|
15192
15212
|
// src/init.ts
|
|
15193
15213
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync2, existsSync as existsSync2, readdirSync as readdirSync2, statSync } from "fs";
|
|
15194
15214
|
import { join as join2, extname } from "path";
|
|
15195
|
-
var SKILLS_VERSION = "0.3.
|
|
15215
|
+
var SKILLS_VERSION = "0.3.4";
|
|
15196
15216
|
var SKILLS = {
|
|
15197
15217
|
"data-load": {
|
|
15198
15218
|
files: {
|
|
@@ -15504,11 +15524,12 @@ spec.height = 400
|
|
|
15504
15524
|
|
|
15505
15525
|
## Workflow
|
|
15506
15526
|
|
|
15507
|
-
1.
|
|
15508
|
-
2.
|
|
15509
|
-
3.
|
|
15510
|
-
4.
|
|
15511
|
-
|
|
15527
|
+
1. Read \`.ggterm/last-plot-vegalite.json\`
|
|
15528
|
+
2. Apply the requested modifications
|
|
15529
|
+
3. Write the updated spec back to \`.ggterm/last-plot-vegalite.json\`
|
|
15530
|
+
4. **DONE** — the live viewer auto-detects the change and displays the customized plot
|
|
15531
|
+
|
|
15532
|
+
**IMPORTANT**: Do NOT re-create the plot with \`npx ggterm-plot\` after customizing. The viewer watches the spec file and auto-updates. Re-running the plot command would overwrite your customizations.
|
|
15512
15533
|
|
|
15513
15534
|
$ARGUMENTS
|
|
15514
15535
|
`
|
|
@@ -15540,9 +15561,12 @@ Apply expert-curated style presets to Vega-Lite specifications for publication-q
|
|
|
15540
15561
|
## Workflow
|
|
15541
15562
|
|
|
15542
15563
|
1. Read \`.ggterm/last-plot-vegalite.json\`
|
|
15543
|
-
2. Apply the requested style preset
|
|
15544
|
-
3. Write the updated spec
|
|
15545
|
-
4.
|
|
15564
|
+
2. Apply the requested style preset (only modify \`config\` — do NOT change \`encoding\`, \`data\`, or \`mark\` structure)
|
|
15565
|
+
3. Write the updated spec back to \`.ggterm/last-plot-vegalite.json\`
|
|
15566
|
+
4. **DONE** — the live viewer auto-detects the change and displays the styled plot
|
|
15567
|
+
5. Inform user they can export with \`/ggterm-publish\`
|
|
15568
|
+
|
|
15569
|
+
**IMPORTANT**: Do NOT re-create the plot with \`npx ggterm-plot\` after styling. The viewer watches the spec file and auto-updates. Re-running the plot command would overwrite your style changes.
|
|
15546
15570
|
|
|
15547
15571
|
## Response Format
|
|
15548
15572
|
|
|
@@ -15748,6 +15772,8 @@ point, line, histogram, boxplot, bar, violin, density, area, ridgeline, heatmap,
|
|
|
15748
15772
|
## Live Viewer
|
|
15749
15773
|
|
|
15750
15774
|
When \`npx ggterm-plot serve\` is running, plots auto-display in the browser/Wave panel as high-resolution interactive Vega-Lite visualizations instead of ASCII art.
|
|
15775
|
+
|
|
15776
|
+
**Style and customize changes also auto-display.** When you modify \`.ggterm/last-plot-vegalite.json\` (via /ggterm-style or /ggterm-customize), the viewer updates automatically. Do NOT re-run \`npx ggterm-plot\` after styling — that would overwrite your changes.
|
|
15751
15777
|
`;
|
|
15752
15778
|
const GGTERM_MARKER = "# ggterm Data Analysis Project";
|
|
15753
15779
|
let shouldWriteClaudeMd = !existsSync2(claudeMdPath);
|
|
@@ -15803,10 +15829,10 @@ When \`npx ggterm-plot serve\` is running, plots auto-display in the browser/Wav
|
|
|
15803
15829
|
// src/cli-plot.ts
|
|
15804
15830
|
function isServeRunning() {
|
|
15805
15831
|
const markerPath = join4(getGGTermDir(), "serve.json");
|
|
15806
|
-
if (!
|
|
15832
|
+
if (!existsSync4(markerPath))
|
|
15807
15833
|
return false;
|
|
15808
15834
|
try {
|
|
15809
|
-
const info = JSON.parse(
|
|
15835
|
+
const info = JSON.parse(readFileSync4(markerPath, "utf-8"));
|
|
15810
15836
|
process.kill(info.pid, 0);
|
|
15811
15837
|
return true;
|
|
15812
15838
|
} catch {
|
|
@@ -15881,7 +15907,7 @@ var GEOM_TYPES = [
|
|
|
15881
15907
|
var datePattern = /^\d{4}-\d{2}-\d{2}/;
|
|
15882
15908
|
function fileExists(path) {
|
|
15883
15909
|
try {
|
|
15884
|
-
|
|
15910
|
+
readFileSync4(path);
|
|
15885
15911
|
return true;
|
|
15886
15912
|
} catch {
|
|
15887
15913
|
return false;
|
|
@@ -16026,7 +16052,7 @@ Make sure the file path is correct and the file exists.`);
|
|
|
16026
16052
|
}
|
|
16027
16053
|
let text;
|
|
16028
16054
|
try {
|
|
16029
|
-
text =
|
|
16055
|
+
text = readFileSync4(dataFile, "utf-8");
|
|
16030
16056
|
} catch (err) {
|
|
16031
16057
|
console.error(`
|
|
16032
16058
|
Error: Cannot read file: ${dataFile}`);
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsgBH,wBAAgB,UAAU,IAAI,IAAI,CA2JjC"}
|
package/dist/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0eH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0eH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAkI/C"}
|