mapslice

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 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 mapslice assembles a slice: the part of the map one task needs. A bare slice is the floor and the headings: the product's rules, and for each capability an agent chose its promise, overview and rules in full, with only the headings of its decisions and questions. The agent then takes the entries its task touches by their slugs, from anywhere in the map. It never matches, ranks or searches the map; it takes only what is named, and the same map and request always give the same slice. Every slice carries the slice skill, and no slice is built from a map the check would reject. It also declares the flags of physa map slice and reads them into a Request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(dir string) (*mapfile.Map, error)

Read reads the map in dir/.physa for a slice. It fails when the map has a problem physa check map would report, with anchors checked for their form only, so neither history nor the forge is read; the error names every problem by file and line.

func Write

func Write(w io.Writer, m *mapfile.Map, f Flags) error

Write builds what f asks for from m and writes it to w, as JSON when f.JSON is set: the entries its request names, or else the slice of its capabilities. Nothing is written when the request fails.

func WriteJSON

func WriteJSON(w io.Writer, s *Slice) error

WriteJSON writes s as one line of JSON with the same content as WriteMD, its fields in a fixed order.

func WriteMD

func WriteMD(w io.Writer, s *Slice) error

WriteMD writes s as markdown, its sections in a fixed order: the header, the product, each capability, the terms, Reading further (the slice skill) and how to anchor, a blank line between sections. Empty sections are omitted. The same slice always gives the same bytes.

func WriteTakenJSON

func WriteTakenJSON(w io.Writer, t *Taken) error

WriteTakenJSON writes t as one line of JSON, {"entries":[...]}, each entry with the capability it lives in.

func WriteTakenMD

func WriteTakenMD(w io.Writer, t *Taken) error

WriteTakenMD writes each taken entry as the map writes it, with one blank line between entries, and nothing else.

Types

type Entry

type Entry struct {
	Slug     string   `json:"slug"`
	Kind     string   `json:"kind"` // "rule", "decision" or "question"
	Heading  string   `json:"heading"`
	Role     string   `json:"role,omitempty"` // "decided" or "raised"
	Person   string   `json:"person,omitempty"`
	How      string   `json:"how,omitempty"`
	Date     string   `json:"date,omitempty"`
	Anchors  []string `json:"anchors,omitempty"` // "#12", "a1b2c3d", "from docs/x.md"
	Body     string   `json:"body,omitempty"`
	Because  string   `json:"because,omitempty"`
	Rejected []string `json:"rejected,omitempty"`
}

Entry is a rule, decision or question in full.

type Flags

type Flags struct {
	Req  Request
	JSON bool
}

Flags is a parsed physa map slice command line: the request it makes and whether the slice is printed as JSON.

type Heading

type Heading struct {
	Kind    string `json:"kind"` // "decision" or "question"
	Slug    string `json:"slug"`
	Heading string `json:"heading"`
}

Heading is one entry shown by its slug and heading alone, to be taken with physa map slice --entry.

type Line

type Line struct {
	// contains filtered or unexported fields
}

Line is one physa map slice command line as its declared flags read it: capability names and --with and --format, or --entry and slugs, in any order, each flag as "--flag value" or "--flag=value". --entry takes no value of its own: every word after it is a slug, and --entry=slug names one; it may be repeated. --with may be repeated and adds up.

func (*Line) Declare

func (l *Line) Declare(fs *pflag.FlagSet)

Declare declares the flags of physa map slice on fs and starts l afresh, so it runs once for every command line.

func (*Line) Flags

func (l *Line) Flags(args []string) (Flags, bool)

Flags turns the line's positionals into the request it makes. It reports false for a bad --with or --format value, for --entry with capability names, with --with, or with no slug, and for no capability at all.

type Request

type Request struct {
	Capabilities                 []string
	WithDecisions, WithQuestions bool
	Entries                      []string // slugs, in the order asked
}

Request is what an agent asks for: either the capabilities its task touches, with the kinds of entry to print in full in place of their headings, or the entries it chose, by slug. A request never asks for both.

type Section

type Section struct {
	Name     string    `json:"name"` // "product" for the product
	Title    string    `json:"title"`
	File     string    `json:"file"`
	Promise  string    `json:"promise"`
	Overview string    `json:"overview"` // empty for the product
	Entries  []Entry   `json:"entries"`  // rules, then decisions, then questions
	Contents []Heading `json:"contents"` // decisions, then questions, shown by heading only
}

Section is the product or one capability: its rules and any kinds asked for in full as entries, and the other kinds as headings.

type Slice

type Slice struct {
	Capabilities   []string  `json:"capabilities"`      // chosen, deduplicated, sorted
	Product        *Section  `json:"product,omitempty"` // nil without the product
	Sections       []Section `json:"sections"`          // one per chosen capability
	Terms          []Term    `json:"terms"`
	ReadingFurther string    `json:"reading_further"` // the slice skill
	Trailers       []string  `json:"trailers"`
}

Slice is an assembled bare slice, ready to write as markdown or JSON. Field order is the JSON field order.

func Build

func Build(m *mapfile.Map, r Request) (*Slice, error)

Build assembles the bare slice r asks for from m. It fails when r names no capability, names one the map does not have, or names entries, which Take takes.

type Taken

type Taken struct {
	Entries []TakenEntry `json:"entries"`
}

Taken is the entries an agent took by slug, in the order it named them.

func Take

func Take(m *mapfile.Map, slugs []string) (*Taken, error)

Take takes exactly the entries slugs name, in full, from the product or any capability, in the order asked; a slug named twice is taken once, at its first place. It fails, taking nothing, when any slug names no entry, and the error names every such slug.

type TakenEntry

type TakenEntry struct {
	Capability string `json:"capability"` // the capability's name, or "product"
	Entry
}

TakenEntry is one taken entry in full and where it lives in the map.

type Term

type Term struct {
	Name       string   `json:"name"`
	Definition string   `json:"definition"`
	Avoid      []string `json:"avoid,omitempty"`
}

Term is a glossary term that appears in the capabilities' text.

Jump to

Keyboard shortcuts

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