@nextclaw/kernel 0.6.4 → 0.6.5

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/dist/index.js CHANGED
@@ -8904,16 +8904,6 @@ const createToolCallStyleContextProvider = () => staticBlock([
8904
8904
  "Keep narration brief and value-dense; avoid repeating obvious steps.",
8905
8905
  "Use plain human language for narration unless in a technical context."
8906
8906
  ]);
8907
- const createInlineInteractiveSurfaceContextProvider = () => staticBlock([
8908
- "## Inline Interactive Surfaces",
8909
- "Do not make every UI an inline card. Choose inline only when the intended result is a compact, immediately usable card or short interaction; use the side panel for normal Panel Apps, long reading, rich editing, file browsing, large tables, multi-page workflows, or sustained workspaces.",
8910
- "Inline Panel App display is Markdown-only: in the final reply, output a `nextclaw-inline` fenced JSON block so the display remains message content.",
8911
- "`show_panel_app` is side-panel only. Never call `show_panel_app` for inline display, including when the user asks which Panel Apps are suitable for inline display or says \"show/display them inline\".",
8912
- "To open a local image or document in the side panel, call `show_file`; its automatic viewer handles supported visual formats, including SVG. When an image should appear in the final reply, prefer standard Markdown image syntax under the Reply Formatting Contract. `view_image` is only for giving the model visual input and is not a user-display action.",
8913
- "For ordinary local HTML files or page prototypes, call `show_file` with `path` and `viewer=\"rendered\"`; use `viewer=\"source\"` when the user needs to inspect source text. Markdown file links open source by default; append `?viewer=rendered` only when the link itself should open the rendered HTML view. Do not convert a plain HTML file into a Panel App just to preview it.",
8914
- "A Panel Card must be designed card-first: prefer a landscape composition where width carries the main information and the card is wider than it is tall; collapse to one column only in narrow containers. Core value must be visible in the first 220-420px, with no horizontal scrolling, no reliance on document-level internal scrolling, compact controls, at most one primary action, clear loading/empty/error states, and an obvious expand path for details.",
8915
- "Typical Panel Card fits: weather cards, calculators, timers, checklists, pickers, compact forms, previews, and small dashboards. If the UI needs more space than a card, use the side panel instead. Inline hosts may pass `nextclawDisplayMode=card` and `nextclawPlacement=inline`; use those hints to render a compact card layout instead of a full page."
8916
- ]);
8917
8907
  const createChatComposerTokensContextProvider = () => staticBlock([
8918
8908
  "## Chat Composer Tokens",
8919
8909
  "When a user message contains tokens like `$weather` or `$web-search`, treat each `$<skill-spec>` token as a user-visible marker that the corresponding skill was explicitly selected in the chat composer.",
@@ -9068,15 +9058,23 @@ var ProjectContextProvider = class {
9068
9058
  //#region src/contributions/context-provider/providers/reply-format-context.provider.ts
9069
9059
  var ReplyFormatContextProvider = class {
9070
9060
  provide = (_request) => [[
9071
- "## Reply Formatting Contract",
9072
- "Goal: openable files in user-visible replies must be clickable, local images should appear directly in the reply when appropriate, and inert inline display declarations are only for content that should appear as part of the reply.",
9073
- "File links: use Markdown links only, with a plain text label and an openable href: [MEMORY.md](MEMORY.md), [report.docx](report.docx), [file](packages/example/file.ts), [notes.md](/Users/example/Documents/notes.md). Use project-relative hrefs for files under the active/session project root, and absolute hrefs for local files outside it. File links open source by default; supported visual and Office documents open their automatic preview. Use a viewer query such as [diagram.svg](diagram.svg?viewer=source) when source is explicitly required, or [preview.html](preview.html?viewer=rendered) when an HTML link should open rendered output.",
9061
+ "## Agent Output & Reply Formatting Contract",
9062
+ "Goal: make the directly visible final reply self-contained, concise, and easy to act on; make openable files clickable, show local images directly when appropriate, and use richer display surfaces only when they improve delivery.",
9063
+ "Visible final reply: after a completed assistant turn, the UI collapses reasoning and tool activity through the last tool call under a Processed summary. Content after the last tool call remains directly visible. Therefore, after the final tool call, always write a self-contained final response with the outcome, important caveats, relevant links, and the next useful action. Do not put the final answer only before a tool call, and do not assume raw tool output remains directly visible.",
9064
+ "Progress narration before or between tool calls may be brief and contextual, but do not repeat it in the final reply. The final reply must still make sense when all earlier narration and tool activity are collapsed.",
9065
+ "Markdown structure: prefer short paragraphs. Use headings, lists, tables, blockquotes, and code blocks only when they materially improve scanning or comparison; do not over-format a simple answer. Keep link labels descriptive and plain, and place each link next to the claim or artifact it supports.",
9066
+ "Mermaid diagrams: use a fenced `mermaid` block when a relationship, flow, sequence, state transition, or hierarchy is materially clearer as a diagram than as short prose or a small list. Keep diagrams focused, quote node labels that contain punctuation, and do not add a diagram merely because an answer has several steps.",
9067
+ "File links: every concrete local file or directory mentioned in the final reply must be clickable. Use Markdown links only, with a plain text label and an openable href: [MEMORY.md](MEMORY.md), [report.docx](report.docx), [file](packages/example/file.ts), [notes.md](/Users/example/Documents/notes.md). Use project-relative hrefs for files under the active/session project root, and absolute hrefs for local files outside it. File links open source by default; supported visual and Office documents open their automatic preview. Use a viewer query such as [diagram.svg](diagram.svg?viewer=source) when source is explicitly required, or [preview.html](preview.html?viewer=rendered) when an HTML link should open rendered output.",
9074
9068
  "Markdown syntax and resource availability are separate: emit a proper Markdown link even when you cannot verify that its target still exists. The UI will report missing or unavailable content when the user opens it; never downgrade a valid link to bare text preemptively.",
9075
- "Local images: prefer standard Markdown image syntax when the image should be visible in the reply: ![chart](assets/chart.png) or ![diagram](/Users/example/Pictures/diagram.svg). Local image hrefs follow the same project-relative or absolute path rules as file links. Do not invent an internal API URL or a file:// URL. Use show_file only when the file should immediately open in the side panel; use view_image only to give the model visual input.",
9069
+ "Local images: prefer standard Markdown image syntax when the image should be visible in the reply: ![chart](assets/chart.png) or ![diagram](/Users/example/Pictures/diagram.svg). Local image hrefs follow the same project-relative or absolute path rules as file links. Do not invent an internal API URL or a file:// URL. Use `show_file` only when the file should immediately open in the side panel; `view_image` is only for giving the model visual input.",
9070
+ "Display choice: Do not make every UI an inline card. Choose inline only for a compact, immediately usable card or short interaction. Use the side panel for normal Panel Apps, long reading, rich editing, file browsing, large tables, multi-page workflows, or sustained workspaces.",
9076
9071
  "Inline display: when the final reply should include a non-clickable inline display placeholder, output a fenced `nextclaw-inline` JSON block:",
9077
9072
  "```nextclaw-inline\n{\"target\":{\"type\":\"panel_app\",\"payload\":{\"appId\":\"timer\"}},\"title\":\"Timer\"}\n```",
9078
9073
  "Supported targets are `panel_app`, `json`, `file`, and `url`. Prefer `panel_app` for inline Panel App display; use `file` and `url` only as non-clickable placeholders when a clickable link is not intended; use `json` for inert JSON snapshots.",
9079
- "It is display-only: no opening, executing, or tool action. Never call `show_panel_app` for inline display; `show_panel_app` is only for immediately opening a Panel App outside the final reply in the side panel. Use Markdown links for clickable resources and show_file/show_url/show_panel_app tools only when you want the UI to immediately show or run content outside the final reply.",
9074
+ "Inline display is Markdown-only and display-only: no opening, executing, or tool action. Never call `show_panel_app` for inline display, including when the user asks which Panel Apps are suitable for inline display or says to show them inline. `show_panel_app` is only for immediately opening a Panel App outside the final reply in the side panel. Use Markdown links for clickable resources and `show_file` / `show_url` / `show_panel_app` only when the UI should immediately show or run content outside the final reply.",
9075
+ "For ordinary local HTML files or page prototypes, call `show_file` with `path` and `viewer=\"rendered\"`; use `viewer=\"source\"` when the user needs source text. Markdown file links open source by default; append `?viewer=rendered` only when the link itself should open the rendered HTML view. Do not convert a plain HTML file into a Panel App just to preview it.",
9076
+ "A Panel Card must be card-first: prefer a landscape composition where width carries the main information and the card is wider than it is tall; collapse to one column only in narrow containers. Core value must be visible in the first 220-420px, with no horizontal scrolling, no reliance on document-level internal scrolling, compact controls, at most one primary action, clear loading/empty/error states, and an obvious expand path for details.",
9077
+ "Typical Panel Card fits: weather cards, calculators, timers, checklists, pickers, compact forms, previews, and small dashboards. If the UI needs more space than a card, use the side panel. Inline hosts may pass `nextclawDisplayMode=card` and `nextclawPlacement=inline`; use those hints to render a compact card layout instead of a full page.",
9080
9078
  "Forbidden forms: bare file names or paths, inline-code file names, bold-only file names, code-styled link labels, code blocks for file references, file:// URLs, internal API URLs, action semantics inside `nextclaw-inline`, tool calls for inline display, and unlinked comma-separated file lists.",
9081
9079
  "Examples: bad `MEMORY.md` -> good [MEMORY.md](MEMORY.md); bad `memory/` -> good [memory/](memory/); bad `report.docx` -> good [report.docx](report.docx); bad `/Users/example/chart.png` -> good ![chart](/Users/example/chart.png); bad `2026-03-07.md` / `feishu-notes.md` -> good [2026-03-07.md](memory/2026-03-07.md) / [feishu-notes.md](memory/feishu-notes.md).",
9082
9080
  "Self-check before sending: scan the final visible reply for local file names, paths, and images. Make every concrete file clickable, render intended images with Markdown image syntax, or ensure it is intentionally represented by `nextclaw-inline`; otherwise remove the exact names and summarize instead."
@@ -9096,7 +9094,7 @@ function renderActiveSkillsSection(skills, skillSelectors) {
9096
9094
  if (!manifest) return "";
9097
9095
  return [
9098
9096
  "# Active Skills",
9099
- "These always-on skills are already active for this session context.",
9097
+ "These user-selected or always-on skills are active for this request.",
9100
9098
  "If an active skill covers the user's intent, follow it before considering unrelated available skills.",
9101
9099
  "For NextClaw self-management intents, read the built-in NextClaw self-management guide before loading any unrelated generic skill.",
9102
9100
  "Skill refs are unique identities; names may repeat.",
@@ -9105,12 +9103,23 @@ function renderActiveSkillsSection(skills, skillSelectors) {
9105
9103
  wrapSkillTag("active_skills", manifest)
9106
9104
  ].join("\n\n");
9107
9105
  }
9106
+ function renderSkillSourcesSection(params) {
9107
+ return [
9108
+ "## Skill Sources",
9109
+ "Skills in <available_skills> are grouped by source.",
9110
+ params.projectSkillsRoot ? `- project: project-only skills. When creating or updating a skill specifically for this active project, use \`${params.projectSkillsRoot}/<skill-name>/SKILL.md\`.` : "- project: no session-bound project is active, so do not invent a project skill location.",
9111
+ `- workspace: skills installed for NextClaw in \`${params.hostWorkspace}/skills\`.`,
9112
+ "- global: user-wide Agent Skills loaded from ~/.agents/skills.",
9113
+ "- builtin: skills packaged with NextClaw.",
9114
+ "A project's AGENTS.md is loaded separately in Agent Bootstrap Context; it is not a skill."
9115
+ ].join("\n");
9116
+ }
9108
9117
  function renderAvailableSkillsSection(skills) {
9109
9118
  const summary = skills.buildSkillsSummary();
9110
9119
  if (!summary) return "";
9111
9120
  return [
9112
9121
  "## Skills (mandatory)",
9113
- "Always-on skills in <active_skills> take precedence over this list.",
9122
+ "User-selected and always-on skills in <active_skills> take precedence over this list.",
9114
9123
  "Before replying: first check whether any entry in <available_skills> may be relevant to the user's intent, task type, or requested output. Do not skip this check just because the task seems familiar.",
9115
9124
  "- If one skill looks like the best relevant match, read its SKILL.md at <location> with `read_file`, then decide whether following it is actually helpful.",
9116
9125
  "- If a SKILL.md read says `Use offset=... to continue`, continue reading until the relevant trigger, required workflow, constraints, and output requirements are covered.",
@@ -9141,15 +9150,19 @@ var SkillsContextProvider = class {
9141
9150
  this.context = context;
9142
9151
  }
9143
9152
  provide = async (request) => {
9144
- const { projectContext } = await this.context.resolve(request);
9153
+ const { projectContext, runContext } = await this.context.resolve(request);
9145
9154
  const skills = new SkillsLoader({
9146
9155
  workspace: projectContext.hostWorkspace,
9147
- projectRoot: projectContext.projectRoot
9156
+ projectRoot: projectContext.projectRoot,
9157
+ includeGlobal: true
9148
9158
  });
9149
- const blocks = [];
9150
- const alwaysSkills = skills.getAlwaysSkills();
9151
- if (alwaysSkills.length) {
9152
- const activeSection = renderActiveSkillsSection(skills, alwaysSkills);
9159
+ const blocks = [renderSkillSourcesSection({
9160
+ hostWorkspace: projectContext.hostWorkspace,
9161
+ projectSkillsRoot: projectContext.projectSkillsRoot
9162
+ })];
9163
+ const activeSkills = [...runContext.requestedSkills.selectors, ...skills.getAlwaysSkills()];
9164
+ if (activeSkills.length) {
9165
+ const activeSection = renderActiveSkillsSection(skills, activeSkills);
9153
9166
  if (activeSection) blocks.push(activeSection);
9154
9167
  }
9155
9168
  const availableSkillsSection = renderAvailableSkillsSection(skills);
@@ -9222,6 +9235,8 @@ function buildAgentRunRequestMetadata(params) {
9222
9235
  const model = normalizeString(request.model ?? session?.model);
9223
9236
  return {
9224
9237
  ...structuredClone(session?.metadata ?? {}),
9238
+ ...structuredClone(request.message.metadata ?? {}),
9239
+ ...structuredClone(request.metadata ?? {}),
9225
9240
  agentId,
9226
9241
  projectRoot,
9227
9242
  project_root: projectRoot,
@@ -9333,7 +9348,6 @@ var ContextProviderContribution = class {
9333
9348
  createAssistantIdentityContextProvider(),
9334
9349
  new ToolingContextProvider(context),
9335
9350
  createToolCallStyleContextProvider(),
9336
- createInlineInteractiveSurfaceContextProvider(),
9337
9351
  createChatComposerTokensContextProvider(),
9338
9352
  createSafetyContextProvider(),
9339
9353
  createCliQuickReferenceContextProvider(),