Build with Syntic CodeAutomationOpen a session from a link

Open a session from a link

A syntic-cli:// link opens Syntic Code in a terminal with a prompt already typed in. Put one in a runbook, a README, an alert or a chat message, and whoever clicks it lands in a session ready to start the task. Nothing runs until they read the prompt and press Enter.

syntic-cli://open?q=Investigate%20the%20spike%20in%20checkout%20errors%20since%2014%3A00

How it works

  1. Someone clicks a syntic-cli:// link in a browser, chat app or document.
  2. The operating system hands the link to the syntic program it has registered for that scheme.
  3. Syntic Code checks the link strictly. Anything it does not recognize is refused.
  4. If the click did not come from a terminal, Syntic Code opens a new terminal window and starts there.
  5. The interactive session starts with the prompt box filled in. The person reviews it, edits it if they like, and presses Enter to send.

Links never send a prompt, run a command or change a setting on their own.

LinkFills the prompt box with
syntic-cli://openNothing; just opens a session.
syntic-cli://open?q=<text><text>, URL-decoded.
syntic-cli://install-plugin/<plugin>@<marketplace>The /plugin install command for that plugin.
syntic-cli://add-marketplace/<source>The /plugin marketplace add command for that source.

The plugin links still leave the final step to the person: they see the command and confirm it like any other plugin install (Install plugins).

Take the prompt text and URL-encode it into the q parameter. Spaces can be %20 or +; line breaks are allowed as %0A.

python3 -c 'import urllib.parse,sys; print("syntic-cli://open?q=" + urllib.parse.quote(sys.argv[1]))' \
  "Read the last 200 lines of /var/log/app/error.log and summarize the errors"
RuleWhy
Only the syntic-cli:// scheme, and only the actions aboveUnknown actions are refused, never guessed.
At most 4,096 charactersLonger links are refused.
No control characters, except line breaks inside the promptThey could be used to smuggle extra arguments.
Plugin and marketplace names must not contain path separators or .. once decodedA link cannot reach outside its slot.

A link that breaks a rule is refused with a message; nothing else happens.

Examples

In a runbook

## High error rate on the payments API
 
1. Check the dashboard for the affected region.
2. [Open a triage session](syntic-cli://open?q=Payments%20API%20error%20rate%20is%20high.%20Check%20recent%20deploys%20with%20git%20log%2C%20read%20the%20error%20logs%2C%20and%20propose%20a%20rollback%20or%20fix.)
3. Page the on-call lead if the rollback is needed.

Most Markdown viewers make links with custom schemes clickable. Some (and some chat apps) only show them as text; in that case paste the link into a browser, or pass it to syntic --handle-uri in a terminal.

From the shell

# macOS
open "syntic-cli://open?q=Review%20the%20diff%20on%20this%20branch"
 
# Linux
xdg-open "syntic-cli://open?q=Review%20the%20diff%20on%20this%20branch"

You can also skip the operating system and pass the link straight to the program:

syntic --handle-uri "syntic-cli://open?q=Review%20the%20diff%20on%20this%20branch"

Share a plugin

syntic-cli://install-plugin/release-tools@team-marketplace

Registration and platforms

Syntic Code registers itself as the handler for syntic-cli:// the first time it starts interactively, and again if the program moves. No administrator rights are needed.

PlatformHow the handler is registeredNew terminal opened with
LinuxA hidden desktop entry in ~/.local/share/applications (or $XDG_DATA_HOME/applications), set as the default handler with xdg-mime.x-terminal-emulator
WindowsA key under HKCU\Software\Classes\syntic-cli in your own part of the registry.A new console window
macOSNot registered automatically: a link scheme needs an application bundle on macOS. Use syntic --handle-uri "<link>" from a terminal.Terminal

Where the session starts

A session opened from a link starts in the folder the new terminal window opens in, usually your home folder. Mention the project in the prompt, or move the session with /cd <path> before sending. When you run syntic --handle-uri yourself from a terminal, the session starts in that terminal’s current folder.

SettingEffect
"disableDeepLinks": trueLinks are not handled, and the handler is not registered.
"disableDeepLinkRegistration": trueSyntic Code does not register itself as the handler. On Linux, an existing entry is removed. Running syntic --handle-uri by hand still works.

Either key can be set in any settings file.

Troubleshooting

ProblemWhat to do
Clicking the link does nothingStart syntic once interactively so it registers itself. On macOS, use syntic --handle-uri instead.
xdg-open is not found on LinuxInstall your desktop’s xdg-utils package, or use syntic --handle-uri.
The link shows as plain textThe app does not allow custom schemes. Copy the link into a browser address bar or a terminal.
The session opens in the wrong folderIt opens where the new terminal starts. Use /cd before sending, or open the link with syntic --handle-uri from the project folder.
The link is refusedCheck it against the rules above. A common cause is an unencoded character or a link over 4,096 characters.
The wrong terminal app opens on LinuxThe system’s x-terminal-emulator choice decides. Change it with your distribution’s alternatives tool.