Generates pseudocode and AST from drakon flowcharts built with DrakonWidget or DrakonHub.
npm install drakongendrakongen generates pseudocode from drakon flowcharts and mind-maps built with DrakonWidget or DrakonHub.
One can use the output pseudocode as a prompt for AI applications like ChatGPT, Grok, or Gemini.
drakongen can also generate a generic AST from drakon flowcharts to generate source code in programming languages, for example, JavaScript.
drakongen turns a drakon flowchart into a tree in the JSON format that one can trivially transform into code in any programming language.
Include the drakongen.js script on the web page.
``html`
Call drakongen.toPseudocode, drakongen.toMindTree, or drakongen.toTree functions.
`html`
Available languages:
- en English
- no Norwegian
- ru Russian
Add the drakongen package to dependencies.
``
npm i drakongen
- Require the drakongen module.
- Call toPseudocode, toMindTree, or toTree functions.
`javascript
const {toTree, toPseudocode} = require("drakongen")
var drakon = ... // Get the drakon chart from DrakonWidget
var mindJson = ... // Graf mind-map as json
var name = "Diagram one"
var filename = "Diagram one.drakon"
var pseudo = toPseudocode(drakon, name, filename, "en")
console.log(pseudo)
var mind = toMindTree(mindJson, name, filename)
console.log(mind)
var tree = toTree(drakon, name, filename, "en")
console.log(tree)
`
Install drakongen globally.
``
npm i --global drakongen
Run the drakongen utility.
A .drakon flowchart will be converted to pseudocode.
A .graf mind-map will be converted to tree-like text.
In this example, the language is Norwegian, the path to the output folder is out, the input file is Hello.drakon:
``
drakongen --language no --output out Hello.drakon
Drakongen in project mode generates a single prompt file by processing and concatenating multiple input files, including flowcharts, mind-maps, text files, and directories. It reads a project file specifying the input files, processes them in the defined order, and outputs a consolidated prompt file suitable for AI-driven code generation.
- Processes multiple file types:
- Plain text files (e.g., .txt) are included as-is..graf
- Mind-map files (e.g., ) are converted to indented text..drakon
- Flowchart files (e.g., ) are converted to pseudocode.
- Directories are recursively processed, including all files within.
- Preserves file order: Files are processed and concatenated in the exact order specified in the project file, which is critical for AI tools relying on sequential context.
- Flexible project file format: A simple text-based project file lists files and directories to process.
Run the tool with the following command:
`bash`
drakongen --project
- --project: Path to the project file (e.g., exampleproject/foo.proj).--output
- : Directory where the output prompt file will be saved (e.g., exampleproject).
Given a project file exampleproject/foo.proj with the following content:
``
start.txt
math
class Point.graf
foo.drakon
Run:
`bash`
drakongen --project exampleproject/foo.proj --output exampleproject
This will:
1. Include start.txt as-is.math
2. Process all files in the directory recursively.class Point.graf
3. Convert (mind-map) to indented text.foo.drakon
4. Convert (flowchart) to pseudocode.exampleproject/foo.txt
5. Concatenate all processed content into .
The output file foo.txt will contain the concatenated text in the exact order specified in foo.proj.
The project file (e.g., foo.proj`) is a plain text file where each line specifies:
- A file path (relative to the project file) for a text, mind-map, or flowchart file.
- A directory path to process all files within it recursively.