@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 CHANGED
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.4.0
4
+
5
+ - New `ai/docs/` module (public through `@mikedown/core/ai`): the documentation base model, home document precedence, link graph, keyword fallback, secrets scan, citations and the navigation loop. Hosts provide `host.docs` (`MikeDownDocsHost`) to back it; without it the chat shows "This document" only.
6
+ - `@mikedown/core/ai` adds the `chat` feature (status `available`), the `docs` task, the `docsBase` value of `AiSendsScope` and an optional `enabled` flag per base.
7
+ - `@mikedown/core` exports the chat panel (`ai-chat-panel.ts`), the documentation bases page (`ai-docs-page.ts`) and the run wiring (`ai-docs-run.ts`) through the AI UI, loaded only when the host has `host.ai`.
8
+ - Run requests can be pinned to one engine and model (`AiRunRequest.pin`). A pinned run never re-routes or falls back within the turn.
9
+ - Inline suggestions: `ai-ghost.ts`, `ai-ghost-plugin.ts` and `ai-ghost-session.ts` in the AI UI, with `ghostContext`, `ghostTrim` and the `continue` prompt in `@mikedown/core/ai`. New `ghostText` feature id and `cursor` consent scope.
10
+ - AI Activity panel: an opt-in, in-memory record of each AI request (`ai-activity.ts`, `ai-activity-panel.ts`), with an optional `saveTextFile` on the host.
11
+ - Insert from chat goes through an allow-list of node and mark types (`ai-insert-guard.ts`).
12
+ - A bare URL at the end of a document's first block is no longer turned into a link on load.
13
+
14
+ ## 0.3.0
4
15
 
5
16
  - New prompt modules under `ai/prompts/` (`rewrite`, `explain`, `structureCheck`, `summary`, `title`, `properties`) for the AI writing features.
6
17
  - `ai/json.ts` parses model JSON leniently and makes one repair retry before reporting `badOutput`. `ai/documentBudget.ts` takes sections from the top of a long document and reports the coverage. `ai-prefs.ts` stores the per-session AI preferences.
package/README.md CHANGED
@@ -195,7 +195,7 @@ const ai: MikeDownAiHost = {
195
195
  createMikeDownEditor(el, { host: { onChange, ai, saveSettings /* persists the ai.* keys */ }, settings: { ai: settings } });
196
196
  ```
197
197
 
198
- **Consent.** Cloud engines are off until the user turns on *Allow cloud engines* in the AI tab. Even then, in tier 2 the first request a cloud engine would serve calls your `requestCloudConsent(engineId)`. Show your own dialog naming the engine, its URL and what is sent (the selection and one paragraph for rewrite; `aiConsentText` in `@mikedown/core/ai` has the words), and resolve `true` (allowed for the workspace; core remembers it for the session), `'once'` (this request only; the next one calls you again), `false` (declined; it counts as unusable for that request, and you may answer later calls with `false` without a dialog, as VS Code and Desktop do until a restart) or `'never'` (a stored refusal; core disables the entries for that engine for the session). **A host without `requestCloudConsent` sends to cloud engines without asking** (the *Allow cloud engines* switch still applies), so implement it if users can add cloud engines. Optionally add `listConsents()` (records of `{ engineId, answer, at, scope }`) and `forgetConsent(engineId)`: the AI tab then shows a *Cloud consents* list with a Forget button for each. In tier 1 core never sees which model answers, so consent is your backend's and your UI's to handle.
198
+ **Consent.** Cloud engines are off until the user turns on *Allow cloud engines* in the AI tab. Even then, in tier 2 the first request a cloud engine would serve calls your `requestCloudConsent(engineId)`. Show your own dialog naming the engine, its URL and what is sent (the selection and one paragraph for rewrite; `aiConsentText` in `@mikedown/core/ai` has the words), and resolve `true` (allowed for the workspace; core remembers it for the session), `'once'` (this request only; the next one calls you again; a chat turn asks the optional `requestTurnConsent(engineId, about)` first, where it means the whole turn: each of its requests carries `req.turn`, and the optional `endTurn(turnId)` says when it is over), `false` (declined; it counts as unusable for that request, and you may answer later calls with `false` without a dialog, as VS Code and Desktop do until a restart) or `'never'` (a stored refusal; core disables the entries for that engine for the session). **A host without `requestCloudConsent` sends to cloud engines without asking** (the *Allow cloud engines* switch still applies), so implement it if users can add cloud engines. Optionally add `listConsents()` (records of `{ engineId, answer, at, scope }`) and `forgetConsent(engineId)`: the AI tab then shows a *Cloud consents* list with a Forget button for each. In tier 1 core never sees which model answers, so consent is your backend's and your UI's to handle.
199
199
 
200
200
  **Setup wizard.** With no engines configured, the toolbar's AI button opens a setup wizard (on the AI Engines page) instead of the engine form. It uses three more optional methods, each of which just hides its part of the wizard when absent: `detectLocalServers(candidates, signal)` looks for running local servers (one GET each, 1.5 s cap, only on request, never in the background; send a key only to the preset's own address), `hardwareInfo()` reports memory, CPU and GPU for the local model size hint, and `detectHostEngines()` lists models the host itself offers without an address or key (VS Code uses it for GitHub Copilot, the `vscode-lm` engine kind). Set `shellEnv: false` if your process cannot see shell variables, so the engine form points at a key file or a pasted key instead of `apiKeyEnv`. Choosing a cloud provider in the wizard turns *Allow cloud engines* on, and AI turns on when the user finishes with a usable default model.
201
201
 
@@ -1,4 +1,4 @@
1
- import { MikeDownAiHost, AiSettings, AiEngineStatus } from './index.js';
1
+ import { MikeDownAiHost, AiSettings, AiEngineStatus, MikeDownDocsHost } from './index.js';
2
2
  import { AiSettingsPatch } from './index.js';
3
3
  import { MikeDownSettingsSectionContext } from '../index.js';
4
4
  import '@tiptap/core';
@@ -91,14 +91,19 @@ interface AiSettingsSessionOptions {
91
91
  * steps, and the wizard's Done is the page's Done. "Change settings in AI Engines"
92
92
  * leaves the wizard for the full page, in the same session.
93
93
  *
94
+ * On a host with `host.docs` the list also has Documentation bases
95
+ * (`ai-docs-page.ts`), the `'bases'` section. A base saves at once through the
96
+ * host; only the bases' advanced options wait for Done.
97
+ *
94
98
  * Modal UI only: nothing here touches the editor document or its DOM.
95
99
  */
96
100
 
97
- type AiEnginesPageSection = 'engines' | 'routing' | 'wizard';
101
+ type AiEnginesPageSection = 'engines' | 'routing' | 'wizard' | 'bases';
98
102
  interface AiEnginesPageOptions extends AiSettingsSessionOptions {
99
103
  /**
100
- * What to show first: an engine, the routing section, or the setup wizard
101
- * (tier 2 only). Default: the first engine (the cards when there is none).
104
+ * What to show first: an engine, the routing section, the documentation
105
+ * bases (with `docs`) or the setup wizard (tier 2 only). Default: the first
106
+ * engine (the cards when there is none).
102
107
  */
103
108
  initial?: {
104
109
  engineId?: string;
@@ -117,6 +122,8 @@ interface AiEnginesPageOptions extends AiSettingsSessionOptions {
117
122
  * in the patch) when the result has a usable default route.
118
123
  */
119
124
  turnOnWhenDone?: boolean;
125
+ /** The host's documentation bases. Absent: no Documentation bases section. */
126
+ docs?: MikeDownDocsHost;
120
127
  }
121
128
  interface AiEnginesPageHandle {
122
129
  /** Tear down (timers, listeners) and leave the container empty. Unresolved changes are discarded. */
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  mountAiEnginesPage
3
- } from "../chunk-7A5HEPLK.js";
4
- import "../chunk-LXZG7IKN.js";
5
- import "../chunk-JZWKEBCI.js";
6
- import "../chunk-QDVY7WW6.js";
3
+ } from "../chunk-DWXGWVA3.js";
4
+ import "../chunk-N4N54LK2.js";
5
+ import "../chunk-IWCXWUWW.js";
6
+ import "../chunk-APPBNQEY.js";
7
+ import "../chunk-TSP7BAV3.js";
7
8
  export {
8
9
  mountAiEnginesPage
9
10
  };