scripts

package
v0.56.15 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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