Skip to content

termsurf/base

Repository files navigation








base

A TreeCode Programming Framework




Introduction

BaseTree is a cross-platform application framework in development (extreme prototype). It is far from being working, so mainly just a collection of packages with API ideas. The long term goal is to now get this working :).

Installation

pnpm add @termsurf/base -g

Folder Structure

Ignore the key folders:

/.base # compiled helper folder
/bind # environment variables
/hold # temporary folder
/host # generated content folder
/link # downloaded packages folder

Here is how a monolithic app might be structured:

/.gitignore
/.base
/base.tree
/bind # env variables, don't commit
  /test.tree
  /base.tree
  /work.tree # dev
  /moon.tree # staging
  /star.tree # prod
/hold # scratchpad/tmp folder
/host
  /javascript
    /browser
    /node
  /log # logs
    /work.tree # dev logs
    /test.tree # test logs
/note # guides
/link
/deck
  /form # schema
    /code
      /user.tree
  /line # command line processing
  /back # backend
    /deck
      /site-1
      /site-2
      /base # REST and webhook handlers
        /task # handle API calls
        /take
        /save
      /note # mailers
      /work # jobs
        /time # cron jobs
      /form # schema
        /user.tree
      /call
        /take # query allowance
      /rule # policies/permissions
  /face # frontend
    /deck
      /test
      /dock # ui components
      /vibe # styles/themes
      /site-1
        /wall # pages
          /host
            /base.tree
            /case.tree
            /deck
              /base.tree
              /case.tree
        /text # copy
      /kink # errors
      /file # public directory
        /text # fonts
        /view # images
  /base # database
    /seed # seeding data
    /move # migrations
  /site # infrastructure
    /hold.tree # don't commit this
    /move # migrations
/task # dev helpers
/text # copy
  /en.tree
  /fr.tree
  /zh.tree

For libraries, you might only have:

/base.tree
/code
/task
/hold
/host
/link
/note

Interfaces

The package manager and several other components can possibly be swapped out potentially in the future, each just depends on a small interface.

Package Manager Interface

An example of this is the bead.tree repo.

const deck = new Deck({ home: '.' })

// save global package
Deck.save()

// remove global package
Deck.toss()

// verify global package
Deck.test()

// link global package
Deck.link()

// install defined packages
deck.load()

// add a package
deck.save({ link, mark, site })

// remove a package
deck.toss({ link, mark, site })

// verify a deck
deck.test({ link, mark, site })

// link a package
deck.link({ link, mark, site })

// resolve file link
deck.find({ file, base })

Compiler Interface

This is defined by the buck library.

class Code {
  make() {
    this.load()
    this.mesh()
    this.lint()
    this.tree()
    this.text()
    this.bind()
  }

  bind() {
    code.on('file', code.make)
  }

  // load from the entrypoint of the project
  load() {
    bead()
    buck()
  }

  // do type-checking, variable resolution, optimizations, etc..
  mesh() {
    chew.mesh()
  }

  // do linting and fix up code
  lint() {
    fish.lint()
  }

  // make output AST in target language
  tree() {
    till.make()
  }

  // write the AST to string
  text() {
    seal.make()
  }
}

Output Generator Interface

An example of this is the seal.tree repo.

const host = new Host({ code })

const ts = host.make({ form: 'typescript' })
const rust = host.make({ form: 'rust' })

The output is typed as a standard AST in each language.

TODO

  • parse mine/mind files (mint)
    • parse tree-role file types
    • parse chat-talk-link tree
    • convert into json

License

Copyright 2021-2024 TermSurf

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

TermSurf

This is being developed by the folks at TermSurf, a California-based project for helping humanity master information and computation. Find us on Twitter, LinkedIn, and Facebook. Check out our other GitHub projects as well!