@mikedown/core 0.3.0 → 0.4.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.
- package/CHANGELOG.md +12 -1
- package/README.md +1 -1
- package/dist/ai/engines-page.d.ts +11 -4
- package/dist/ai/engines-page.js +5 -4
- package/dist/ai/index.d.ts +1201 -10
- package/dist/ai/index.js +297 -8
- package/dist/{ai-ui-C7ENTWWU.js → ai-ui-QFYFN73D.js} +3165 -138
- package/dist/ai-ui-QFYFN73D.js.map +1 -0
- package/dist/{chunk-QDVY7WW6.js → chunk-APPBNQEY.js} +53 -2
- package/dist/chunk-APPBNQEY.js.map +1 -0
- package/dist/{chunk-7A5HEPLK.js → chunk-DWXGWVA3.js} +850 -12
- package/dist/chunk-DWXGWVA3.js.map +1 -0
- package/dist/{chunk-JZWKEBCI.js → chunk-IWCXWUWW.js} +3260 -201
- package/dist/chunk-IWCXWUWW.js.map +1 -0
- package/dist/{chunk-LXZG7IKN.js → chunk-N4N54LK2.js} +2 -2
- package/dist/chunk-N4N54LK2.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +399 -38
- package/dist/index.js.map +1 -1
- package/dist/schema-DVfssxQX.d.ts +100 -0
- package/dist/styles.css +943 -4
- package/dist/{types-CsVNVSNY.d.ts → types-2TZErbJr.d.ts} +25 -3
- package/dist/{types-CgEeIUhi.d.ts → types-DO8UBybZ.d.ts} +316 -7
- package/package.json +1 -1
- package/dist/ai-ui-C7ENTWWU.js.map +0 -1
- package/dist/chunk-7A5HEPLK.js.map +0 -1
- package/dist/chunk-JZWKEBCI.js.map +0 -1
- package/dist/chunk-LXZG7IKN.js.map +0 -1
- package/dist/chunk-QDVY7WW6.js.map +0 -1
- package/dist/schema-DYzxkuSb.d.ts +0 -46
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { f as AiFeatureSettings, a6 as AiGhostTextOptions, i as AiEngineKind, A as AiSettings, _ as AiDocBase, m as AiDocsOptions, a2 as AiDocsSettings } from './types-DO8UBybZ.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `mikedown.ai.*` settings: parse (validate, fill defaults, keep unknown
|
|
5
|
+
* keys) and serialize back to a settings patch.
|
|
6
|
+
*
|
|
7
|
+
* `parseAiSettings` never throws. Malformed entries (an engine that is not
|
|
8
|
+
* an object or has no base URL, a model with no id, a route without both
|
|
9
|
+
* ids) are dropped with a warning; everything it does not recognize is kept
|
|
10
|
+
* as is, on every object, so a newer version's settings survive a save.
|
|
11
|
+
* Engines without an id get one, once: the id is written back by
|
|
12
|
+
* `serializeAiSettings`, so it is stable from then on.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface ParseAiSettingsOptions {
|
|
16
|
+
/** Id for an engine that has none. Default: a slug of its name plus random characters. */
|
|
17
|
+
generateId?: (name: string) => string;
|
|
18
|
+
/** Called once per dropped or repaired entry. Default `console.warn`. */
|
|
19
|
+
onWarning?: (message: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/** The top-level keys, without the `ai.` prefix. */
|
|
22
|
+
declare const AI_SETTINGS_KEYS: readonly ["enabled", "allowCloud", "engines", "routing", "features", "localNetworks", "showToolbarButton", "activityPanel", "docBases", "docs"];
|
|
23
|
+
|
|
24
|
+
declare function isKnownEngineKind(kind: string): kind is AiEngineKind;
|
|
25
|
+
/** A kind only one host runs, with no address or key (`vscode-lm`); see `AI_HOST_ENGINE_KINDS`. */
|
|
26
|
+
declare function isHostEngineKind(kind: string): boolean;
|
|
27
|
+
/** A new engine id: `omlx-mac-studio-k3f9a2`. Never shown, only has to be unique and stable. */
|
|
28
|
+
declare function generateAiId(name?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Read `raw` as AI settings. Accepts the nested object VS Code returns for
|
|
31
|
+
* `getConfiguration('mikedown.ai')` (`{ enabled, engines, ... }`) or a flat
|
|
32
|
+
* store with `ai.`-prefixed keys (Desktop, a settings patch). Anything else,
|
|
33
|
+
* including undefined, gives the defaults.
|
|
34
|
+
*/
|
|
35
|
+
declare function parseAiSettings(raw: unknown, opts?: ParseAiSettingsOptions): AiSettings;
|
|
36
|
+
/** Defaults and ranges for `features.ghostText` (decision D12). */
|
|
37
|
+
declare const GHOST_DELAY_MS_DEFAULT = 400;
|
|
38
|
+
declare const GHOST_DELAY_MS_MIN = 100;
|
|
39
|
+
declare const GHOST_DELAY_MS_MAX = 5000;
|
|
40
|
+
declare const GHOST_MAX_TOKENS_DEFAULT = 48;
|
|
41
|
+
declare const GHOST_MAX_TOKENS_MIN = 8;
|
|
42
|
+
declare const GHOST_MAX_TOKENS_MAX = 256;
|
|
43
|
+
/**
|
|
44
|
+
* The Inline suggestions knobs: defaults (400 ms, 48 tokens, `auto`, local
|
|
45
|
+
* engines only) for anything absent or of the wrong type, numbers rounded and
|
|
46
|
+
* clamped (delay 100 to 5000 ms, tokens 8 to 256).
|
|
47
|
+
*/
|
|
48
|
+
declare function ghostTextOptions(features: AiFeatureSettings | undefined): AiGhostTextOptions;
|
|
49
|
+
/** The settings patch keys, `ai.`-prefixed: what the editor sends to `host.saveSettings`. */
|
|
50
|
+
type AiSettingsPatch = Record<`ai.${string}`, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Settings to a `saveSettings` patch: one `ai.<key>` per top-level key,
|
|
53
|
+
* including unknown ones, as plain JSON (deep copies). VS Code writes each as
|
|
54
|
+
* `mikedown.ai.<key>`; Desktop stores the flat keys. Secrets are never here.
|
|
55
|
+
*/
|
|
56
|
+
declare function serializeAiSettings(settings: AiSettings): AiSettingsPatch;
|
|
57
|
+
/** What `checkDocRoot` says about one folder path. */
|
|
58
|
+
type DocRootCheck = {
|
|
59
|
+
ok: true;
|
|
60
|
+
path: string;
|
|
61
|
+
windows: boolean;
|
|
62
|
+
} | {
|
|
63
|
+
ok: false;
|
|
64
|
+
reason: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Is `raw` an acceptable base root (decision 2)? Absolute, normalized
|
|
68
|
+
* (separators collapsed, `.` and `..` resolved, no trailing separator), no
|
|
69
|
+
* `${...}` token, not a filesystem root, and not a markdown file where the
|
|
70
|
+
* name says so. Pure string work: a host still checks the folder on disk.
|
|
71
|
+
* POSIX (`/a/b`), drive (`C:\a\b`, `C:/a/b`) and UNC (`\\server\share\a`)
|
|
72
|
+
* paths are accepted; the result keeps the style it came in (a drive letter
|
|
73
|
+
* is upper-cased, a Windows path uses `\`).
|
|
74
|
+
*/
|
|
75
|
+
declare function checkDocRoot(raw: unknown): DocRootCheck;
|
|
76
|
+
/** The key two roots are compared by: case-insensitive for Windows paths only. */
|
|
77
|
+
declare function docRootKey(path: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* A base's home override: a markdown file name, or a relative path under the
|
|
80
|
+
* root, with `/` separators. No absolute path, no `..`, no `${...}`. Null
|
|
81
|
+
* when `raw` is not one.
|
|
82
|
+
*/
|
|
83
|
+
declare function normalizeDocHomeFile(raw: unknown): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Read `ai.docBases`. Drops, each with a warning that says why: an entry that
|
|
86
|
+
* is not an object, one with no valid root, a root that fails `checkDocRoot`
|
|
87
|
+
* or repeats another root (in this base or any earlier one; case-insensitive
|
|
88
|
+
* for Windows paths). A bad `homeFile` is dropped and the base kept. A base
|
|
89
|
+
* with no id gets one, once (written back by `serializeAiSettings`).
|
|
90
|
+
* `allowCloud` is false unless exactly `true`; `enabled` is true unless
|
|
91
|
+
* exactly `false`. Unknown keys survive.
|
|
92
|
+
*/
|
|
93
|
+
declare function parseDocBases(raw: unknown, genId: (name: string) => string, warn: (m: string) => void): AiDocBase[];
|
|
94
|
+
/** Read `ai.docs`: hops clamped to 1 to 5, share to 30 to 80, `navigateBy` to `section` or `page`. Unknown keys survive. */
|
|
95
|
+
declare function parseDocsOptions(raw: unknown, warn: (m: string) => void): AiDocsOptions;
|
|
96
|
+
/** What the navigation loop runs with: the advanced options plus the bases. */
|
|
97
|
+
declare function resolveDocsSettings(settings: Pick<AiSettings, 'docBases' | 'docs'>): AiDocsSettings;
|
|
98
|
+
|
|
99
|
+
export { GHOST_DELAY_MS_DEFAULT as G, AI_SETTINGS_KEYS as a, GHOST_DELAY_MS_MAX as b, GHOST_DELAY_MS_MIN as c, GHOST_MAX_TOKENS_DEFAULT as d, GHOST_MAX_TOKENS_MAX as e, GHOST_MAX_TOKENS_MIN as f, checkDocRoot as g, docRootKey as h, generateAiId as i, ghostTextOptions as j, isHostEngineKind as k, isKnownEngineKind as l, parseDocBases as m, normalizeDocHomeFile as n, parseDocsOptions as o, parseAiSettings as p, resolveDocsSettings as r, serializeAiSettings as s };
|
|
100
|
+
export type { AiSettingsPatch as A, DocRootCheck as D, ParseAiSettingsOptions as P };
|