Proposal: WikiShell / TiddlyCLI - A Command Console for TiddlyWiki

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

Rather than a command line tool I did build a process for what I called at the time “action tiddlers”. You could drop an action tiddler on a “drop bar” and it would sit there until clicked to action or X to remove. On click it would trigger the actions stored there in which could do anything you wanted to one or more tiddlers. An example may be exporting the trash to a wiki acting as an archive.

  • It could be useful to modify rather than replace one or more tiddlers.

Although I did not continue this when I established how useful bookmarklets are see https://bookmarklets.tiddlyhost.com/ because they can add (basic) and change / delete tiddlers on any wiki if needed with a little Javascript.

Other prior ideas;

Some time ago I created a kind of command line where I allowed a user to edit a text field that was then fed to the action list ops widgets “” to action the filter, subfilter or tags. eg you could type +tagname +[[tag name]] or -tag2name, I belive there is a full set of posibilities that could be developed to add a whole suite of text driven actions (with an enter or go button) this way.

It is interesting. A lot to do with your approach to Bookmarklets that nurtures them in-wiki.

That said, a set of browser communal JS bookmarklets for TW could be ace?

If you look in detail at tiddlyhost bookmarklets, if you use advanced search filter tab to list some tiddlers, there are two icons like bookmarks. One can be used to drag a bookmarklet of all tiddlers to the browser bookmarks, the other creates a tiddler containing the bookmarklet allowing sharing as a tiddler.

  • The advantage being its well established how to share tiddlers, thus bookmarklets.

If you have a bookmarklet tiddler as generated on https://bookmarklets.tiddlyhost.com/ it permits sharing and the following;

  • Drage to bookmarkets and use over many wikis.
  • Click to action from within the wiki/tiddler.

Futures with bookmarklets

The current bookmarklets solution uses TiddlyWiki’s $tw.wiki.addTiddlers function to basicaly pack tiddlers into a bookmarklet.

  • This points us to the fact that any JS function in tiddlywiki, or added via plugin can be executed in an interactive wiki via bookmarklets or JavaScript “links”.
  • I would like to make a tool that lets a user look inside the bookmarklet to see what changes it will apply, because if we share bookmarks publicaly we need to add some security.