@mono-lit/utility 0.0.0-stage → 0.0.1
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.
- package/LICENSE.md +54 -0
- package/README.md +156 -2
- package/dist/app-roots-BJsIxzjk.d.ts +91 -0
- package/dist/app-roots-CvJnmXcs.js +128 -0
- package/dist/config-node-UzJrXg0Z.js +76 -0
- package/dist/config-node.d.ts +977 -0
- package/dist/config-node.js +7 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +3 -0
- package/dist/create-config-D3m6xTaQ.d.ts +733 -0
- package/dist/create-config-DdL3Fh6T.js +357 -0
- package/dist/fetching.d.ts +239 -0
- package/dist/fetching.js +867 -0
- package/dist/generate-CJ7MtcDd.js +291 -0
- package/dist/index-C2hZeNkq.d.ts +365 -0
- package/dist/index-ClrZbU7n.d.ts +518 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +939 -0
- package/dist/merge-file-C5nzi_MY.d.ts +122 -0
- package/dist/merge-file-CtyKTu5L.js +133 -0
- package/dist/mock-db-5mJTObSC.js +1282 -0
- package/dist/mock-db.d.ts +2 -0
- package/dist/mock-db.js +4 -0
- package/dist/mono-alias-DNDm-jB_.js +508 -0
- package/dist/mono-clone.mjs +958 -0
- package/dist/mono-db.d.ts +1 -0
- package/dist/mono-db.js +151 -0
- package/dist/mono-env.mjs +231 -0
- package/dist/mono-git.mjs +798 -0
- package/dist/mono-link-YlOQ2PVS.js +488 -0
- package/dist/mono-prepare.d.ts +1 -0
- package/dist/mono-prepare.js +27 -0
- package/dist/mono-skills.d.ts +1 -0
- package/dist/mono-skills.js +830 -0
- package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
- package/dist/mono.mjs +34 -0
- package/dist/nuxt-layers-DP1m7f1-.js +176 -0
- package/dist/nuxt-layers.d.ts +34 -0
- package/dist/nuxt-layers.js +3 -0
- package/dist/nuxt-runtime.d.ts +18 -0
- package/dist/nuxt-runtime.js +102 -0
- package/dist/nuxt.d.ts +386 -0
- package/dist/nuxt.js +590 -0
- package/dist/runtime-C_IWNrAG.js +5817 -0
- package/dist/runtime.d.ts +2583 -0
- package/dist/runtime.js +4 -0
- package/dist/session-Bk985AIM.js +1721 -0
- package/dist/types-B6FdB7LJ.d.ts +57 -0
- package/dist/universal-B2eD9xho.d.ts +97 -0
- package/dist/universal-BNTo_83u.js +599 -0
- package/dist/virtual-mono-apps.d.ts +16 -0
- package/dist/vite.d.ts +940 -0
- package/dist/vite.js +1132 -0
- package/package.json +141 -3
|
@@ -0,0 +1,977 @@
|
|
|
1
|
+
import { S as MonoSkillConfig, c as MonoConfig, o as MonoAppType, w as MonoTemplate } from "./create-config-D3m6xTaQ.js";
|
|
2
|
+
import { a as ResolveAppRootsOptions, c as isMissingPathError, d as pathAppRoots, f as resetAppPathWarnings, i as MonoMissingPathPolicy, l as linkedAppRoots, n as MonoAppRootInput, o as appRootDirs, p as resolveAppRoots, r as MonoAppRootSource, s as hasUrl, t as MonoAppRoot, u as missingPathMessage } from "./app-roots-BJsIxzjk.js";
|
|
3
|
+
import { LoadConfigOptions } from "c12";
|
|
4
|
+
import { TSConfig } from "pkg-types";
|
|
5
|
+
|
|
6
|
+
//#region src/composables/config-node.d.ts
|
|
7
|
+
interface LoadMonoConfigOptions extends Partial<LoadConfigOptions<MonoConfig>> {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function loadMonoConfig(options?: LoadMonoConfigOptions): Promise<{
|
|
11
|
+
config: MonoConfig;
|
|
12
|
+
layers?: import("c12").ConfigLayer<MonoConfig, import("c12").ConfigLayerMeta>[] | undefined;
|
|
13
|
+
cwd?: string;
|
|
14
|
+
_configFile?: string;
|
|
15
|
+
source?: string;
|
|
16
|
+
sourceOptions?: import("c12").SourceOptions<MonoConfig, import("c12").ConfigLayerMeta> | undefined;
|
|
17
|
+
meta?: import("c12").ConfigLayerMeta | undefined;
|
|
18
|
+
configFile?: string;
|
|
19
|
+
}>;
|
|
20
|
+
declare function getMonoConfig(options?: LoadMonoConfigOptions): Promise<MonoConfig>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/composables/mono-alias.d.ts
|
|
23
|
+
interface MonoAliasOptions {
|
|
24
|
+
/** App root (absolute). Pass `fileURLToPath(new URL('.', import.meta.url))`. */
|
|
25
|
+
dirname: string;
|
|
26
|
+
/** Override the own name instead of reading it from mono.config.ts. */
|
|
27
|
+
name?: string;
|
|
28
|
+
/** Folder scanned for remotes. Default './.mono/apps'. */
|
|
29
|
+
appsDir?: string;
|
|
30
|
+
/** Fallback source subdir when an app's `type` is unknown. Default 'src'. */
|
|
31
|
+
srcDir?: string;
|
|
32
|
+
/** Suffix for the root-level alias. Default '-root'. */
|
|
33
|
+
rootSuffix?: string;
|
|
34
|
+
/** Override the own app's kind (else read from mono.config.ts top-level `type`). */
|
|
35
|
+
ownType?: MonoAppType;
|
|
36
|
+
/** Override/augment per-remote kinds (else read from mono.config.ts `apps[].type`). */
|
|
37
|
+
appTypes?: Record<string, MonoAppType>;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated `apps[].path` is authoritative in every command (dev, build,
|
|
40
|
+
* prepare, sync); this option is ignored.
|
|
41
|
+
*/
|
|
42
|
+
link?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Strip `//` and `/* */` comments without touching string contents, so a
|
|
46
|
+
* commented-out `name:` never shadows the real one.
|
|
47
|
+
*
|
|
48
|
+
* Ported verbatim from `bin/mono-clone.mjs`.
|
|
49
|
+
*/
|
|
50
|
+
declare function stripCommentsSafe(code: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Absolute path of the mono config file in `dir`, or `null`. The same lookup
|
|
53
|
+
* order every static reader here uses.
|
|
54
|
+
*/
|
|
55
|
+
declare function monoConfigFileFor(dir: string): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Read the top-level `name: '...'` literal from mono.config.ts text without
|
|
58
|
+
* executing it. The first lowercase `name:` string literal is the config name —
|
|
59
|
+
* `apps[].name` entries appear later in the file.
|
|
60
|
+
*/
|
|
61
|
+
declare function extractConfigName(dir: string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Read the top-level `template: 'host' | 'remote'` literal from mono.config.ts
|
|
64
|
+
* text without executing it — the same trick `extractConfigName` uses, and for
|
|
65
|
+
* the same reason: `monoNuxtLayers()` runs while `nuxt.config` is being loaded,
|
|
66
|
+
* where the config's `extends` chain (which imports the host's own config
|
|
67
|
+
* through an alias that does not exist yet) cannot be resolved.
|
|
68
|
+
*
|
|
69
|
+
* Only the text BEFORE `apps:` is searched, so a per-app key can never be
|
|
70
|
+
* mistaken for the top-level one. `null` when absent — which, per `MonoTemplate`,
|
|
71
|
+
* reads as `'remote'`.
|
|
72
|
+
*/
|
|
73
|
+
declare function extractTemplate(dir: string): MonoTemplate | null;
|
|
74
|
+
/** A statically-parsed `apps[]` entry (only fields we rely on here). */
|
|
75
|
+
interface ExtractedApp {
|
|
76
|
+
name: string;
|
|
77
|
+
type?: MonoAppType;
|
|
78
|
+
/** Where `mono sync` clones from — optional when `path` is set. */
|
|
79
|
+
url?: string;
|
|
80
|
+
/** Directory the app is read from in place. See `MonoAppConfig.path`. */
|
|
81
|
+
path?: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
/** Statically read `{ name, type }` of a config without executing it. */
|
|
85
|
+
interface ExtractedConfig {
|
|
86
|
+
name: string | null;
|
|
87
|
+
type: MonoAppType;
|
|
88
|
+
apps: ExtractedApp[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read a mono.config.ts's own `name`/`type` and its `apps[]` (name + type)
|
|
92
|
+
* WITHOUT executing it — `monoAlias` runs before the config is loaded, so it
|
|
93
|
+
* can only parse the source text. The apps array is eval'd in isolation (same
|
|
94
|
+
* approach as `bin/mono-clone.mjs`), so keep apps static (no variables/fns).
|
|
95
|
+
*
|
|
96
|
+
* The top-level `type` is read from the text BEFORE `apps:` so it can't be
|
|
97
|
+
* shadowed by an `apps[].type` (or a `fetching.api.*.type`). Declare the
|
|
98
|
+
* config's own `type` above `apps`.
|
|
99
|
+
*/
|
|
100
|
+
declare function extractConfig(dir: string): ExtractedConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Statically read the top-level `skill: { url, envToken? }` literal of a
|
|
103
|
+
* mono.config.ts WITHOUT executing it — the `mono skills` CLI runs in a bare
|
|
104
|
+
* checkout where the config's `extends` imports (other apps' aliases) may not be
|
|
105
|
+
* resolvable, so it can only parse the source text, exactly like `extractConfig`.
|
|
106
|
+
*
|
|
107
|
+
* Read from THIS file only: `skill` is never inherited through `extends` (see
|
|
108
|
+
* `MonoConfig.skill`). The object literal is eval'd in isolation, so keep it
|
|
109
|
+
* static — no variables, no template expressions.
|
|
110
|
+
*
|
|
111
|
+
* `null` when the key is absent (the feature is off). THROWS when the key is
|
|
112
|
+
* present but is not a static object literal with a string `url` — a present
|
|
113
|
+
* but broken `skill` must surface as an error, not silently read as "off".
|
|
114
|
+
*/
|
|
115
|
+
declare function extractSkill(dir: string): MonoSkillConfig | null;
|
|
116
|
+
/**
|
|
117
|
+
* Every `apps[]` entry must say where it comes from: a `url` (`mono sync`
|
|
118
|
+
* clones it), a `path` (read in place), or both (`path` wins, `url` is the
|
|
119
|
+
* fallback when the directory is absent). An entry with neither is a config
|
|
120
|
+
* error, reported here by name rather than as a mysterious missing alias later.
|
|
121
|
+
*
|
|
122
|
+
* Run on the ROOT config only — a sibling's config is that sibling's business
|
|
123
|
+
* and is validated when IT runs.
|
|
124
|
+
*/
|
|
125
|
+
declare function assertAppSources(apps: ExtractedApp[], file: string): void;
|
|
126
|
+
interface ResolveFederatedRootsOptions {
|
|
127
|
+
/** App root (absolute). */
|
|
128
|
+
dirname: string;
|
|
129
|
+
/** Folder holding the clones. @default './.mono/apps' */
|
|
130
|
+
appsDir?: string;
|
|
131
|
+
/** Policy for the ROOT config's own `path` entries. @default 'report' */
|
|
132
|
+
onMissingPath?: MonoMissingPathPolicy;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The root config's apps, plus ONE level of the apps each of those declares by
|
|
136
|
+
* `path` — resolved against THAT app's directory, not ours.
|
|
137
|
+
*
|
|
138
|
+
* In a mono-lith every sibling carries its own `mono.config.ts`, and a
|
|
139
|
+
* remote's config can name a third sibling this root never listed. Its
|
|
140
|
+
* `extends` chain then imports `@<third>-root/mono.config`, which only
|
|
141
|
+
* resolves if that app has an alias here. So "present" and "aliased" are
|
|
142
|
+
* decided by this one walk, and `monoAlias` / `monoMissingApps` both take its
|
|
143
|
+
* answer.
|
|
144
|
+
*
|
|
145
|
+
* One level, never recursive: a host and its remote list each other, and the
|
|
146
|
+
* cycle must not loop. A sibling's own `.mono/apps` is never listed
|
|
147
|
+
* (`listClones: false`) — its clones are its standalone-dev business — and a
|
|
148
|
+
* sibling's missing `path` is skipped silently (`onMissingPath: 'ignore'`):
|
|
149
|
+
* that sibling reports it when it runs.
|
|
150
|
+
*/
|
|
151
|
+
declare function resolveFederatedRoots(opts: ResolveFederatedRootsOptions): MonoAppRoot[];
|
|
152
|
+
/**
|
|
153
|
+
* Build the mono alias map for both Vite's `resolve.alias` and the jiti alias
|
|
154
|
+
* that `getMonoConfig` needs to parse `mono.config.ts`.
|
|
155
|
+
*
|
|
156
|
+
* The source subdir of each app is derived from its `type` (`vue` -> `src`,
|
|
157
|
+
* `nuxt` -> `app`): the own type from the config's top-level `type`, each
|
|
158
|
+
* remote's from its `apps[].type`. Unknown types fall back to `srcDir`.
|
|
159
|
+
*
|
|
160
|
+
* Convention (keyed off app names; `<src>` = `srcDirForType(type)`):
|
|
161
|
+
* - `@<own-name>` -> `<dirname>/<src>`
|
|
162
|
+
* - `@<own-name>-root` -> `<dirname>`
|
|
163
|
+
* - `@<remote>` -> `<dirname>/.mono/apps/<remote>/<src>`
|
|
164
|
+
* - `@<remote>-root` -> `<dirname>/.mono/apps/<remote>`
|
|
165
|
+
* - `@mono-apps` -> `<dirname>/.mono/apps`
|
|
166
|
+
*
|
|
167
|
+
* Name/type are read from `mono.config.ts` (or passed via `name`/`ownType`/
|
|
168
|
+
* `appTypes`). Remotes come from {@link resolveFederatedRoots}: the
|
|
169
|
+
* `.mono/apps/` listing, plus every app whose `apps[].path` names a directory
|
|
170
|
+
* — in which case `@<remote>` resolves THERE, in every command — plus the
|
|
171
|
+
* `path` apps those apps declare themselves. Returns absolute paths.
|
|
172
|
+
*/
|
|
173
|
+
declare function monoAlias(opts: MonoAliasOptions): Record<string, string>;
|
|
174
|
+
/** An app some config federates that has no directory under `.mono/apps/`. */
|
|
175
|
+
interface MonoMissingApp {
|
|
176
|
+
/** The app's `name` — the thing `@<name>` / `@<name>-root` is keyed on. */
|
|
177
|
+
name: string;
|
|
178
|
+
/** Which config asked for it: this app's own name, or a cloned app's. */
|
|
179
|
+
via: string;
|
|
180
|
+
/** Its `apps[].envToken`, when it was declared — what to set for a private repo. */
|
|
181
|
+
envToken?: string;
|
|
182
|
+
}
|
|
183
|
+
interface MonoMissingAppsOptions {
|
|
184
|
+
/** App root (absolute). */
|
|
185
|
+
dirname: string;
|
|
186
|
+
/** Folder scanned for remotes. Default './.mono/apps'. */
|
|
187
|
+
appsDir?: string;
|
|
188
|
+
/** Suffix for the root-level alias. Default '-root'. */
|
|
189
|
+
rootSuffix?: string;
|
|
190
|
+
/** @deprecated `apps[].path` is authoritative in every command; ignored. */
|
|
191
|
+
link?: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Apps that are federated somewhere in the chain but aren't on disk.
|
|
195
|
+
*
|
|
196
|
+
* A cloned app never carries its own `.mono/` (gitignored, so it's absent from the
|
|
197
|
+
* archive `mono sync` downloads), so a host that federates apps of its own arrives
|
|
198
|
+
* with `import … from '@some-app-root/mono.config'` and nothing to resolve it
|
|
199
|
+
* against. `monoAlias` keys off the `.mono/apps/` DIRECTORY LISTING, so there is no
|
|
200
|
+
* key and jiti falls through to bare-package resolution — `Cannot find module`, and
|
|
201
|
+
* the config never loads. Finding those names first is what lets
|
|
202
|
+
* {@link monoStubAliases} neutralise them.
|
|
203
|
+
*
|
|
204
|
+
* Static only — {@link extractConfig} text-parses each config without executing it,
|
|
205
|
+
* which is the sole option: this runs BEFORE any config can be loaded.
|
|
206
|
+
*
|
|
207
|
+
* Two sources, union'd:
|
|
208
|
+
* - names in any reachable `apps[]` with no directory (carries `envToken`)
|
|
209
|
+
* - `@<name>-root/…` import specifiers with no alias key — covers a config that
|
|
210
|
+
* imports an app it never declared in `apps[]`
|
|
211
|
+
*
|
|
212
|
+
* Only the `-root` suffix form is scanned for the second source: `@scope/pkg` npm
|
|
213
|
+
* imports are syntactically identical to `@app/file`, and mistaking `@vueuse/core`
|
|
214
|
+
* for a mono app would stub a real dependency out of the build.
|
|
215
|
+
*/
|
|
216
|
+
declare function monoMissingApps(opts: MonoMissingAppsOptions): MonoMissingApp[];
|
|
217
|
+
interface MonoStubAliasesOptions extends MonoMissingAppsOptions {
|
|
218
|
+
/** Pre-computed missing apps (else discovered via {@link monoMissingApps}). */
|
|
219
|
+
missing?: MonoMissingApp[];
|
|
220
|
+
}
|
|
221
|
+
interface MonoStubAliases {
|
|
222
|
+
/** Alias entries to merge ON TOP of {@link monoAlias}'s map. Empty when nothing is missing. */
|
|
223
|
+
alias: Record<string, string>;
|
|
224
|
+
/** What was stubbed — feed to {@link formatMissingApps}. */
|
|
225
|
+
missing: MonoMissingApp[];
|
|
226
|
+
/** The generated stub module, or `null` when nothing was missing. */
|
|
227
|
+
stubFile: string | null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Alias entries that let a config chain load with apps missing from `.mono/apps/`.
|
|
231
|
+
*
|
|
232
|
+
* Each unsynced app gets EXACT keys for its config specifier only —
|
|
233
|
+
* `@<name>-root/mono.config` (+ `.ts`/`.js`/`.mjs`, and the `@<name>` form) — all
|
|
234
|
+
* pointing at one generated module that exports `{ apps: [], extends: [] }`. The
|
|
235
|
+
* import resolves, the layer merges to nothing, the build starts.
|
|
236
|
+
*
|
|
237
|
+
* Deliberately NOT the bare `@<name>` / `@<name>-root` prefixes: app code that
|
|
238
|
+
* imports a missing app (`@some-app/components/Foo.vue`) must still fail loudly. A
|
|
239
|
+
* page that can't exist is better than a page that silently renders blank.
|
|
240
|
+
*
|
|
241
|
+
* Exact keys work because alias matching (pathe's `resolveAlias`, used by jiti;
|
|
242
|
+
* the same rule in Vite) treats a key with no trailing segment as a full match, and
|
|
243
|
+
* sorts keys with more slashes first — so `@x-root/mono.config` is always tried
|
|
244
|
+
* before `@x-root`. For a missing app that prefix key doesn't exist anyway.
|
|
245
|
+
*
|
|
246
|
+
* Merge into BOTH alias maps: jiti's (so `getMonoConfig` can load) and Vite's (the
|
|
247
|
+
* browser graph resolves the same chain via `import monoConfig from '../mono.config'`
|
|
248
|
+
* in an app's `main.ts` — stub only jiti and the dev server starts, then dies on
|
|
249
|
+
* first page load).
|
|
250
|
+
*/
|
|
251
|
+
declare function monoStubAliases(opts: MonoStubAliasesOptions): MonoStubAliases;
|
|
252
|
+
/**
|
|
253
|
+
* The warning for stubbed apps — names them, says what was lost, and gives the
|
|
254
|
+
* command that fixes it. `envToken` is the actionable part: a private repo fails to
|
|
255
|
+
* sync silently until someone knows which variable to set.
|
|
256
|
+
*/
|
|
257
|
+
declare function formatMissingApps(missing: MonoMissingApp[]): string;
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/composables/mono-tsconfig.d.ts
|
|
260
|
+
/** Folder (relative to an app root) that holds the generated tsconfig. */
|
|
261
|
+
declare const MONO_DIR = ".mono";
|
|
262
|
+
/** Reference to the generated tsconfig, as written into the root `extends`. */
|
|
263
|
+
declare const MONO_TSCONFIG_REF = "./.mono/tsconfig.json";
|
|
264
|
+
/** Folder (relative to an app root) that holds the cloned remotes. */
|
|
265
|
+
declare const MONO_APPS_DIR = ".mono/apps";
|
|
266
|
+
/**
|
|
267
|
+
* Build the `compilerOptions.paths` map for `.mono/tsconfig.json` from the mono
|
|
268
|
+
* alias map.
|
|
269
|
+
*
|
|
270
|
+
* `monoAlias` returns absolute directory paths keyed WITHOUT a `/*` glob (e.g.
|
|
271
|
+
* `@mono-host` -> `<abs>/src`). tsconfig `paths` need the `/*` glob on both the
|
|
272
|
+
* key and the value, and the value must be relative to the `.mono/` folder that
|
|
273
|
+
* the file lives in. So `@mono-host` -> `{ "@mono-host/*": ["../src/*"] }`.
|
|
274
|
+
*
|
|
275
|
+
* All alias/type/srcDir rules are inherited from `monoAlias` — nothing is
|
|
276
|
+
* re-implemented here.
|
|
277
|
+
*/
|
|
278
|
+
declare function monoTsconfigPaths(opts: MonoAliasOptions): Record<string, string[]>;
|
|
279
|
+
/** The object written to `<dirname>/.mono/tsconfig.json`. */
|
|
280
|
+
declare function buildMonoTsconfig(opts: MonoAliasOptions): TSConfig;
|
|
281
|
+
interface RunMonoPrepareOptions {
|
|
282
|
+
/** App root (absolute) containing `mono.config.ts` and `tsconfig.json`. */
|
|
283
|
+
dirname: string;
|
|
284
|
+
}
|
|
285
|
+
interface RunMonoPrepareResult {
|
|
286
|
+
/** Absolute path of the generated `.mono/tsconfig.json`. */
|
|
287
|
+
monoTsconfigPath: string;
|
|
288
|
+
/** Absolute path of the root `tsconfig.json` that was wired. */
|
|
289
|
+
rootTsconfigPath: string;
|
|
290
|
+
/** The alias keys (with `/*`) written into `.mono/tsconfig.json`. */
|
|
291
|
+
writtenKeys: string[];
|
|
292
|
+
/** Inline `@mono-*` path keys stripped from the root tsconfig. */
|
|
293
|
+
removedKeys: string[];
|
|
294
|
+
/** Whether the `extends` entry was added (false if it was already present). */
|
|
295
|
+
addedExtends: boolean;
|
|
296
|
+
/** Cloned remotes under `.mono/apps/` whose tsconfig was (re)wired. */
|
|
297
|
+
wiredApps: string[];
|
|
298
|
+
/**
|
|
299
|
+
* Alias keys whose directory lies outside the project (`apps[].path`
|
|
300
|
+
* siblings) while the root tsconfig sets `rootDir` — TypeScript will reject
|
|
301
|
+
* them until `rootDir` is removed or widened.
|
|
302
|
+
*/
|
|
303
|
+
outsideProject: string[];
|
|
304
|
+
/**
|
|
305
|
+
* `path` apps whose own `tsconfig.json` extends a `.mono/tsconfig.json` that
|
|
306
|
+
* does not exist yet — they have not run their own `mono prepare`.
|
|
307
|
+
*/
|
|
308
|
+
unpreparedApps: string[];
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Generate `<dirname>/.mono/tsconfig.json` from the mono alias map and wire it
|
|
312
|
+
* into the root `tsconfig.json` via `extends`, stripping the now-redundant
|
|
313
|
+
* inline `@mono-*` paths. Idempotent: safe to run repeatedly.
|
|
314
|
+
*/
|
|
315
|
+
declare function runMonoPrepare(opts: RunMonoPrepareOptions): Promise<RunMonoPrepareResult>;
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/skills/config.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Built-in behavioural defaults. Users never configure these — they only set
|
|
320
|
+
* `skill.url` / `skill.envToken`.
|
|
321
|
+
*/
|
|
322
|
+
declare const SKILLS_DEFAULTS: Readonly<{
|
|
323
|
+
/** Local staging + clone directory (under the already-gitignored `.mono/`). */stagingDir: ".mono/skills"; /** Subfolder of `stagingDir` holding the working clone of the skills repo. */
|
|
324
|
+
repoDir: "repo"; /** Conversation chunk size before splitting into `part-NNNN.jsonl`. 750 KB. */
|
|
325
|
+
chunkSizeBytes: number; /** Remove the local staging dir after a successful upload. */
|
|
326
|
+
cleanupAfterSuccess: true; /** Move a failed session from `pending/` to `failed/`. */
|
|
327
|
+
moveFailedSessions: true; /** `read`/`search` re-fetch the clone when its last fetch is older than this. */
|
|
328
|
+
refreshTtlMs: number; /** How many times a rejected (non-fast-forward) push is replayed on a fresh tip. */
|
|
329
|
+
pushAttempts: 3; /** Timeout for a single remote git operation (probe, fetch, push). */
|
|
330
|
+
gitTimeoutMs: number;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* The ONLY CLI flags any `mono skills` subcommand may accept. The argument guard
|
|
334
|
+
* rejects everything else — in particular `--token`, `--owner`, `--repo`,
|
|
335
|
+
* `--branch`, `--url`, `--destination`, etc. — so the AI can never (accidentally
|
|
336
|
+
* or otherwise) retarget the repo or leak a token via argv.
|
|
337
|
+
*/
|
|
338
|
+
declare const ALLOWED_FLAGS: readonly string[];
|
|
339
|
+
/**
|
|
340
|
+
* Default/generic template app names. While an app still carries one of these
|
|
341
|
+
* placeholder names, `save`/`retry` are skipped — we don't want session history
|
|
342
|
+
* filed under a non-specific id. The user is expected to rename the app first
|
|
343
|
+
* (see Template Rule 1 — "confirm the app name"). Comparison is case-insensitive
|
|
344
|
+
* against the normalized app id.
|
|
345
|
+
*/
|
|
346
|
+
declare const GENERIC_APP_NAMES: readonly string[];
|
|
347
|
+
/** True when `id` is still a default/generic template name. */
|
|
348
|
+
declare function isGenericAppName(id: string): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Load `.env` (and `.env.dev` if present) from `cwd` into `process.env` without
|
|
351
|
+
* overriding values already set in the real environment, so `skill.envToken`
|
|
352
|
+
* can name a variable kept in a dotenv file — exactly like `apps[].envToken`
|
|
353
|
+
* for `mono sync`. Missing files are ignored silently.
|
|
354
|
+
*/
|
|
355
|
+
declare function loadSkillsEnv(cwd?: string): void;
|
|
356
|
+
/**
|
|
357
|
+
* Read `skill` from the `mono.config.ts` in `cwd`. `null` = not configured (the
|
|
358
|
+
* feature is off). Throws when the key is present but malformed.
|
|
359
|
+
*/
|
|
360
|
+
declare function loadSkillConfig(cwd?: string): MonoSkillConfig | null;
|
|
361
|
+
/** How `skill.url` was recognised. Decides token support and probing. */
|
|
362
|
+
type SkillUrlKind = 'github' | 'https' | 'ssh' | 'local';
|
|
363
|
+
/** `skill.url` parsed into what the git layer needs. Pure data, no I/O. */
|
|
364
|
+
interface SkillTarget {
|
|
365
|
+
kind: SkillUrlKind;
|
|
366
|
+
/** Plain, credential-free clone URL — the ONLY form that is ever logged or stored. */
|
|
367
|
+
remoteUrl: string;
|
|
368
|
+
/** Hostname (`null` for a local path). */
|
|
369
|
+
host: string | null;
|
|
370
|
+
/** GitHub only. */
|
|
371
|
+
owner?: string;
|
|
372
|
+
repo?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Branch to use. `null` = the remote's default branch (resolved by probing
|
|
375
|
+
* `HEAD`). For a GitHub deep URL this is filled in AFTER the probe splits
|
|
376
|
+
* `refAndDir`, so it stays `null` here.
|
|
377
|
+
*/
|
|
378
|
+
ref: string | null;
|
|
379
|
+
/**
|
|
380
|
+
* Raw remainder of a GitHub `/tree/<…>` URL. `release/v2/app` could be branch
|
|
381
|
+
* `release/v2` + folder `app` or branch `release` + folder `v2/app`; only the
|
|
382
|
+
* remote knows, so the split happens in `resolveRemote`, not here.
|
|
383
|
+
*/
|
|
384
|
+
refAndDir: string | null;
|
|
385
|
+
/** Subfolder inside the repo everything is written under. `''` = repo root. */
|
|
386
|
+
dir: string;
|
|
387
|
+
/** Env var NAME holding the PAT, when configured. */
|
|
388
|
+
tokenEnv?: string;
|
|
389
|
+
/** HTTPS only: a token can ride the URL. `ssh`/`local` = machine access only. */
|
|
390
|
+
tokenSupported: boolean;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Parse `skill.url` into a {@link SkillTarget}. Throws `Invalid skill.url: …`
|
|
394
|
+
* for anything that is not a repository (`/blob/` file links, an owner with no
|
|
395
|
+
* repo, garbage).
|
|
396
|
+
*/
|
|
397
|
+
declare function resolveSkillTarget(cfg: MonoSkillConfig): SkillTarget;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/skills/types.d.ts
|
|
400
|
+
/** Outcome status a session can carry. */
|
|
401
|
+
type SessionStatus = 'completed' | 'partial' | 'failed';
|
|
402
|
+
/** A file the session touched — METADATA ONLY; contents are never uploaded. */
|
|
403
|
+
interface ChangedFile {
|
|
404
|
+
path: string;
|
|
405
|
+
operation: 'added' | 'modified' | 'deleted' | 'renamed';
|
|
406
|
+
}
|
|
407
|
+
/** A technical/business decision recorded during the session. */
|
|
408
|
+
interface SessionDecision {
|
|
409
|
+
title: string;
|
|
410
|
+
decision: string;
|
|
411
|
+
reason?: string;
|
|
412
|
+
}
|
|
413
|
+
/** Shape of `metadata.json` the AI (or a human) writes before `mono skills save`. */
|
|
414
|
+
interface SessionMetadata {
|
|
415
|
+
schemaVersion: number;
|
|
416
|
+
sessionId: string;
|
|
417
|
+
status: SessionStatus;
|
|
418
|
+
startedAt?: string;
|
|
419
|
+
finishedAt?: string;
|
|
420
|
+
topics?: string[];
|
|
421
|
+
userRequests?: string[];
|
|
422
|
+
commandsRun?: string[];
|
|
423
|
+
validation?: {
|
|
424
|
+
testsRun?: boolean;
|
|
425
|
+
testsPassed?: boolean | null;
|
|
426
|
+
buildRun?: boolean;
|
|
427
|
+
buildPassed?: boolean | null;
|
|
428
|
+
};
|
|
429
|
+
outcome?: {
|
|
430
|
+
result?: string;
|
|
431
|
+
notes?: string;
|
|
432
|
+
};
|
|
433
|
+
[key: string]: unknown;
|
|
434
|
+
}
|
|
435
|
+
/** The effective local git identity used for attribution (`whoami`). */
|
|
436
|
+
interface Actor {
|
|
437
|
+
name: string;
|
|
438
|
+
email: string;
|
|
439
|
+
/** `<name-slug>__<6 hex>` — the per-actor folder under `<app>/history/`. */
|
|
440
|
+
actorFolder: string;
|
|
441
|
+
}
|
|
442
|
+
/** Result of a successful `mono skills save` / `retry`. */
|
|
443
|
+
interface SaveResult {
|
|
444
|
+
success: true;
|
|
445
|
+
sessionId: string;
|
|
446
|
+
/** The configured repository (plain URL, never a token). */
|
|
447
|
+
repository: string;
|
|
448
|
+
/** Branch the session was pushed to. */
|
|
449
|
+
ref: string;
|
|
450
|
+
/** Subfolder inside the repo (`''` = root). */
|
|
451
|
+
dir: string;
|
|
452
|
+
/** Which credentials got through: the machine's own git access, or `envToken`. */
|
|
453
|
+
transport: 'git' | 'token';
|
|
454
|
+
/** `<app>/history/<actor>/<date>/<time>_<id>` — relative to `dir`. */
|
|
455
|
+
savedPath: string;
|
|
456
|
+
/** `dir` + `savedPath` — the path as seen from the repository root. */
|
|
457
|
+
repoPath: string;
|
|
458
|
+
/** The commit that landed on the remote. */
|
|
459
|
+
commit: string;
|
|
460
|
+
/** 1 = first push; 2+ = replayed after a concurrent save. */
|
|
461
|
+
pushAttempts: number;
|
|
462
|
+
filesUploaded: number;
|
|
463
|
+
localCleanup: boolean;
|
|
464
|
+
}
|
|
465
|
+
/** Result when `skill` is not configured in mono.config.ts — NOT an error. */
|
|
466
|
+
interface SkippedResult {
|
|
467
|
+
success: true;
|
|
468
|
+
skipped: true;
|
|
469
|
+
reason: 'MONO_SKILLS_NOT_CONFIGURED';
|
|
470
|
+
hint?: string;
|
|
471
|
+
}
|
|
472
|
+
/** Generic failure payload. */
|
|
473
|
+
interface FailureResult {
|
|
474
|
+
success: false;
|
|
475
|
+
error: string;
|
|
476
|
+
[key: string]: unknown;
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/skills/git.d.ts
|
|
480
|
+
/**
|
|
481
|
+
* Applied to EVERY git invocation (same list as `mono sync`, same reasons):
|
|
482
|
+
* stop Git Credential Manager from popping a dialog, keep LF so the tree is
|
|
483
|
+
* byte-identical across machines, no symlinks/submodules, long paths, no gc.
|
|
484
|
+
*/
|
|
485
|
+
declare const BASE_ARGS: string[];
|
|
486
|
+
/** Environment for every git child process. */
|
|
487
|
+
declare function gitEnv(extra?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
488
|
+
interface GitResult {
|
|
489
|
+
ok: boolean;
|
|
490
|
+
code: number | null;
|
|
491
|
+
signal: NodeJS.Signals | null;
|
|
492
|
+
stdout: string;
|
|
493
|
+
stderr: string;
|
|
494
|
+
error?: NodeJS.ErrnoException;
|
|
495
|
+
timedOut: boolean;
|
|
496
|
+
}
|
|
497
|
+
interface RunGitOptions {
|
|
498
|
+
cwd?: string;
|
|
499
|
+
timeoutMs?: number;
|
|
500
|
+
env?: NodeJS.ProcessEnv;
|
|
501
|
+
}
|
|
502
|
+
type GitRunner = (args: string[], opts?: RunGitOptions) => GitResult;
|
|
503
|
+
/**
|
|
504
|
+
* Run git. NEVER throws — returns a record for the caller to classify.
|
|
505
|
+
* `shell: false` so a path like `C:\Program Files\…` needs no quoting.
|
|
506
|
+
*/
|
|
507
|
+
declare function runGit(args: string[], {
|
|
508
|
+
cwd,
|
|
509
|
+
timeoutMs,
|
|
510
|
+
env
|
|
511
|
+
}?: RunGitOptions): GitResult;
|
|
512
|
+
/** First `fatal:`/`error:`/`remote:` line of stderr, tag stripped — and redacted. */
|
|
513
|
+
declare function firstFatal(stderr: string): string;
|
|
514
|
+
type GitFailureKind = 'no-git' | 'timeout' | 'ref-missing' | 'network' | 'no-access' | 'unknown';
|
|
515
|
+
type GitNoAccessWhy = 'not-invited' | 'bad-credential' | 'no-credential';
|
|
516
|
+
interface GitFailure {
|
|
517
|
+
kind: GitFailureKind;
|
|
518
|
+
why?: GitNoAccessWhy;
|
|
519
|
+
detail?: string;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Turn a `runGit` result into an actionable cause. The `not-invited` vs
|
|
523
|
+
* `bad-credential` split matters: GitHub answers 404 for private repos you
|
|
524
|
+
* cannot see, but a STALE cached credential answers "Authentication failed".
|
|
525
|
+
*/
|
|
526
|
+
declare function classifyGitFailure(res: GitResult | undefined): GitFailure;
|
|
527
|
+
/** Strip any embedded credential before a URL (or a line containing one) reaches a log or an error. */
|
|
528
|
+
declare function redactUrl(text: string): string;
|
|
529
|
+
/**
|
|
530
|
+
* Put a token on an https clone URL for ONE fetch/push. GitHub authenticates a
|
|
531
|
+
* PAT as user `x-access-token`; GitLab-style hosts as `oauth2`; Azure DevOps
|
|
532
|
+
* accepts any user name with a PAT password. Never store the result — pass it
|
|
533
|
+
* as the positional remote argument only, so `.git/config` stays clean.
|
|
534
|
+
*/
|
|
535
|
+
declare function tokenRemote(remoteUrl: string, token: string): string;
|
|
536
|
+
/**
|
|
537
|
+
* Every legal split of a `/tree/<refAndDir>` URL remainder into ref + folder,
|
|
538
|
+
* longest ref first — `release/v2/app` may be branch `release/v2` + `app` or
|
|
539
|
+
* branch `release` + `v2/app`. Only the remote can tell, so the caller probes
|
|
540
|
+
* each candidate in this order. (Ported from `bin/mono-git.mjs`.)
|
|
541
|
+
*/
|
|
542
|
+
declare function refDirCandidates(refAndDir: string): Array<{
|
|
543
|
+
ref: string;
|
|
544
|
+
dir: string;
|
|
545
|
+
}>;
|
|
546
|
+
/** Refs to ask `ls-remote` about for a branch-or-tag name. */
|
|
547
|
+
declare function refPatterns(ref: string): string[];
|
|
548
|
+
/** Pick the SHA for `ref` out of `ls-remote` output. Branch beats tag. */
|
|
549
|
+
declare function parseLsRemote(stdout: string, ref: string): string | null;
|
|
550
|
+
/**
|
|
551
|
+
* The default branch from `git ls-remote --symref <url> HEAD`:
|
|
552
|
+
* `ref: refs/heads/main\tHEAD` → `main`. `null` for an empty (unborn) remote.
|
|
553
|
+
*/
|
|
554
|
+
declare function parseSymref(stdout: string): string | null;
|
|
555
|
+
/** The SHA that `ls-remote … HEAD` reports (second line of a `--symref` answer). */
|
|
556
|
+
declare function parseHeadSha(stdout: string): string | null;
|
|
557
|
+
/** Did a push get rejected because the remote moved on (someone else pushed first)? */
|
|
558
|
+
declare function isNonFastForward(stderr: string): boolean;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/skills/repo.d.ts
|
|
561
|
+
type SkillTransport = 'git' | 'token';
|
|
562
|
+
/** `skill.url` resolved against the live remote: which URL works, which branch, which folder. */
|
|
563
|
+
interface ResolvedRemote {
|
|
564
|
+
target: SkillTarget;
|
|
565
|
+
transport: SkillTransport;
|
|
566
|
+
/** The URL that reached the remote. MAY CARRY THE TOKEN — never log or store; `redactUrl()` it. */
|
|
567
|
+
fetchUrl: string;
|
|
568
|
+
/** Resolved branch. */
|
|
569
|
+
ref: string;
|
|
570
|
+
/** Resolved subfolder (`''` = repo root). */
|
|
571
|
+
dir: string;
|
|
572
|
+
/** Tip of `ref` at probe time; `null` when the remote is empty. */
|
|
573
|
+
headSha: string | null;
|
|
574
|
+
/** The remote has no refs at all — the first push creates `ref`. */
|
|
575
|
+
emptyRemote: boolean;
|
|
576
|
+
}
|
|
577
|
+
/** The remote could not be reached with any transport we were allowed to try. */
|
|
578
|
+
declare class SkillsAccessError extends Error {
|
|
579
|
+
kind: GitFailureKind;
|
|
580
|
+
why?: GitNoAccessWhy;
|
|
581
|
+
transportTried: SkillTransport[];
|
|
582
|
+
constructor(message: string, failure: GitFailure, transportTried: SkillTransport[]);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Work out how to reach `skill.url` and what branch/folder it names.
|
|
586
|
+
* Throws {@link SkillsAccessError} (message already redacted) when neither the
|
|
587
|
+
* machine's credentials nor the configured token get through.
|
|
588
|
+
*/
|
|
589
|
+
declare function resolveRemote({
|
|
590
|
+
target,
|
|
591
|
+
env,
|
|
592
|
+
run,
|
|
593
|
+
timeoutMs
|
|
594
|
+
}: {
|
|
595
|
+
target: SkillTarget;
|
|
596
|
+
env?: NodeJS.ProcessEnv;
|
|
597
|
+
run?: GitRunner;
|
|
598
|
+
timeoutMs?: number;
|
|
599
|
+
}): ResolvedRemote;
|
|
600
|
+
/** Absolute path of the working clone: `<cwd>/.mono/skills/repo`. */
|
|
601
|
+
declare function repoDir(cwd?: string): string;
|
|
602
|
+
type RepoRefresh = 'always' | 'if-stale' | 'never';
|
|
603
|
+
interface EnsureRepoResult {
|
|
604
|
+
repoDir: string;
|
|
605
|
+
/** A fetch ran and the working tree now matches the remote tip. */
|
|
606
|
+
refreshed: boolean;
|
|
607
|
+
/** A refresh was wanted but failed; the clone is being served as-is. */
|
|
608
|
+
stale: boolean;
|
|
609
|
+
/** Local HEAD after the call (`null` on an unborn branch — empty remote). */
|
|
610
|
+
headSha: string | null;
|
|
611
|
+
/** Age of the last successful fetch, ms (`null` if never fetched). */
|
|
612
|
+
lastFetchMs: number | null;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Make `.mono/skills/repo` a valid clone of the resolved remote on `ref`, and
|
|
616
|
+
* bring it up to date according to `refresh`:
|
|
617
|
+
*
|
|
618
|
+
* - `always` — fetch now (before a save).
|
|
619
|
+
* - `if-stale` — fetch when the last fetch is older than `refreshTtlMs`, or the
|
|
620
|
+
* branch was never fetched (before a read).
|
|
621
|
+
* - `never` — serve whatever is there (diagnostics), fetching only if the
|
|
622
|
+
* branch has never been fetched at all.
|
|
623
|
+
*
|
|
624
|
+
* A failed refresh of an EXISTING clone degrades to `stale: true` — offline
|
|
625
|
+
* reads still work. A failed FIRST fetch throws, since there is nothing to serve.
|
|
626
|
+
*/
|
|
627
|
+
declare function ensureRepo({
|
|
628
|
+
cwd,
|
|
629
|
+
remote,
|
|
630
|
+
refresh,
|
|
631
|
+
run,
|
|
632
|
+
timeoutMs
|
|
633
|
+
}: {
|
|
634
|
+
cwd?: string;
|
|
635
|
+
remote: ResolvedRemote;
|
|
636
|
+
refresh: RepoRefresh;
|
|
637
|
+
run?: GitRunner;
|
|
638
|
+
timeoutMs?: number;
|
|
639
|
+
}): EnsureRepoResult;
|
|
640
|
+
interface CommitAndPushResult {
|
|
641
|
+
/** SHA of the commit that landed on the remote. */
|
|
642
|
+
sha: string;
|
|
643
|
+
/** 1 = pushed first time; 2+ = replayed after someone else pushed first. */
|
|
644
|
+
attempts: number;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Write files (via `apply`), commit them as `actor`, push to `ref`. On a
|
|
648
|
+
* non-fast-forward rejection: fetch, hard-reset to the new remote tip, run
|
|
649
|
+
* `apply` again (it re-checks immutability on the fresh tree), commit, push —
|
|
650
|
+
* up to `attempts` times.
|
|
651
|
+
*/
|
|
652
|
+
declare function commitAndPush({
|
|
653
|
+
repoDir: dir,
|
|
654
|
+
remote,
|
|
655
|
+
actor,
|
|
656
|
+
message,
|
|
657
|
+
apply,
|
|
658
|
+
attempts,
|
|
659
|
+
run,
|
|
660
|
+
timeoutMs
|
|
661
|
+
}: {
|
|
662
|
+
repoDir: string;
|
|
663
|
+
remote: ResolvedRemote;
|
|
664
|
+
actor: Actor;
|
|
665
|
+
message: string;
|
|
666
|
+
apply: (repoDir: string) => void;
|
|
667
|
+
attempts?: number;
|
|
668
|
+
run?: GitRunner;
|
|
669
|
+
timeoutMs?: number;
|
|
670
|
+
}): CommitAndPushResult;
|
|
671
|
+
/** Absolute path of the skills root inside the clone (`repoDir/<dir>`). */
|
|
672
|
+
declare function skillsRoot(dir: string, sub: string): string;
|
|
673
|
+
/** Read one file under `<repoDir>/<dir>/<rel>`; `null` when absent or a directory. */
|
|
674
|
+
declare function readRepoFile(dir: string, sub: string, rel: string): string | null;
|
|
675
|
+
/**
|
|
676
|
+
* List files under `<repoDir>/<dir>/<prefix>` recursively, as forward-slash
|
|
677
|
+
* paths relative to `<repoDir>/<dir>`. `.git` is never entered.
|
|
678
|
+
*/
|
|
679
|
+
declare function listRepoFiles(dir: string, sub: string, prefix?: string): string[];
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/skills/actor.d.ts
|
|
682
|
+
/**
|
|
683
|
+
* Resolve the actor from `git config user.name` / `user.email`.
|
|
684
|
+
*
|
|
685
|
+
* `actorFolder` = `<name-slug>__<6 hex>` where the 6 hex come from a sha256 of
|
|
686
|
+
* the email (stable per identity, so the same person always maps to the same
|
|
687
|
+
* folder). Example: `John Doe` / `john.doe@company.com` -> `john_doe__8f219a`.
|
|
688
|
+
*/
|
|
689
|
+
declare function detectActor(cwd?: string): Actor;
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/skills/appid.d.ts
|
|
692
|
+
/**
|
|
693
|
+
* Normalize an app id: lowercase, keep only `[a-z0-9_-]`, collapse the rest to
|
|
694
|
+
* `-`, trim separators. Rejects path-traversal / separators outright.
|
|
695
|
+
*/
|
|
696
|
+
declare function normalizeAppId(raw: string): string;
|
|
697
|
+
/**
|
|
698
|
+
* Resolve the effective app id for a command. `app` is the explicit `--app`
|
|
699
|
+
* value (if any); `cwd` is the working directory.
|
|
700
|
+
*/
|
|
701
|
+
declare function resolveAppId({
|
|
702
|
+
app,
|
|
703
|
+
cwd
|
|
704
|
+
}: {
|
|
705
|
+
app?: string;
|
|
706
|
+
cwd?: string;
|
|
707
|
+
}): string;
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/skills/staging.d.ts
|
|
710
|
+
/** Absolute `.mono/skills` for a given project root. */
|
|
711
|
+
declare function stagingRoot(cwd?: string): string;
|
|
712
|
+
declare const REQUIRED_FILES: readonly ["metadata.json", "summary.md"];
|
|
713
|
+
/** A single staged session on disk. */
|
|
714
|
+
interface StagedSession {
|
|
715
|
+
sessionId: string;
|
|
716
|
+
dir: string;
|
|
717
|
+
files: string[];
|
|
718
|
+
metadata: SessionMetadata;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Load + validate a staged session directory. Throws a clear error when a
|
|
722
|
+
* required file is missing, `metadata.json` is malformed, or any staged file
|
|
723
|
+
* doesn't match the template standard — so the caller (save/retry) refuses to
|
|
724
|
+
* upload a session that doesn't conform, and nothing reaches GitHub.
|
|
725
|
+
*/
|
|
726
|
+
declare function loadStagedSession(dir: string): StagedSession;
|
|
727
|
+
/** List session ids under `pending/` (or `failed/`). */
|
|
728
|
+
declare function listSessions(cwd: string, kind: 'pending' | 'failed'): string[];
|
|
729
|
+
/** Move a session directory from `pending/` to `failed/` (spec §22). Returns the new path. */
|
|
730
|
+
declare function moveToFailed(cwd: string, sessionId: string): string;
|
|
731
|
+
/** Remove a staged session directory after a successful upload (spec §20 cleanup). */
|
|
732
|
+
declare function removeSession(dir: string): void;
|
|
733
|
+
/** Cache directory for remote reads (`knowledge` / `skills` / `search`). */
|
|
734
|
+
declare function cacheDir(cwd: string, kind: 'knowledge' | 'skills' | 'search'): string;
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/skills/validate.d.ts
|
|
737
|
+
/**
|
|
738
|
+
* Validate a staged session's files against the template standard. Throws a
|
|
739
|
+
* single error listing every problem when the session doesn't conform, so
|
|
740
|
+
* `save`/`retry` refuse to upload it. A conforming session returns silently.
|
|
741
|
+
*/
|
|
742
|
+
declare function validateStagedSession(dir: string, metadata: SessionMetadata): void;
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/skills/redact.d.ts
|
|
745
|
+
/**
|
|
746
|
+
* Redact a string. Returns the cleaned text. Safe to run on any text content
|
|
747
|
+
* (summaries, conversation lines, decisions, metadata serialized to JSON).
|
|
748
|
+
*/
|
|
749
|
+
declare function redact(input: string): string;
|
|
750
|
+
/**
|
|
751
|
+
* Redact a Buffer (e.g. a conversation chunk before upload) by round-tripping
|
|
752
|
+
* through UTF-8. Returns a new Buffer.
|
|
753
|
+
*/
|
|
754
|
+
declare function redactBuffer(buf: Buffer): Buffer;
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/skills/chunk.d.ts
|
|
757
|
+
interface ConversationPart {
|
|
758
|
+
/** `part-0001.jsonl` */
|
|
759
|
+
name: string;
|
|
760
|
+
/** The chunk's raw bytes (already newline-joined). */
|
|
761
|
+
content: Buffer;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Chunk newline-delimited `jsonl` text into parts. Blank lines are dropped.
|
|
765
|
+
* Returns `[]` for empty input.
|
|
766
|
+
*/
|
|
767
|
+
declare function chunkConversation(jsonl: string, chunkSizeBytes?: number): ConversationPart[];
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region src/skills/save.d.ts
|
|
770
|
+
/** A single file to write into the permanent session folder. */
|
|
771
|
+
interface PlannedFile {
|
|
772
|
+
/** Path relative to the skills root (`dir`). */
|
|
773
|
+
repoPath: string;
|
|
774
|
+
/** Already-redacted bytes. */
|
|
775
|
+
content: Buffer;
|
|
776
|
+
}
|
|
777
|
+
interface SavePlan {
|
|
778
|
+
appId: string;
|
|
779
|
+
actor: Actor;
|
|
780
|
+
sessionId: string;
|
|
781
|
+
/** The configured repository (plain URL). */
|
|
782
|
+
repository: string;
|
|
783
|
+
/** `<app>/history/<actor>/<date>/<time>_<id>` */
|
|
784
|
+
savedPath: string;
|
|
785
|
+
/** Files that WILL be written (skills-root-relative), in order. */
|
|
786
|
+
files: PlannedFile[];
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Build the full upload plan from a staged session WITHOUT touching the network.
|
|
790
|
+
* `--dry-run` returns exactly this. Everything textual is redacted here.
|
|
791
|
+
*/
|
|
792
|
+
declare function buildSavePlan({
|
|
793
|
+
cwd,
|
|
794
|
+
app,
|
|
795
|
+
dir,
|
|
796
|
+
target
|
|
797
|
+
}: {
|
|
798
|
+
cwd?: string;
|
|
799
|
+
app?: string;
|
|
800
|
+
dir: string;
|
|
801
|
+
target?: SkillTarget;
|
|
802
|
+
}): SavePlan;
|
|
803
|
+
/**
|
|
804
|
+
* Write the plan into the clone. Runs inside `commitAndPush`, so it may run
|
|
805
|
+
* more than once (after a replay onto a newer tip) — every step is idempotent:
|
|
806
|
+
* `app.json` / `user.json` are created once and never overwritten (so human
|
|
807
|
+
* edits to them survive), and an existing session folder is REFUSED (sessions
|
|
808
|
+
* are immutable).
|
|
809
|
+
*/
|
|
810
|
+
declare function applyPlan(plan: SavePlan, root: string): void;
|
|
811
|
+
/**
|
|
812
|
+
* Execute a save: resolve the remote, refresh the clone, apply, commit, push.
|
|
813
|
+
* On any failure the local staging dir is preserved / moved to `failed/` and
|
|
814
|
+
* the error is rethrown (already redacted).
|
|
815
|
+
*/
|
|
816
|
+
declare function runSave({
|
|
817
|
+
cwd,
|
|
818
|
+
app,
|
|
819
|
+
dir,
|
|
820
|
+
target,
|
|
821
|
+
remote,
|
|
822
|
+
env,
|
|
823
|
+
run
|
|
824
|
+
}: {
|
|
825
|
+
cwd?: string;
|
|
826
|
+
app?: string;
|
|
827
|
+
dir: string; /** Pre-parsed `skill` (the CLI parses it once). */
|
|
828
|
+
target?: SkillTarget; /** Pre-resolved remote (skips the probe). */
|
|
829
|
+
remote?: ResolvedRemote;
|
|
830
|
+
env?: NodeJS.ProcessEnv;
|
|
831
|
+
run?: GitRunner;
|
|
832
|
+
}): SaveResult;
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region src/skills/read.d.ts
|
|
835
|
+
/** Where the answer came from — every read result carries this. */
|
|
836
|
+
interface ReadSource {
|
|
837
|
+
source: 'local-clone';
|
|
838
|
+
/** The clone could not be refreshed and may be behind the remote. */
|
|
839
|
+
stale: boolean;
|
|
840
|
+
ref: string;
|
|
841
|
+
dir: string;
|
|
842
|
+
}
|
|
843
|
+
interface ReadResult extends ReadSource {
|
|
844
|
+
app: string;
|
|
845
|
+
type?: 'knowledge' | 'skills';
|
|
846
|
+
/** Files returned: skills-root-relative path + text. */
|
|
847
|
+
files: Array<{
|
|
848
|
+
path: string;
|
|
849
|
+
text: string;
|
|
850
|
+
}>;
|
|
851
|
+
}
|
|
852
|
+
interface RepoAccess {
|
|
853
|
+
cwd?: string;
|
|
854
|
+
remote: ResolvedRemote;
|
|
855
|
+
run?: GitRunner;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Read either a whole `--type knowledge|skills` folder for an app, or a single
|
|
859
|
+
* safe `--path` under that app. Returns the matched files' text.
|
|
860
|
+
*/
|
|
861
|
+
declare function runRead({
|
|
862
|
+
cwd,
|
|
863
|
+
app,
|
|
864
|
+
type,
|
|
865
|
+
path: relPath,
|
|
866
|
+
remote,
|
|
867
|
+
run
|
|
868
|
+
}: RepoAccess & {
|
|
869
|
+
app?: string;
|
|
870
|
+
type?: 'knowledge' | 'skills';
|
|
871
|
+
path?: string;
|
|
872
|
+
}): ReadResult;
|
|
873
|
+
interface SearchHit {
|
|
874
|
+
path: string;
|
|
875
|
+
score: number;
|
|
876
|
+
/** A short snippet around the first match. */
|
|
877
|
+
snippet: string;
|
|
878
|
+
}
|
|
879
|
+
interface SearchResult extends ReadSource {
|
|
880
|
+
app: string;
|
|
881
|
+
query: string;
|
|
882
|
+
hits: SearchHit[];
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Search an app's knowledge/skills + history summaries/decisions/index for a
|
|
886
|
+
* query. Returns the top `limit` matches with snippets. Conversation chunks are
|
|
887
|
+
* intentionally excluded from the scan (too large / low signal).
|
|
888
|
+
*/
|
|
889
|
+
declare function runSearch({
|
|
890
|
+
cwd,
|
|
891
|
+
app,
|
|
892
|
+
query,
|
|
893
|
+
limit,
|
|
894
|
+
remote,
|
|
895
|
+
run
|
|
896
|
+
}: RepoAccess & {
|
|
897
|
+
app?: string;
|
|
898
|
+
query: string;
|
|
899
|
+
limit?: number;
|
|
900
|
+
}): SearchResult;
|
|
901
|
+
//#endregion
|
|
902
|
+
//#region src/skills/check.d.ts
|
|
903
|
+
interface CheckReport {
|
|
904
|
+
/** `skill` is present (and parseable) in mono.config.ts. */
|
|
905
|
+
configured: boolean;
|
|
906
|
+
/** Plain repository URL, never a token. */
|
|
907
|
+
url: string | null;
|
|
908
|
+
kind: SkillUrlKind | null;
|
|
909
|
+
/** Resolved branch / subfolder (after probing). */
|
|
910
|
+
ref: string | null;
|
|
911
|
+
dir: string | null;
|
|
912
|
+
/** The env var NAME from `skill.envToken`, and whether it is set. */
|
|
913
|
+
tokenEnv: string | null;
|
|
914
|
+
tokenPresent: boolean;
|
|
915
|
+
tokenSupported: boolean;
|
|
916
|
+
/** Which credentials reached the remote. */
|
|
917
|
+
transport: SkillTransport | null;
|
|
918
|
+
canRead: boolean | null;
|
|
919
|
+
canPush: boolean | null;
|
|
920
|
+
remoteHead: string | null;
|
|
921
|
+
emptyRemote: boolean | null;
|
|
922
|
+
localClone: {
|
|
923
|
+
path: string;
|
|
924
|
+
exists: boolean;
|
|
925
|
+
headSha: string | null; /** ISO time of the last successful fetch, if any. */
|
|
926
|
+
lastFetchAt: string | null;
|
|
927
|
+
};
|
|
928
|
+
/** The resolved current app id, and whether it's still a generic template name. */
|
|
929
|
+
currentApp: string | null;
|
|
930
|
+
genericAppName: boolean;
|
|
931
|
+
actor: Actor;
|
|
932
|
+
gitIdentityConfigured: boolean;
|
|
933
|
+
notes: string[];
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Run every check that is possible given the current config. Never throws:
|
|
937
|
+
* an absent `skill` reports `configured: false`; an unreachable remote reports
|
|
938
|
+
* `null`s plus a note.
|
|
939
|
+
*/
|
|
940
|
+
declare function runCheck({
|
|
941
|
+
cwd,
|
|
942
|
+
env,
|
|
943
|
+
run
|
|
944
|
+
}?: {
|
|
945
|
+
cwd?: string;
|
|
946
|
+
env?: NodeJS.ProcessEnv;
|
|
947
|
+
run?: GitRunner;
|
|
948
|
+
}): CheckReport;
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/skills/session.d.ts
|
|
951
|
+
interface SessionShowResult extends ReadSource {
|
|
952
|
+
app: string;
|
|
953
|
+
sessionId: string;
|
|
954
|
+
/** Skills-root-relative session folder, if found. */
|
|
955
|
+
path: string | null;
|
|
956
|
+
metadata: unknown | null;
|
|
957
|
+
summary: string | null;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Locate `<app>/history/**/HH-mm-ss_<sessionId>/` in the clone, then return its
|
|
961
|
+
* `metadata.json` + `summary.md`. Returns nulls when the session isn't found.
|
|
962
|
+
*/
|
|
963
|
+
declare function runSessionShow({
|
|
964
|
+
cwd,
|
|
965
|
+
app,
|
|
966
|
+
sessionId,
|
|
967
|
+
remote,
|
|
968
|
+
run
|
|
969
|
+
}: {
|
|
970
|
+
cwd?: string;
|
|
971
|
+
app?: string;
|
|
972
|
+
sessionId: string;
|
|
973
|
+
remote: ResolvedRemote;
|
|
974
|
+
run?: GitRunner;
|
|
975
|
+
}): SessionShowResult;
|
|
976
|
+
//#endregion
|
|
977
|
+
export { ALLOWED_FLAGS, Actor, BASE_ARGS, ChangedFile, CheckReport, CommitAndPushResult, ConversationPart, EnsureRepoResult, ExtractedApp, ExtractedConfig, FailureResult, GENERIC_APP_NAMES, GitFailure, GitFailureKind, GitNoAccessWhy, GitResult, GitRunner, LoadMonoConfigOptions, MONO_APPS_DIR, MONO_DIR, MONO_TSCONFIG_REF, MonoAliasOptions, MonoAppRoot, MonoAppRootInput, MonoAppRootSource, MonoMissingApp, MonoMissingAppsOptions, MonoMissingPathPolicy, type MonoSkillConfig, MonoStubAliases, MonoStubAliasesOptions, REQUIRED_FILES, ReadResult, ReadSource, RepoRefresh, ResolveAppRootsOptions, ResolveFederatedRootsOptions, ResolvedRemote, RunGitOptions, RunMonoPrepareOptions, RunMonoPrepareResult, SKILLS_DEFAULTS, SavePlan, SaveResult, SearchHit, SearchResult, SessionDecision, SessionMetadata, SessionShowResult, SessionStatus, SkillTarget, SkillTransport, SkillUrlKind, SkillsAccessError, SkippedResult, StagedSession, appRootDirs, applyPlan, assertAppSources, buildMonoTsconfig, buildSavePlan, cacheDir, chunkConversation, classifyGitFailure, commitAndPush, detectActor, ensureRepo, extractConfig, extractConfigName, extractSkill, extractTemplate, firstFatal, formatMissingApps, getMonoConfig, gitEnv, hasUrl, isGenericAppName, isMissingPathError, isNonFastForward, linkedAppRoots, listRepoFiles, listSessions, loadMonoConfig, loadSkillConfig, loadSkillsEnv, loadStagedSession, missingPathMessage, monoAlias, monoConfigFileFor, monoMissingApps, monoStubAliases, monoTsconfigPaths, moveToFailed, normalizeAppId, parseHeadSha, parseLsRemote, parseSymref, pathAppRoots, readRepoFile, redact, redactBuffer, redactUrl, refDirCandidates, refPatterns, removeSession, repoDir, resetAppPathWarnings, resolveAppId, resolveAppRoots, resolveFederatedRoots, resolveRemote, resolveSkillTarget, runCheck, runGit, runMonoPrepare, runRead, runSave, runSearch, runSessionShow, skillsRoot, stagingRoot, stripCommentsSafe, tokenRemote, validateStagedSession };
|