scripts

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package scripts is the repo-local store of reusable multi-step command sequences — a proven recipe ("rebuild the cli", "commit, push, deploy") saved once and replayed by name instead of re-derived every time. Each script is a real shell file at .memcode/scripts/<slug>.sh: a shebang line followed by a hand-parsed `#`-comment metadata header (description/created/last-run/run-count — no YAML dependency, matching the internal/skills package's existing convention) and then the command body.

.memcode is gitignored, so scripts are per-machine and a hard delete isn't git-recoverable — Delete therefore moves a script to a .trash/ subdirectory rather than removing it outright.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(root, slug string) error

Delete soft-deletes a script: moves it to .memcode/scripts/.trash/<slug>-<unixnano>.sh rather than removing it outright, since .memcode is gitignored (a hard delete wouldn't be git-recoverable).

func Dir

func Dir(root string) string

Dir returns the repo-local scripts directory (.memcode/scripts). It may not exist yet.

func RecordRun

func RecordRun(root, slug string)

RecordRun best-effort bumps the run counter and last-run timestamp after a successful run. Errors are swallowed — a lost stat bump is never worth failing the command that just ran.

func ValidSlug

func ValidSlug(slug string) bool

ValidSlug reports whether slug is the required lowercase-letters/digits/hyphens charset.

Types

type Script

type Script struct {
	Slug        string
	Description string
	Body        string
	CreatedAt   time.Time
	LastRunAt   time.Time // zero value: never run
	RunCount    int
	Path        string
}

Script is one saved command sequence.

func Get

func Get(root, slug string) (Script, bool)

Get returns one saved script by exact slug.

func List

func List(root string) ([]Script, error)

List returns every saved (non-trashed) script, sorted by slug. An absent directory is not an error — it just means nothing has been saved yet.

func Save

func Save(root, slug, description, body string) (Script, error)

Save writes (or upserts) a script under .memcode/scripts/<slug>.sh. Validates the slug and requires a description and a non-empty body; updating an existing slug preserves its CreatedAt/RunCount/LastRunAt history rather than resetting it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL