@ggterm/core 0.3.2 → 0.3.4
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 +173 -152
- 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") {
|
|
@@ -14693,6 +14713,15 @@ function handleServe(port) {
|
|
|
14693
14713
|
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
14694
14714
|
res.end(CLIENT_HTML);
|
|
14695
14715
|
});
|
|
14716
|
+
server.on("error", (err) => {
|
|
14717
|
+
if (err.code === "EADDRINUSE") {
|
|
14718
|
+
console.error(`Port ${p} is already in use.`);
|
|
14719
|
+
console.error(`Kill the existing server: lsof -ti:${p} | xargs kill`);
|
|
14720
|
+
console.error(`Or use a different port: npx ggterm-plot serve ${p + 1}`);
|
|
14721
|
+
process.exit(1);
|
|
14722
|
+
}
|
|
14723
|
+
throw err;
|
|
14724
|
+
});
|
|
14696
14725
|
server.listen(p, () => {
|
|
14697
14726
|
const url = `http://localhost:${p}`;
|
|
14698
14727
|
console.log(`ggterm live viewer running at ${url}`);
|
|
@@ -15177,13 +15206,13 @@ var init_serve = __esm(() => {
|
|
|
15177
15206
|
// src/cli-plot.ts
|
|
15178
15207
|
init_src();
|
|
15179
15208
|
init_history();
|
|
15180
|
-
import { readFileSync as
|
|
15209
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, existsSync as existsSync4 } from "fs";
|
|
15181
15210
|
import { join as join4 } from "path";
|
|
15182
15211
|
|
|
15183
15212
|
// src/init.ts
|
|
15184
15213
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync2, existsSync as existsSync2, readdirSync as readdirSync2, statSync } from "fs";
|
|
15185
15214
|
import { join as join2, extname } from "path";
|
|
15186
|
-
var SKILLS_VERSION = "0.2
|
|
15215
|
+
var SKILLS_VERSION = "0.3.2";
|
|
15187
15216
|
var SKILLS = {
|
|
15188
15217
|
"data-load": {
|
|
15189
15218
|
files: {
|
|
@@ -15197,73 +15226,41 @@ allowed-tools: Bash(npx:*), Read, Write
|
|
|
15197
15226
|
|
|
15198
15227
|
Load data into arrays of records for use with ggterm plotting and analysis.
|
|
15199
15228
|
|
|
15200
|
-
##
|
|
15201
|
-
|
|
15202
|
-
### CSV
|
|
15229
|
+
## Built-in Datasets (No files needed!)
|
|
15203
15230
|
|
|
15204
|
-
|
|
15205
|
-
import { parse } from 'csv-parse/sync'
|
|
15206
|
-
import { readFileSync } from 'fs'
|
|
15231
|
+
ggterm includes built-in datasets that can be used directly by name:
|
|
15207
15232
|
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
skip_empty_lines: true
|
|
15213
|
-
})
|
|
15214
|
-
\`\`\`
|
|
15215
|
-
|
|
15216
|
-
**Alternative with d3-dsv** (lighter weight):
|
|
15233
|
+
| Dataset | Rows | Columns |
|
|
15234
|
+
|---------|------|---------|
|
|
15235
|
+
| \`iris\` | 150 | sepal_length, sepal_width, petal_length, petal_width, species |
|
|
15236
|
+
| \`mtcars\` | 16 | mpg, cyl, hp, wt, name |
|
|
15217
15237
|
|
|
15218
|
-
|
|
15219
|
-
import { csvParse, autoType } from 'd3-dsv'
|
|
15238
|
+
Use them directly in plot commands:
|
|
15220
15239
|
|
|
15221
|
-
|
|
15240
|
+
\`\`\`bash
|
|
15241
|
+
npx ggterm-plot iris sepal_length sepal_width species "Iris Dataset" point
|
|
15242
|
+
npx ggterm-plot mtcars mpg hp cyl "Motor Trend Cars" point
|
|
15222
15243
|
\`\`\`
|
|
15223
15244
|
|
|
15224
|
-
|
|
15245
|
+
**IMPORTANT**: When the user asks about iris, mtcars, or bundled/built-in datasets, use these names directly with \`npx ggterm-plot\`. Do NOT try to generate CSV files or install Python packages.
|
|
15225
15246
|
|
|
15226
|
-
|
|
15227
|
-
import { readFileSync } from 'fs'
|
|
15247
|
+
## External Files
|
|
15228
15248
|
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
### JSONL (Newline-delimited JSON)
|
|
15234
|
-
|
|
15235
|
-
\`\`\`typescript
|
|
15236
|
-
const data = readFileSync('data.jsonl', 'utf-8')
|
|
15237
|
-
.trim()
|
|
15238
|
-
.split('\\n')
|
|
15239
|
-
.map(line => JSON.parse(line))
|
|
15249
|
+
\`\`\`bash
|
|
15250
|
+
npx ggterm-plot data.csv x_column y_column color_column "Title" point
|
|
15251
|
+
npx ggterm-plot data.json x_column y_column
|
|
15252
|
+
npx ggterm-plot data.jsonl x_column y_column
|
|
15240
15253
|
\`\`\`
|
|
15241
15254
|
|
|
15242
15255
|
## Verification
|
|
15243
15256
|
|
|
15244
|
-
|
|
15257
|
+
Inspect any data file to see columns and types:
|
|
15245
15258
|
|
|
15246
|
-
\`\`\`
|
|
15247
|
-
|
|
15248
|
-
console.log('Columns:', Object.keys(data[0]))
|
|
15249
|
-
console.log('Sample row:', data[0])
|
|
15259
|
+
\`\`\`bash
|
|
15260
|
+
npx ggterm-plot inspect data.csv
|
|
15250
15261
|
\`\`\`
|
|
15251
15262
|
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
Once data is loaded, pass directly to ggterm:
|
|
15255
|
-
|
|
15256
|
-
\`\`\`typescript
|
|
15257
|
-
import { gg, geom_point } from '@ggterm/core'
|
|
15258
|
-
|
|
15259
|
-
const data = loadData('measurements.csv')
|
|
15260
|
-
|
|
15261
|
-
const plot = gg(data)
|
|
15262
|
-
.aes({ x: 'time', y: 'value' })
|
|
15263
|
-
.geom(geom_point())
|
|
15264
|
-
|
|
15265
|
-
console.log(plot.render({ width: 80, height: 24 }))
|
|
15266
|
-
\`\`\`
|
|
15263
|
+
$ARGUMENTS
|
|
15267
15264
|
`
|
|
15268
15265
|
}
|
|
15269
15266
|
},
|
|
@@ -15277,62 +15274,77 @@ allowed-tools: Bash(npx:ggterm-plot*), Read
|
|
|
15277
15274
|
|
|
15278
15275
|
# Terminal Plotting with ggterm
|
|
15279
15276
|
|
|
15280
|
-
Create plots using the CLI tool.
|
|
15277
|
+
Create plots using the CLI tool. Supports both built-in datasets and external files.
|
|
15278
|
+
|
|
15279
|
+
## Built-in Datasets
|
|
15281
15280
|
|
|
15282
|
-
|
|
15281
|
+
ggterm includes datasets that work by name — no CSV files needed:
|
|
15282
|
+
|
|
15283
|
+
| Dataset | Rows | Columns |
|
|
15284
|
+
|---------|------|---------|
|
|
15285
|
+
| \`iris\` | 150 | sepal_length, sepal_width, petal_length, petal_width, species |
|
|
15286
|
+
| \`mtcars\` | 16 | mpg, cyl, hp, wt, name |
|
|
15283
15287
|
|
|
15284
15288
|
\`\`\`bash
|
|
15285
|
-
npx ggterm-plot
|
|
15289
|
+
npx ggterm-plot iris sepal_length sepal_width species "Iris" point
|
|
15290
|
+
npx ggterm-plot mtcars mpg hp cyl "Cars" point
|
|
15286
15291
|
\`\`\`
|
|
15287
15292
|
|
|
15288
|
-
|
|
15293
|
+
**IMPORTANT**: When the user mentions iris, mtcars, or asks for demo/sample data, use these built-in names directly. Do NOT look for CSV files or generate data.
|
|
15294
|
+
|
|
15295
|
+
## Live Plot Viewer
|
|
15289
15296
|
|
|
15290
|
-
|
|
15297
|
+
Start the companion viewer for high-resolution interactive plots:
|
|
15291
15298
|
|
|
15292
15299
|
\`\`\`bash
|
|
15293
|
-
npx ggterm-plot
|
|
15300
|
+
npx ggterm-plot serve # default port 4242
|
|
15301
|
+
npx ggterm-plot serve 8080 # custom port
|
|
15294
15302
|
\`\`\`
|
|
15295
15303
|
|
|
15296
|
-
|
|
15304
|
+
When serve is running, plots auto-display in the browser/Wave panel instead of ASCII art.
|
|
15297
15305
|
|
|
15298
|
-
##
|
|
15306
|
+
## CLI Command
|
|
15299
15307
|
|
|
15300
15308
|
\`\`\`bash
|
|
15301
|
-
npx ggterm-plot <data
|
|
15309
|
+
npx ggterm-plot <data> <x> <y> [color] [title] [geom]
|
|
15302
15310
|
\`\`\`
|
|
15303
15311
|
|
|
15304
15312
|
Arguments:
|
|
15305
|
-
- \`data
|
|
15313
|
+
- \`data\` - Built-in dataset name (\`iris\`, \`mtcars\`) OR path to CSV/JSON/JSONL file
|
|
15306
15314
|
- \`x\` - Column name for x-axis
|
|
15307
15315
|
- \`y\` - Column name for y-axis (use \`-\` for histogram)
|
|
15308
15316
|
- \`color\` - Column name for color (optional, use \`-\` to skip)
|
|
15309
15317
|
- \`title\` - Plot title (optional, use \`-\` to skip)
|
|
15310
|
-
- \`geom\` - Geometry type: \`point\` (default), \`line\`, \`histogram\`, \`boxplot\`, \`bar\`, \`violin\`, \`area\`, etc.
|
|
15318
|
+
- \`geom\` - Geometry type: \`point\` (default), \`line\`, \`histogram\`, \`boxplot\`, \`bar\`, \`violin\`, \`density\`, \`area\`, etc.
|
|
15311
15319
|
|
|
15312
|
-
##
|
|
15320
|
+
## Inspect & Suggest (for external files)
|
|
15313
15321
|
|
|
15314
|
-
Scatter plot:
|
|
15315
15322
|
\`\`\`bash
|
|
15316
|
-
npx ggterm-plot data.csv
|
|
15323
|
+
npx ggterm-plot inspect <data.csv>
|
|
15324
|
+
npx ggterm-plot suggest <data.csv>
|
|
15317
15325
|
\`\`\`
|
|
15318
15326
|
|
|
15319
|
-
|
|
15327
|
+
## Examples
|
|
15328
|
+
|
|
15329
|
+
Built-in data:
|
|
15320
15330
|
\`\`\`bash
|
|
15321
|
-
npx ggterm-plot
|
|
15331
|
+
npx ggterm-plot iris sepal_length sepal_width species "Iris Dataset" point
|
|
15332
|
+
npx ggterm-plot iris petal_length - species "Petal Length" histogram
|
|
15333
|
+
npx ggterm-plot mtcars mpg hp cyl "MPG vs HP" point
|
|
15322
15334
|
\`\`\`
|
|
15323
15335
|
|
|
15324
|
-
|
|
15336
|
+
External files:
|
|
15325
15337
|
\`\`\`bash
|
|
15326
|
-
npx ggterm-plot data.csv
|
|
15338
|
+
npx ggterm-plot data.csv x y color "Title" point
|
|
15339
|
+
npx ggterm-plot data.json date value - "Time Series" line
|
|
15327
15340
|
\`\`\`
|
|
15328
15341
|
|
|
15329
15342
|
## Workflow
|
|
15330
15343
|
|
|
15331
|
-
1.
|
|
15332
|
-
2.
|
|
15333
|
-
3. Run
|
|
15334
|
-
4.
|
|
15335
|
-
5. Briefly describe what the plot shows
|
|
15344
|
+
1. If user asks for iris/mtcars/demo data, use built-in dataset names directly
|
|
15345
|
+
2. For external files: run \`inspect\` to see columns, then \`suggest\` for recommendations
|
|
15346
|
+
3. Run the plot command
|
|
15347
|
+
4. Briefly describe what the plot shows
|
|
15336
15348
|
|
|
15337
15349
|
$ARGUMENTS
|
|
15338
15350
|
|
|
@@ -15345,6 +15357,11 @@ $ARGUMENTS
|
|
|
15345
15357
|
| Distribution of 1 variable | \`histogram\` | Frequency distribution |
|
|
15346
15358
|
| Distribution by group | \`boxplot\` | Compare medians |
|
|
15347
15359
|
| Category comparison | \`bar\` | Counts per category |
|
|
15360
|
+
| Smoothed distribution | \`density\` | Kernel density estimate |
|
|
15361
|
+
| Density shape | \`violin\` | Distribution shape |
|
|
15362
|
+
| Stacked distributions | \`ridgeline\` | Joy plot |
|
|
15363
|
+
| Filled region | \`area\` | Cumulative or stacked |
|
|
15364
|
+
| Cumulative distribution | \`ecdf\` | Empirical CDF |
|
|
15348
15365
|
`
|
|
15349
15366
|
}
|
|
15350
15367
|
},
|
|
@@ -15465,7 +15482,7 @@ $ARGUMENTS
|
|
|
15465
15482
|
"SKILL.md": `---
|
|
15466
15483
|
name: ggterm-customize
|
|
15467
15484
|
description: Customize plot aesthetics using natural language. Use when the user wants to change colors, fonts, titles, labels, themes, or any visual aspect of a plot before publication.
|
|
15468
|
-
allowed-tools: Read, Write
|
|
15485
|
+
allowed-tools: Read, Write, Bash(npx:*)
|
|
15469
15486
|
---
|
|
15470
15487
|
|
|
15471
15488
|
# Natural Language Plot Customization
|
|
@@ -15522,7 +15539,7 @@ $ARGUMENTS
|
|
|
15522
15539
|
"SKILL.md": `---
|
|
15523
15540
|
name: ggterm-style
|
|
15524
15541
|
description: Apply publication-quality style presets to plots. Use when the user wants to style a plot like Wilke, Tufte, Nature, The Economist, or apply minimal/publication styling.
|
|
15525
|
-
allowed-tools: Read, Write
|
|
15542
|
+
allowed-tools: Read, Write, Bash(npx:*)
|
|
15526
15543
|
---
|
|
15527
15544
|
|
|
15528
15545
|
# Plot Style Presets
|
|
@@ -15547,47 +15564,6 @@ Apply expert-curated style presets to Vega-Lite specifications for publication-q
|
|
|
15547
15564
|
3. Write the updated spec
|
|
15548
15565
|
4. Inform user they can export with \`/ggterm-publish\`
|
|
15549
15566
|
|
|
15550
|
-
## Style Configurations
|
|
15551
|
-
|
|
15552
|
-
### Wilke Style (Recommended Default)
|
|
15553
|
-
|
|
15554
|
-
\`\`\`javascript
|
|
15555
|
-
const wilkeStyle = {
|
|
15556
|
-
config: {
|
|
15557
|
-
font: "Helvetica Neue, Helvetica, Arial, sans-serif",
|
|
15558
|
-
background: "white",
|
|
15559
|
-
view: { stroke: null },
|
|
15560
|
-
title: { fontSize: 14, fontWeight: "normal", anchor: "start" },
|
|
15561
|
-
axis: { grid: false, labelFontSize: 11, titleFontSize: 12 },
|
|
15562
|
-
axisY: { grid: true, gridColor: "#ebebeb" }
|
|
15563
|
-
}
|
|
15564
|
-
}
|
|
15565
|
-
\`\`\`
|
|
15566
|
-
|
|
15567
|
-
### Tufte Style
|
|
15568
|
-
|
|
15569
|
-
\`\`\`javascript
|
|
15570
|
-
const tufteStyle = {
|
|
15571
|
-
config: {
|
|
15572
|
-
font: "Georgia, serif",
|
|
15573
|
-
view: { stroke: null },
|
|
15574
|
-
axis: { domain: false, grid: false, ticks: false }
|
|
15575
|
-
}
|
|
15576
|
-
}
|
|
15577
|
-
\`\`\`
|
|
15578
|
-
|
|
15579
|
-
### Economist Style
|
|
15580
|
-
|
|
15581
|
-
\`\`\`javascript
|
|
15582
|
-
const economistStyle = {
|
|
15583
|
-
config: {
|
|
15584
|
-
background: "#d5e4eb",
|
|
15585
|
-
axis: { grid: true, gridColor: "#ffffff" },
|
|
15586
|
-
axisX: { grid: false, domain: true }
|
|
15587
|
-
}
|
|
15588
|
-
}
|
|
15589
|
-
\`\`\`
|
|
15590
|
-
|
|
15591
15567
|
## Response Format
|
|
15592
15568
|
|
|
15593
15569
|
After applying a style:
|
|
@@ -15624,18 +15600,6 @@ Generate analysis reports with embedded terminal visualizations.
|
|
|
15624
15600
|
3. **Visualizations** - Embedded plots with interpretations
|
|
15625
15601
|
4. **Findings** - Key insights from the analysis
|
|
15626
15602
|
|
|
15627
|
-
## Embedding Plots
|
|
15628
|
-
|
|
15629
|
-
\`\`\`markdown
|
|
15630
|
-
## Visualization
|
|
15631
|
-
|
|
15632
|
-
\\\`\\\`\\\`
|
|
15633
|
-
[terminal plot output here]
|
|
15634
|
-
\\\`\\\`\\\`
|
|
15635
|
-
|
|
15636
|
-
**Interpretation**: The scatter plot shows [describe the relationship observed].
|
|
15637
|
-
\`\`\`
|
|
15638
|
-
|
|
15639
15603
|
## Width Guidelines
|
|
15640
15604
|
|
|
15641
15605
|
| Context | Width | Height |
|
|
@@ -15765,6 +15729,63 @@ function handleInit() {
|
|
|
15765
15729
|
console.log(`ggterm v${SKILLS_VERSION} ready`);
|
|
15766
15730
|
console.log("");
|
|
15767
15731
|
}
|
|
15732
|
+
const claudeMdPath = join2(cwd, "CLAUDE.md");
|
|
15733
|
+
const claudeMdContent = `# ggterm Data Analysis Project
|
|
15734
|
+
|
|
15735
|
+
This project uses ggterm (@ggterm/core) for data visualization.
|
|
15736
|
+
|
|
15737
|
+
## IMPORTANT: Built-in Datasets
|
|
15738
|
+
|
|
15739
|
+
ggterm has built-in datasets that work by name — NO CSV files or Python packages needed:
|
|
15740
|
+
|
|
15741
|
+
\`\`\`bash
|
|
15742
|
+
npx ggterm-plot iris sepal_length sepal_width species "Iris" point
|
|
15743
|
+
npx ggterm-plot mtcars mpg hp cyl "Cars" point
|
|
15744
|
+
\`\`\`
|
|
15745
|
+
|
|
15746
|
+
| Dataset | Rows | Columns |
|
|
15747
|
+
|---------|------|---------|
|
|
15748
|
+
| \`iris\` | 150 | sepal_length, sepal_width, petal_length, petal_width, species |
|
|
15749
|
+
| \`mtcars\` | 16 | mpg, cyl, hp, wt, name |
|
|
15750
|
+
|
|
15751
|
+
When asked about iris, mtcars, or sample data, use these names directly as the first argument to \`npx ggterm-plot\`. Do NOT search for CSV files or generate data.
|
|
15752
|
+
|
|
15753
|
+
## Plotting Commands
|
|
15754
|
+
|
|
15755
|
+
\`\`\`bash
|
|
15756
|
+
npx ggterm-plot <data> <x> <y> [color] [title] [geom]
|
|
15757
|
+
npx ggterm-plot serve # Start live viewer (port 4242)
|
|
15758
|
+
npx ggterm-plot inspect <file> # Show column types
|
|
15759
|
+
npx ggterm-plot suggest <file> # Suggest visualizations
|
|
15760
|
+
npx ggterm-plot history # List previous plots
|
|
15761
|
+
npx ggterm-plot export <id> out.html # Export plot
|
|
15762
|
+
\`\`\`
|
|
15763
|
+
|
|
15764
|
+
## Geom Types
|
|
15765
|
+
|
|
15766
|
+
point, line, histogram, boxplot, bar, violin, density, area, ridgeline, heatmap, scatter, ecdf, smooth, and 50+ more.
|
|
15767
|
+
|
|
15768
|
+
## Live Viewer
|
|
15769
|
+
|
|
15770
|
+
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.
|
|
15771
|
+
`;
|
|
15772
|
+
const GGTERM_MARKER = "# ggterm Data Analysis Project";
|
|
15773
|
+
let shouldWriteClaudeMd = !existsSync2(claudeMdPath);
|
|
15774
|
+
if (!shouldWriteClaudeMd) {
|
|
15775
|
+
try {
|
|
15776
|
+
const existing = readFileSync2(claudeMdPath, "utf-8");
|
|
15777
|
+
shouldWriteClaudeMd = existing.startsWith(GGTERM_MARKER);
|
|
15778
|
+
} catch {}
|
|
15779
|
+
}
|
|
15780
|
+
if (shouldWriteClaudeMd) {
|
|
15781
|
+
writeFileSync2(claudeMdPath, claudeMdContent);
|
|
15782
|
+
console.log(" ✓ CLAUDE.md (project instructions for Claude Code)");
|
|
15783
|
+
console.log("");
|
|
15784
|
+
}
|
|
15785
|
+
console.log("Built-in datasets:");
|
|
15786
|
+
console.log(" • iris (150 rows: sepal_length, sepal_width, petal_length, petal_width, species)");
|
|
15787
|
+
console.log(" • mtcars (16 rows: mpg, cyl, hp, wt, name)");
|
|
15788
|
+
console.log("");
|
|
15768
15789
|
const dataFiles = findDataFiles(cwd);
|
|
15769
15790
|
if (dataFiles.length > 0) {
|
|
15770
15791
|
console.log("Data files:");
|
|
@@ -15792,9 +15813,9 @@ function handleInit() {
|
|
|
15792
15813
|
}
|
|
15793
15814
|
if (needsInstall) {
|
|
15794
15815
|
console.log("Try:");
|
|
15795
|
-
console.log('
|
|
15796
|
-
console.log(
|
|
15797
|
-
console.log(' "
|
|
15816
|
+
console.log(' npx ggterm-plot iris sepal_length sepal_width species "Iris" point');
|
|
15817
|
+
console.log(" npx ggterm-plot serve # Start live viewer");
|
|
15818
|
+
console.log(' "Plot the iris dataset" # Ask Claude Code');
|
|
15798
15819
|
console.log("");
|
|
15799
15820
|
}
|
|
15800
15821
|
}
|
|
@@ -15802,10 +15823,10 @@ function handleInit() {
|
|
|
15802
15823
|
// src/cli-plot.ts
|
|
15803
15824
|
function isServeRunning() {
|
|
15804
15825
|
const markerPath = join4(getGGTermDir(), "serve.json");
|
|
15805
|
-
if (!
|
|
15826
|
+
if (!existsSync4(markerPath))
|
|
15806
15827
|
return false;
|
|
15807
15828
|
try {
|
|
15808
|
-
const info = JSON.parse(
|
|
15829
|
+
const info = JSON.parse(readFileSync4(markerPath, "utf-8"));
|
|
15809
15830
|
process.kill(info.pid, 0);
|
|
15810
15831
|
return true;
|
|
15811
15832
|
} catch {
|
|
@@ -15880,7 +15901,7 @@ var GEOM_TYPES = [
|
|
|
15880
15901
|
var datePattern = /^\d{4}-\d{2}-\d{2}/;
|
|
15881
15902
|
function fileExists(path) {
|
|
15882
15903
|
try {
|
|
15883
|
-
|
|
15904
|
+
readFileSync4(path);
|
|
15884
15905
|
return true;
|
|
15885
15906
|
} catch {
|
|
15886
15907
|
return false;
|
|
@@ -16025,7 +16046,7 @@ Make sure the file path is correct and the file exists.`);
|
|
|
16025
16046
|
}
|
|
16026
16047
|
let text;
|
|
16027
16048
|
try {
|
|
16028
|
-
text =
|
|
16049
|
+
text = readFileSync4(dataFile, "utf-8");
|
|
16029
16050
|
} catch (err) {
|
|
16030
16051
|
console.error(`
|
|
16031
16052
|
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;AAkgBH,wBAAgB,UAAU,IAAI,IAAI,CAyJjC"}
|
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"}
|