noggin

Noggin

The primary handle every consumer uses to read a noggin's state and drive verbs. Same shape whether the noggin lives in-process behind a provider or behind an RPC transport.

A live noggin. The handle every consumer uses to drive verbs and read state — independent of whether the noggin lives in this process or behind an RPC transport.

Two implementations satisfy this shape today:

- In-process providers (MemoryNoggin, FileNoggin etc.). They also satisfy the wider NogginStore contract, which adds the atomic apply() primitive that verbs use internally. - RemoteNoggin from @noggin/rpc, which dispatches verbs over a JSON-RPC transport. Local accessors stay synchronous because RemoteNoggin mirrors the server's state into a memory noggin and reconciles on each noggin.changed notification.

Storage-tracking contract: - Accessors always reflect the latest known state. - onDidChange fires after every mutation (in-process, externally observed, or remote). After it fires, accessors are up to date.

Verb method semantics mirror the free verbs.*(noggin, opts) namespace: same option shapes, same return types, same error codes. They're convenience bindings — noggin.push(opts) is identical to verbs.push(noggin, opts) for in-process callers. Hosts and UI components should prefer the methods so the same code works against any noggin.

Extended by

Properties

PropertyModifierTypeDescription
activereadonlyItem-
itemsreadonlyreadonly Item[]-
locationreadonlystringCanonical URL the provider opened. Mirrors the location the caller passed to openNoggin (e.g. file:///work/today.yaml, memory://scratch, localstorage://groceries).
onDidChangereadonlyEvent<ChangeEvent>-
onDidErrorreadonlyEvent<NogginError>-
readOnlyreadonlybooleanWhen true, the provider has declared this noggin read-only. Every apply() call will reject with NogginError({ code: 'read-only' }). UIs read this to gate mutation affordances preemptively rather than waiting for a failed round-trip. A provider is responsible for keeping the noggin's in-memory state in sync with its backing store on its own — via watchers for the fast path plus polling as a safety net. There is no refresh() verb because callers shouldn't need to know when a provider might have missed an external change: they observe onDidChange and trust the accessors.
rootsreadonlyreadonly Item[]-

Methods

add()
add(opts: AddOptions): Promise<CurrentTreeView>;

Create a child without making it active.

Parameters
ParameterType
optsAddOptions
Returns

Promise<CurrentTreeView>

childrenOf()
childrenOf(k: string): readonly Item[];
Parameters
ParameterType
kstring
Returns

readonly Item[]

delete()
delete(opts: DeleteOptions): Promise<DeleteResult>;

Remove an item (and optionally its subtree).

Parameters
ParameterType
optsDeleteOptions
Returns

Promise<DeleteResult>

describe()
describe(): string;

Human-readable description of where this noggin lives. Not machine-parseable.

Returns

string

dispose()
dispose(): Promise<void>;

Release provider resources. After dispose the noggin is unusable.

Returns

Promise<void>

done()
done(opts?: DoneOptions): Promise<CurrentTreeView>;

Mark target done and surface to its parent. Idempotent.

Parameters
ParameterType
opts?DoneOptions
Returns

Promise<CurrentTreeView>

edit()
edit(opts: EditOptions): Promise<CurrentTreeView>;

Idempotent mutation of an item's done state and/or title.

Parameters
ParameterType
optsEditOptions
Returns

Promise<CurrentTreeView>

findByKey()
findByKey(k: string): Item;
Parameters
ParameterType
kstring
Returns

Item

goto()
goto(opts: GotoOptions): Promise<CurrentTreeView>;

Make the item at the given path active.

Parameters
ParameterType
optsGotoOptions
Returns

Promise<CurrentTreeView>

move()
move(opts: MoveOptions): Promise<CurrentTreeView>;

Relocate an item under a new parent / among siblings.

Parameters
ParameterType
optsMoveOptions
Returns

Promise<CurrentTreeView>

note()
note(opts: NoteOptions): Promise<CurrentTreeView>;

Append a timestamped note to an item.

Parameters
ParameterType
optsNoteOptions
Returns

Promise<CurrentTreeView>

pathOf()
pathOf(item: Item): string;
Parameters
ParameterType
itemItem
Returns

string

pop()
pop(opts?: PopOptions): Promise<CurrentTreeView>;

Shorthand for done on the active item.

Parameters
ParameterType
opts?PopOptions
Returns

Promise<CurrentTreeView>

push()
push(opts: PushOptions): Promise<CurrentTreeView>;

Create a child of active and immediately become it.

Parameters
ParameterType
optsPushOptions
Returns

Promise<CurrentTreeView>

show()
show(opts?: ShowOptions): Promise<CurrentTreeView>;

Render the current-position view (spine + peers + first-level children).

Parameters
ParameterType
opts?ShowOptions
Returns

Promise<CurrentTreeView>

tryResolvePath()
tryResolvePath(p: string): Item;
Parameters
ParameterType
pstring
Returns

Item