Proposal: WikiShell / TiddlyCLI - A Command Console for TiddlyWiki

Great input, @Christian_Byron !
Visually, very appealing and straightforward.

With a new line after the pipe… there is so much you could do with that. For example, you could “undo” steps, as it were, before executing the process. That’s just a thought, though.

You might want to see what those “5 tiddlers selected” actually are in a list, and that wouldn’t be a problem.

You’re right, the subject of autocomplete and error messages/suggestions comes up a lot. I haven’t thought how that would be implemented; perhaps in the “action” tiddlers themselves.

Hopefully, we can make this so intuitive that error messages would be very rare :slight_smile: Remember in the old days they didn’t tell you much, only: Syntax Error.

Do you have any good name ideas for the command console?

Somewhat different, I note from building Bookmarklets using javascript, many functions can also be called from the browser console. I wonder if one provides aliases, or documented functions, with the ability to reference or give parameters one could make a feature rich command line of sorts from the browser console? The language may thus be a meta language, Javascript or a subset of javascript.

So I started experimenting with the javascript parser peggy.js to see if this could provide a way to interpret the user input as being a valid command etc and so later on provide autocomplete options suitable to that context.

I’ve put the experiement up on glitch at : https://ceebee-peggyjs-poc.glitch.me/

At the moment it only parses the syntax for filter runs, but it validates the operators within that syntax based on the values provided at runtime. So if you use a invalid operator the error message provides the list of valid values ( useful for auto complete to filter on )

I’m pretty sure it would be easy to extend the grammar to a command syntax (commandname then arguements etc ) so that these could be auto completed as well … and once parsed the resulting tree could be used to correctly invoke a procedure…

Lots of possibilities
:smiley:

2 Likes

I think a great way to start is using actions inside a button widget. If you find that insufficient, the next step would be to ask in help channels (here, discord, or even ChatGPT) if there is a way to accomplish what you’re trying to do. As developers (generically speaking), it is hard to predict exactly what a user wants to accomplish, but it’s much easier to translate from one existing way of doing things to another, or implement once we understand the desired use case.

Perhaps what we need isn’t command line arguments, but rather Tash (a name I just made up), which executes actions in a wikitext file the same way clicking a button does in the browser.

Also, the only thing keeping PowerShell from being truly great is the lack of intellisense. It would not be hard to build a working interface between TiddlyWiki and PowerShell.

Very interesting. That is something I’d use.

So still experimenting here and learning alot about the keyboard widget !!

It turns out its surprisingly easy to run <action... widgets that are typed into a edit field. Here is a brief version of the code to do just this:

\procedure onEnter()
		{{temp!!command}}
\end

<$keyboard key="enter" actions=<<onEnter>> >
<$edit-text field="command" placeholder="Enter commands here..." />
</$keyboard>

I’v put a demo up here with a bit more functionality (mostly up and down arrow keystrokes to navigate a “history” of command entered - just to eliminate some typing when checking out the demo so far)

3 Likes

Let’s keep it simple at first. Let’s start with one command line function and work from there. I was originally thinking of starting with a useful export function, but realise that it may be a little further down the road.

How about tagging a tiddler? The syntax could be straightforward such as tag-tiddler tag="[[CLI]] [[Done]] [[Review and Check]]" tiddler="[[Tiddler-A]] [[Tiddler-B]]".

At some point we might want to get a sub-group together to discuss this topic. I could even host a TiddlyWiki if you like? Correct me if this is faux-pas or not doable. I don’t really know what the conventions are here.

@AlfieA Hi, have you tried https://tiddly-gittly.github.io/tw-command-palette/

If you read Command palette plugin v1.0 , powerful context search bar, search under filter, etc
You will find you can add command with tag

caption: Tiddler Commander
tags: $:/tags/Actions
title: $:/plugins/kookma/commander/buttons/ActionOpenCommander

<$action-navigate $to="$:/Commander"/>

like Create ActionOpenCommander.tid by linonetwo · Pull Request #36 · kookma/TW-Commander · GitHub

Then it works:

And you simply need to ctrl+shift+P (this works in Tiddlywiki Desktop and TidGi desktop, in browser it is crtl+shift and type $ manually), and type open comm and press Enter, to open this example command.

图片

Action tiddler have access to variables like <<storyTiddler>>, so you can add tag to it. Use log action widget in it to find more variable available to use.

And in TidGi desktop environment, you can use https://tiddly-gittly.github.io/zx-script to run any JS like in a browser JS console.

TidGi desktop is an electron wrapper of Nodejs wiki that provides additional features like this.

Yes.

It is still very obscure to a newbie user!

Who (your targets) need which competence to use it?

Anyone?

Just asking, TT

Sounds good - I think there are examples of community projects on this discussion forum - so I would check a few out to see what they do and then go from there.

Yes - this is a good starting use case - I’ll modify the demo to see if this can be done entirely in WikiText & existing widgets…

I had a quick play around with this but it felt a bit clunky for me (for example the pallette disappeared after each command - so you need to keep opening it up each time to use it) … But its definately worth another look to understand its mechansims - maybe the UI’s of our approaches could differ but the underlying commands could be consistent (and hence shared)

If you just accept a line of text you can give this to the listops parameter to add and remove tags eg -tag1 -[[tag 2]] +tag3 tag4.

In fact if you look closely at the tiddlywiki syntax there are plenty of places where someone with tiddlywiki knowledge can type in filters, parameters, values that are given to widgets and triggered by a button.

  • One could also create a kind of meta language where what is entered is first parsed from shortcut terms to generate actions.

Please forgive me: if it seems I’m trying to revive this old post. I am. And I am not. But, yes, I am. Please let me outline my reasons why:

WARNING!: GROVELLING FOLLOWS:

BEGIN: GROVELLING 
I don't think I need to tell you that TW is one of the most ground-breaking applications of HTML5.
As I recall, Jeremy Ruston once said that a coder at Google couldn't wrap his head around the idea
that TW would be a single page. I think I speak for many when I say that TiddlyWiki's
pulled me deeper and deeper into the world of computing and coding. -TW user since 2016. 
END: GROVELLING

So, here is why I am posing this. Big picture: A CLI could be a unique addition to a future of the TW interface. Could it be bigger? In short: I think so. TiddlyWiki could be the launch pad for an interface with a “page” not yet applied anywhere else. Imagine a script you run on a travel booking website that includes all your requests in one go so that you don’t need to keep scrolling and selection things like calendars, dates etc.

Back to Earth. I believe that a CLI for TiddlyWiki would be a game changer. We could integrate the work of so many contributors who’ve created plug-ins and code snippets.

I may be over the top, but I will be welcoming all input be it positive or negative.

I think the closest thing to this that we have now is action widgets. I think action widgets and messages are probably the closest thing to this that we have already, and they are quite powerful. The problem is that it seems like people don’t really see the possibilities immediately. Most of the things you propose in your initial post are things that can already be done, if I’m not mistaken.

@Arlen22 You are absolutely correct.

Hello again,

Sorry for a delay in getting back to this topic… but I came up with a idea today that could be straight forward to implement and possibly very familiar to most TW users… The idea is to use an extension of filter syntax to execute one or more modification steps… So to tag a tiddler you would enter the following into a Command Line :

[[Task Tiddler A]addtag[Done]]

The addtag operator would be a new operator that takes in the input of tiddlers (via any filter steps already available) and a parameter that is the tag to add. Just like filter operators you could chain multiple “modifier operators” together into a run …

Ultimately there would be a modifier operator similar to the function filter operator that would call any defined procedure with the parameters supplied in the filter syntax. Those procedures would then use action-widgets to modify tiddlers.

From an implementation POV - its possible to do this now using what is available in the core ( so enabling indirect parameters, variable parameters etc…) by simply adding a tiddler with module-type: filteroperator … The one catch is to ensure the modifiers don’t execute when used in a standard list widget or others that render with regular filters - but again there is a means to do that in the core using the parameters supplied to the filter functions. If needed it may be possible to split these into a seperate module-type.

Let me know if the syntax works … I think it should be familiar enough to be very user friendly.
:smiley:

GUI is easier to use than Shell, see my plugin linonetwo/edit-tags-on-view-mode

图片

While I mostly like this, I wonder if we could include a syntactic convention to note that this is not a typical filter operator, none of which, I believe, ever modify the tiddler store. (Are there exceptions?) Perhaps a convention I’ve seen in Ruby and LISP of appending a “!” on such a modifier:

[[Task Tiddler A]addtag![Done]]

I would prefer that the mark comes up front, but we can’t do that with the bang (exclamation mark), as it’s already in use as the Boolean “not”. What about #? Would that be backwardly compatible?

[[Task Tiddler A]#addtag[Done]]

I think so. We should be easily able to separate those operators which only work in this sort of command situation from our more typical query ones.

I’m not a developer. I have used DOS batch files & Powershell for decades because they have “simple overall control”. Used them to get precision for my needs.

That seems right. Innerwiki is super-cool, relatively simple to use and offers a great way to test and create new things.

TT