@mjasnikovs/pi-task 0.40.28 → 0.40.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ /**
2
+ * eco-go — reading Go packages for the docs Worker tool.
3
+ *
4
+ * Three things separate this row from the others.
5
+ *
6
+ * A Go IMPORT PATH is not a module. `github.com/gin-gonic/gin/binding` is served
7
+ * by the `gin` module, and `github.com/aws/aws-sdk-go-v2/service/s3` is its own
8
+ * module despite looking like a subdirectory of one. No syntactic rule tells
9
+ * them apart, so the module boundary is found by asking the proxy for the
10
+ * longest prefix that resolves — longest FIRST, because shorter prefixes answer
11
+ * too: `github.com/go-redis/redis` is a real, ancient, different module from
12
+ * `github.com/go-redis/redis/v8`.
13
+ *
14
+ * The go.mod IS the lockfile. From Go 1.17 the indirect block is the complete
15
+ * pruned closure with resolved versions, so nothing here walks a dependency
16
+ * graph and `go.sum` is never read: it carries integrity hashes for versions
17
+ * that were considered and rejected, so using it would over-report.
18
+ *
19
+ * And Go has no re-export syntax at all — no `pub use`, no export list — so this
20
+ * row sets neither `supplements` nor `exportGap`. Every name a package exports
21
+ * is declared in that package's own files.
22
+ */
23
+ import { type ResolvedPackage } from './docs-resolve.js';
24
+ import type { NpmVersionInfo } from './npm-version.js';
25
+ export declare function isValidImportPath(name: string): boolean;
26
+ /**
27
+ * The proxy and the module cache both spell an uppercase letter as `!` plus its
28
+ * lowercase form, so that a case-insensitive filesystem cannot collide two
29
+ * modules whose paths differ only in case.
30
+ */
31
+ export declare function escapeModulePath(name: string): string;
32
+ export declare function unescapeModulePath(name: string): string;
33
+ /**
34
+ * Go's own rule, from `cmd/go`'s `IsStandardImportPath`: the first path element
35
+ * of a standard-library import contains no dot. `net/http` is stdlib,
36
+ * `go.uber.org/zap` is not.
37
+ */
38
+ export declare function isStdlibImport(importPath: string): boolean;
39
+ /**
40
+ * Is this import path the standard library, in THIS project?
41
+ *
42
+ * Go's rule is purely lexical, so a project whose own module path has no dot —
43
+ * `module myapp` — makes `myapp/internal/db` look like stdlib. The project's own
44
+ * module is stripped first, which is what `cmd/go` effectively does too.
45
+ */
46
+ export declare function isProjectStdlib(importPath: string, cwd: string): boolean;
47
+ export declare function isGoFile(name: string): boolean;
48
+ export interface GoRequire {
49
+ module: string;
50
+ version: string;
51
+ indirect: boolean;
52
+ }
53
+ export interface GoMod {
54
+ module: string | null;
55
+ /** The `go` directive, which says which language version the source targets. */
56
+ goVersion: string | null;
57
+ toolchain: string | null;
58
+ requires: GoRequire[];
59
+ /** `replace` targets, by the module being replaced. */
60
+ replaces: Map<string, string>;
61
+ }
62
+ /**
63
+ * Parse a `go.mod`.
64
+ *
65
+ * Written against what real files contain rather than the grammar's happy path:
66
+ * gin has THREE `require` blocks, single-line and block forms mix freely, and
67
+ * the direct/indirect split is the `// indirect` comment and never the block a
68
+ * line happens to sit in.
69
+ */
70
+ export declare function parseGoMod(text: string): GoMod;
71
+ /** The `use` directories a `go.work` names, resolved against its own location. */
72
+ export declare function parseGoWork(text: string, dir: string): string[];
73
+ /**
74
+ * Every `go.mod` that governs `cwd`.
75
+ *
76
+ * A `go.work` wins where there is one: each of its `use` directories is a
77
+ * first-class module, and taking only the root would miss every dependency the
78
+ * members declare.
79
+ */
80
+ export declare function goManifests(cwd: string): string[];
81
+ export declare function detectGo(cwd: string): boolean;
82
+ /** The project's own module path, from the nearest manifest. */
83
+ export declare function goProjectName(cwd: string): string | null;
84
+ /**
85
+ * Every module version the project resolves, direct and indirect.
86
+ *
87
+ * A `replace` onto a local directory is dropped: nothing can be fetched for it,
88
+ * and its recorded version is a placeholder rather than a fact about a release.
89
+ */
90
+ export declare function goDeclaredDeps(cwd: string): Record<string, string> | undefined;
91
+ /**
92
+ * The modules the project may import directly — the requires with no
93
+ * `// indirect` marker, less the workspace's own members, which resolve from the
94
+ * working tree rather than from a registry.
95
+ */
96
+ export declare function goManifestDeps(cwd: string): Set<string> | undefined;
97
+ /**
98
+ * The version the project pins the module serving `importPath` to.
99
+ *
100
+ * The longest require whose path prefixes the import wins, so
101
+ * `github.com/aws/aws-sdk-go-v2/service/s3` takes the s3 submodule's own pin and
102
+ * not the SDK core's.
103
+ */
104
+ export declare function goDeclaredVersion(importPath: string, cwd: string): string | null;
105
+ export interface VendorEntry {
106
+ module: string;
107
+ version: string;
108
+ }
109
+ /**
110
+ * The package-to-module map `vendor/modules.txt` states outright.
111
+ *
112
+ * Exact and free: no prefix walk, no request, and replaces already applied. Its
113
+ * one limit is that `go mod vendor` copies only the packages the project
114
+ * imports, so a question about an untouched corner of a dependency still needs
115
+ * the module zip.
116
+ */
117
+ export declare function parseVendorModules(text: string): Map<string, VendorEntry>;
118
+ export interface GoResolveDirs {
119
+ /** `$GOMODCACHE`, holding extracted module trees and downloaded zips. */
120
+ goModCache: string;
121
+ /** Where a module fetched by this tool was extracted. */
122
+ modulesDir: string;
123
+ /** A local Go installation, whose `src/` is the standard library for free. */
124
+ goroot?: string | undefined;
125
+ }
126
+ export declare function defaultGoModCache(): string;
127
+ /** Candidate module paths for an import, longest first. */
128
+ export declare function modulePrefixes(importPath: string): string[];
129
+ /**
130
+ * Find a Go package's source on disk.
131
+ *
132
+ * Vendored source first: it is exact, already extracted, and needs nothing from
133
+ * the network. Then the module cache, then whatever this tool fetched earlier.
134
+ */
135
+ export declare function resolveGoPackage(importPath: string, cwd: string, dirs: GoResolveDirs): ResolvedPackage;
136
+ /**
137
+ * Which module serves `importPath`, by asking the proxy about the longest
138
+ * prefix first.
139
+ *
140
+ * Longest first is not an optimisation. `github.com/go-redis/redis/v8` and
141
+ * `github.com/go-redis/redis` both resolve, to different modules a major apart,
142
+ * and a walk that grows from the left returns the wrong one every time.
143
+ */
144
+ export declare function resolveModulePath(importPath: string, fetchFn: typeof fetch, signal?: AbortSignal): Promise<{
145
+ module: string;
146
+ version: string;
147
+ } | null>;
148
+ /** The newest published version of the module serving `importPath`. */
149
+ export declare function goLatest(importPath: string, fetchFn: typeof fetch, signal?: AbortSignal): Promise<NpmVersionInfo | null>;
150
+ export declare function moduleZipUrl(module: string, version: string): string;
151
+ /**
152
+ * Fetch a module and extract its Go source under `<modulesDir>/go`.
153
+ *
154
+ * Entries are laid out exactly as the module cache lays them out —
155
+ * `<module>@<version>/…`, in the module's original case — so what lands on disk
156
+ * is indistinguishable from a tree `go mod download` would have written, and
157
+ * `findInRoot` reads both with one rule.
158
+ */
159
+ export declare function acquireGoModule(importPath: string, pinned: string | null, cwd: string, dirs: GoResolveDirs, fetchFn: typeof fetch, signal?: AbortSignal): Promise<{
160
+ success: boolean;
161
+ installDir: string;
162
+ stderr: string;
163
+ }>;
164
+ /**
165
+ * Keep one file per set of build-tag variants.
166
+ *
167
+ * Go does what npm's `.d.ts`/`.d.cts` twins do: `binding.go` and
168
+ * `binding_nomsgpack.go` declare the same twelve names under opposite
169
+ * constraints, and `internal/json` declares the same five names four times. All
170
+ * of them in one index is duplicate text competing for the retrieval budget with
171
+ * nothing to tell the copies apart.
172
+ *
173
+ * The default build decides, which is what a reader gets by running `go build`
174
+ * with no tags: a bare negation holds, a bare tag does not.
175
+ */
176
+ export declare function selectBuildVariants(files: readonly string[]): string[];
177
+ /**
178
+ * Keep the package the caller asked for, and only the subpackages it can reach.
179
+ *
180
+ * A Go subdirectory is a DIFFERENT importable package — `zapcore` is not reachable
181
+ * as `zap.X` and `ginS` is not `gin` — so walking a module's whole tree files every
182
+ * one of them under the parent's name and its version banner. Measured on re-run 9's
183
+ * cache: 71% of `encoding/json`'s chunks, 54% of zap's and 34% of gin's belonged to
184
+ * a package nobody asked about, and it reached retrieval — a question about
185
+ * registering a gin route came back with 10 `ginS` chunks of 51, in a corpus already
186
+ * spending 19,941 of its 24,000 bytes.
187
+ *
188
+ * The gate is the ROOT'S OWN IMPORTS, closed over: zap's `Field` is
189
+ * `= zapcore.Field`, so dropping `zapcore` would break the alias hop that defect 3
190
+ * exists to serve, and zapcore in turn reaches `buffer`. What that keeps is what a
191
+ * caller of this package can actually be handed; `zapgrpc`, `zaptest`, `ginS`,
192
+ * `httputil` and `net/http/pprof` are reachable only by importing them directly,
193
+ * which the tool already resolves on its own — `github.com/gin-gonic/gin/binding`
194
+ * asked for by path reads 0% foreign.
195
+ *
196
+ * A mismatching top-level `vN/` goes whatever the imports say. `encoding/json` is
197
+ * built ON `encoding/json/v2` and imports it, but v2 is a different major of the
198
+ * same API with the same identifiers — `Marshal`, `Unmarshal` — and half the
199
+ * retrieval for the commonest decode question came back from it under a
200
+ * `Per encoding/json@go1.25.14` header. That is `dropDeadMajors`' case, which
201
+ * cannot fire here because it reads the major with `/^(\d+)\./` and Go spells its
202
+ * versions `v1.12.0` and `go1.25.14`.
203
+ *
204
+ * A module whose root holds no Go files is not a package at all — the aws-sdk shape
205
+ * — and keeps everything, for the same reason `dropDeadMajors` keeps a package whose
206
+ * whole surface lives under one `vN/`.
207
+ */
208
+ export declare function selectOwnPackage(files: readonly string[], root: string, name: string, version: string): string[];
209
+ /**
210
+ * Everything below `goSurface` and the file-selection rule that feeds it, by
211
+ * source, so a fix to either re-indexes rather than being masked by a cache hit.
212
+ */
213
+ export declare function goContentFingerprintParts(): string[];