scriptshare

package
v1.162.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package scriptshare finds the functions a script being saved shares with the deployment's libraries and other scripts (#2273).

Libraries exist and work (#1941), and an agent writing its tenth automation still writes its own copy of the pagination helper the other nine carry, because nothing tells it the function already exists. The save gate reads every saved source anyway, so it can see a duplicate at the moment one is written and say so in the response the agent reads: the library and version that already holds the function and the load line that replaces the copy, or the scripts that also define it. A match is reported and never refused.

Two functions match when their bodies are the same after normalization: the docstring, comments, formatting, the function's own name and the names of its parameters and local variables do not count. Anything else -- a constant, an operator, a call, the shape of a statement -- does, so a function that differs in one expression is a different function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListProperties

func ListProperties() map[string]any

ListProperties is the schema fragment for ListInput.

Types

type ListInput

type ListInput struct {
	Library *bool `json:"library,omitempty"`
}

ListInput is manage_script list's library filter (#2273): true lists the libraries alone, false the scripts that run, and leaving it out both.

type Match

type Match struct {
	// Function is the function's name in the saved source.
	Function string `json:"function"`
	// Library, Version and LibraryFunction name the library holding the same
	// function and its name there, and Load is the line that replaces the copy.
	Library         string `json:"library,omitempty"`
	Version         int    `json:"version,omitempty"`
	LibraryFunction string `json:"library_function,omitempty"`
	Load            string `json:"load,omitempty"`
	// Scripts are the other scripts that define it, when no library does.
	Scripts []string `json:"scripts,omitempty"`
	// Next is what to do about it.
	Next string `json:"next"`
}

Match is one function of the saved source that already exists elsewhere. It names functions and scripts, never source.

func Find

func Find(code, self string, library bool, others []Source) []Match

Find is every function of code (saved as the script self, a library when library) that a library or another script in others also defines, in the order code defines them. A source that does not parse shares nothing.

type Source

type Source struct {
	ID      string
	Name    string
	Library bool
	Version int
	Code    string
}

Source is one saved script's current source, as a comparison reads it.

type Sources

type Sources interface {
	CodeSources(ctx context.Context) ([]Source, error)
}

Sources reads every live script's current source: the libraries and the scripts a saved source is compared with.

Jump to

Keyboard shortcuts

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