@vpxa/aikit 0.1.289 → 0.1.291

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.
@@ -353,7 +353,7 @@ When technical decisions need resolution, follow the **3-phase multi-model decis
353
353
  - Researcher-Delta (Executor): Feasibility, performance, fastest implementation path
354
354
  3. **Phase 2 — Peer Review** — anonymize outputs as Perspective A/B/C/D, launch 4 reviewers in parallel asking: strongest argument, biggest blind spot, consensus gap, verdict
355
355
  4. **Phase 3 — Structured Verdict** — synthesize into: Where Agrees / Where Clashes / Blind Spots Caught / Recommendation (with confidence) / First Step
356
- 5. **Present & Record** — Render verdict with \`present({ schemaVersion: 1, title: "Decision Verdict", blocks: [...] })\`; use \`table\` for multi-perspective comparisons, \`list\` for blind spots/recommendations, and \`kv\` for verdict metadata. NEVER \`code\` blocks for structured data. Produce ADR via \`adr-skill\`
356
+ 5. **Present & Record** — Render verdict with \`present({ schemaVersion: 1, title: "Decision Verdict", blocks: [...] })\`; use \`table\` for multi-perspective comparisons and \`markdown\` (bullet list) for recommendations/blind spots. NEVER \`code\` blocks for structured data. Produce ADR via \`adr-skill\`
357
357
 
358
358
  **Floor tier shortcut**: Skip Phase 2 (peer review), go straight from research to verdict.
359
359
 
@@ -1192,7 +1192,7 @@ For small features that need minimal design:
1192
1192
  - **Phase 1**: Launch ALL 4 Researcher variants in parallel (Alpha/Beta/Gamma/Delta)
1193
1193
  - **Phase 2**: Anonymize outputs as A/B/C/D, run peer review round (4 reviewers in parallel)
1194
1194
  - **Phase 3**: Synthesize into structured verdict (Agrees / Clashes / Blind Spots / Recommendation / First Step)
1195
- - Present verdict visually using \`present({ schemaVersion: 1, title: "Decision Verdict", blocks: [...] })\`; use \`table\` for multi-approach comparisons, \`list\` for recommendations/blind spots, and \`kv\` for verdict metadata. NEVER \`code\` blocks for structured data. Produce ADR for Standard+ tiers
1195
+ - Present verdict visually using \`present({ schemaVersion: 1, title: "Decision Verdict", blocks: [...] })\`; use \`table\` for multi-approach comparisons and \`markdown\` (bullet list) for recommendations/blind spots. NEVER \`code\` blocks for structured data. Produce ADR for Standard+ tiers
1196
1196
  4. **Write \`{{artifacts_path}}/design-decisions.md\`** to disk:
1197
1197
 
1198
1198
  \`\`\`markdown
@@ -1 +1 @@
1
- function e(){return[{file:`SKILL.md`,content:'---\nname: present\ndescription: "Use the AI Kit `present` tool to display rich interactive dashboards, charts, timelines, status boards, and data visualizations in the browser or in-chat. Covers all block types, chart types, actions, composition patterns, and MCP Apps templates (list-sort, data-table, picker, flame-graph, form, checklist, document, report, error, timeline, kanban, tree, diff-view, dashboard, status-board). Load this skill before calling the present tool to ensure professional output."\nmetadata:\n category: cross-cutting\n domain: general\n applicability: always\n inputs: [data, analysis]\n outputs: [dashboards, charts, reports]\n requires: [aikit]\nargument-hint: "Content to present — data, analysis results, status report, comparison, or interactive MCP App"\n---\n\n# Present Tool — Rich Interactive Dashboards\n\n## 1. API Shape\n\n- `schemaVersion: 1` is always required.\n- `title: string` is always required; do not use unicode escapes like `\\u2014`, use the actual character.\n- Optional layout fields: `layout?: { maxWidth?: string, padding?: string, columns?: number }`.\n- Optional appearance field: `colorScheme?: z.enum([\'light\', \'dark\', \'auto\'])`.\n- Interactive surfaces can also include `response?: { timeout?: number, required?: boolean }`.\n- Mode 1: block surface with `blocks: [{ type, title?, value }]`.\n- Mode 2: MCP App template with `template` + `data`.\n- Mode 3: viewer template with `template` + `data` for richer diagrams or flows.\n- No `actions` array means inline MCP App transport in the host client (except browser-only templates which auto-route to browser).\n- Inline transport is cross-host: AI Kit returns standard MCP Apps metadata, OpenAI compatibility metadata, and `ChannelSurface` structured content for hosts such as Codex, ChatGPT, and Copilot VS Code.\n- Any `actions` array means browser transport and opens the system browser. Valid action types: `button | select | multi-select | form-submit | text-submit | confirm | custom`.\n- CLI has no inline host; add a minimal action if you need the browser to open.\n\n```json\n{ "schemaVersion": 1, "title": "Release Review", "blocks": [{ "type": "metrics", "value": [] }] }\n```\n\n## 2. Content Blocks\n\nPass content as a `blocks` array of `{ type, title?, value }` objects.\n\n| Type | Value shape | Use for |\n|------|-------------|---------|\n| `prompt` | string | Prompt or callout text |\n| `text` | string | Plain text without markdown parsing |\n| `heading` | string | Standalone section headings |\n| `paragraph` | string | Standalone paragraph copy |\n| `markdown` | string | Prose, headings, code snippets |\n| `table` | `Record[]` or `{ headers, rows }` | Tabular data |\n| `chart` | `{ chartType, data, xKey?, yKeys? }` | `line | area | bar | horizontal-bar | pie | donut | sparkline | heatmap` |\n| `metrics` | `[{ label, value, trend?, status? }]` | KPI cards |\n| `cards` | `[{ title, body?, badge?, status? }]` | Summary cards |\n| `mermaid` | string | Diagrams (works in both mcp-app and browser) |\n| `tree` | `{ name, children? }` | Hierarchies |\n| `timeline` | `[{ title, description?, timestamp?, status? }]` | Event sequences |\n| `checklist` | `[{ label, checked }]` | Task lists |\n| `code` | string | Code or diff excerpts |\n| `comparison` | `[{title, items}]` or `{columns: [{title, items}]}` | Side-by-side option comparisons |\n| `status-board` | `[{category, items}]` or `{items: [{category, items}]}` | Service health boards |\n| `progress` | `{label, value, max?}` or `{items: [{label, value, max?, color?}]}` | Progress bars |\n| `graph` | `{ nodes: [{id, label?}], edges: [{from, to, label?}] }` | Network graphs |\n| `docs-browser` | `{ files: [{path, title?, content?, status?}], title? }` | Documentation indexes |\n| `actions` | `[{ type, id, label, variant?, options? }]` | Inline action group using the same action enum as top-level `actions` |\n| `separator` | none | Visual divider between block groups |\n\n> Anti-patterns:\n> - Prefer `table` blocks for tabular data (pipe tables in `markdown` are auto-normalized, but explicit table blocks are clearer and more efficient).\n> - Use `{ chartType, data, xKey, yKeys }`, not Chart.js `{ labels, datasets }`.\n> - Keep `markdown` for prose, headings, and code, not UI structure.\n> - **NEVER use `code` block for structured data** (arrays, objects, decisions, lists). Use `list`, `table`, `kv`, or `checklist` instead.\n> - **NEVER JSON.stringify() data into a `code` or `markdown` block** — use the typed block that matches your data shape.\n\n### Data → Block Type Quick Reference\n\n| Your data looks like... | Use this block type | NOT this |\n|---|---|---|\n| Array of strings (decisions, findings, steps) | `list` | ~~`code` with JSON array~~ |\n| Key-value pairs (status, config, metadata) | `kv` | ~~`code` with JSON object~~ |\n| Rows × columns (comparisons, components) | `table` | ~~`markdown` with pipe table~~ |\n| Items with done/not-done state | `checklist` | ~~`list` with checkmark prefixes~~ |\n| Hierarchical items (file tree, org chart) | `tree` | ~~`code` with indentation~~ |\n| Numeric KPIs with labels | `metrics` | ~~`kv` or `markdown`~~ |\n| Before/after or option A vs B | `comparison` | ~~two `code` blocks~~ |\n\n## 3. Actions\n\nAction shape: `{ type, id, label, variant?, options? }`\n\nValid action types: `button | select | multi-select | form-submit | text-submit | confirm | custom`\n\n\n```json\n{ "actions": [{ "type": "button", "id": "ack", "label": "Acknowledge", "variant": "primary" }] }\n```\n\n## 4. MCP App Templates\n\nUse templates for structured interactive widgets. They take `template` + `data`; returns depend on the widget.\n\n| Template | Purpose | Data shape | Returns |\n|----------|---------|------------|---------|\n| `list-sort` | Reorder a ranked list | `{ items: [{ id, label }] }` | Reordered items or IDs |\n| `data-table` | Inspect structured rows | `{ columns, rows, stats? }` | Current selection or filtered rows |\n| `picker` | Choose items from categories | `{ categories, items }` | Selected item IDs |\n| `flame-graph` | Explore hierarchical totals | `{ profile }` | Clicked node |\n| `form` | Collect field values | `{ fields }` | Submitted field map |\n| `checklist` | Run an interactive checklist | `{ items, title? }` | Checked state or submission payload |\n| `document` | Present structured long-form content | `{ sections, title? }` | Display only |\n| `report` | Present synthesized report content | `{ title, sections, metrics?, tables? }` | Display only |\n| `error` | Show structured error states and recovery actions | `{ code, message, details?, stack? }` | Display only |\n| `kanban` | Move cards across columns | `{ columns, cards }` | Card move payload |\n| `timeline` | Show ordered milestones | `{ events }` | Display only |\n| `tree` | Browse nested nodes | `{ root }` | Display only |\n| `diff-view` | Show file diffs | `{ files, stats? }` | Display only |\n| `dashboard` | Show metric cards | `{ metrics }` | Display only |\n| `status-board` | Show grouped status or health views | `{ categories }` | Display only |\n\n> **Auto-routing:** Browser-only templates (form, kanban, flame-graph, picker, list-sort) auto-route to browser transport even without explicit `actions`. No need to add a dummy action — the tool handles it.\n\n### `list-sort`\n`data`: `{ "items": [{ "id": "task-1", "label": "Fix auth bug" }] }`\n\n### `data-table`\n`data`: `{ "columns": [{ "key": "file", "label": "File" }], "rows": [{ "file": "auth.ts" }], "stats": [{ "label": "Files", "value": "1" }] }`\n\n### `picker`\n`data`: `{ "categories": [{ "id": "core", "label": "Core" }], "items": [{ "id": "auth", "label": "Auth", "category": "core", "tags": ["security"] }] }`\n\n### `flame-graph`\n`data`: `{ "profile": { "name": "root", "total": 100, "children": [{ "name": "packages/server", "total": 60 }] } }`\n\n### `form`\n`data`: `{ "fields": [{ "name": "projectName", "label": "Project Name", "type": "text", "value": "my-app" }] }`\n\n### `checklist`\n`data`: `{ "items": [{ "label": "Write tests", "checked": true }, { "label": "Update docs", "checked": false }], "title": "Sprint Tasks" }`\n\nTransports: mcp-app, browser (interactive — checkboxes toggle). NOT export.\n\n### `document`\n`data`: `{ "title": "Architecture Overview", "sections": [{ "heading": "Introduction", "content": "System overview text" }, { "heading": "Components", "content": [{ "type": "list", "value": ["API Gateway", "Auth Service"] }] }] }`\n\nSections `content` can be a plain string OR an array of TypedBlock objects.\n\n### `report`\n`data`: `{ "title": "Weekly Status", "metrics": [{ "label": "Coverage", "value": "94%", "trend": "+2%", "status": "success" }], "sections": [{ "heading": "Summary", "content": "All systems operational" }], "tables": [{ "title": "Services", "headers": ["Name", "Status"], "rows": [["API", "healthy"], ["DB", "degraded"]] }] }`\n\nAll fields except `title` and `sections` are optional. `metrics` renders as metric cards; `tables` renders after sections.\n\n### `error`\n`data`: `{ "code": "AUTH_EXPIRED", "message": "Session token has expired", "details": "Token issued at 2026-01-01T00:00:00Z exceeded 24h TTL", "stack": "Error: AUTH_EXPIRED\\n at validateToken (auth.ts:42)" }`\n\nOnly `code` and `message` are required. `details` adds context below the message; `stack` renders as a separate code block.\n\n### `kanban`\n`data`: `{ "columns": [{ "id": "todo", "label": "To Do" }], "cards": [{ "id": "c1", "title": "Fix auth bug", "column": "todo" }] }`\n\n### `timeline`\n`data`: `{ "events": [{ "title": "v1.0 Release", "timestamp": "2026-05", "status": "complete" }] }`\n\nThe timeline template also accepts `entries` or `items` as the array field name (all three are equivalent).\n\n### `tree`\n`data`: `{ "root": { "label": "packages/", "children": [{ "label": "server/" }] } }`\n\n### `diff-view`\n`data`: `{ "files": [{ "path": "auth.ts", "status": "modified", "hunks": [{ "header": "@@ -1 +1 @@", "changes": [{ "type": "add", "content": "const ok = true;" }] }] }], "stats": { "filesChanged": 1 } }`\n\n### `dashboard`\n`data`: `{ "metrics": [{ "label": "Uptime", "value": "99.9%", "status": "success" }] }`\n\n### `status-board`\n`data`: `{ "categories": [{ "category": "Production", "items": [{ "label": "API Gateway", "status": "healthy" }, { "label": "Auth Service", "status": "degraded" }] }] }`\n\nNote: The template requires `{ categories: [...] }` (object with a `categories` key). This differs from the **block type** `status-board` which accepts a bare array as its value.\n\n## 5. Viewer Templates\n\nViewer templates render richer visual surfaces from `template` + `data`.\n\n| Template | Transport | Purpose |\n|----------|-----------|---------|\n| `c4-static@1` | mcp-app | Static architecture diagram |\n| `c4@1` | browser | Interactive architecture diagram |\n| `process-flow-static@1` | mcp-app | Static process flow |\n| `process-flow@1` | browser | Interactive process flow |\n| `tour@1` | browser | Guided walkthrough or code tour |\n| `task-plan-static@1` | mcp-app | Static task execution plan with phases, batches, agent assignments |\n| `task-plan@1` | browser | Interactive task plan with ReactFlow — drag/zoom/pan, dependency edges, ELK layout |\n\n`c4`: `{ "nodes": [{ "id": "web", "type": "container", "label": "Web App", "technology?": "React" }], "edges": [{ "source": "web", "target": "api", "label": "HTTPS" }] }`\n\n`process-flow`: `{ "nodes": [{ "id": "start", "label": "Start", "type": "start-end" }], "edges": [{ "source": "start", "target": "review", "type?": "standard" }] }`\n\nNode types: `start-end` | `manual` | `automated` | `integration` | `decision` | `prerequisite`. Default: `manual`.\nEdge types: `standard` | `loop-back` | `exception`. Default: `standard`. `loop-back` and `exception` edges animate.\n\n`tour`: `{ "steps": [{ "id": "overview", "title": "Overview", "file": "src/index.ts", "explanation": "Entry point", "code?": "...", "line?": 1 }] }`\n\n`task-plan`: `{ "title": "Feature Name", "description?": "Optional", "phases": [{ "id": "p1", "label": "Phase 1", "outcome?": "...", "batches": [{ "id": "b1", "order": 1, "parallel": true, "label?": "Parallel Research", "tasks": [{ "id": "t1", "title": "Research auth", "agent": "Researcher-Alpha", "files?": ["src/auth/"], "status?": "done", "description?": "...", "dependsOn?": [] }] }] }] }`\n\nTask status values: `pending` | `in-progress` | `done` | `blocked`. Default: `pending`.\n\nGotcha: edges use `source` and `target`, not `from` and `to`.\n\nDecision tree:\n- Architecture, systems, containers, deployments: load the `c4-architecture` skill and use `c4@1` or `c4-static@1`.\n- Stateful workflows, approvals, or branching processes: use `process-flow@1` or `process-flow-static@1`.\n- Agent task decomposition, execution plans, or parallel batch visualization: use `task-plan@1` or `task-plan-static@1`.\n- Ordered walkthroughs, onboarding, or narrated analysis: use `tour@1`.\n\n## 6. Rules\n\n- Pick transport once: no `actions` for inline, any `actions` for browser.\n- Combine block types in one `blocks` array; metrics + chart + table + markdown is the normal composition pattern.\n- Use concise schemas in docs; do not expand to full `present()` calls unless behavior depends on them.\n- Use `table`, `comparison`, and `status-board` for structured data instead of formatting it inside markdown.\n- Architecture requests are delegated: load the `c4-architecture` skill for diagram guidance and data contracts.\n- If inline rendering only shows a title, raw JSON, or fallback text, first assume the host lacks or has disabled MCP Apps rendering. Switch to browser transport with a minimal action only when you need a deterministic fallback.\n- For large or mixed-content surfaces, browser transport is usually easier to review and more reliable.\n- For custom HTML demos or visual prototypes, do NOT use the "html" block type (renders as raw text inline). Instead, write an HTML file, serve it locally (e.g. "npx -y serve" or "python -m http.server"), then open with the AI Kit "browser" tool: browser({ action: "open", url: "http://localhost:PORT/file.html", mode: "ui" }). This gives a controlled Chromium instance the LLM can read/interact with. Avoid "Start-Process" (opens uncontrolled system browser).\n'}]}export{e as default};
1
+ function e(){return[{file:`SKILL.md`,content:'---\nname: present\ndescription: "Use the AI Kit `present` tool to display rich interactive dashboards, charts, timelines, status boards, and data visualizations in the browser or in-chat. Covers all block types, chart types, actions, composition patterns, and MCP Apps templates (list-sort, data-table, picker, flame-graph, form, checklist, document, report, error, timeline, kanban, tree, diff-view, dashboard, status-board). Load this skill before calling the present tool to ensure professional output."\nmetadata:\n category: cross-cutting\n domain: general\n applicability: always\n inputs: [data, analysis]\n outputs: [dashboards, charts, reports]\n requires: [aikit]\nargument-hint: "Content to present — data, analysis results, status report, comparison, or interactive MCP App"\n---\n\n# Present Tool — Rich Interactive Dashboards\n\n## 1. API Shape\n\n- `schemaVersion: 1` is always required.\n- `title: string` is always required; do not use unicode escapes like `\\u2014`, use the actual character.\n- Optional layout fields: `layout?: { maxWidth?: string, padding?: string, columns?: number }`.\n- Optional appearance field: `colorScheme?: z.enum([\'light\', \'dark\', \'auto\'])`.\n- Interactive surfaces can also include `response?: { timeout?: number, required?: boolean }`.\n- Mode 1: block surface with `blocks: [{ type, title?, value }]`.\n- Mode 2: MCP App template with `template` + `data`.\n- Mode 3: viewer template with `template` + `data` for richer diagrams or flows.\n- No `actions` array means inline MCP App transport in the host client (except browser-only templates which auto-route to browser).\n- Inline transport is cross-host: AI Kit returns standard MCP Apps metadata, OpenAI compatibility metadata, and `ChannelSurface` structured content for hosts such as Codex, ChatGPT, and Copilot VS Code.\n- Any `actions` array means browser transport and opens the system browser. Valid action types: `button | select | multi-select | form-submit | text-submit | confirm | custom`.\n- CLI has no inline host; add a minimal action if you need the browser to open.\n\n```json\n{ "schemaVersion": 1, "title": "Release Review", "blocks": [{ "type": "metrics", "value": [] }] }\n```\n\n## 2. Content Blocks\n\nPass content as a `blocks` array of `{ type, title?, value }` objects.\n\n| Type | Value shape | Use for |\n|------|-------------|---------|\n| `prompt` | string | Prompt or callout text |\n| `text` | string | Plain text without markdown parsing |\n| `heading` | string | Standalone section headings |\n| `paragraph` | string | Standalone paragraph copy |\n| `markdown` | string | Prose, headings, code snippets |\n| `table` | `Record[]` or `{ headers, rows }` | Tabular data |\n| `chart` | `{ chartType, data, xKey?, yKeys? }` | `line | area | bar | horizontal-bar | pie | donut | sparkline | heatmap` |\n| `metrics` | `[{ label, value, trend?, status? }]` | KPI cards |\n| `cards` | `[{ title, body?, badge?, status? }]` | Summary cards |\n| `mermaid` | string | Diagrams (works in both mcp-app and browser) |\n| `tree` | `{ name, children? }` | Hierarchies |\n| `timeline` | `[{ title, description?, timestamp?, status? }]` | Event sequences |\n| `checklist` | `[{ label, checked }]` | Task lists |\n| `code` | string | Code or diff excerpts |\n| `comparison` | `[{title, items}]` or `{columns: [{title, items}]}` | Side-by-side option comparisons |\n| `status-board` | `[{category, items}]` or `{items: [{category, items}]}` | Service health boards |\n| `progress` | `{label, value, max?}` or `{items: [{label, value, max?, color?}]}` | Progress bars |\n| `graph` | `{ nodes: [{id, label?}], edges: [{from, to, label?}] }` | Network graphs |\n| `docs-browser` | `{ files: [{path, title?, content?, status?}], title? }` | Documentation indexes |\n| `actions` | `[{ type, id, label, variant?, options? }]` | Inline action group using the same action enum as top-level `actions` |\n| `separator` | none | Visual divider between block groups |\n\n> Anti-patterns:\n> - Prefer `table` blocks for tabular data (pipe tables in `markdown` are auto-normalized, but explicit table blocks are clearer and more efficient).\n> - Use `{ chartType, data, xKey, yKeys }`, not Chart.js `{ labels, datasets }`.\n> - Keep `markdown` for prose, headings, and code, not UI structure.\n> - **NEVER use `code` block for structured data** (arrays, objects, decisions, lists). Use `table`, `checklist`, or `markdown` instead.\n> - **NEVER JSON.stringify() data into a `code` or `markdown` block** — use the typed block that matches your data shape.\n\n### Data → Block Type Quick Reference\n\n| Your data looks like... | Use this block type | NOT this |\n|---|---|---|\n| Array of strings (decisions, findings, steps) | `markdown` (bullet list) | ~~`code` with JSON array~~ |\n| Key-value pairs (status, config, metadata) | `table` (two columns) | ~~`code` with JSON object~~ |\n| Rows × columns (comparisons, components) | `table` | ~~`markdown` with pipe table~~ |\n| Items with done/not-done state | `checklist` | ~~`markdown` with checkmark prefixes~~ |\n| Hierarchical items (file tree, org chart) | `tree` | ~~`code` with indentation~~ |\n| Numeric KPIs with labels | `metrics` | ~~`markdown`~~ |\n| Before/after or option A vs B | `comparison` | ~~two `code` blocks~~ |\n\n## 3. Actions\n\nAction shape: `{ type, id, label, variant?, options? }`\n\nValid action types: `button | select | multi-select | form-submit | text-submit | confirm | custom`\n\n\n```json\n{ "actions": [{ "type": "button", "id": "ack", "label": "Acknowledge", "variant": "primary" }] }\n```\n\n## 4. MCP App Templates\n\nUse templates for structured interactive widgets. They take `template` + `data`; returns depend on the widget.\n\n| Template | Purpose | Data shape | Returns |\n|----------|---------|------------|---------|\n| `list-sort` | Reorder a ranked list | `{ items: [{ id, label }] }` | Reordered items or IDs |\n| `data-table` | Inspect structured rows | `{ columns, rows, stats? }` | Current selection or filtered rows |\n| `picker` | Choose items from categories | `{ categories, items }` | Selected item IDs |\n| `flame-graph` | Explore hierarchical totals | `{ profile }` | Clicked node |\n| `form` | Collect field values | `{ fields }` | Submitted field map |\n| `checklist` | Run an interactive checklist | `{ items, title? }` | Checked state or submission payload |\n| `document` | Present structured long-form content | `{ sections, title? }` | Display only |\n| `report` | Present synthesized report content | `{ title, sections, metrics?, tables? }` | Display only |\n| `error` | Show structured error states and recovery actions | `{ code, message, details?, stack? }` | Display only |\n| `kanban` | Move cards across columns | `{ columns, cards }` | Card move payload |\n| `timeline` | Show ordered milestones | `{ events }` | Display only |\n| `tree` | Browse nested nodes | `{ root }` | Display only |\n| `diff-view` | Show file diffs | `{ files, stats? }` | Display only |\n| `dashboard` | Show metric cards | `{ metrics }` | Display only |\n| `status-board` | Show grouped status or health views | `{ categories }` | Display only |\n\n> **Auto-routing:** Browser-only templates (form, kanban, flame-graph, picker, list-sort) auto-route to browser transport even without explicit `actions`. No need to add a dummy action — the tool handles it.\n\n### `list-sort`\n`data`: `{ "items": [{ "id": "task-1", "label": "Fix auth bug" }] }`\n\n### `data-table`\n`data`: `{ "columns": [{ "key": "file", "label": "File" }], "rows": [{ "file": "auth.ts" }], "stats": [{ "label": "Files", "value": "1" }] }`\n\n### `picker`\n`data`: `{ "categories": [{ "id": "core", "label": "Core" }], "items": [{ "id": "auth", "label": "Auth", "category": "core", "tags": ["security"] }] }`\n\n### `flame-graph`\n`data`: `{ "profile": { "name": "root", "total": 100, "children": [{ "name": "packages/server", "total": 60 }] } }`\n\n### `form`\n`data`: `{ "fields": [{ "name": "projectName", "label": "Project Name", "type": "text", "value": "my-app" }] }`\n\n### `checklist`\n`data`: `{ "items": [{ "label": "Write tests", "checked": true }, { "label": "Update docs", "checked": false }], "title": "Sprint Tasks" }`\n\nTransports: mcp-app, browser (interactive — checkboxes toggle). NOT export.\n\n### `document`\n`data`: `{ "title": "Architecture Overview", "sections": [{ "heading": "Introduction", "content": "System overview text" }, { "heading": "Components", "content": [{ "type": "markdown", "value": "- API Gateway\\n- Auth Service" }] }] }`\n\nSections `content` can be a plain string OR an array of TypedBlock objects.\n\n### `report`\n`data`: `{ "title": "Weekly Status", "metrics": [{ "label": "Coverage", "value": "94%", "trend": "+2%", "status": "success" }], "sections": [{ "heading": "Summary", "content": "All systems operational" }], "tables": [{ "title": "Services", "headers": ["Name", "Status"], "rows": [["API", "healthy"], ["DB", "degraded"]] }] }`\n\nAll fields except `title` and `sections` are optional. `metrics` renders as metric cards; `tables` renders after sections.\n\n### `error`\n`data`: `{ "code": "AUTH_EXPIRED", "message": "Session token has expired", "details": "Token issued at 2026-01-01T00:00:00Z exceeded 24h TTL", "stack": "Error: AUTH_EXPIRED\\n at validateToken (auth.ts:42)" }`\n\nOnly `code` and `message` are required. `details` adds context below the message; `stack` renders as a separate code block.\n\n### `kanban`\n`data`: `{ "columns": [{ "id": "todo", "label": "To Do" }], "cards": [{ "id": "c1", "title": "Fix auth bug", "column": "todo" }] }`\n\n### `timeline`\n`data`: `{ "events": [{ "title": "v1.0 Release", "timestamp": "2026-05", "status": "complete" }] }`\n\nThe timeline template also accepts `entries` or `items` as the array field name (all three are equivalent).\n\n### `tree`\n`data`: `{ "root": { "label": "packages/", "children": [{ "label": "server/" }] } }`\n\n### `diff-view`\n`data`: `{ "files": [{ "path": "auth.ts", "status": "modified", "hunks": [{ "header": "@@ -1 +1 @@", "changes": [{ "type": "add", "content": "const ok = true;" }] }] }], "stats": { "filesChanged": 1 } }`\n\n### `dashboard`\n`data`: `{ "metrics": [{ "label": "Uptime", "value": "99.9%", "status": "success" }] }`\n\n### `status-board`\n`data`: `{ "categories": [{ "category": "Production", "items": [{ "label": "API Gateway", "status": "healthy" }, { "label": "Auth Service", "status": "degraded" }] }] }`\n\nNote: The template requires `{ categories: [...] }` (object with a `categories` key). This differs from the **block type** `status-board` which accepts a bare array as its value.\n\n⚠️ **WARNING:** Do NOT confuse template format with block format. When using `type: "status-board"` (block), value must be `[{category, items}]` (bare array) or `{items: [{category, items}]}`. The `{categories: [{category, items}]}` shape is ONLY for `template: "status-board"`.\n\n## 5. Viewer Templates\n\nViewer templates render richer visual surfaces from `template` + `data`.\n\n| Template | Transport | Purpose |\n|----------|-----------|---------|\n| `c4-static@1` | mcp-app | Static architecture diagram |\n| `c4@1` | browser | Interactive architecture diagram |\n| `process-flow-static@1` | mcp-app | Static process flow |\n| `process-flow@1` | browser | Interactive process flow |\n| `tour@1` | browser | Guided walkthrough or code tour |\n| `task-plan-static@1` | mcp-app | Static task execution plan with phases, batches, agent assignments |\n| `task-plan@1` | browser | Interactive task plan with ReactFlow — drag/zoom/pan, dependency edges, ELK layout |\n\n`c4`: `{ "nodes": [{ "id": "web", "type": "container", "label": "Web App", "technology?": "React" }], "edges": [{ "source": "web", "target": "api", "label": "HTTPS" }] }`\n\n`process-flow`: `{ "nodes": [{ "id": "start", "label": "Start", "type": "start-end" }], "edges": [{ "source": "start", "target": "review", "type?": "standard" }] }`\n\nNode types: `start-end` | `manual` | `automated` | `integration` | `decision` | `prerequisite`. Default: `manual`.\nEdge types: `standard` | `loop-back` | `exception`. Default: `standard`. `loop-back` and `exception` edges animate.\n\n`tour`: `{ "steps": [{ "id": "overview", "title": "Overview", "file": "src/index.ts", "explanation": "Entry point", "code?": "...", "line?": 1 }] }`\n\n`task-plan`: `{ "title": "Feature Name", "description?": "Optional", "phases": [{ "id": "p1", "label": "Phase 1", "outcome?": "...", "batches": [{ "id": "b1", "order": 1, "parallel": true, "label?": "Parallel Research", "tasks": [{ "id": "t1", "title": "Research auth", "agent": "Researcher-Alpha", "files?": ["src/auth/"], "status?": "done", "description?": "...", "dependsOn?": [] }] }] }] }`\n\nTask status values: `pending` | `in-progress` | `done` | `blocked`. Default: `pending`.\n\nGotcha: edges use `source` and `target`, not `from` and `to`.\n\nDecision tree:\n- Architecture, systems, containers, deployments: load the `c4-architecture` skill and use `c4@1` or `c4-static@1`.\n- Stateful workflows, approvals, or branching processes: use `process-flow@1` or `process-flow-static@1`.\n- Agent task decomposition, execution plans, or parallel batch visualization: use `task-plan@1` or `task-plan-static@1`.\n- Ordered walkthroughs, onboarding, or narrated analysis: use `tour@1`.\n\n## 6. Rules\n\n- Pick transport once: no `actions` for inline, any `actions` for browser.\n- Combine block types in one `blocks` array; metrics + chart + table + markdown is the normal composition pattern.\n- Use concise schemas in docs; do not expand to full `present()` calls unless behavior depends on them.\n- Use `table`, `comparison`, and `status-board` for structured data instead of formatting it inside markdown.\n- Architecture requests are delegated: load the `c4-architecture` skill for diagram guidance and data contracts.\n- If inline rendering only shows a title, raw JSON, or fallback text, first assume the host lacks or has disabled MCP Apps rendering. Switch to browser transport with a minimal action only when you need a deterministic fallback.\n- For large or mixed-content surfaces, browser transport is usually easier to review and more reliable.\n- For custom HTML demos or visual prototypes, do NOT use the "html" block type (renders as raw text inline). Instead, write an HTML file, serve it locally (e.g. "npx -y serve" or "python -m http.server"), then open with the AI Kit "browser" tool: browser({ action: "open", url: "http://localhost:PORT/file.html", mode: "ui" }). This gives a controlled Chromium instance the LLM can read/interact with. Avoid "Start-Process" (opens uncontrolled system browser).\n'}]}export{e as default};
@@ -1 +0,0 @@
1
- import{a as e,t}from"./retention-B4ITAs7F.js";import{o as n,t as r}from"./supersession-CWEne3av.js";import{existsSync as i,mkdirSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{dirname as c,isAbsolute as l,relative as u,resolve as d}from"node:path";import{fileURLToPath as f}from"node:url";import{AIKIT_RUNTIME_PATHS as p,EMBEDDING_DEFAULTS as m,computePartitionKey as h,createLogger as g,getPartitionDir as _,migrateLegacyWorkspaceLayout as v,serializeError as y}from"../../core/dist/index.js";const b=c(f(import.meta.url)),x=g(`server`),S=[`auto`,`manual`,`smart`],C={model:m.model,nativeDim:m.nativeDim,dimensions:m.dimensions,queryPrefix:m.queryPrefix,childProcess:!0,idleTimeoutMs:6e4};function w(e){return typeof e==`string`&&S.includes(e)}function T(e,t,n){let r=d(e),i=u(d(t),r);if(i.startsWith(`..`)||l(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function E(e,t){let n=d(e),r=u(d(t),n);return!(r.startsWith(`..`)||l(r))}function D(e){return _(h(e))}function O(e,t,n,r,i){let a=r?d(t,r):t;if(!n)return T(a,t,i);let o=d(e,n);return E(o,t)?r&&d(o)===d(t)?T(a,t,i):T(o,t,i):T(a,t,i)}function k(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir];for(let e of t)e&&a(e,{recursive:!0})}function A(e,t){v(t);let n=D(t);e.store={...e.store,path:O(t,n,e.store?.path,p.data,`store`)},e.curated={...e.curated,path:O(t,n,e.curated?.path,p.curated,`curated`)},e.onboardDir=O(t,n,e.onboardDir,p.onboard,`onboard`),e.stateDir=O(t,n,e.stateDir,p.state,`state`)}function j(e){let t=process.env.AIKIT_INDEX_MODE;if(w(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function M(){let a=process.env.AIKIT_CONFIG_PATH??(i(d(process.cwd(),`aikit.config.json`))?d(process.cwd(),`aikit.config.json`):d(b,`..`,`..`,`..`,`aikit.config.json`));try{if(!i(a))return x.info(`No config file found, using defaults`,{configPath:a}),P();let s=o(a,`utf-8`),l=JSON.parse(s),u={...C,...l.embedding};if(l.embedding=u,l.memory={retention:{...t,...l.memory?.retention},lessons:{...n,...l.memory?.lessons},consolidation:{...e,...l.memory?.consolidation},supersession:{...r,...l.memory?.supersession}},l.logging?.errorDetails!==void 0&&typeof l.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(l.logging={errorDetails:l.logging?.errorDetails===!0},!l.sources||!Array.isArray(l.sources)||l.sources.length===0)throw Error(`Config must have at least one source`);if(!l.store?.path)throw Error(`Config must specify store.path`);if(l.autoIndex!==void 0&&typeof l.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(l.indexMode!==void 0&&!w(l.indexMode))throw Error(`Config indexMode must be one of: ${S.join(`, `)}`);if(typeof u.model!=`string`||u.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(!Number.isInteger(u.nativeDim)||u.nativeDim<=0)throw Error(`Config embedding.nativeDim must be a positive integer`);if(!Number.isInteger(u.dimensions)||u.dimensions<=0)throw Error(`Config embedding.dimensions must be a positive integer`);if(u.dimensions>u.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(typeof u.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let f=c(a);return l.sources=l.sources.map(e=>({...e,path:T(d(f,e.path),f,`source`)})),F(l,a),A(l,f),l.indexMode=j(l),l}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),x.error(`Failed to load config`,{configPath:a,...y(e)}),x.warn(`Falling back to default configuration`,{configPath:a});let n=P();return n.configError=t,n}}const N=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function P(){let i=process.env.AIKIT_WORKSPACE_ROOT??process.cwd(),a=D(i),o={sources:[{path:i,excludePatterns:[...N]}],serverName:`aikit`,indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{...C},store:{backend:`sqlite-vec`,path:d(a,p.data)},curated:{path:d(a,p.curated)},memory:{retention:{...t},lessons:{...n},consolidation:{...e},supersession:{...r}},logging:{errorDetails:!1},onboardDir:d(a,p.onboard),stateDir:d(a,p.state)};return o.indexMode=j(o),o}function F(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of N)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{s(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),x.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){x.warn(`Failed to write upgraded config`,{configPath:t,...y(e)})}return e}function I(e,t){if(!i(t))throw Error(`Workspace root does not exist: ${t}`);v(t),x.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),x.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){x.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...y(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],A(e,t),k(e)}export{N as DEFAULT_EXCLUDE_PATTERNS,M as loadConfig,I as reconfigureForWorkspace,j as resolveIndexMode};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as e,t}from"./retention-C3tsarCT.js";import{o as n,t as r}from"./supersession-DO_ZROFl.js";import{existsSync as i,mkdirSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{dirname as c,isAbsolute as l,relative as u,resolve as d}from"node:path";import{fileURLToPath as f}from"node:url";import{AIKIT_RUNTIME_PATHS as p,EMBEDDING_DEFAULTS as m,computePartitionKey as h,createLogger as g,getPartitionDir as _,migrateLegacyWorkspaceLayout as v,serializeError as y}from"../../core/dist/index.js";const b=c(f(import.meta.url)),x=g(`server`),S=[`auto`,`manual`,`smart`],C={model:m.model,nativeDim:m.nativeDim,dimensions:m.dimensions,queryPrefix:m.queryPrefix,childProcess:!0,idleTimeoutMs:6e4};function w(e){return typeof e==`string`&&S.includes(e)}function T(e,t,n){let r=d(e),i=u(d(t),r);if(i.startsWith(`..`)||l(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function E(e,t){let n=d(e),r=u(d(t),n);return!(r.startsWith(`..`)||l(r))}function D(e){return _(h(e))}function O(e,t,n,r,i){let a=r?d(t,r):t;if(!n)return T(a,t,i);let o=d(e,n);return E(o,t)?r&&d(o)===d(t)?T(a,t,i):T(o,t,i):T(a,t,i)}function k(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir];for(let e of t)e&&a(e,{recursive:!0})}function A(e,t){v(t);let n=D(t);e.store={...e.store,path:O(t,n,e.store?.path,p.data,`store`)},e.curated={...e.curated,path:O(t,n,e.curated?.path,p.curated,`curated`)},e.onboardDir=O(t,n,e.onboardDir,p.onboard,`onboard`),e.stateDir=O(t,n,e.stateDir,p.state,`state`)}function j(e){let t=process.env.AIKIT_INDEX_MODE;if(w(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function M(){let a=process.env.AIKIT_CONFIG_PATH??(i(d(process.cwd(),`aikit.config.json`))?d(process.cwd(),`aikit.config.json`):d(b,`..`,`..`,`..`,`aikit.config.json`));try{if(!i(a))return x.info(`No config file found, using defaults`,{configPath:a}),P();let s=o(a,`utf-8`),l=JSON.parse(s),u={...C,...l.embedding};if(l.embedding=u,l.memory={retention:{...t,...l.memory?.retention},lessons:{...n,...l.memory?.lessons},consolidation:{...e,...l.memory?.consolidation},supersession:{...r,...l.memory?.supersession}},l.logging?.errorDetails!==void 0&&typeof l.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(l.logging={errorDetails:l.logging?.errorDetails===!0},!l.sources||!Array.isArray(l.sources)||l.sources.length===0)throw Error(`Config must have at least one source`);if(!l.store?.path)throw Error(`Config must specify store.path`);if(l.autoIndex!==void 0&&typeof l.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(l.indexMode!==void 0&&!w(l.indexMode))throw Error(`Config indexMode must be one of: ${S.join(`, `)}`);if(typeof u.model!=`string`||u.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(!Number.isInteger(u.nativeDim)||u.nativeDim<=0)throw Error(`Config embedding.nativeDim must be a positive integer`);if(!Number.isInteger(u.dimensions)||u.dimensions<=0)throw Error(`Config embedding.dimensions must be a positive integer`);if(u.dimensions>u.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(typeof u.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let f=c(a);return l.sources=l.sources.map(e=>({...e,path:T(d(f,e.path),f,`source`)})),F(l,a),A(l,f),l.indexMode=j(l),l}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),x.error(`Failed to load config`,{configPath:a,...y(e)}),x.warn(`Falling back to default configuration`,{configPath:a});let n=P();return n.configError=t,n}}const N=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function P(){let i=process.env.AIKIT_WORKSPACE_ROOT??process.cwd(),a=D(i),o={sources:[{path:i,excludePatterns:[...N]}],serverName:`aikit`,indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{...C},store:{backend:`sqlite-vec`,path:d(a,p.data)},curated:{path:d(a,p.curated)},memory:{retention:{...t},lessons:{...n},consolidation:{...e},supersession:{...r}},logging:{errorDetails:!1},onboardDir:d(a,p.onboard),stateDir:d(a,p.state)};return o.indexMode=j(o),o}function F(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of N)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{s(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),x.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){x.warn(`Failed to write upgraded config`,{configPath:t,...y(e)})}return e}function I(e,t){if(!i(t))throw Error(`Workspace root does not exist: ${t}`);v(t),x.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),x.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){x.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...y(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],A(e,t),k(e)}export{N as DEFAULT_EXCLUDE_PATTERNS,M as loadConfig,I as reconfigureForWorkspace,j as resolveIndexMode};
@@ -1 +0,0 @@
1
- const e={workingToEpisodicAccesses:2,episodicToSemanticReferences:3,semanticToProceduralVerifications:5},t={working:1,episodic:2,semantic:4,procedural:12};function n(t,n=e){switch(t.tier){case`working`:if(t.accessCount>=n.workingToEpisodicAccesses)return`episodic`;break;case`episodic`:if(t.accessCount>=n.workingToEpisodicAccesses+n.episodicToSemanticReferences)return`semantic`;break;case`semantic`:if(t.accessCount>=n.workingToEpisodicAccesses+n.episodicToSemanticReferences+n.semanticToProceduralVerifications)return`procedural`;break;case`procedural`:break;default:break}}function r(e,t,n){e.memoryMetaUpdateTier(t,n)}const i={stabilityHours:168,accessMultiplier:1.5,flagThreshold:.1,maxStabilityHours:8760};function a(e){return{...i,...e}}function o(e,t){if(!e)return t;let n=Date.parse(e);return Number.isNaN(n)?t:n}function s(e){return e&&e in t?e:`working`}function c(e,n,r,c=i,l){let u=typeof c==`string`?s(c):`working`,d=a(typeof c==`string`?l:c),f=o(e,o(r,Date.now())),p=Math.max(0,Date.now()-f)/(1e3*60*60),m=Math.min(d.stabilityHours*t[u]*d.accessMultiplier**Math.max(0,n),d.maxStabilityHours);return Math.exp(-p/m)}function l(e,t,n){let r=e.memoryMetaGet(t);if(!r)return;let i=c(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return r.retentionScore!==i&&e.memoryMetaUpdateScore(t,i),e.memoryMetaGet(t)??{...r,retentionScore:i}}function u(e,t,n){e.memoryMetaGet(t)||e.memoryMetaCreate(t),e.memoryMetaTouch(t);let r=e.memoryMetaGet(t);if(!r)return 1;let i=c(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return e.memoryMetaUpdateScore(t,i),i}function d(e,t){let n=a(t);return e.memoryMetaList().map(t=>l(e,t.entryId,n)??t).filter(e=>e.retentionScore<n.flagThreshold).sort((e,t)=>e.retentionScore-t.retentionScore)}export{e as a,u as i,d as n,n as o,l as r,r as s,i as t};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- const e={workingToEpisodicAccesses:2,episodicToSemanticReferences:3,semanticToProceduralVerifications:5},t={working:1,episodic:2,semantic:4,procedural:12};function n(t,n=e){switch(t.tier){case`working`:if(t.accessCount>=n.workingToEpisodicAccesses)return`episodic`;break;case`episodic`:if(t.accessCount>=n.workingToEpisodicAccesses+n.episodicToSemanticReferences)return`semantic`;break;case`semantic`:if(t.accessCount>=n.workingToEpisodicAccesses+n.episodicToSemanticReferences+n.semanticToProceduralVerifications)return`procedural`;break;case`procedural`:break;default:break}}function r(e,t,n){e.memoryMetaUpdateTier(t,n)}const i={stabilityHours:168,accessMultiplier:1.5,flagThreshold:.1,maxStabilityHours:8760};function a(e){return{...i,...e}}function o(e,t){if(!e)return t;let n=Date.parse(e);return Number.isNaN(n)?t:n}function s(e){return e&&e in t?e:`working`}function c(e,n,r,c=i,l){let u=typeof c==`string`?s(c):`working`,d=a(typeof c==`string`?l:c),f=o(e,o(r,Date.now())),p=Math.max(0,Date.now()-f)/(1e3*60*60),m=Math.min(d.stabilityHours*t[u]*d.accessMultiplier**Math.max(0,n),d.maxStabilityHours);return Math.exp(-p/m)}function l(e,t,n){let r=e.memoryMetaGet(t);if(!r)return;let i=c(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return r.retentionScore!==i&&e.memoryMetaUpdateScore(t,i),e.memoryMetaGet(t)??{...r,retentionScore:i}}function u(e,t,n){e.memoryMetaGet(t)||e.memoryMetaCreate(t),e.memoryMetaTouch(t);let r=e.memoryMetaGet(t);if(!r)return 1;let i=c(r.lastAccessedAt,r.accessCount,r.createdAt,r.tier,n);return e.memoryMetaUpdateScore(t,i),i}function d(e,t){let n=a(t);return e.memoryMetaList().map(t=>l(e,t.entryId,n)??t).filter(e=>e.retentionScore<n.flagThreshold).sort((e,t)=>e.retentionScore-t.retentionScore)}export{e as a,u as i,d as n,n as o,l as r,r as s,i as t};