@anokye-labs/kbexplorer-engine 0.1.0

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,194 @@
1
+ import { Affordance, KBConfig, ResourceQuery, Resource, SourceConfig } from '@anokye-labs/kbexplorer-core';
2
+ import { R as RepoManifest, C as CacheStore } from './build-manifest-BkgZUL0E.cjs';
3
+ export { B as BuildManifestOptions, G as GHFileContent, i as GITHUB_ENDPOINT_PATTERNS, j as GitHubApiError, N as NotModifiedError, k as RateLimitError, b as buildManifest, f as fetchCommits, a as fetchFile, c as fetchFiles, d as fetchIssues, e as fetchPullRequests, g as fetchReleases, h as fetchTree } from './build-manifest-BkgZUL0E.cjs';
4
+ import { R as RepoSource, d as RepoData, E as EngineEnv } from './repo-data-0JvFdLGv.cjs';
5
+ export { k as GHCommit, G as GHIssue, c as GHRelease, b as GHTreeItem, w as RepoMetadata, x as RepoPullRequest } from './repo-data-0JvFdLGv.cjs';
6
+
7
+ /**
8
+ * ManifestSource (Phase 4 / F4 #320; moved in
9
+ * anokye-labs/kbexplorer-template#472, slice 4/5).
10
+ *
11
+ * A read-only {@link RepoSource} backed by a pre-built `repo-manifest.json`.
12
+ * Every resource it retrieves carries exactly `['read']` — a manifest is a
13
+ * frozen snapshot, so nothing can be written or staged through it. There is no
14
+ * staging area (and therefore no `staging-area` link): staging is a Git/GitHub
15
+ * concern, absent from a static manifest.
16
+ */
17
+
18
+ declare class ManifestSource implements RepoSource {
19
+ readonly id = "manifest";
20
+ readonly name = "Repo Manifest";
21
+ /** A manifest is a frozen snapshot — read is the only possible affordance. */
22
+ readonly possibleAffordances: Affordance[];
23
+ private readonly manifest;
24
+ private readonly config;
25
+ constructor(manifest: RepoManifest, config: KBConfig);
26
+ getRepoData(): Promise<RepoData>;
27
+ /**
28
+ * Read-only resource surface. Files (tree blobs/trees) and issues are
29
+ * retrievable; every resource is afforded `['read']` and links only to
30
+ * itself. No write/stage, no staging area.
31
+ */
32
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
33
+ get(href: string): Promise<Resource | undefined>;
34
+ private fileResource;
35
+ private issueResource;
36
+ }
37
+
38
+ /**
39
+ * GitHubApiSource (Phase 4 / F4 #321, #322; moved in
40
+ * anokye-labs/kbexplorer-template#472, slice 4/5).
41
+ *
42
+ * A composite {@link RepoSource} over the live GitHub API. It is deliberately a
43
+ * *composite* of two resource families that are never conflated:
44
+ *
45
+ * • **Git** resources — `file` / `tree` / `commit` / `staging-area`, with the
46
+ * git-worktree affordances `read` / `write` / `stage`. Addressed `git://`.
47
+ * • **GitHub** resources — `issue` / `pull-request` / `release`, with their own
48
+ * operations (`comment` / `close` / `merge`). Addressed `github://`.
49
+ *
50
+ * Affordances are **per-retrieval**: the same file comes back `['read']` from a
51
+ * plain read, `['read','write','stage']` when retrieved against a writable
52
+ * worktree, and — once staged — additionally carries a first-class
53
+ * `{ rel: 'staging-area', href }` link to the retrievable staging area. PR
54
+ * draft/proposed/merge states are GitHub concepts and never appear as git
55
+ * `stage` sub-states.
56
+ *
57
+ * The data path (`getRepoData`) reproduces the former remote loader's fetch
58
+ * exactly, so the unified loader stays byte-identical for this source. The one
59
+ * adaptation vs template is env-injection: the GitHub client's API base is now
60
+ * supplied per call, so this source threads its optional {@link EngineEnv}
61
+ * through every fetch it makes.
62
+ */
63
+
64
+ type ResolutionPreset = 'summary' | 'standard' | 'full';
65
+ declare class GitHubApiSource implements RepoSource {
66
+ readonly id = "github-api";
67
+ readonly name = "GitHub API";
68
+ /** Advisory universe; authoritative affordances live on each retrieval. */
69
+ readonly possibleAffordances: Affordance[];
70
+ private fetchPromise;
71
+ private readonly source;
72
+ private readonly preset;
73
+ private readonly env?;
74
+ private readonly cache?;
75
+ constructor(source: SourceConfig, preset?: ResolutionPreset, env?: EngineEnv, cache?: CacheStore);
76
+ /** The locator of this repo's staging area (git index). */
77
+ private get stagingHref();
78
+ /** Fetch (memoized) so `resolveConfig` + `getRepoData` share one round-trip. */
79
+ private fetch;
80
+ /** Resolve the config without re-fetching. */
81
+ resolveConfig(): Promise<KBConfig>;
82
+ resolveThemeFileRaw(): Promise<string | null>;
83
+ getRepoData(): Promise<RepoData>;
84
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
85
+ get(href: string): Promise<Resource | undefined>;
86
+ /**
87
+ * A git file/tree resource. Affordances are situational:
88
+ * - plain read → `['read']`
89
+ * - writable worktree → `['read','write','stage']`
90
+ * - staged → `['read','write','stage']` PLUS a `staging-area` link.
91
+ */
92
+ private gitFileResource;
93
+ private stagingAreaResource;
94
+ private commitResource;
95
+ private issueResource;
96
+ private pullRequestResource;
97
+ private releaseResource;
98
+ private fetchGitHubData;
99
+ /**
100
+ * Direct children of `dir` in an already-fetched git tree — a nodemap
101
+ * `directory:` entry's listing derived with no extra API call. Skips
102
+ * dotfile-named children, mirroring the local source's `listNodemapDir`.
103
+ */
104
+ private listNodemapDirFromTree;
105
+ private fetchContentModel;
106
+ }
107
+
108
+ /** Options controlling how a {@link FileSystemSource} interprets a directory. */
109
+ interface FileSystemSourceOptions {
110
+ /**
111
+ * `owner/name` slug used for file-node identity. Defaults to the root
112
+ * directory's base name (with no owner segment).
113
+ */
114
+ repo?: string;
115
+ /**
116
+ * Sub-directory (relative to the root) whose `.md` files become authored
117
+ * content nodes. Defaults to `'content'`. Pass `''` (or `'.'`) to treat
118
+ * **top-level** `.md` files in the root itself as authored content (the
119
+ * legacy root-scan convention) — `README.md` still stays the repo readme.
120
+ */
121
+ contentPath?: string;
122
+ /**
123
+ * Sub-directory (relative to the root) holding structured content-model
124
+ * files. Defaults to `'content-model'`.
125
+ */
126
+ contentModelPath?: string;
127
+ /**
128
+ * Directory names to skip while walking (in addition to the always-skipped
129
+ * `.git`, `node_modules`, and `dist`).
130
+ */
131
+ ignore?: string[];
132
+ /**
133
+ * Whether the walked file tree is exposed as `RepoData.tree` (which the
134
+ * unified loader turns into structural file/dir/repo-root nodes via
135
+ * `FilesProvider`). Defaults to `true` (byte-identical to prior behavior).
136
+ * Set `false` for a **content-only** graph — authored content + provider
137
+ * entities, with none of the file-tree scaffolding nodes. `listFiles` and
138
+ * authored-content ingestion are unaffected; only the emitted `tree` (and the
139
+ * `retrieve`/`get` resource surface derived from it) is suppressed.
140
+ */
141
+ includeFileTree?: boolean;
142
+ }
143
+ declare class FileSystemSource implements RepoSource {
144
+ readonly id = "filesystem";
145
+ readonly name = "File System";
146
+ /** A local snapshot read — read is the only possible affordance. */
147
+ readonly possibleAffordances: Affordance[];
148
+ private readonly rootDir;
149
+ private readonly repo;
150
+ private readonly contentPath;
151
+ private readonly contentModelPath;
152
+ private readonly ignore;
153
+ private readonly includeFileTree;
154
+ private cache;
155
+ constructor(rootDir: string, options?: FileSystemSourceOptions);
156
+ getRepoData(): Promise<RepoData>;
157
+ private readRepoData;
158
+ /** Read one repo-relative file as UTF-8. */
159
+ private read;
160
+ /** Read one repo-relative file as UTF-8, returning `null` when missing/unreadable. */
161
+ private readSafe;
162
+ /** Read `nodemap.yaml`/`nodemap.yml` from the repo root, or `null` if neither exists. */
163
+ private readNodemapRaw;
164
+ /** Read `${contentPath}/config.yaml`(`.yml`), falling back to a root-level `config.yaml`. */
165
+ private readConfigRaw;
166
+ /**
167
+ * Read the raw contents of the dedicated theme file referenced by
168
+ * `config.theme.themesFile`, mirroring the old generator's `readThemeFile`.
169
+ * `null` when no `themesFile` is configured, the config can't be parsed, the
170
+ * path escapes the repo root, or the file is missing — a safe no-op.
171
+ */
172
+ private resolveThemeFileRaw;
173
+ /**
174
+ * One-level directory listing (with file sizes) for a nodemap `directory:`
175
+ * entry — distinct from `walk()`, which is recursive and does not stat
176
+ * files. Mirrors the old generator's `listDir`.
177
+ */
178
+ private listNodemapDir;
179
+ /** Convert an absolute path under the root into a POSIX repo-relative path. */
180
+ private toRepoRelative;
181
+ /**
182
+ * Recursively enumerate the root directory into blob/tree entries with
183
+ * POSIX-separated, repo-relative paths (sorted for determinism). Skips
184
+ * dotfiles/dot-directories (except `.github`, which the StructuralProvider
185
+ * reads) in addition to the always-ignored directories — mirrors the old
186
+ * generator's `walkFileSystem` (anokye-labs/kbexplorer-engine#23).
187
+ */
188
+ private walk;
189
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
190
+ get(href: string): Promise<Resource | undefined>;
191
+ private fileResource;
192
+ }
193
+
194
+ export { CacheStore, FileSystemSource, type FileSystemSourceOptions, GitHubApiSource, ManifestSource, RepoData, RepoManifest, RepoSource, type ResolutionPreset };
@@ -0,0 +1,194 @@
1
+ import { Affordance, KBConfig, ResourceQuery, Resource, SourceConfig } from '@anokye-labs/kbexplorer-core';
2
+ import { R as RepoManifest, C as CacheStore } from './build-manifest-BT0sY84J.js';
3
+ export { B as BuildManifestOptions, G as GHFileContent, i as GITHUB_ENDPOINT_PATTERNS, j as GitHubApiError, N as NotModifiedError, k as RateLimitError, b as buildManifest, f as fetchCommits, a as fetchFile, c as fetchFiles, d as fetchIssues, e as fetchPullRequests, g as fetchReleases, h as fetchTree } from './build-manifest-BT0sY84J.js';
4
+ import { R as RepoSource, d as RepoData, E as EngineEnv } from './repo-data-0JvFdLGv.js';
5
+ export { k as GHCommit, G as GHIssue, c as GHRelease, b as GHTreeItem, w as RepoMetadata, x as RepoPullRequest } from './repo-data-0JvFdLGv.js';
6
+
7
+ /**
8
+ * ManifestSource (Phase 4 / F4 #320; moved in
9
+ * anokye-labs/kbexplorer-template#472, slice 4/5).
10
+ *
11
+ * A read-only {@link RepoSource} backed by a pre-built `repo-manifest.json`.
12
+ * Every resource it retrieves carries exactly `['read']` — a manifest is a
13
+ * frozen snapshot, so nothing can be written or staged through it. There is no
14
+ * staging area (and therefore no `staging-area` link): staging is a Git/GitHub
15
+ * concern, absent from a static manifest.
16
+ */
17
+
18
+ declare class ManifestSource implements RepoSource {
19
+ readonly id = "manifest";
20
+ readonly name = "Repo Manifest";
21
+ /** A manifest is a frozen snapshot — read is the only possible affordance. */
22
+ readonly possibleAffordances: Affordance[];
23
+ private readonly manifest;
24
+ private readonly config;
25
+ constructor(manifest: RepoManifest, config: KBConfig);
26
+ getRepoData(): Promise<RepoData>;
27
+ /**
28
+ * Read-only resource surface. Files (tree blobs/trees) and issues are
29
+ * retrievable; every resource is afforded `['read']` and links only to
30
+ * itself. No write/stage, no staging area.
31
+ */
32
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
33
+ get(href: string): Promise<Resource | undefined>;
34
+ private fileResource;
35
+ private issueResource;
36
+ }
37
+
38
+ /**
39
+ * GitHubApiSource (Phase 4 / F4 #321, #322; moved in
40
+ * anokye-labs/kbexplorer-template#472, slice 4/5).
41
+ *
42
+ * A composite {@link RepoSource} over the live GitHub API. It is deliberately a
43
+ * *composite* of two resource families that are never conflated:
44
+ *
45
+ * • **Git** resources — `file` / `tree` / `commit` / `staging-area`, with the
46
+ * git-worktree affordances `read` / `write` / `stage`. Addressed `git://`.
47
+ * • **GitHub** resources — `issue` / `pull-request` / `release`, with their own
48
+ * operations (`comment` / `close` / `merge`). Addressed `github://`.
49
+ *
50
+ * Affordances are **per-retrieval**: the same file comes back `['read']` from a
51
+ * plain read, `['read','write','stage']` when retrieved against a writable
52
+ * worktree, and — once staged — additionally carries a first-class
53
+ * `{ rel: 'staging-area', href }` link to the retrievable staging area. PR
54
+ * draft/proposed/merge states are GitHub concepts and never appear as git
55
+ * `stage` sub-states.
56
+ *
57
+ * The data path (`getRepoData`) reproduces the former remote loader's fetch
58
+ * exactly, so the unified loader stays byte-identical for this source. The one
59
+ * adaptation vs template is env-injection: the GitHub client's API base is now
60
+ * supplied per call, so this source threads its optional {@link EngineEnv}
61
+ * through every fetch it makes.
62
+ */
63
+
64
+ type ResolutionPreset = 'summary' | 'standard' | 'full';
65
+ declare class GitHubApiSource implements RepoSource {
66
+ readonly id = "github-api";
67
+ readonly name = "GitHub API";
68
+ /** Advisory universe; authoritative affordances live on each retrieval. */
69
+ readonly possibleAffordances: Affordance[];
70
+ private fetchPromise;
71
+ private readonly source;
72
+ private readonly preset;
73
+ private readonly env?;
74
+ private readonly cache?;
75
+ constructor(source: SourceConfig, preset?: ResolutionPreset, env?: EngineEnv, cache?: CacheStore);
76
+ /** The locator of this repo's staging area (git index). */
77
+ private get stagingHref();
78
+ /** Fetch (memoized) so `resolveConfig` + `getRepoData` share one round-trip. */
79
+ private fetch;
80
+ /** Resolve the config without re-fetching. */
81
+ resolveConfig(): Promise<KBConfig>;
82
+ resolveThemeFileRaw(): Promise<string | null>;
83
+ getRepoData(): Promise<RepoData>;
84
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
85
+ get(href: string): Promise<Resource | undefined>;
86
+ /**
87
+ * A git file/tree resource. Affordances are situational:
88
+ * - plain read → `['read']`
89
+ * - writable worktree → `['read','write','stage']`
90
+ * - staged → `['read','write','stage']` PLUS a `staging-area` link.
91
+ */
92
+ private gitFileResource;
93
+ private stagingAreaResource;
94
+ private commitResource;
95
+ private issueResource;
96
+ private pullRequestResource;
97
+ private releaseResource;
98
+ private fetchGitHubData;
99
+ /**
100
+ * Direct children of `dir` in an already-fetched git tree — a nodemap
101
+ * `directory:` entry's listing derived with no extra API call. Skips
102
+ * dotfile-named children, mirroring the local source's `listNodemapDir`.
103
+ */
104
+ private listNodemapDirFromTree;
105
+ private fetchContentModel;
106
+ }
107
+
108
+ /** Options controlling how a {@link FileSystemSource} interprets a directory. */
109
+ interface FileSystemSourceOptions {
110
+ /**
111
+ * `owner/name` slug used for file-node identity. Defaults to the root
112
+ * directory's base name (with no owner segment).
113
+ */
114
+ repo?: string;
115
+ /**
116
+ * Sub-directory (relative to the root) whose `.md` files become authored
117
+ * content nodes. Defaults to `'content'`. Pass `''` (or `'.'`) to treat
118
+ * **top-level** `.md` files in the root itself as authored content (the
119
+ * legacy root-scan convention) — `README.md` still stays the repo readme.
120
+ */
121
+ contentPath?: string;
122
+ /**
123
+ * Sub-directory (relative to the root) holding structured content-model
124
+ * files. Defaults to `'content-model'`.
125
+ */
126
+ contentModelPath?: string;
127
+ /**
128
+ * Directory names to skip while walking (in addition to the always-skipped
129
+ * `.git`, `node_modules`, and `dist`).
130
+ */
131
+ ignore?: string[];
132
+ /**
133
+ * Whether the walked file tree is exposed as `RepoData.tree` (which the
134
+ * unified loader turns into structural file/dir/repo-root nodes via
135
+ * `FilesProvider`). Defaults to `true` (byte-identical to prior behavior).
136
+ * Set `false` for a **content-only** graph — authored content + provider
137
+ * entities, with none of the file-tree scaffolding nodes. `listFiles` and
138
+ * authored-content ingestion are unaffected; only the emitted `tree` (and the
139
+ * `retrieve`/`get` resource surface derived from it) is suppressed.
140
+ */
141
+ includeFileTree?: boolean;
142
+ }
143
+ declare class FileSystemSource implements RepoSource {
144
+ readonly id = "filesystem";
145
+ readonly name = "File System";
146
+ /** A local snapshot read — read is the only possible affordance. */
147
+ readonly possibleAffordances: Affordance[];
148
+ private readonly rootDir;
149
+ private readonly repo;
150
+ private readonly contentPath;
151
+ private readonly contentModelPath;
152
+ private readonly ignore;
153
+ private readonly includeFileTree;
154
+ private cache;
155
+ constructor(rootDir: string, options?: FileSystemSourceOptions);
156
+ getRepoData(): Promise<RepoData>;
157
+ private readRepoData;
158
+ /** Read one repo-relative file as UTF-8. */
159
+ private read;
160
+ /** Read one repo-relative file as UTF-8, returning `null` when missing/unreadable. */
161
+ private readSafe;
162
+ /** Read `nodemap.yaml`/`nodemap.yml` from the repo root, or `null` if neither exists. */
163
+ private readNodemapRaw;
164
+ /** Read `${contentPath}/config.yaml`(`.yml`), falling back to a root-level `config.yaml`. */
165
+ private readConfigRaw;
166
+ /**
167
+ * Read the raw contents of the dedicated theme file referenced by
168
+ * `config.theme.themesFile`, mirroring the old generator's `readThemeFile`.
169
+ * `null` when no `themesFile` is configured, the config can't be parsed, the
170
+ * path escapes the repo root, or the file is missing — a safe no-op.
171
+ */
172
+ private resolveThemeFileRaw;
173
+ /**
174
+ * One-level directory listing (with file sizes) for a nodemap `directory:`
175
+ * entry — distinct from `walk()`, which is recursive and does not stat
176
+ * files. Mirrors the old generator's `listDir`.
177
+ */
178
+ private listNodemapDir;
179
+ /** Convert an absolute path under the root into a POSIX repo-relative path. */
180
+ private toRepoRelative;
181
+ /**
182
+ * Recursively enumerate the root directory into blob/tree entries with
183
+ * POSIX-separated, repo-relative paths (sorted for determinism). Skips
184
+ * dotfiles/dot-directories (except `.github`, which the StructuralProvider
185
+ * reads) in addition to the always-ignored directories — mirrors the old
186
+ * generator's `walkFileSystem` (anokye-labs/kbexplorer-engine#23).
187
+ */
188
+ private walk;
189
+ retrieve(query: ResourceQuery): Promise<Resource[]>;
190
+ get(href: string): Promise<Resource | undefined>;
191
+ private fileResource;
192
+ }
193
+
194
+ export { CacheStore, FileSystemSource, type FileSystemSourceOptions, GitHubApiSource, ManifestSource, RepoData, RepoManifest, RepoSource, type ResolutionPreset };