code-lc4ricode-lc4ri: Markdown + LC4RI for VS Code Tags
Demo
Do you often use "jupyter notebook" when choosing a documentation tool for your operations manual?
jupyter is very excellent tool, but I know more usefull for text edit. it's VSCode! AdvantagesThis extention, usually write markdown document. and additional commands can be executed.
Installationdownload vsix from release page. uninstalluse caserecommendationset keybindings.json, enable it's shortcut do.
formatsBasic. You can write markdown usually, but it's can run following. list format
note) If not exists code section after list, will create code section and output to it.
If "ls existsfile.txt" is success, next indent run. horizon lineIf you write horizon line, split commands.
note) In this case, run command to the horizon line. variablenumber list is create variable value.
create variable {1}.
variable {1} output.
note) variable can use 1-9 integer. file open (v0.91-)To the top "!" at the beginning opens the specified file in a new tab
v0.5: "config file" support!This extension easier use, support config file. sample settingjson format.
file createIf does not exist, it will be created in the following folder.
file loadWhen VSCode run, loading config. optionsoptions detail following. timeoutThis option is the timeout time when the command is executed. 10000 -> 10 seconds. templateThis option is default commands template, and can be defined on a per-OS.
"OS Type" is following. {COMMAND} included the original commands.
chageWordThis option is convert keywords list.
toutf8 (v0.91-)If set to false, force UTF-8 conversion process to be skipped (default is true) toterminal (v0.91-)If true, the command execution results are not returned to the markdown, but are executed directly on the open terminal. v0.6: executed time auto print.
It can be used as evidence of execution time. v1.0: major refactor — what's newThis release rewrites the core runner. All existing v0.x documents keep working (list / number list / 1. Asynchronous execution + progress + cancelThe old
New command: 2. Inline ▶ Run / Dry-run buttons (CodeLens)Every
You no longer need to move the cursor and trigger the global shortcut for a one-off line. Disable with 3. settings.json migration (backward-compatible)The extension now reads its configuration from VS Code settings first, then falls back to the legacy
Other hardening: 4. Workspace Trust + dangerous-command guard
5. Named variables, built-ins, output bindingPreviously variables were limited to
Example:
6. Assertions (
|
| Command | What it does |
|---|---|
extension.lc4ri |
Run from cursor (the original behaviour) |
extension.lc4ri.dryRun |
Run from cursor, but only show the resolved commands |
extension.lc4ri.runLine |
Run a single line (used by CodeLens) |
extension.lc4ri.cancel |
Cancel every running child process |
extension.lc4ri.switchProfile |
Pick an execution profile |
extension.lc4ri.clearOutput |
Empty the nearest ``` block below the cursor |
extension.lc4ri.exportReport |
Export an HTML report |
extension.lc4ri.exportReportMd |
Export a Markdown report |
11. New settings cheatsheet
| Key | Default | Description |
|---|---|---|
lc4ri.timeout |
10000 |
Per-command timeout in ms |
lc4ri.template |
{} |
Legacy per-OS template ({ "linux": "ssh u@h {COMMAND}" }) |
lc4ri.profiles |
{} |
Named profiles selectable from the status bar |
lc4ri.changeWord |
{} |
Pre→post substitution map |
lc4ri.toUtf8 |
true |
Auto-detect encoding and convert to UTF-8 |
lc4ri.toTerminal |
false |
Send to active terminal instead of capturing |
lc4ri.outputFormat |
codeblock |
codeblock or collapsible (uses <details>) |
lc4ri.dangerousPatterns |
(see below) | Regex patterns that prompt a confirmation |
lc4ri.allowList |
[] |
If non-empty, only matching commands run |
lc4ri.denyList |
[] |
Matching commands never run |
lc4ri.confirmDangerous |
true |
Show a modal for dangerous matches |
lc4ri.showCodeLens |
true |
Show ▶ Run / Dry-run on list lines |
lc4ri.shell |
null |
Shell binary (null = system default) |
Default dangerous patterns: rm -rf /, dd if=, mkfs., shutdown, reboot, fork bombs, curl|sh, wget|sh, > /dev/sd*.
12. Developer-side changes
engines.vscoderaised to^1.74.0;@types/vscodeand@types/nodeupdated;typescriptbumped to 5.x;eslintto 8.x; redundanticonv/iconv-lite/jschardetremoved.- Pure helpers (
regTab,horizonCheck,detectListCommand,detectNumbered,extractBinding,substituteVars,applyChangeWord,applyTemplate,checkSecurity,parseAssert) are nowexported. npm testruns a stand-alone Node test runner (src/test/runUnit.ts) over those helpers — 32 cases, novscodehost required.
13. Migration notes
Nothing to do — your existing documents and ~/.code-lc4ri/config.json keep working as before. To opt into the new features, add the relevant lc4ri.* keys to your settings.json. To migrate off the legacy file entirely, copy its contents under the matching lc4ri.* keys and delete the file.
v1.1: New features
1. Command execution prefix
Prefix your prompt to control how Bash calls are dispatched in the current turn:
| Prefix | Behavior |
|---|---|
& <message> |
All Bash calls in this turn run in background |
! <command> |
Run directly in the user's terminal (Claude Code built-in) |
| (none) | Normal foreground execution (default) |
2. .env file loading
Write the following anywhere in a runbook to load environment variables from a file:
# env: .env.prod
- echo {DB_HOST}
parseEnvFile() is exported and usable from the CLI as well.
3. Runbook include
Inline-execute another Markdown file. Variable bindings set inside the included file propagate back to the parent scope:
- include: setup.md
- echo setup complete
Circular references are detected and blocked by the CLI.
4. Parallel execution
Lines prefixed with [parallel] are grouped and executed with Promise.all:
- [parallel] ssh server1 uptime
- [parallel] ssh server2 uptime
- [parallel] ssh server3 uptime
All commands must succeed for the AND-chain to continue; one failure resets it.
5. File open and terminal send directives
| Runbook syntax | Behavior |
|---|---|
- ! path.md / - open: path.md |
Open the file in a new VS Code tab |
- ! command |
Send to the active terminal (no output capture) |
Terminal send uses vscode.window.activeTerminal?.sendText(). In CLI mode - ! command runs as a normal shell command.
6. AND-chain indent fix (tabWidth default changed to 2)
DEFAULT_INDENT_SPACES was changed from 4 to 2 so that standard 2-space Markdown indentation maps correctly to AND-chain depth:
| Spaces | Old (tabWidth=4) | New (tabWidth=2) |
|---|---|---|
| 2 spaces | depth 1 | depth 1 |
| 4 spaces | depth 1 ← bug | depth 2 ✓ |
| 6 spaces | depth 2 | depth 3 |
Example:
- echo a ← depth 0: always runs
- echo b ← depth 1: runs only if a succeeds
- echo c ← depth 2: runs only if b succeeds
- echo d ← depth 0: always runs
Users who prefer 4-space indentation can restore the previous behaviour with "lc4ri.tabWidth": 4.
7. write: directive
Write the contents of a fenced code block to a file directly from a runbook:
- write: output/config.yaml
```yaml
database:
host: localhost
port: 5432
```
- The fenced block (
```or~~~) content is written verbatim to the specified file. - Variable substitution (
{varName},{$PREV}, etc.) is supported in the file path. - Missing parent directories are created automatically.
- Participates in AND-chain — an indented
write:only runs if the parent command succeeded. --dry-runshows the resolved path and content without writing.
LICENSE
MIT License





