Documentation
¶
Overview ¶
Package count is the CLI's single source for "how many plugins are there". It embeds a vendored copy of the public plugins repo's generated plugins/counts.json artifact so `nself plugin count` answers offline, with no registry checkout and no network call.
Purpose: parse and expose the locked counts.json schema (v1) so exactly one number — Artifact.Advertised — is ever shown to a user as "the plugin count", replacing three prior implementations (this CLI's scripts/plugin-counts.sh, the web build, and ad hoc doc counts) that each encoded a different counting rule and disagreed even when all three were freshly regenerated.
Inputs: the embedded counts.json bytes (see the sync TODO below); no runtime inputs.
Outputs: a parsed Artifact plus the raw embedded bytes verbatim, for callers that need the exact published JSON (e.g. `--json` output).
Constraints: this package must never compute a count itself — it only parses and re-serves the artifact produced by plugins/scripts/plugin-counts.sh in the nself-org/plugins repo. Schema source of truth: that repo's COUNTS-SCHEMA.md (schema_version 1).
TODO(sync): counts.json here is a manually vendored snapshot, not yet wired to auto-update. Once nself-org/plugins publishes plugins/counts.json on its main branch, add a CI job in this repo (.github/workflows/) that fetches it from that repo's origin/main on a schedule (or on the plugins repo's release webhook) and opens a PR updating internal/plugin/count/counts.json — the same generated-artifact pattern already used for internal/deprecation/registry.yaml. Until that job exists, refresh this file by hand from https://github.com/nself-org/plugins/blob/main/plugins/counts.json and note the source commit in the commit message.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Artifact ¶
type Artifact struct {
Generated string `json:"_generated"`
SchemaVersion int `json:"schema_version"`
GeneratedAt string `json:"generated_at"`
Sources Sources `json:"sources"`
Free RegistryCount `json:"free"`
Pro RegistryCount `json:"pro"`
Overlap Overlap `json:"overlap"`
Totals Totals `json:"totals"`
Advertised int `json:"advertised"`
}
Artifact is the parsed shape of plugins/counts.json (schema_version 1).
Advertised is THE number for any user-facing surface — website, CLI, docs, marketing. Never publish Totals.Entries or either registry's Entries field as a headline count.
type Overlap ¶
type Overlap struct {
TierPairs []string `json:"tierPairs"`
Duplicates []string `json:"duplicates"`
}
Overlap describes slugs present in both registries.
sharedSlugs is every slug in both. A shared slug is one two-tier product: the free entry is its free tier, the pro entry its pro tier. Both registry entries carry tier_pair:true, and the product counts once, so tierPairs and duplicates hold the same slugs. Both are emitted because duplicates says what was subtracted from the naive sum and tierPairs says why.
There is no counted-twice case. An earlier draft of this model had one, keyed on a dualRegistry flag that no registry entry has ever carried, so the field was always empty and the real rule went unread.
type RegistryCount ¶
type RegistryCount struct {
Entries int `json:"entries"`
Installable int `json:"installable"`
NonInstallable []string `json:"nonInstallable"`
}
RegistryCount is the entries/installable/nonInstallable breakdown for one registry (free or pro).
entries is the raw registry slug count. installable excludes any slug whose manifest declares installable: false. Per the locked schema, entries is never a user-facing number — only installable and, after de-duplication across registries, advertised are.
type RepoSource ¶
RepoSource identifies the registry file a count was computed from.
type Sources ¶
type Sources struct {
Free RepoSource `json:"free"`
Pro RepoSource `json:"pro"`
}
Sources names the two registries the artifact was computed from.