@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ai-lite.ts"],"sourcesContent":["/**\n * The little of the AI layer the editor needs before the AI UI is loaded,\n * and the loader for the rest.\n *\n * Everything behind `host.ai` (the rewrite popover, the AI settings tab and\n * Engines page, the toolbar menu, the prompts and the router) lives in\n * `ai-ui.ts`, which the editor imports with `import()` only when the host has\n * an AI adapter. Bundlers split it into its own chunk, so an editor without\n * AI never downloads it. A host that wants it in its main bundle, loaded\n * synchronously (the VS Code webview), imports `ai-ui-eager.ts` once.\n */\n\nimport type { AiSettings, MikeDownAiHost } from './ai/types';\n\nexport type AiUi = typeof import('./ai-ui');\n\nlet aiUi: AiUi | null = null;\nlet loading: Promise<AiUi> | null = null;\n\n/** The AI UI when it is already loaded (or registered), else null. */\nexport function loadedAiUi(): AiUi | null {\n return aiUi;\n}\n\n/** Load the AI UI chunk once; a failed load is tried again on the next call. */\nexport function loadAiUi(): Promise<AiUi> {\n if (aiUi) {return Promise.resolve(aiUi);}\n loading ??= import('./ai-ui').then(\n (m) => { aiUi = m; return m; },\n (err: unknown) => { loading = null; throw err; },\n );\n return loading;\n}\n\n/** Make the AI UI available synchronously (`ai-ui-eager.ts`); null forgets it (tests). */\nexport function registerAiUi(m: AiUi | null): void {\n aiUi = m;\n loading = null;\n}\n\n// ── Host tier ───────────────────────────────────────────────────────────────\n\n/** 1: `complete` only, the host routes. 2: the host has an engine registry and core routes. */\nexport type AiHostTier = 1 | 2;\n\nexport function aiHostTier(ai: MikeDownAiHost): AiHostTier {\n return typeof ai.listEngines === 'function' ? 2 : 1;\n}\n\n// ── Toolbar button ──────────────────────────────────────────────────────────\n\nexport type AiToolbarButtonMode = 'hidden' | 'firstRun' | 'menu';\n\n/** What the button does: hidden without AI support or when turned off in settings. */\nexport function aiToolbarButtonMode(hasAiHost: boolean, settings: Pick<AiSettings, 'enabled' | 'showToolbarButton'>): AiToolbarButtonMode {\n if (!hasAiHost || !settings.showToolbarButton) {return 'hidden';}\n return settings.enabled ? 'menu' : 'firstRun';\n}\n"],"mappings":";AAgBA,IAAI,OAAoB;AACxB,IAAI,UAAgC;AAG7B,SAAS,aAA0B;AACxC,SAAO;AACT;AAGO,SAAS,WAA0B;AACxC,MAAI,MAAM;AAAC,WAAO,QAAQ,QAAQ,IAAI;AAAA,EAAE;AACxC,wBAAY,OAAO,qBAAS,EAAE;AAAA,IAC5B,CAAC,MAAM;AAAE,aAAO;AAAG,aAAO;AAAA,IAAG;AAAA,IAC7B,CAAC,QAAiB;AAAE,gBAAU;AAAM,YAAM;AAAA,IAAK;AAAA,EACjD;AACA,SAAO;AACT;AAaO,SAAS,WAAW,IAAgC;AACzD,SAAO,OAAO,GAAG,gBAAgB,aAAa,IAAI;AACpD;AAOO,SAAS,oBAAoB,WAAoB,UAAkF;AACxI,MAAI,CAAC,aAAa,CAAC,SAAS,mBAAmB;AAAC,WAAO;AAAA,EAAS;AAChE,SAAO,SAAS,UAAU,SAAS;AACrC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ai/locality.ts","../src/ai/defaults.ts","../src/shared/tagSyntax.ts"],"sourcesContent":["/**\n * Local or cloud, from an engine's base URL. Loopback, link-local, IPv6\n * unique-local, `localhost`, `.local`, `.lan`, `.home.arpa` and `.internal`\n * are always local; `localNetworks` adds CIDR ranges (RFC 1918 by default, a\n * WireGuard range such as `10.0.98.0/24`) and `.suffix` host names. Anything\n * else, including a URL that does not parse, is cloud.\n */\n\nimport type { AiEngineConfig, AiLocality } from './types';\n\n/** Default `mikedown.ai.localNetworks`: RFC 1918. */\nexport const DEFAULT_LOCAL_NETWORKS: readonly string[] = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'];\n\nconst ALWAYS_LOCAL_IPV4 = ['127.0.0.0/8', '169.254.0.0/16', '0.0.0.0/32'];\nconst LOCAL_SUFFIXES = ['.localhost', '.local', '.lan', '.home.arpa', '.internal'];\n\n/** Lower-cased host of a URL (no port, no brackets), or null. Accepts a bare `host:port`. */\nexport function hostOfUrl(url: string): string | null {\n const trimmed = url.trim();\n if (!trimmed) {return null;}\n const withoutScheme = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(trimmed) ? trimmed.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i, '') : trimmed;\n const authority = withoutScheme.split(/[/?#]/, 1)[0];\n const hostPort = authority.includes('@') ? authority.slice(authority.lastIndexOf('@') + 1) : authority;\n if (!hostPort) {return null;}\n if (hostPort.startsWith('[')) {\n const end = hostPort.indexOf(']');\n return end > 1 ? hostPort.slice(1, end).toLowerCase() : null;\n }\n // More than one colon and no brackets: a bare IPv6 address.\n if ((hostPort.match(/:/g) ?? []).length > 1) {return hostPort.toLowerCase();}\n const host = hostPort.split(':', 1)[0].toLowerCase().replace(/\\.$/, '');\n return host || null;\n}\n\nfunction parseIpv4(host: string): number | null {\n const m = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(host);\n if (!m) {return null;}\n const parts = m.slice(1).map(Number);\n if (parts.some((p) => p > 255)) {return null;}\n return ((parts[0] << 24) >>> 0) + (parts[1] << 16) + (parts[2] << 8) + parts[3];\n}\n\nfunction inIpv4Cidr(ip: number, cidr: string): boolean {\n const [base, bitsText] = cidr.split('/');\n const baseIp = parseIpv4(base.trim());\n const bits = bitsText === undefined ? 32 : Number(bitsText);\n if (baseIp === null || !Number.isInteger(bits) || bits < 0 || bits > 32) {return false;}\n if (bits === 0) {return true;}\n const mask = (0xffffffff << (32 - bits)) >>> 0;\n return ((ip & mask) >>> 0) === ((baseIp & mask) >>> 0);\n}\n\nfunction isLocalIpv6(host: string): boolean {\n if (!host.includes(':')) {return false;}\n if (host === '::1' || host === '::') {return true;}\n // IPv4-mapped (::ffff:192.168.1.2) is judged by its IPv4 part elsewhere.\n const first = host.split(':')[0];\n if (!first) {return false;}\n const word = parseInt(first, 16);\n if (Number.isNaN(word)) {return false;}\n // fe80::/10 link-local, fc00::/7 unique-local.\n return (word & 0xffc0) === 0xfe80 || (word & 0xfe00) === 0xfc00;\n}\n\n/**\n * `local` or `cloud` for a base URL. `localNetworks` entries are IPv4 CIDR\n * ranges (`10.0.98.0/24`, a bare address counts as /32) or host-name\n * suffixes (`.ts.net`, `studio.example.com`).\n */\nexport function detectLocality(baseUrl: string, localNetworks: readonly string[] = DEFAULT_LOCAL_NETWORKS): AiLocality {\n const host = hostOfUrl(baseUrl);\n if (!host) {return 'cloud';}\n if (host === 'localhost' || LOCAL_SUFFIXES.some((s) => host.endsWith(s))) {return 'local';}\n\n const mapped = /^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/.exec(host);\n const ip = parseIpv4(mapped ? mapped[1] : host);\n if (ip !== null) {\n if (ALWAYS_LOCAL_IPV4.some((c) => inIpv4Cidr(ip, c))) {return 'local';}\n return localNetworks.some((entry) => /^\\d/.test(entry.trim()) && inIpv4Cidr(ip, entry.trim())) ? 'local' : 'cloud';\n }\n if (isLocalIpv6(host)) {return 'local';}\n\n for (const raw of localNetworks) {\n const entry = raw.trim().toLowerCase();\n if (!entry || /^\\d/.test(entry)) {continue;}\n if (entry.startsWith('.') ? host.endsWith(entry) : host === entry || host.endsWith(`.${entry}`)) {return 'local';}\n }\n return 'cloud';\n}\n\n/**\n * The engine's effective locality: its pin, or `detectLocality` for `auto`.\n * A `vscode-lm` engine is always cloud, whatever its pin: it has no address,\n * and the text goes to GitHub's Copilot service.\n */\nexport function engineLocality(engine: Pick<AiEngineConfig, 'baseUrl' | 'locality'> & { kind?: string }, localNetworks?: readonly string[]): AiLocality {\n if (engine.kind === 'vscode-lm') {return 'cloud';}\n if (engine.locality === 'local' || engine.locality === 'cloud') {return engine.locality;}\n return detectLocality(engine.baseUrl, localNetworks);\n}\n\n/**\n * True when a pinned locality disagrees with the URL (cloud pinned on a\n * private address, or local pinned on a public one). The indicator shows a\n * warning glyph for it.\n */\nexport function localityMismatch(engine: Pick<AiEngineConfig, 'baseUrl' | 'locality'> & { kind?: string }, localNetworks?: readonly string[]): boolean {\n if (engine.locality === 'auto' || engine.kind === 'vscode-lm') {return false;}\n return engine.locality !== detectLocality(engine.baseUrl, localNetworks);\n}\n","/**\n * The settings before the host sends any. Its own module so the editor can\n * start from them without loading the rest of the AI layer (see `ai-lite.ts`).\n */\n\nimport { DEFAULT_LOCAL_NETWORKS } from './locality';\nimport type { AiSettings } from './types';\n\nexport function defaultAiSettings(): AiSettings {\n return {\n enabled: false,\n allowCloud: false,\n engines: [],\n routing: { default: null, fallback: 'anyLocal', tasks: {} },\n features: {},\n localNetworks: [...DEFAULT_LOCAL_NETWORKS],\n showToolbarButton: true,\n };\n}\n","// Shared tag syntax — pure, no DOM or vscode imports so both the extension\n// host and the webview bundle can consume it (same cross-bundle pattern as\n// `frontmatterYaml.ts` / `imageDisplayPath.ts`).\n//\n// A tag is `#` followed by one or more `/`-separated segments of\n// [A-Za-z0-9_-]. It must NOT be preceded by a word char, `/`, `#`, or `&`\n// (so it won't fire inside URLs, `##` sequences, or HTML entities) and must\n// contain at least one letter (so pure numbers like `#1234` aren't tags).\n// Inline tags that look like hex colors (`#2563eb`, `#ffffff`, `#f0f`) are\n// skipped too; frontmatter `tags:` entries are explicit, so they aren't.\n// Nested tags use slashes: `#project/active`.\n\nconst SEGMENT = '[A-Za-z0-9_-]+';\nconst TAG_SOURCE = `(?<![\\\\w/#&])#(${SEGMENT}(?:/${SEGMENT})*)`;\n\n/** Fresh global regex each call (global regexes carry mutable lastIndex). */\nexport function inlineTagRegex(): RegExp {\n return new RegExp(TAG_SOURCE, 'g');\n}\n\n/** A tag is only valid if it contains at least one letter. */\nexport function isValidTag(tag: string): boolean {\n return /[A-Za-z]/.test(tag);\n}\n\n/** Normalize a tag for indexing/matching: strip a leading `#`, lowercase. */\nexport function normalizeTag(raw: string): string | null {\n const t = raw.trim().replace(/^#+/, '').toLowerCase();\n if (!t || !isValidTag(t)) return null;\n return t;\n}\n\n/** Hex-color-like tokens: any all-hex run containing a digit (`#0f`,\n * `#2563eb`), or 6/8 hex letters (`#ffffff`). All-letter words such as\n * `#bad`, `#cafe`, `#face` still count as tags. */\nexport function looksLikeHexColor(tag: string): boolean {\n if (!/^[0-9a-f]+$/i.test(tag)) return false;\n return /[0-9]/.test(tag) || tag.length === 6 || tag.length === 8;\n}\n\nexport interface InlineTagMatch {\n /** The tag without its leading `#`, original case. */\n tag: string;\n /** Offset of the `#` within the scanned string. */\n index: number;\n /** Length of the full `#tag` token. */\n length: number;\n}\n\n/** Find every inline `#tag` token in a single string. */\nexport function findInlineTags(text: string): InlineTagMatch[] {\n const re = inlineTagRegex();\n const out: InlineTagMatch[] = [];\n let m: RegExpExecArray | null;\n while ((m = re.exec(text)) !== null) {\n if (!isValidTag(m[1]) || looksLikeHexColor(m[1])) continue;\n out.push({ tag: m[1], index: m.index, length: m[0].length });\n }\n return out;\n}\n"],"mappings":";AAWO,IAAM,yBAA4C,CAAC,cAAc,iBAAiB,gBAAgB;AAEzG,IAAM,oBAAoB,CAAC,eAAe,kBAAkB,YAAY;AACxE,IAAM,iBAAiB,CAAC,cAAc,UAAU,QAAQ,cAAc,WAAW;AAG1E,SAAS,UAAU,KAA4B;AACpD,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,CAAC,SAAS;AAAC,WAAO;AAAA,EAAK;AAC3B,QAAM,gBAAgB,2BAA2B,KAAK,OAAO,IAAI,QAAQ,QAAQ,4BAA4B,EAAE,IAAI;AACnH,QAAM,YAAY,cAAc,MAAM,SAAS,CAAC,EAAE,CAAC;AACnD,QAAM,WAAW,UAAU,SAAS,GAAG,IAAI,UAAU,MAAM,UAAU,YAAY,GAAG,IAAI,CAAC,IAAI;AAC7F,MAAI,CAAC,UAAU;AAAC,WAAO;AAAA,EAAK;AAC5B,MAAI,SAAS,WAAW,GAAG,GAAG;AAC5B,UAAM,MAAM,SAAS,QAAQ,GAAG;AAChC,WAAO,MAAM,IAAI,SAAS,MAAM,GAAG,GAAG,EAAE,YAAY,IAAI;AAAA,EAC1D;AAEA,OAAK,SAAS,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,GAAG;AAAC,WAAO,SAAS,YAAY;AAAA,EAAE;AAC5E,QAA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;AACT;","names":[]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { h as AiEngineKind, A as AiSettings } from './types-CgEeIUhi.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"];
|
|
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
|
-
/** The settings patch keys, `ai.`-prefixed: what the editor sends to `host.saveSettings`. */
|
|
37
|
-
type AiSettingsPatch = Record<`ai.${string}`, unknown>;
|
|
38
|
-
/**
|
|
39
|
-
* Settings to a `saveSettings` patch: one `ai.<key>` per top-level key,
|
|
40
|
-
* including unknown ones, as plain JSON (deep copies). VS Code writes each as
|
|
41
|
-
* `mikedown.ai.<key>`; Desktop stores the flat keys. Secrets are never here.
|
|
42
|
-
*/
|
|
43
|
-
declare function serializeAiSettings(settings: AiSettings): AiSettingsPatch;
|
|
44
|
-
|
|
45
|
-
export { AI_SETTINGS_KEYS as a, isKnownEngineKind as b, generateAiId as g, isHostEngineKind as i, parseAiSettings as p, serializeAiSettings as s };
|
|
46
|
-
export type { AiSettingsPatch as A, ParseAiSettingsOptions as P };
|