jig-console 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +77 -2
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +224 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/convert.d.ts +10 -0
- package/dist/commands/convert.d.ts.map +1 -0
- package/dist/commands/convert.js +40 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/history.d.ts +8 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +112 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +225 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/pipeline.d.ts +17 -0
- package/dist/commands/pipeline.d.ts.map +1 -0
- package/dist/commands/pipeline.js +137 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/play.d.ts +13 -0
- package/dist/commands/play.d.ts.map +1 -0
- package/dist/commands/play.js +109 -0
- package/dist/commands/play.js.map +1 -0
- package/dist/commands/providers.d.ts +17 -0
- package/dist/commands/providers.d.ts.map +1 -0
- package/dist/commands/providers.js +161 -0
- package/dist/commands/providers.js.map +1 -0
- package/dist/commands/recipes.d.ts +16 -0
- package/dist/commands/recipes.d.ts.map +1 -0
- package/dist/commands/recipes.js +135 -0
- package/dist/commands/recipes.js.map +1 -0
- package/dist/commands/replay.d.ts +40 -0
- package/dist/commands/replay.d.ts.map +1 -0
- package/dist/commands/replay.js +206 -0
- package/dist/commands/replay.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +14 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/show.d.ts +15 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +39 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +77 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/validate.d.ts +6 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +36 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/help/jig-help.d.ts +25 -0
- package/dist/help/jig-help.d.ts.map +1 -0
- package/dist/help/jig-help.js +147 -0
- package/dist/help/jig-help.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +14 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +68 -0
- package/dist/keys.js.map +1 -0
- package/dist/live-view.d.ts +90 -0
- package/dist/live-view.d.ts.map +1 -0
- package/dist/live-view.js +239 -0
- package/dist/live-view.js.map +1 -0
- package/dist/permissions.d.ts +40 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +88 -0
- package/dist/permissions.js.map +1 -0
- package/dist/providers.d.ts +68 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +230 -0
- package/dist/providers.js.map +1 -0
- package/dist/session/app.d.ts +28 -0
- package/dist/session/app.d.ts.map +1 -0
- package/dist/session/app.js +458 -0
- package/dist/session/app.js.map +1 -0
- package/dist/session/ascii.d.ts +5 -0
- package/dist/session/ascii.d.ts.map +1 -0
- package/dist/session/ascii.js +39 -0
- package/dist/session/ascii.js.map +1 -0
- package/dist/session/commands.d.ts +26 -0
- package/dist/session/commands.d.ts.map +1 -0
- package/dist/session/commands.js +828 -0
- package/dist/session/commands.js.map +1 -0
- package/dist/session/controller.d.ts +291 -0
- package/dist/session/controller.d.ts.map +1 -0
- package/dist/session/controller.js +779 -0
- package/dist/session/controller.js.map +1 -0
- package/dist/session/editor.d.ts +60 -0
- package/dist/session/editor.d.ts.map +1 -0
- package/dist/session/editor.js +128 -0
- package/dist/session/editor.js.map +1 -0
- package/dist/session/jig-theme.json +1 -0
- package/dist/session/keys.d.ts +26 -0
- package/dist/session/keys.d.ts.map +1 -0
- package/dist/session/keys.js +95 -0
- package/dist/session/keys.js.map +1 -0
- package/dist/session/lines.d.ts +65 -0
- package/dist/session/lines.d.ts.map +1 -0
- package/dist/session/lines.js +370 -0
- package/dist/session/lines.js.map +1 -0
- package/dist/session/markdown.d.ts +13 -0
- package/dist/session/markdown.d.ts.map +1 -0
- package/dist/session/markdown.js +188 -0
- package/dist/session/markdown.js.map +1 -0
- package/dist/session/models.d.ts +24 -0
- package/dist/session/models.d.ts.map +1 -0
- package/dist/session/models.js +17 -0
- package/dist/session/models.js.map +1 -0
- package/dist/session/start.d.ts +27 -0
- package/dist/session/start.d.ts.map +1 -0
- package/dist/session/start.js +140 -0
- package/dist/session/start.js.map +1 -0
- package/dist/session/theme.d.ts +137 -0
- package/dist/session/theme.d.ts.map +1 -0
- package/dist/session/theme.js +129 -0
- package/dist/session/theme.js.map +1 -0
- package/dist/session-runner.d.ts +107 -0
- package/dist/session-runner.d.ts.map +1 -0
- package/dist/session-runner.js +463 -0
- package/dist/session-runner.js.map +1 -0
- package/dist/terminal-width.d.ts +7 -0
- package/dist/terminal-width.d.ts.map +1 -0
- package/dist/terminal-width.js +45 -0
- package/dist/terminal-width.js.map +1 -0
- package/dist/topology-arg.d.ts +12 -0
- package/dist/topology-arg.d.ts.map +1 -0
- package/dist/topology-arg.js +26 -0
- package/dist/topology-arg.js.map +1 -0
- package/docs/jig-help.md +70 -0
- package/package.json +73 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ============================================
|
|
3
|
+
// jig: the command
|
|
4
|
+
// ============================================
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
import { runCommand } from "./commands/run.js";
|
|
8
|
+
import { initCommand } from "./commands/init.js";
|
|
9
|
+
import { statusCommand } from "./commands/status.js";
|
|
10
|
+
import { brainsCommand, doctorCommand, providersCommand } from "./commands/providers.js";
|
|
11
|
+
import { historyCommand } from "./commands/history.js";
|
|
12
|
+
import { pipelineCommand } from "./commands/pipeline.js";
|
|
13
|
+
import { recipesCommand } from "./commands/recipes.js";
|
|
14
|
+
import { startSession } from "./session/start.js";
|
|
15
|
+
import { configCommand } from "./commands/config.js";
|
|
16
|
+
import { showCommand } from "./commands/show.js";
|
|
17
|
+
import { validateCommand } from "./commands/validate.js";
|
|
18
|
+
import { convertCommand } from "./commands/convert.js";
|
|
19
|
+
import { replayCommand } from "./commands/replay.js";
|
|
20
|
+
const program = new Command();
|
|
21
|
+
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8")).version;
|
|
22
|
+
program
|
|
23
|
+
.name("jig")
|
|
24
|
+
.description("Jig, a Joint Inference Graph: your own topology of models, used for real work and measured. With no command, a session.")
|
|
25
|
+
.version(version)
|
|
26
|
+
// The session's options come before any command, so run, show and the rest keep their own.
|
|
27
|
+
.enablePositionalOptions()
|
|
28
|
+
.option("--resume [session-id]", "Open the last session here again, or the one named")
|
|
29
|
+
.option("-t, --topology <id|file>", "The topology each task runs through (default: exec-eval, or the resumed session's)")
|
|
30
|
+
.option("-p, --provider <name>", "The provider roles run on when nothing names one")
|
|
31
|
+
.option("-m, --model <name>", "The model roles run on when nothing names one")
|
|
32
|
+
.option("--dir <path>", "Working directory", ".")
|
|
33
|
+
.option("--plain", "No colour or styles")
|
|
34
|
+
.option("--ascii", "ASCII only, for a terminal that cannot show the glyphs")
|
|
35
|
+
.option("--permission-mode <mode>", "default (asks before edits and commands), acceptEdits or plan; Shift+Tab cycles them")
|
|
36
|
+
.option("--add-dir <path>", "Another working directory roles may read and write in (repeatable)", collect, [])
|
|
37
|
+
.option("--dangerously-skip-permissions", "Run every tool call without asking, for this session only, except deny rules, ask rules and dangerous removals")
|
|
38
|
+
.action(async (options) => {
|
|
39
|
+
await startSession(options, version);
|
|
40
|
+
});
|
|
41
|
+
// ---- Commands ----
|
|
42
|
+
const runCmd = program
|
|
43
|
+
.command("run")
|
|
44
|
+
.description("Run a topology on a task (the Ralph Loop unless --topology says otherwise)")
|
|
45
|
+
.option("-t, --topology <id|file>", "Topology to run: a built-in id or a definition file", "ralph-loop")
|
|
46
|
+
.option("--task <text>", "The task (default: the prompt file's contents)")
|
|
47
|
+
.option("-p, --provider <name>", "LLM provider (ollama, openai, anthropic, google, openrouter)")
|
|
48
|
+
.option("-m, --model <name>", "Model to use")
|
|
49
|
+
.option("-i, --iterations <n>", "Round limit (turns, for the Ralph Loop)")
|
|
50
|
+
.option("-d, --delay <ms>", "Pause between rounds (ms)")
|
|
51
|
+
.option("--prompt <file>", "Prompt file the task is read from", "PROMPT.md")
|
|
52
|
+
.option("--plan <file>", "Plan file", "PLAN.md")
|
|
53
|
+
.option("--specs <dir>", "Specs directory")
|
|
54
|
+
.option("--dir <path>", "Working directory", ".")
|
|
55
|
+
.option("--param <key=value>", "Topology parameter (repeatable)", collect, [])
|
|
56
|
+
.option("--json", "Print every engine event as a JSON line")
|
|
57
|
+
.option("-v, --verbose", "Verbose output (role starts and signals)")
|
|
58
|
+
.option("--temperature <n>", "LLM temperature")
|
|
59
|
+
.option("--max-tokens <n>", "Max tokens per LLM call")
|
|
60
|
+
.option("--tools <names>", "Comma-separated list of tools to enable")
|
|
61
|
+
.option("--task-file <file>", "A task with its checks, as JSON (task, checks, checkFiles)")
|
|
62
|
+
.option("--check <command>", "A check the lab runs after the run: passes when it exits 0 (repeatable)", collect, [])
|
|
63
|
+
.option("--check-file <path>", "A file a check depends on, copied back in before every check (repeatable)", collect, [])
|
|
64
|
+
.option("--verdict-from <source>", "Check's verdict, with a check: measured (default) or model")
|
|
65
|
+
.option("--token-budget <n>", "Tokens this attempt may spend")
|
|
66
|
+
.option("--memory-scope <scope>", "How far back recall reaches: off, run, task or shared")
|
|
67
|
+
.option("--live", "Draw the run on the topology's grid as it goes (the default in a terminal)")
|
|
68
|
+
.option("--no-live", "Print the run's events as lines instead")
|
|
69
|
+
.option("--frames <file>", "Write each frame of the live view to a file (plain), and with colours to <file>.ansi")
|
|
70
|
+
.option("--record <file>", "Write every frame drawn, clock ticks included, with its time, as JSON lines")
|
|
71
|
+
.option("--layout <name>", "For --live: auto, horizontal, vertical or strip", "auto")
|
|
72
|
+
.option("--width <n>", "For --live: columns to draw for")
|
|
73
|
+
.option("--plain", "No colour");
|
|
74
|
+
withPermissionFlags(runCmd).action(runCommand);
|
|
75
|
+
program
|
|
76
|
+
.command("show <topology>")
|
|
77
|
+
.description("Draw a topology at rest: a built-in id or a definition file (.yaml or .json)")
|
|
78
|
+
.option("--layout <name>", "auto, horizontal, vertical or strip", "auto")
|
|
79
|
+
.option("--width <n>", "Columns to draw for (default: the terminal's)")
|
|
80
|
+
.option("--sight", "Add the walls: what each role sees, measured with a mock model (no tokens)")
|
|
81
|
+
.option("--model <name>", "The model to name in each box")
|
|
82
|
+
.option("--plain", "No colour")
|
|
83
|
+
.option("--play", "Animate a dry run on a scripted model, no tokens: until a key or Ctrl+C")
|
|
84
|
+
.option("--speed <x>", "For --play: how fast (1 is a model call every 0.7 s, 4 four times as fast)", "1")
|
|
85
|
+
.option("--once", "For --play: play it once, then stop")
|
|
86
|
+
.option("--frames <file>", "For --play: write each event's frame to a file (plain), and with colours to <file>.ansi")
|
|
87
|
+
.option("--record <file>", "For --play: write every frame drawn, with its time, as JSON lines")
|
|
88
|
+
.action(showCommand);
|
|
89
|
+
program
|
|
90
|
+
.command("replay <run-id>")
|
|
91
|
+
.description("Play a recorded run on its topology's screen, from its step records (Postgres, or the run's folder)")
|
|
92
|
+
.option("--dir <path>", "Working directory the run was in", ".")
|
|
93
|
+
.option("--speed <x>", "1 plays it at the speed it ran, 10 ten times as fast", "1")
|
|
94
|
+
.option("-t, --topology <id|file>", "Draw it with this topology instead of the one its record names")
|
|
95
|
+
.option("--layout <name>", "auto, horizontal, vertical or strip", "auto")
|
|
96
|
+
.option("--width <n>", "Columns to draw for (default: the terminal's)")
|
|
97
|
+
.option("--plain", "No colour")
|
|
98
|
+
.option("--frames <file>", "Write each event's frame to a file (plain), and with colours to <file>.ansi")
|
|
99
|
+
.option("--record <file>", "Write every frame drawn, with its time, as JSON lines")
|
|
100
|
+
.action(replayCommand);
|
|
101
|
+
program
|
|
102
|
+
.command("validate <file>")
|
|
103
|
+
.description("Check a definition file (or a built-in topology by name): its syntax, its dialect, and every problem at its path and line")
|
|
104
|
+
.option("--dialect <id>", "Read as this dialect (agentspec or legacy) instead of recognising it")
|
|
105
|
+
.option("--json", "Print the result as JSON")
|
|
106
|
+
.action(validateCommand);
|
|
107
|
+
program
|
|
108
|
+
.command("convert <file>")
|
|
109
|
+
.description("Convert a definition between dialects and between JSON and YAML, reporting what is lost")
|
|
110
|
+
.option("--to <syntax>", "yaml or json (default: the other one)")
|
|
111
|
+
.option("--dialect <id>", "The dialect to write: agentspec (default) or legacy")
|
|
112
|
+
.option("--from <id>", "Read as this dialect instead of recognising it")
|
|
113
|
+
.option("-o, --output <file>", "Write to a file instead of stdout")
|
|
114
|
+
.option("--expanded", "Write every node's inputs, outputs and branches, as an SDK's export does (default: compact, with what Agent Spec infers left out)")
|
|
115
|
+
.action(convertCommand);
|
|
116
|
+
const pipelineCmd = program
|
|
117
|
+
.command("pipeline")
|
|
118
|
+
.description("Run composable multi-loop pipelines from recipes")
|
|
119
|
+
.option("--recipe <id>", "Recipe ID to instantiate and run")
|
|
120
|
+
.option("-p, --provider <name>", "LLM provider (ollama, openai, anthropic, google, openrouter)")
|
|
121
|
+
.option("-m, --model <name>", "Model to use")
|
|
122
|
+
.option("--dir <path>", "Working directory", ".")
|
|
123
|
+
.option("-v, --verbose", "Verbose output (show signals)")
|
|
124
|
+
.option("--param <key=value>", "Recipe parameter (repeatable)", collect, [])
|
|
125
|
+
.option("--task <text>", "The task (default: the prompt file's contents)")
|
|
126
|
+
.option("-i, --iterations <n>", "Round limit")
|
|
127
|
+
.option("--json", "Print every engine event as a JSON line")
|
|
128
|
+
.option("--list", "List available recipes")
|
|
129
|
+
.option("--nodes", "List available node types")
|
|
130
|
+
.option("--info <id>", "Show recipe details");
|
|
131
|
+
withPermissionFlags(pipelineCmd).action(pipelineCommand);
|
|
132
|
+
const recipesCmd = program
|
|
133
|
+
.command("recipes")
|
|
134
|
+
.description("Browse, inspect, and run pipeline recipes")
|
|
135
|
+
.option("--run <id>", "Run a recipe")
|
|
136
|
+
.option("--info <id>", "Show recipe details")
|
|
137
|
+
.option("-p, --provider <name>", "LLM provider (ollama, openai, anthropic, google, openrouter)")
|
|
138
|
+
.option("-m, --model <name>", "Model to use")
|
|
139
|
+
.option("--dir <path>", "Working directory", ".")
|
|
140
|
+
.option("--param <key=value>", "Recipe parameter (repeatable)", collect, [])
|
|
141
|
+
.option("--task <text>", "The task (default: the prompt file's contents)")
|
|
142
|
+
.option("-i, --iterations <n>", "Round limit")
|
|
143
|
+
.option("--json", "Print every engine event as a JSON line")
|
|
144
|
+
.option("-v, --verbose", "Verbose output")
|
|
145
|
+
.option("--category <name>", "Filter by category");
|
|
146
|
+
withPermissionFlags(recipesCmd).action(recipesCommand);
|
|
147
|
+
// The one-model chat became the session: a single-role topology answers as one model did.
|
|
148
|
+
program
|
|
149
|
+
.command("chat", { hidden: true })
|
|
150
|
+
.allowUnknownOption()
|
|
151
|
+
.action(() => {
|
|
152
|
+
process.stderr.write("jig chat is gone: run jig for a session, where each message is a task (/topology ralph-loop has one role). For one answer from a script: jig run --topology ralph-loop --task \"...\".\n");
|
|
153
|
+
process.exitCode = 2;
|
|
154
|
+
});
|
|
155
|
+
program
|
|
156
|
+
.command("config")
|
|
157
|
+
.description("View and validate configuration")
|
|
158
|
+
.option("--dir <path>", "Working directory", ".")
|
|
159
|
+
.option("--check", "Run validation checks")
|
|
160
|
+
.option("--meta", "Show system meta-knowledge")
|
|
161
|
+
.action(configCommand);
|
|
162
|
+
program
|
|
163
|
+
.command("init")
|
|
164
|
+
.description("Initialize a new agentic workspace (creates PROMPT.md, PLAN.md, specs/)")
|
|
165
|
+
.option("--dir <path>", "Directory to initialize", ".")
|
|
166
|
+
.option("--template <name>", "Prompt template (simple, advanced)", "simple")
|
|
167
|
+
.action(initCommand);
|
|
168
|
+
program
|
|
169
|
+
.command("status")
|
|
170
|
+
.description("Show status of the current agentic workspace")
|
|
171
|
+
.option("--dir <path>", "Working directory", ".")
|
|
172
|
+
.action(statusCommand);
|
|
173
|
+
program
|
|
174
|
+
.command("providers [action] [names...]")
|
|
175
|
+
.description("Provider entries: list, discover (this machine's model servers, 127.0.0.1 only), add <name>, test [names], remove <name>. Keys are references, never written in clear")
|
|
176
|
+
.option("--kind <kind>", "For add: ollama, anthropic, openai, gemini, openrouter or openai-compatible")
|
|
177
|
+
.option("--preset <name>", "For add: an openai-compatible server Jig knows (lmstudio, llamacpp, vllm, jan, groq, mistral, deepseek, together)")
|
|
178
|
+
.option("--base-url <url>", "For add: where the server is")
|
|
179
|
+
.option("--key <ref>", "For add: env:NAME or command:<program and arguments>")
|
|
180
|
+
.option("--keychain", "For add: type the key, hidden, and keep it in the OS keychain")
|
|
181
|
+
.option("--default-model <model>", "For add: the model it answers with when none is named")
|
|
182
|
+
.option("--model <model>", "For test: the model to call")
|
|
183
|
+
.option("--save", "For discover: keep every server found in your config")
|
|
184
|
+
.action((action, names, options) => providersCommand(action, names ?? [], options));
|
|
185
|
+
program
|
|
186
|
+
.command("brains [action] [args...]")
|
|
187
|
+
.description("Brains, named chains of models: list, set <name> <entry/model>..., test [names] (which model would answer now)")
|
|
188
|
+
.action((action, args) => brainsCommand(action, args ?? []));
|
|
189
|
+
program
|
|
190
|
+
.command("doctor")
|
|
191
|
+
.description("Providers, whether each has its key (never shown), and which model each brain would answer with now")
|
|
192
|
+
.action(doctorCommand);
|
|
193
|
+
program
|
|
194
|
+
.command("history")
|
|
195
|
+
.description("Show history of past loop runs")
|
|
196
|
+
.option("--dir <path>", "Working directory", ".")
|
|
197
|
+
.option("--last <n>", "Show last N runs", "10")
|
|
198
|
+
.option("--detail <runId>", "Show details for a specific run")
|
|
199
|
+
.action(historyCommand);
|
|
200
|
+
// ---- Helpers ----
|
|
201
|
+
/** Collect repeatable options into an array */
|
|
202
|
+
/** The permission flags of a run with nobody to ask: what would ask is denied unless one of these allows it. */
|
|
203
|
+
function withPermissionFlags(cmd) {
|
|
204
|
+
return cmd
|
|
205
|
+
.option("--permission-mode <mode>", "default, acceptEdits or plan: with nobody to ask, what would ask is denied")
|
|
206
|
+
.option("--allow <rule>", "Allow a tool call for this run, as 'Shell(npm test *)' or 'Write(src/**)' (repeatable)", collect, [])
|
|
207
|
+
.option("--deny <rule>", "Deny a tool call for this run, as 'Shell(git push *)' or 'Read(./.env)' (repeatable)", collect, [])
|
|
208
|
+
.option("--add-dir <path>", "Another working directory roles may read and write in (repeatable)", collect, [])
|
|
209
|
+
.option("--dangerously-skip-permissions", "Allow every tool call for this run, except deny rules, ask rules and dangerous removals");
|
|
210
|
+
}
|
|
211
|
+
function collect(value, previous) {
|
|
212
|
+
return previous.concat([value]);
|
|
213
|
+
}
|
|
214
|
+
// ---- Parse ----
|
|
215
|
+
program.parse();
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,+CAA+C;AAC/C,mBAAmB;AACnB,+CAA+C;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EA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EAAE,OAAO,EAAE,EAAE,CAAC;SAC5H,MAAM,CAAC,kBAAkB,EAAE,oEAAoE,EAAE,OAAO,EAAE,EAAE,CAAC;SAC7G,MAAM,CAAC,gCAAgC,EAAE,yFAAyF,CAAC,CAAC;AACzI,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,QAAkB;IAChD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,kBAAkB;AAElB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Key = "space" | "right" | "left" | "up" | "down" | "pageup" | "pagedown" | "home" | "end" | "enter" | "escape" | "ctrl-c" | string;
|
|
2
|
+
export interface KeyReader {
|
|
3
|
+
stop(): void;
|
|
4
|
+
}
|
|
5
|
+
/** The keys that scroll a view's log, and what they do to it. */
|
|
6
|
+
export declare function scrollKey(key: Key, view: {
|
|
7
|
+
scroll(n: number): void;
|
|
8
|
+
page(d: 1 | -1): void;
|
|
9
|
+
follow(): void;
|
|
10
|
+
top(): void;
|
|
11
|
+
}): boolean;
|
|
12
|
+
/** Call `onKey` for each key pressed, when stdin is a terminal; a no-op otherwise. */
|
|
13
|
+
export declare function readKeys(onKey: (key: Key) => void, stdin?: NodeJS.ReadStream): KeyReader;
|
|
14
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/I,MAAM,WAAW,SAAS;IACxB,IAAI,IAAI,IAAI,CAAC;CACd;AAsBD,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAAC,MAAM,IAAI,IAAI,CAAC;IAAC,GAAG,IAAI,IAAI,CAAA;CAAE,GAAG,OAAO,CASlI;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,EAAE,KAAK,GAAE,MAAM,CAAC,UAA0B,GAAG,SAAS,CAoBvG"}
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// Keys from a terminal, one at a time
|
|
3
|
+
// ============================================
|
|
4
|
+
// show --play and replay read single keys: stdin in raw mode, given back as
|
|
5
|
+
// it was when they stop. In raw mode Ctrl+C is a key, not a signal, so it is
|
|
6
|
+
// reported as "ctrl-c" and the caller decides.
|
|
7
|
+
const NAMES = {
|
|
8
|
+
" ": "space",
|
|
9
|
+
"\r": "enter",
|
|
10
|
+
"\n": "enter",
|
|
11
|
+
"\x1b": "escape",
|
|
12
|
+
"\x03": "ctrl-c",
|
|
13
|
+
"\x1b[C": "right",
|
|
14
|
+
"\x1b[D": "left",
|
|
15
|
+
"\x1b[A": "up",
|
|
16
|
+
"\x1b[B": "down",
|
|
17
|
+
"\x1b[5~": "pageup",
|
|
18
|
+
"\x1b[6~": "pagedown",
|
|
19
|
+
"\x1b[H": "home",
|
|
20
|
+
"\x1b[1~": "home",
|
|
21
|
+
"\x1bOH": "home",
|
|
22
|
+
"\x1b[F": "end",
|
|
23
|
+
"\x1b[4~": "end",
|
|
24
|
+
"\x1bOF": "end",
|
|
25
|
+
};
|
|
26
|
+
/** The keys that scroll a view's log, and what they do to it. */
|
|
27
|
+
export function scrollKey(key, view) {
|
|
28
|
+
if (key === "up")
|
|
29
|
+
view.scroll(1);
|
|
30
|
+
else if (key === "down")
|
|
31
|
+
view.scroll(-1);
|
|
32
|
+
else if (key === "pageup")
|
|
33
|
+
view.page(1);
|
|
34
|
+
else if (key === "pagedown")
|
|
35
|
+
view.page(-1);
|
|
36
|
+
else if (key === "end")
|
|
37
|
+
view.follow();
|
|
38
|
+
else if (key === "home")
|
|
39
|
+
view.top();
|
|
40
|
+
else
|
|
41
|
+
return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/** Call `onKey` for each key pressed, when stdin is a terminal; a no-op otherwise. */
|
|
45
|
+
export function readKeys(onKey, stdin = process.stdin) {
|
|
46
|
+
if (!stdin.isTTY)
|
|
47
|
+
return { stop: () => { } };
|
|
48
|
+
const wasRaw = stdin.isRaw;
|
|
49
|
+
stdin.setRawMode(true);
|
|
50
|
+
stdin.resume();
|
|
51
|
+
const onData = (data) => {
|
|
52
|
+
const text = data.toString("utf-8");
|
|
53
|
+
onKey(NAMES[text] ?? text);
|
|
54
|
+
};
|
|
55
|
+
stdin.on("data", onData);
|
|
56
|
+
let stopped = false;
|
|
57
|
+
const stop = () => {
|
|
58
|
+
if (stopped)
|
|
59
|
+
return;
|
|
60
|
+
stopped = true;
|
|
61
|
+
stdin.off("data", onData);
|
|
62
|
+
stdin.setRawMode(wasRaw);
|
|
63
|
+
stdin.pause();
|
|
64
|
+
};
|
|
65
|
+
process.once("exit", stop);
|
|
66
|
+
return { stop };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,sCAAsC;AACtC,+CAA+C;AAC/C,4EAA4E;AAC5E,6EAA6E;AAC7E,+CAA+C;AAQ/C,MAAM,KAAK,GAAwB;IACjC,GAA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AK,CAAC;IAC3B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,CAAC,MAAM,EAAE,CAAC;IACf,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;IACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,GAAG,IAAI,CAAC;QACf,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type Drawing, type LayoutName, type RunState, type SessionEvent, type Topology } from "jig-core";
|
|
2
|
+
export interface LiveViewOptions {
|
|
3
|
+
write: (text: string) => void;
|
|
4
|
+
/** Draw in place, full screen, on the alternate screen (a terminal). */
|
|
5
|
+
inPlace: boolean;
|
|
6
|
+
color: boolean;
|
|
7
|
+
width: number;
|
|
8
|
+
/** Rows the terminal shows: the screen fills them. */
|
|
9
|
+
rows?: number;
|
|
10
|
+
layout?: LayoutName | "auto";
|
|
11
|
+
/** Each frame as text, with what made it: an event, the clock, or a scroll. */
|
|
12
|
+
onFrame?: (frame: {
|
|
13
|
+
n: number;
|
|
14
|
+
event: string;
|
|
15
|
+
text: string;
|
|
16
|
+
ansi: string;
|
|
17
|
+
at: number;
|
|
18
|
+
}) => void;
|
|
19
|
+
source?: string;
|
|
20
|
+
model?: string;
|
|
21
|
+
/** The command the footer shows, as typed. */
|
|
22
|
+
command?: string;
|
|
23
|
+
/** What follows the command in the footer (a replay's position), drawn fresh on every frame. */
|
|
24
|
+
extra?: () => string;
|
|
25
|
+
/** The keys the log's border names. */
|
|
26
|
+
logHints?: string;
|
|
27
|
+
/** The time the view shows; a replay gives its own. */
|
|
28
|
+
clock?: () => number;
|
|
29
|
+
/** A dry run on a scripted model: no tokens. */
|
|
30
|
+
dry?: boolean;
|
|
31
|
+
/** Redraws a second while running (default 8). */
|
|
32
|
+
fps?: number;
|
|
33
|
+
/** The timer; a test gives its own. */
|
|
34
|
+
every?: (fn: () => void, ms: number) => {
|
|
35
|
+
stop(): void;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function describe(e: SessionEvent): string;
|
|
39
|
+
export declare class LiveView {
|
|
40
|
+
private readonly options;
|
|
41
|
+
private state;
|
|
42
|
+
readonly drawing: Drawing;
|
|
43
|
+
private frame;
|
|
44
|
+
private spin;
|
|
45
|
+
private timer;
|
|
46
|
+
private readonly clock;
|
|
47
|
+
private width;
|
|
48
|
+
private rows?;
|
|
49
|
+
private entered;
|
|
50
|
+
private stopped;
|
|
51
|
+
/** The log line after the last one shown while scrolled back; null while following the newest. */
|
|
52
|
+
private logEnd;
|
|
53
|
+
private lastScreen;
|
|
54
|
+
/** Log lines already written, off a terminal. */
|
|
55
|
+
private printed;
|
|
56
|
+
constructor(topology: Topology, options: LiveViewOptions);
|
|
57
|
+
/** The state drawn now. */
|
|
58
|
+
get current(): RunState;
|
|
59
|
+
/** Whether the log follows its newest lines. */
|
|
60
|
+
get following(): boolean;
|
|
61
|
+
private render;
|
|
62
|
+
/** Overwrite the last frame with this one, row by row, in one write. */
|
|
63
|
+
private paint;
|
|
64
|
+
private record;
|
|
65
|
+
private paused;
|
|
66
|
+
/** Hold the spinner and the clock while a replay or a dry run is paused. */
|
|
67
|
+
pause(on: boolean): void;
|
|
68
|
+
/** Redraw now: the clock and the spinner move on. */
|
|
69
|
+
tick(): void;
|
|
70
|
+
start(): void;
|
|
71
|
+
/** The terminal changed size. */
|
|
72
|
+
resize(width: number, rows?: number): void;
|
|
73
|
+
event(e: SessionEvent, at?: number): void;
|
|
74
|
+
/** Draw again without anything changing in the run (a key, a pause, a resize). */
|
|
75
|
+
redraw(why?: string): void;
|
|
76
|
+
/** Scroll the log back by `lines` (forward when negative); reaching the newest follows it again. */
|
|
77
|
+
scroll(lines: number): void;
|
|
78
|
+
/** Scroll the log a page back (1) or forward (-1). */
|
|
79
|
+
page(direction: 1 | -1): void;
|
|
80
|
+
/** Follow the newest log lines again. */
|
|
81
|
+
follow(): void;
|
|
82
|
+
/** Scroll to the first log line. */
|
|
83
|
+
top(): void;
|
|
84
|
+
private footerWords;
|
|
85
|
+
/** Give the terminal back: the cursor, and the screen it had. Safe to call more than once. */
|
|
86
|
+
restore(): void;
|
|
87
|
+
/** Stop: the terminal is given back, and the scrollback gets the final drawing, the whole log and the footer. */
|
|
88
|
+
stop(): void;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=live-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-view.d.ts","sourceRoot":"","sources":["../src/live-view.ts"],"names":[],"mappings":"AAiBA,OAAO,EASL,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;I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