aide-memory 0.5.16 → 0.5.17
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/cli/aide-memory.js +89 -87
- package/dist/memory/cli.js +1 -1
- package/dist/memory/index.js +1 -1
- package/package.json +1 -1
- package/src/templates/rules/shared/body.md +14 -17
package/dist/memory/cli.js
CHANGED
|
@@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS meta (
|
|
|
104
104
|
SELECT rowid, rank FROM memories_fts WHERE memories_fts MATCH ?
|
|
105
105
|
ORDER BY rank
|
|
106
106
|
) fts ON m.id = fts.rowid
|
|
107
|
-
`,a=[o],s=[];return n?.layer&&(s.push("m.layer = ?"),a.push(n.layer)),s.length>0&&(i+=" WHERE "+s.join(" AND ")),i+=" ORDER BY fts.rank",i+=" LIMIT ?",a.push(r),this.db.prepare(i).all(...a).map(u=>this.rowToMemory(u))}searchLike(e,n){if(!e||!e.trim())return[];let o=["(what LIKE ? OR why LIKE ?)"],r=`%${e}%`,i=[r,r];n?.layer&&(o.push("layer = ?"),i.push(n.layer));let a="SELECT * FROM memories WHERE "+o.join(" AND ");a+=" ORDER BY created_at DESC, id DESC";let s=n?.limit??50;a+=" LIMIT ?",i.push(s);let u=this.db.prepare(a).all(...i).map(l=>this.rowToMemory(l));return u.length<3&&this.embeddingService?.isReady(),u}async searchWithEmbeddings(e,n){let o=n?.limit??50,r=n?.mode??"auto";if(r==="semantic"){if(!this.embeddingService?.isReady())return[];try{let a=await this.embeddingService.semanticSearch(this.db,e,o),s=[];for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!(n?.layer&&u.layer!==n.layer)&&(s.push(u),s.length>=o))break}return this.logEvent("search_performed","semantic"),s}catch{return[]}}if(r==="keyword")return this.search(e,n);let i=this.search(e,n);if(i.length<3&&this.embeddingService?.isReady())try{let a=await this.embeddingService.semanticSearch(this.db,e,o),s=new Set(i.map(c=>c.id));for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!s.has(u.id)&&!(n?.layer&&u.layer!==n.layer)&&(i.push(u),s.add(u.id),i.length>=o))break}}catch{}return i}pruneOld(e){let n=new Date(Date.now()-e*864e5).toISOString();if(this.memoriesDir){let r=this.db.prepare("SELECT uuid, layer, shared FROM memories WHERE created_at < ?").all(n);for(let i of r)this.deleteMemoryFile(i.uuid,i.layer,i.shared===1)}let o=this.db.prepare("DELETE FROM memories WHERE created_at < ?").run(n);return this.memoriesDir&&this.updateDirHash(),o.changes}close(){this.analytics&&this.analytics.shutdown(),this.db.close()}getProjectRoot(){return this.projectRoot}get hasFileStorage(){return this.memoriesDir!==null}get memoriesPath(){return this.memoriesDir}rowToMemory(e){return{id:e.id,uuid:e.uuid,layer:e.layer,what:e.what,why:e.why,scope:e.scope,context_label:e.context_label,contributor:e.contributor,tags:e.tags?JSON.parse(e.tags):[],source:e.source,shared:e.shared===1,priority:e.priority==="always"?"always":"normal",generated_by:e.generated_by?JSON.parse(e.generated_by):null,derived_from:e.derived_from?JSON.parse(e.derived_from):null,created_at:e.created_at,updated_at:e.updated_at,recalled_count:e.recalled_count,last_recalled_at:e.last_recalled_at}}}});var cS,sS=we(()=>{cS={"hooks.read.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-read hard-blocks per file path per session. 0 disables the pre-read hook entirely. 1 is the default and fires a block on the first read of each file that has scoped memories."},"hooks.edit.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-edit hard-blocks per file path per session. 0 disables the pre-edit hook entirely. 1 is the default."},"hooks.stop.schedule":{value:[{until:9,every:3},{until:29,every:5},{every:10}],public:!0,pro:!1,description:"Phased interval schedule for the Stop hook's 'worth remembering?' nudge. Each entry = {until, every}. Default ramps from every-3-turns for first 9 turns \u2192 every-5 for turns 10-29 \u2192 every-10 afterwards."},"hooks.search.mode":{value:"soft",public:!0,pro:!1,description:"Pre-search hook mode: 'off' (no nudge), 'soft' (additionalContext only, default), 'block' (hard decision:block envelope)."},"hooks.correction.enabled":{value:!0,public:!0,pro:!1,description:"Enable UserPromptSubmit correction detection. When true, messages like 'no, use X instead' trigger a nudge to call aide_remember."},"hooks.precompact.mode":{value:"cleanup",public:!0,pro:!1,description:"PreCompact hook behavior: 'off' preserves tracking files across compaction; 'cleanup' (default) clears recalled-paths/stop-count/correction-pending so the post-compact turn re-blocks cleanly."},"hooks.visible":{value:!0,public:!0,pro:!1,description:"Surface user-facing systemMessage lines when hooks fire (soft recalls, correction detected, session-start injection, Stop checkpoints, etc). Default true so users can see what aide-memory is doing. Set to false to hide all aide-memory systemMessages \u2014 hooks still function (context injection + block enforcement unchanged). Does not affect what Claude sees."},"recall.limit":{value:20,public:!0,pro:!1,description:"Max memories returned per aide_recall call before layer-diversity balancing applies."},"recall.ensureLayerDiversity":{value:!0,public:!0,pro:!1,description:"If true, recall results are swapped to surface under-represented layers up to recall.layerDiversityMinLimit. Ensures each enabled layer gets at least some representation instead of the top-scoring one dominating."},"recall.layerDiversityMinLimit":{value:5,public:!0,pro:!1,description:"Minimum total results below which layer diversity swap kicks in. Above this threshold, natural ranking wins."},"recall.minScopeDepth":{value:1,public:!0,pro:!1,description:"Minimum fixed-prefix segment count a scope needs to surface via per-file path-recall. Scopes below this threshold surface only at SessionStart injection instead. Think of it as 'how specific must a scope be to show up when I open a file?' Default 1 is permissive \u2014 any scope with \u22651 segment (e.g. 'src/**', 'pages/**', 'packages/**') counts. Works across project shapes (src-wrapped, flat Next.js, deep monorepos). Bump to 2 if you have many broad scopes and want per-file recall quieter (broad scopes still surface at SessionStart). Bump to 3+ for very strict per-file recall."},"injection.enabled":{value:!0,public:!0,pro:!1,description:"Master switch for SessionStart dynamic injection. When true (default), the sessionStart handler loads + injects preferences / guidelines / priority:always memories into the agent's starting context; when false, the handler short-circuits before any SQLite read or template render \u2014 zero per-turn overhead from dynamic injection. The rules file still ships (static content) but carries no memory-derived content. Granular per-layer knobs (injection.preferences, injection.guidelines, etc.) only apply when this master switch is true. Flip to false if you want aide-memory's hooks + MCP tools without any session-start context injection."},"injection.preferences":{value:15,public:!0,pro:!1,description:"Max preferences injected at SessionStart. 0/false disables; number = hard cap; 'all' = every preference. Default 15 matches spec memory #297 ('top 15 most-recalled preferences'). Only honored when injection.enabled is true."},"injection.excludeScopedPreferences":{value:!1,public:!0,pro:!1,description:"If true, SessionStart injection skips preferences with a non-null scope \u2014 they surface via Read/Edit path hooks when the agent touches matching paths. Default false preserves current 'inject all preferences regardless of scope' behavior. Set to true for tighter SessionStart token usage when you have many scoped preferences. (NB: renamed from `injection.preferences.excludeScoped` to avoid key collision with `injection.preferences` which is a scalar limit, not an object.)"},"injection.technical":{value:!1,public:!0,pro:!1,description:"Inject technical-layer memories at SessionStart? Default false \u2014 technical context should surface via path hooks when relevant. Set to a number to cap, 'all' for unlimited, true for enabled-with-no-cap."},"injection.area_context":{value:!1,public:!0,pro:!1,description:"Inject area_context-layer memories at SessionStart? Default false \u2014 area context by definition is area-specific and should surface via path hooks."},"injection.guidelines":{value:"all",public:!0,pro:!1,description:"Inject guidelines at SessionStart. 'all' (default) injects every guideline regardless of scope \u2014 guidelines apply broadly so early visibility matters. Set to a number for a cap, or false to disable."},"injection.priorityAlwaysOverride":{value:!0,public:!0,pro:!1,description:"When true (default), any memory with priority='always' is injected at SessionStart regardless of layer-specific injection settings. User-marked 'always' memories surface in the ## Always section (rendered first since 0.4.3 so they survive char-cap truncation)."},"injection.maxChars":{value:1200,public:!0,pro:!1,description:"Overall character cap for the combined SessionStart injection (preferences + technical + area_context + guidelines + always). Applied after all layer sections are concatenated; truncates with '...truncated' suffix. Bump to 2000+ for richer context, drop to 600 for token-conscious sessions. Default 1200 matches the pre-0.4.3 hard-coded MAX_INJECT_CHARS constant."},"memories.hideFromGrep":{value:!0,public:!0,pro:!1,description:"Add an aide-memory-managed block to .ignore so grep/ripgrep/etc skip .aide/memories/ by default. Flipping this live triggers drift-repair on the next hook fire."},"memories.softening.threshold":{value:10,public:!0,pro:!1,description:"Total-memory count below which pre-read/pre-edit hard blocks become soft additionalContext nudges. Keeps small projects from feeling hostile. Default 10 \u2014 once you have 10+ total memories, hard blocking resumes on first-touch."},"memories.defaultShared":{value:!0,public:!0,pro:!1,description:"Default `shared` flag for new memories when the caller doesn't pass one. When true (default), aide_remember without an explicit shared param writes to `.aide/memories/preferences/shared/` (committed to repo). When false, defaults to `personal/` (gitignored). Per-call `shared: true|false` always overrides this default. Flip to false if you want personal-by-default and explicit opt-in for shared memories."}}});function xd(){return m1}function h1(t,e){let n=t;for(let o of e){if(n==null||typeof n!="object"||Array.isArray(n)||!Object.prototype.hasOwnProperty.call(n,o))return!1;n=n[o]}return!0}function g1(t,e){let n=t;for(let o of e)n=n[o];return n}function ut(t,e){let o=xd()[e];if(!o)return;let r=o.value;if(o.public!==!0||!t)return r;let i=uS.default.join(t,".aide","config.json");if(!gy.default.existsSync(i))return r;let a;try{a=JSON.parse(gy.default.readFileSync(i,"utf8"))}catch{return r}let s=e.split(".");return h1(a,s)?g1(a,s):r}function lS(){let t=xd(),e={};for(let[n,o]of Object.entries(t))o.public===!0&&(e[n]=o.value);return e}function dS(t){let e={};for(let[n,o]of Object.entries(t)){let r=n.split("."),i=e;for(let a=0;a<r.length-1;a++){let s=r[a],c=i[s];(!c||typeof c!="object"||Array.isArray(c))&&(i[s]={}),i=i[s]}i[r[r.length-1]]=o}return e}var gy,uS,m1,kd=we(()=>{"use strict";gy=re(require("fs")),uS=re(require("path"));sS();m1=cS});function _S(t=Ha){let e=[];for(let n of t){if(!n.hasMatcher||!n.matchers||n.matchers.length===0){e.push({event:n,matcher:null});continue}for(let o of n.matchers)e.push({event:n,matcher:o})}return e}var Ha,yy=we(()=>{"use strict";Ha=[{id:"session-start",script:"session-start-clear.sh",purpose:"Inject top-N preferences + guidelines + priority:always at session start",timeout:10,hasMatcher:!1},{id:"pre-compact",script:"pre-compact-save.sh",purpose:"Clear session tracking before compaction",timeout:30,hasMatcher:!1},{id:"stop",script:"stop-remember.sh",purpose:"Reflection nudge on schedule + correction-pending flag",timeout:30,hasMatcher:!1},{id:"pre-prompt",script:"detect-correction.sh",purpose:"Detect correction/decision/preference in user prompt",timeout:5,hasMatcher:!1},{id:"pre-read",script:"pre-read-recall.sh",purpose:"Block/soft on file read with scoped memories",timeout:10,hasMatcher:!0,matchers:["read"]},{id:"pre-edit",script:"pre-edit-recall.sh",purpose:"Block/soft on file edit with scoped memories",timeout:10,hasMatcher:!0,matchers:["edit","write"]},{id:"pre-search",script:"pre-search-nudge.sh",purpose:"Nudge aide_search when matching memories exist",timeout:10,hasMatcher:!0,matchers:["search","glob"]},{id:"pre-recall",script:"track-recall.sh",purpose:"Track paths on aide_recall pre-tool-use",timeout:5,hasMatcher:!0,matchers:["mcp-aide-recall"]},{id:"post-tool-use-recall",script:"track-recall-post.sh",purpose:"Record recalled ids post-tool-use",timeout:5,hasMatcher:!0,matchers:["mcp-aide-recall"]},{id:"post-remember",script:"track-remember.sh",purpose:"Clear correction-pending flag on aide_remember/update/forget",timeout:5,hasMatcher:!0,matchers:["mcp-aide-remember","mcp-aide-update","mcp-aide-forget"]},{id:"post-search",script:"track-search.sh",purpose:"Mark query as searched post aide_search",timeout:5,hasMatcher:!0,matchers:["mcp-aide-search"]}]});function zd(t,e){let n=[],o=new Set;for(let{event:r,matcher:i}of _S(Ha)){let a=t.eventNameMap[r.id];if(a===null)continue;let s=null;if(i!==null){let l=t.matcherMap[i];if(l===null)continue;s=l}let c=_1(e.packageRoot,r.script),u=`${a}|${s??""}|${c}`;o.has(u)||(o.add(u),n.push({eventName:a,matcher:s,command:c,timeout:r.timeout}))}return n}function _1(t,e){return`bash ${bS.join(t,"scripts","hooks",e)}`}function Id(t){let e=new Map;for(let n of t){let o=e.get(n.eventName)??[];o.push(n),e.set(n.eventName,o)}return e}var bS,vy=we(()=>{"use strict";bS=re(require("path"));yy()});var _y,$S=we(()=>{"use strict";vy();_y={id:"claude-code",displayName:"Claude Code",hookConfigPath:".claude/settings.json",mcpConfigPath:".mcp.json",rules:[{template:"claude-code.md",dest:".claude/rules/aide-memory.md"}],ruleFrontmatter:"",ruleNotes:"",ruleToolId:"claude-code",supportsHooks:!0,supportsMcp:!0,supportsRules:!0,eventNameMap:{"session-start":"SessionStart","pre-compact":"PreCompact",stop:"Stop","pre-prompt":"UserPromptSubmit","pre-read":"PreToolUse","pre-edit":"PreToolUse","pre-search":"PreToolUse","pre-recall":"PreToolUse","post-tool-use-recall":"PostToolUse","post-remember":"PostToolUse","post-search":"PostToolUse"},matcherMap:{read:"Read",edit:"Edit",write:"Write",search:"Grep",glob:"Glob","mcp-aide-recall":"mcp__aide-memory__aide_recall","mcp-aide-remember":"mcp__aide-memory__aide_remember","mcp-aide-update":"mcp__aide-memory__aide_update","mcp-aide-forget":"mcp__aide-memory__aide_forget","mcp-aide-search":"mcp__aide-memory__aide_search"},buildHookConfig(t){let e=zd(_y,t),n=Id(e),o={};for(let[r,i]of n){let a=i.some(s=>s.matcher!==null);o[r]=i.map(s=>{let c={type:"command",command:s.command,timeout:s.timeout};return a?{matcher:s.matcher,hooks:[c]}:{hooks:[c]}})}return{hooks:o}},buildMcpConfig({serverEntry:t,projectRoot:e}){return{mcpServers:{"aide-memory":{command:"node",args:[t,e]}}}},detectRuntime(t){return t.CURSOR_VERSION||t.CURSOR_PROJECT_DIR?!1:!!t.CLAUDECODE},translateInput(t){return t},translateOutput(t){switch(t.kind){case"block":{let e={decision:"block",reason:t.reason};return t.systemMessage&&(e.systemMessage=t.systemMessage),JSON.stringify(e,null,2)}case"additionalContext":{let e={hookSpecificOutput:{hookEventName:t.event,additionalContext:t.context}};return t.systemMessage&&(e.systemMessage=t.systemMessage),JSON.stringify(e,null,2)}case"systemMessage":return JSON.stringify({systemMessage:t.text},null,2);case"silent":return""}}}});function bn(t){return t.replace(b1,"")}var b1,by,xS=we(()=>{"use strict";vy();b1=/\[[0-9;]*m/g;by={id:"cursor",displayName:"Cursor",hookConfigPath:".cursor/hooks.json",mcpConfigPath:".cursor/mcp.json",rules:[{template:"cursor.mdc",dest:".cursor/rules/aide-memory.mdc"}],ruleFrontmatter:`---
|
|
107
|
+
`,a=[o],s=[];return n?.layer&&(s.push("m.layer = ?"),a.push(n.layer)),s.length>0&&(i+=" WHERE "+s.join(" AND ")),i+=" ORDER BY fts.rank",i+=" LIMIT ?",a.push(r),this.db.prepare(i).all(...a).map(u=>this.rowToMemory(u))}searchLike(e,n){if(!e||!e.trim())return[];let o=["(what LIKE ? OR why LIKE ?)"],r=`%${e}%`,i=[r,r];n?.layer&&(o.push("layer = ?"),i.push(n.layer));let a="SELECT * FROM memories WHERE "+o.join(" AND ");a+=" ORDER BY created_at DESC, id DESC";let s=n?.limit??50;a+=" LIMIT ?",i.push(s);let u=this.db.prepare(a).all(...i).map(l=>this.rowToMemory(l));return u.length<3&&this.embeddingService?.isReady(),u}async searchWithEmbeddings(e,n){let o=n?.limit??50,r=n?.mode??"auto";if(r==="semantic"){if(!this.embeddingService?.isReady())return[];try{let a=await this.embeddingService.semanticSearch(this.db,e,o),s=[];for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!(n?.layer&&u.layer!==n.layer)&&(s.push(u),s.length>=o))break}return this.logEvent("search_performed","semantic"),s}catch{return[]}}if(r==="keyword")return this.search(e,n);let i=this.search(e,n);if(i.length<3&&this.embeddingService?.isReady())try{let a=await this.embeddingService.semanticSearch(this.db,e,o),s=new Set(i.map(c=>c.id));for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!s.has(u.id)&&!(n?.layer&&u.layer!==n.layer)&&(i.push(u),s.add(u.id),i.length>=o))break}}catch{}return i}pruneOld(e){let n=new Date(Date.now()-e*864e5).toISOString();if(this.memoriesDir){let r=this.db.prepare("SELECT uuid, layer, shared FROM memories WHERE created_at < ?").all(n);for(let i of r)this.deleteMemoryFile(i.uuid,i.layer,i.shared===1)}let o=this.db.prepare("DELETE FROM memories WHERE created_at < ?").run(n);return this.memoriesDir&&this.updateDirHash(),o.changes}close(){this.analytics&&this.analytics.shutdown(),this.db.close()}getProjectRoot(){return this.projectRoot}get hasFileStorage(){return this.memoriesDir!==null}get memoriesPath(){return this.memoriesDir}rowToMemory(e){return{id:e.id,uuid:e.uuid,layer:e.layer,what:e.what,why:e.why,scope:e.scope,context_label:e.context_label,contributor:e.contributor,tags:e.tags?JSON.parse(e.tags):[],source:e.source,shared:e.shared===1,priority:e.priority==="always"?"always":"normal",generated_by:e.generated_by?JSON.parse(e.generated_by):null,derived_from:e.derived_from?JSON.parse(e.derived_from):null,created_at:e.created_at,updated_at:e.updated_at,recalled_count:e.recalled_count,last_recalled_at:e.last_recalled_at}}}});var cS,sS=we(()=>{cS={"hooks.read.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-read hard-blocks per file path per session. 0 disables the pre-read hook entirely. 1 is the default and fires a block on the first read of each file that has scoped memories."},"hooks.edit.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-edit hard-blocks per file path per session. 0 disables the pre-edit hook entirely. 1 is the default."},"hooks.stop.schedule":{value:[{until:9,every:3},{until:29,every:5},{every:10}],public:!0,pro:!1,description:"Phased interval schedule for the Stop hook's 'worth remembering?' nudge. Each entry = {until, every}. Default ramps from every-3-turns for first 9 turns \u2192 every-5 for turns 10-29 \u2192 every-10 afterwards."},"hooks.search.mode":{value:"soft",public:!0,pro:!1,description:"Pre-search hook mode: 'off' (no nudge), 'soft' (additionalContext only, default), 'block' (hard decision:block envelope)."},"hooks.correction.enabled":{value:!0,public:!0,pro:!1,description:"Enable UserPromptSubmit correction detection. When true, messages like 'no, use X instead' trigger a nudge to call aide_remember."},"hooks.correction.escalate":{value:"off",public:!0,pro:!1,description:"When a correction is detected, optionally write a correction-pending flag so the next Stop fire reminds the agent if the correction wasn't stored. 'off' (default) \u2014 never reminds; correction surfaces only as the soft UserPromptSubmit hint at detection time. 'block' \u2014 flag is written and the next Stop fires decision:block with the reminder, regardless of hooks.stop.mode. Master switch: hooks.correction.enabled=false disables the entire correction system including this. (A 'soft' value existed in spec drafts but was dropped \u2014 Claude Code's Stop hook protocol doesn't accept hookSpecificOutput.additionalContext, so a soft Stop emit is impossible. Use the always-on UserPromptSubmit soft hint as the soft channel; escalate to 'block' only when you want an explicit follow-up reminder.)"},"hooks.stop.mode":{value:"block",public:!0,pro:!1,description:"How the scheduled Stop checkpoint surfaces. 'block' (default) uses decision:block + a softened reason prompt + chrome systemMessage. The Claude Code TUI collapses the 'Stop hook error:' label behind ctrl+o when systemMessage is present, so the brand chrome is the primary visible line. 'off' skips the scheduled checkpoint entirely (zero Stop noise). Frequency is still controlled by hooks.stop.schedule. (A 'soft' mode existed in spec drafts but was dropped \u2014 Claude Code's Stop hook protocol doesn't accept hookSpecificOutput.additionalContext, so 'block' is the only way to deliver text to the agent on Stop.) When a correction-pending flag is set and hooks.correction.escalate='block', that branch wins and the scheduled checkpoint is skipped that turn."},"hooks.precompact.mode":{value:"cleanup",public:!0,pro:!1,description:"PreCompact hook behavior: 'off' preserves tracking files across compaction; 'cleanup' (default) clears recalled-paths/stop-count/correction-pending so the post-compact turn re-blocks cleanly."},"hooks.visible":{value:!0,public:!0,pro:!1,description:"Surface user-facing systemMessage lines when hooks fire (soft recalls, correction detected, session-start injection, Stop checkpoints, etc). Default true so users can see what aide-memory is doing. Set to false to hide all aide-memory systemMessages \u2014 hooks still function (context injection + block enforcement unchanged). Does not affect what Claude sees."},"recall.limit":{value:20,public:!0,pro:!1,description:"Max memories returned per aide_recall call before layer-diversity balancing applies."},"recall.ensureLayerDiversity":{value:!0,public:!0,pro:!1,description:"If true, recall results are swapped to surface under-represented layers up to recall.layerDiversityMinLimit. Ensures each enabled layer gets at least some representation instead of the top-scoring one dominating."},"recall.layerDiversityMinLimit":{value:5,public:!0,pro:!1,description:"Minimum total results below which layer diversity swap kicks in. Above this threshold, natural ranking wins."},"recall.minScopeDepth":{value:1,public:!0,pro:!1,description:"Minimum fixed-prefix segment count a scope needs to surface via per-file path-recall. Scopes below this threshold surface only at SessionStart injection instead. Think of it as 'how specific must a scope be to show up when I open a file?' Default 1 is permissive \u2014 any scope with \u22651 segment (e.g. 'src/**', 'pages/**', 'packages/**') counts. Works across project shapes (src-wrapped, flat Next.js, deep monorepos). Bump to 2 if you have many broad scopes and want per-file recall quieter (broad scopes still surface at SessionStart). Bump to 3+ for very strict per-file recall."},"injection.enabled":{value:!0,public:!0,pro:!1,description:"Master switch for SessionStart dynamic injection. When true (default), the sessionStart handler loads + injects preferences / guidelines / priority:always memories into the agent's starting context; when false, the handler short-circuits before any SQLite read or template render \u2014 zero per-turn overhead from dynamic injection. The rules file still ships (static content) but carries no memory-derived content. Granular per-layer knobs (injection.preferences, injection.guidelines, etc.) only apply when this master switch is true. Flip to false if you want aide-memory's hooks + MCP tools without any session-start context injection."},"injection.preferences":{value:15,public:!0,pro:!1,description:"Max preferences injected at SessionStart. 0/false disables; number = hard cap; 'all' = every preference. Default 15 matches spec memory #297 ('top 15 most-recalled preferences'). Only honored when injection.enabled is true."},"injection.excludeScopedPreferences":{value:!1,public:!0,pro:!1,description:"If true, SessionStart injection skips preferences with a non-null scope \u2014 they surface via Read/Edit path hooks when the agent touches matching paths. Default false preserves current 'inject all preferences regardless of scope' behavior. Set to true for tighter SessionStart token usage when you have many scoped preferences. (NB: renamed from `injection.preferences.excludeScoped` to avoid key collision with `injection.preferences` which is a scalar limit, not an object.)"},"injection.technical":{value:!1,public:!0,pro:!1,description:"Inject technical-layer memories at SessionStart? Default false \u2014 technical context should surface via path hooks when relevant. Set to a number to cap, 'all' for unlimited, true for enabled-with-no-cap."},"injection.area_context":{value:!1,public:!0,pro:!1,description:"Inject area_context-layer memories at SessionStart? Default false \u2014 area context by definition is area-specific and should surface via path hooks."},"injection.guidelines":{value:"all",public:!0,pro:!1,description:"Inject guidelines at SessionStart. 'all' (default) injects every guideline regardless of scope \u2014 guidelines apply broadly so early visibility matters. Set to a number for a cap, or false to disable."},"injection.priorityAlwaysOverride":{value:!0,public:!0,pro:!1,description:"When true (default), any memory with priority='always' is injected at SessionStart regardless of layer-specific injection settings. User-marked 'always' memories surface in the ## Always section (rendered first since 0.4.3 so they survive char-cap truncation)."},"injection.maxChars":{value:1200,public:!0,pro:!1,description:"Overall character cap for the combined SessionStart injection (preferences + technical + area_context + guidelines + always). Applied after all layer sections are concatenated; truncates with '...truncated' suffix. Bump to 2000+ for richer context, drop to 600 for token-conscious sessions. Default 1200 matches the pre-0.4.3 hard-coded MAX_INJECT_CHARS constant."},"memories.hideFromGrep":{value:!0,public:!0,pro:!1,description:"Add an aide-memory-managed block to .ignore so grep/ripgrep/etc skip .aide/memories/ by default. Flipping this live triggers drift-repair on the next hook fire."},"memories.softening.threshold":{value:10,public:!0,pro:!1,description:"Total-memory count below which pre-read/pre-edit hard blocks become soft additionalContext nudges. Keeps small projects from feeling hostile. Default 10 \u2014 once you have 10+ total memories, hard blocking resumes on first-touch."},"memories.defaultShared":{value:!0,public:!0,pro:!1,description:"Default `shared` flag for new memories when the caller doesn't pass one. When true (default), aide_remember without an explicit shared param writes to `.aide/memories/preferences/shared/` (committed to repo). When false, defaults to `personal/` (gitignored). Per-call `shared: true|false` always overrides this default. Flip to false if you want personal-by-default and explicit opt-in for shared memories."}}});function xd(){return m1}function h1(t,e){let n=t;for(let o of e){if(n==null||typeof n!="object"||Array.isArray(n)||!Object.prototype.hasOwnProperty.call(n,o))return!1;n=n[o]}return!0}function g1(t,e){let n=t;for(let o of e)n=n[o];return n}function ut(t,e){let o=xd()[e];if(!o)return;let r=o.value;if(o.public!==!0||!t)return r;let i=uS.default.join(t,".aide","config.json");if(!gy.default.existsSync(i))return r;let a;try{a=JSON.parse(gy.default.readFileSync(i,"utf8"))}catch{return r}let s=e.split(".");return h1(a,s)?g1(a,s):r}function lS(){let t=xd(),e={};for(let[n,o]of Object.entries(t))o.public===!0&&(e[n]=o.value);return e}function dS(t){let e={};for(let[n,o]of Object.entries(t)){let r=n.split("."),i=e;for(let a=0;a<r.length-1;a++){let s=r[a],c=i[s];(!c||typeof c!="object"||Array.isArray(c))&&(i[s]={}),i=i[s]}i[r[r.length-1]]=o}return e}var gy,uS,m1,kd=we(()=>{"use strict";gy=re(require("fs")),uS=re(require("path"));sS();m1=cS});function _S(t=Ha){let e=[];for(let n of t){if(!n.hasMatcher||!n.matchers||n.matchers.length===0){e.push({event:n,matcher:null});continue}for(let o of n.matchers)e.push({event:n,matcher:o})}return e}var Ha,yy=we(()=>{"use strict";Ha=[{id:"session-start",script:"session-start-clear.sh",purpose:"Inject top-N preferences + guidelines + priority:always at session start",timeout:10,hasMatcher:!1},{id:"pre-compact",script:"pre-compact-save.sh",purpose:"Clear session tracking before compaction",timeout:30,hasMatcher:!1},{id:"stop",script:"stop-remember.sh",purpose:"Reflection nudge on schedule + correction-pending flag",timeout:30,hasMatcher:!1},{id:"pre-prompt",script:"detect-correction.sh",purpose:"Detect correction/decision/preference in user prompt",timeout:5,hasMatcher:!1},{id:"pre-read",script:"pre-read-recall.sh",purpose:"Block/soft on file read with scoped memories",timeout:10,hasMatcher:!0,matchers:["read"]},{id:"pre-edit",script:"pre-edit-recall.sh",purpose:"Block/soft on file edit with scoped memories",timeout:10,hasMatcher:!0,matchers:["edit","write"]},{id:"pre-search",script:"pre-search-nudge.sh",purpose:"Nudge aide_search when matching memories exist",timeout:10,hasMatcher:!0,matchers:["search","glob"]},{id:"pre-recall",script:"track-recall.sh",purpose:"Track paths on aide_recall pre-tool-use",timeout:5,hasMatcher:!0,matchers:["mcp-aide-recall"]},{id:"post-tool-use-recall",script:"track-recall-post.sh",purpose:"Record recalled ids post-tool-use",timeout:5,hasMatcher:!0,matchers:["mcp-aide-recall"]},{id:"post-remember",script:"track-remember.sh",purpose:"Clear correction-pending flag on aide_remember/update/forget",timeout:5,hasMatcher:!0,matchers:["mcp-aide-remember","mcp-aide-update","mcp-aide-forget"]},{id:"post-search",script:"track-search.sh",purpose:"Mark query as searched post aide_search",timeout:5,hasMatcher:!0,matchers:["mcp-aide-search"]}]});function zd(t,e){let n=[],o=new Set;for(let{event:r,matcher:i}of _S(Ha)){let a=t.eventNameMap[r.id];if(a===null)continue;let s=null;if(i!==null){let l=t.matcherMap[i];if(l===null)continue;s=l}let c=_1(e.packageRoot,r.script),u=`${a}|${s??""}|${c}`;o.has(u)||(o.add(u),n.push({eventName:a,matcher:s,command:c,timeout:r.timeout}))}return n}function _1(t,e){return`bash ${bS.join(t,"scripts","hooks",e)}`}function Id(t){let e=new Map;for(let n of t){let o=e.get(n.eventName)??[];o.push(n),e.set(n.eventName,o)}return e}var bS,vy=we(()=>{"use strict";bS=re(require("path"));yy()});var _y,$S=we(()=>{"use strict";vy();_y={id:"claude-code",displayName:"Claude Code",hookConfigPath:".claude/settings.json",mcpConfigPath:".mcp.json",rules:[{template:"claude-code.md",dest:".claude/rules/aide-memory.md"}],ruleFrontmatter:"",ruleNotes:"",ruleToolId:"claude-code",supportsHooks:!0,supportsMcp:!0,supportsRules:!0,eventNameMap:{"session-start":"SessionStart","pre-compact":"PreCompact",stop:"Stop","pre-prompt":"UserPromptSubmit","pre-read":"PreToolUse","pre-edit":"PreToolUse","pre-search":"PreToolUse","pre-recall":"PreToolUse","post-tool-use-recall":"PostToolUse","post-remember":"PostToolUse","post-search":"PostToolUse"},matcherMap:{read:"Read",edit:"Edit",write:"Write",search:"Grep",glob:"Glob","mcp-aide-recall":"mcp__aide-memory__aide_recall","mcp-aide-remember":"mcp__aide-memory__aide_remember","mcp-aide-update":"mcp__aide-memory__aide_update","mcp-aide-forget":"mcp__aide-memory__aide_forget","mcp-aide-search":"mcp__aide-memory__aide_search"},buildHookConfig(t){let e=zd(_y,t),n=Id(e),o={};for(let[r,i]of n){let a=i.some(s=>s.matcher!==null);o[r]=i.map(s=>{let c={type:"command",command:s.command,timeout:s.timeout};return a?{matcher:s.matcher,hooks:[c]}:{hooks:[c]}})}return{hooks:o}},buildMcpConfig({serverEntry:t,projectRoot:e}){return{mcpServers:{"aide-memory":{command:"node",args:[t,e]}}}},detectRuntime(t){return t.CURSOR_VERSION||t.CURSOR_PROJECT_DIR?!1:!!t.CLAUDECODE},translateInput(t){return t},translateOutput(t){switch(t.kind){case"block":{let e={decision:"block",reason:t.reason};return t.systemMessage&&(e.systemMessage=t.systemMessage),JSON.stringify(e,null,2)}case"additionalContext":{let e={hookSpecificOutput:{hookEventName:t.event,additionalContext:t.context}};return t.systemMessage&&(e.systemMessage=t.systemMessage),JSON.stringify(e,null,2)}case"systemMessage":return JSON.stringify({systemMessage:t.text},null,2);case"silent":return""}}}});function bn(t){return t.replace(b1,"")}var b1,by,xS=we(()=>{"use strict";vy();b1=/\[[0-9;]*m/g;by={id:"cursor",displayName:"Cursor",hookConfigPath:".cursor/hooks.json",mcpConfigPath:".cursor/mcp.json",rules:[{template:"cursor.mdc",dest:".cursor/rules/aide-memory.mdc"}],ruleFrontmatter:`---
|
|
108
108
|
description: AIDE Memory - persistent context for AI coding agents
|
|
109
109
|
globs: **/*
|
|
110
110
|
alwaysApply: true
|
package/dist/memory/index.js
CHANGED
|
@@ -96,7 +96,7 @@ CREATE TABLE IF NOT EXISTS meta (
|
|
|
96
96
|
SELECT rowid, rank FROM memories_fts WHERE memories_fts MATCH ?
|
|
97
97
|
ORDER BY rank
|
|
98
98
|
) fts ON m.id = fts.rowid
|
|
99
|
-
`,a=[i],s=[];return r?.layer&&(s.push("m.layer = ?"),a.push(r.layer)),s.length>0&&(o+=" WHERE "+s.join(" AND ")),o+=" ORDER BY fts.rank",o+=" LIMIT ?",a.push(n),this.db.prepare(o).all(...a).map(u=>this.rowToMemory(u))}searchLike(e,r){if(!e||!e.trim())return[];let i=["(what LIKE ? OR why LIKE ?)"],n=`%${e}%`,o=[n,n];r?.layer&&(i.push("layer = ?"),o.push(r.layer));let a="SELECT * FROM memories WHERE "+i.join(" AND ");a+=" ORDER BY created_at DESC, id DESC";let s=r?.limit??50;a+=" LIMIT ?",o.push(s);let u=this.db.prepare(a).all(...o).map(l=>this.rowToMemory(l));return u.length<3&&this.embeddingService?.isReady(),u}async searchWithEmbeddings(e,r){let i=r?.limit??50,n=r?.mode??"auto";if(n==="semantic"){if(!this.embeddingService?.isReady())return[];try{let a=await this.embeddingService.semanticSearch(this.db,e,i),s=[];for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!(r?.layer&&u.layer!==r.layer)&&(s.push(u),s.length>=i))break}return this.logEvent("search_performed","semantic"),s}catch{return[]}}if(n==="keyword")return this.search(e,r);let o=this.search(e,r);if(o.length<3&&this.embeddingService?.isReady())try{let a=await this.embeddingService.semanticSearch(this.db,e,i),s=new Set(o.map(c=>c.id));for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!s.has(u.id)&&!(r?.layer&&u.layer!==r.layer)&&(o.push(u),s.add(u.id),o.length>=i))break}}catch{}return o}pruneOld(e){let r=new Date(Date.now()-e*864e5).toISOString();if(this.memoriesDir){let n=this.db.prepare("SELECT uuid, layer, shared FROM memories WHERE created_at < ?").all(r);for(let o of n)this.deleteMemoryFile(o.uuid,o.layer,o.shared===1)}let i=this.db.prepare("DELETE FROM memories WHERE created_at < ?").run(r);return this.memoriesDir&&this.updateDirHash(),i.changes}close(){this.analytics&&this.analytics.shutdown(),this.db.close()}getProjectRoot(){return this.projectRoot}get hasFileStorage(){return this.memoriesDir!==null}get memoriesPath(){return this.memoriesDir}rowToMemory(e){return{id:e.id,uuid:e.uuid,layer:e.layer,what:e.what,why:e.why,scope:e.scope,context_label:e.context_label,contributor:e.contributor,tags:e.tags?JSON.parse(e.tags):[],source:e.source,shared:e.shared===1,priority:e.priority==="always"?"always":"normal",generated_by:e.generated_by?JSON.parse(e.generated_by):null,derived_from:e.derived_from?JSON.parse(e.derived_from):null,created_at:e.created_at,updated_at:e.updated_at,recalled_count:e.recalled_count,last_recalled_at:e.last_recalled_at}}}});var F$,Z$=qe(()=>{F$={"hooks.read.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-read hard-blocks per file path per session. 0 disables the pre-read hook entirely. 1 is the default and fires a block on the first read of each file that has scoped memories."},"hooks.edit.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-edit hard-blocks per file path per session. 0 disables the pre-edit hook entirely. 1 is the default."},"hooks.stop.schedule":{value:[{until:9,every:3},{until:29,every:5},{every:10}],public:!0,pro:!1,description:"Phased interval schedule for the Stop hook's 'worth remembering?' nudge. Each entry = {until, every}. Default ramps from every-3-turns for first 9 turns \u2192 every-5 for turns 10-29 \u2192 every-10 afterwards."},"hooks.search.mode":{value:"soft",public:!0,pro:!1,description:"Pre-search hook mode: 'off' (no nudge), 'soft' (additionalContext only, default), 'block' (hard decision:block envelope)."},"hooks.correction.enabled":{value:!0,public:!0,pro:!1,description:"Enable UserPromptSubmit correction detection. When true, messages like 'no, use X instead' trigger a nudge to call aide_remember."},"hooks.precompact.mode":{value:"cleanup",public:!0,pro:!1,description:"PreCompact hook behavior: 'off' preserves tracking files across compaction; 'cleanup' (default) clears recalled-paths/stop-count/correction-pending so the post-compact turn re-blocks cleanly."},"hooks.visible":{value:!0,public:!0,pro:!1,description:"Surface user-facing systemMessage lines when hooks fire (soft recalls, correction detected, session-start injection, Stop checkpoints, etc). Default true so users can see what aide-memory is doing. Set to false to hide all aide-memory systemMessages \u2014 hooks still function (context injection + block enforcement unchanged). Does not affect what Claude sees."},"recall.limit":{value:20,public:!0,pro:!1,description:"Max memories returned per aide_recall call before layer-diversity balancing applies."},"recall.ensureLayerDiversity":{value:!0,public:!0,pro:!1,description:"If true, recall results are swapped to surface under-represented layers up to recall.layerDiversityMinLimit. Ensures each enabled layer gets at least some representation instead of the top-scoring one dominating."},"recall.layerDiversityMinLimit":{value:5,public:!0,pro:!1,description:"Minimum total results below which layer diversity swap kicks in. Above this threshold, natural ranking wins."},"recall.minScopeDepth":{value:1,public:!0,pro:!1,description:"Minimum fixed-prefix segment count a scope needs to surface via per-file path-recall. Scopes below this threshold surface only at SessionStart injection instead. Think of it as 'how specific must a scope be to show up when I open a file?' Default 1 is permissive \u2014 any scope with \u22651 segment (e.g. 'src/**', 'pages/**', 'packages/**') counts. Works across project shapes (src-wrapped, flat Next.js, deep monorepos). Bump to 2 if you have many broad scopes and want per-file recall quieter (broad scopes still surface at SessionStart). Bump to 3+ for very strict per-file recall."},"injection.enabled":{value:!0,public:!0,pro:!1,description:"Master switch for SessionStart dynamic injection. When true (default), the sessionStart handler loads + injects preferences / guidelines / priority:always memories into the agent's starting context; when false, the handler short-circuits before any SQLite read or template render \u2014 zero per-turn overhead from dynamic injection. The rules file still ships (static content) but carries no memory-derived content. Granular per-layer knobs (injection.preferences, injection.guidelines, etc.) only apply when this master switch is true. Flip to false if you want aide-memory's hooks + MCP tools without any session-start context injection."},"injection.preferences":{value:15,public:!0,pro:!1,description:"Max preferences injected at SessionStart. 0/false disables; number = hard cap; 'all' = every preference. Default 15 matches spec memory #297 ('top 15 most-recalled preferences'). Only honored when injection.enabled is true."},"injection.excludeScopedPreferences":{value:!1,public:!0,pro:!1,description:"If true, SessionStart injection skips preferences with a non-null scope \u2014 they surface via Read/Edit path hooks when the agent touches matching paths. Default false preserves current 'inject all preferences regardless of scope' behavior. Set to true for tighter SessionStart token usage when you have many scoped preferences. (NB: renamed from `injection.preferences.excludeScoped` to avoid key collision with `injection.preferences` which is a scalar limit, not an object.)"},"injection.technical":{value:!1,public:!0,pro:!1,description:"Inject technical-layer memories at SessionStart? Default false \u2014 technical context should surface via path hooks when relevant. Set to a number to cap, 'all' for unlimited, true for enabled-with-no-cap."},"injection.area_context":{value:!1,public:!0,pro:!1,description:"Inject area_context-layer memories at SessionStart? Default false \u2014 area context by definition is area-specific and should surface via path hooks."},"injection.guidelines":{value:"all",public:!0,pro:!1,description:"Inject guidelines at SessionStart. 'all' (default) injects every guideline regardless of scope \u2014 guidelines apply broadly so early visibility matters. Set to a number for a cap, or false to disable."},"injection.priorityAlwaysOverride":{value:!0,public:!0,pro:!1,description:"When true (default), any memory with priority='always' is injected at SessionStart regardless of layer-specific injection settings. User-marked 'always' memories surface in the ## Always section (rendered first since 0.4.3 so they survive char-cap truncation)."},"injection.maxChars":{value:1200,public:!0,pro:!1,description:"Overall character cap for the combined SessionStart injection (preferences + technical + area_context + guidelines + always). Applied after all layer sections are concatenated; truncates with '...truncated' suffix. Bump to 2000+ for richer context, drop to 600 for token-conscious sessions. Default 1200 matches the pre-0.4.3 hard-coded MAX_INJECT_CHARS constant."},"memories.hideFromGrep":{value:!0,public:!0,pro:!1,description:"Add an aide-memory-managed block to .ignore so grep/ripgrep/etc skip .aide/memories/ by default. Flipping this live triggers drift-repair on the next hook fire."},"memories.softening.threshold":{value:10,public:!0,pro:!1,description:"Total-memory count below which pre-read/pre-edit hard blocks become soft additionalContext nudges. Keeps small projects from feeling hostile. Default 10 \u2014 once you have 10+ total memories, hard blocking resumes on first-touch."},"memories.defaultShared":{value:!0,public:!0,pro:!1,description:"Default `shared` flag for new memories when the caller doesn't pass one. When true (default), aide_remember without an explicit shared param writes to `.aide/memories/preferences/shared/` (committed to repo). When false, defaults to `personal/` (gitignored). Per-call `shared: true|false` always overrides this default. Flip to false if you want personal-by-default and explicit opt-in for shared memories."}}});function $c(){return iO}function oO(t,e){let r=t;for(let i of e){if(r==null||typeof r!="object"||Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,i))return!1;r=r[i]}return!0}function aO(t,e){let r=t;for(let i of e)r=r[i];return r}function _t(t,e){let i=$c()[e];if(!i)return;let n=i.value;if(i.public!==!0||!t)return n;let o=q$.default.join(t,".aide","config.json");if(!qp.default.existsSync(o))return n;let a;try{a=JSON.parse(qp.default.readFileSync(o,"utf8"))}catch{return n}let s=e.split(".");return oO(a,s)?aO(a,s):n}function V$(){let t=$c(),e={};for(let[r,i]of Object.entries(t))i.public===!0&&(e[r]=i.value);return e}function H$(t){let e={};for(let[r,i]of Object.entries(t)){let n=r.split("."),o=e;for(let a=0;a<n.length-1;a++){let s=n[a],c=o[s];(!c||typeof c!="object"||Array.isArray(c))&&(o[s]={}),o=o[s]}o[n[n.length-1]]=i}return e}var qp,q$,iO,xc=qe(()=>{"use strict";qp=ae(require("fs")),q$=ae(require("path"));Z$();iO=F$});var Ps=v(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.regexpCode=xe.getEsmExportName=xe.getProperty=xe.safeStringify=xe.stringify=xe.strConcat=xe.addCodeArg=xe.str=xe._=xe.nil=xe._Code=xe.Name=xe.IDENTIFIER=xe._CodeOrName=void 0;var Es=class{};xe._CodeOrName=Es;xe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var li=class extends Es{constructor(e){if(super(),!xe.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};xe.Name=li;var Kt=class extends Es{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,i)=>`${r}${i}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,i)=>(i instanceof li&&(r[i.str]=(r[i.str]||0)+1),r),{})}};xe._Code=Kt;xe.nil=new Kt("");function t0(t,...e){let r=[t[0]],i=0;for(;i<e.length;)vy(r,e[i]),r.push(t[++i]);return new Kt(r)}xe._=t0;var yy=new Kt("+");function r0(t,...e){let r=[Ts(t[0])],i=0;for(;i<e.length;)r.push(yy),vy(r,e[i]),r.push(yy,Ts(t[++i]));return WD(r),new Kt(r)}xe.str=r0;function vy(t,e){e instanceof Kt?t.push(...e._items):e instanceof li?t.push(e):t.push(YD(e))}xe.addCodeArg=vy;function WD(t){let e=1;for(;e<t.length-1;){if(t[e]===yy){let r=KD(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function KD(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof li||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof li))return`"${t}${e.slice(1)}`}function XD(t,e){return e.emptyStr()?t:t.emptyStr()?e:r0`${t}${e}`}xe.strConcat=XD;function YD(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Ts(Array.isArray(t)?t.join(","):t)}function QD(t){return new Kt(Ts(t))}xe.stringify=QD;function Ts(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}xe.safeStringify=Ts;function eC(t){return typeof t=="string"&&xe.IDENTIFIER.test(t)?new Kt(`.${t}`):t0`[${t}]`}xe.getProperty=eC;function tC(t){if(typeof t=="string"&&xe.IDENTIFIER.test(t))return new Kt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}xe.getEsmExportName=tC;function rC(t){return new Kt(t.toString())}xe.regexpCode=rC});var $y=v(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.ValueScope=Rt.ValueScopeName=Rt.Scope=Rt.varKinds=Rt.UsedValueState=void 0;var zt=Ps(),_y=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},af;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(af||(Rt.UsedValueState=af={}));Rt.varKinds={const:new zt.Name("const"),let:new zt.Name("let"),var:new zt.Name("var")};var sf=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof zt.Name?e:this.name(e)}name(e){return new zt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,i;if(!((i=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||i===void 0)&&i.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Rt.Scope=sf;var cf=class extends zt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:i}){this.value=e,this.scopePath=(0,zt._)`.${new zt.Name(r)}[${i}]`}};Rt.ValueScopeName=cf;var nC=(0,zt._)`\n`,by=class extends sf{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?nC:zt.nil}}get(){return this._scope}name(e){return new cf(e,this._newName(e))}value(e,r){var i;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,a=(i=r.key)!==null&&i!==void 0?i:r.ref,s=this._values[o];if(s){let l=s.get(a);if(l)return l}else s=this._values[o]=new Map;s.set(a,n);let c=this._scope[o]||(this._scope[o]=[]),u=c.length;return c[u]=r.ref,n.setValue(r,{property:o,itemIndex:u}),n}getValue(e,r){let i=this._values[e];if(i)return i.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,zt._)`${e}${i.scopePath}`})}scopeCode(e=this._values,r,i){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,i)}_reduceValues(e,r,i={},n){let o=zt.nil;for(let a in e){let s=e[a];if(!s)continue;let c=i[a]=i[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,af.Started);let l=r(u);if(l){let d=this.opts.es5?Rt.varKinds.var:Rt.varKinds.const;o=(0,zt._)`${o}${d} ${u} = ${l};${this.opts._n}`}else if(l=n?.(u))o=(0,zt._)`${o}${l}${this.opts._n}`;else throw new _y(u);c.set(u,af.Completed)})}return o}};Rt.ValueScope=by});var ce=v(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.or=de.and=de.not=de.CodeGen=de.operators=de.varKinds=de.ValueScopeName=de.ValueScope=de.Scope=de.Name=de.regexpCode=de.stringify=de.getProperty=de.nil=de.strConcat=de.str=de._=void 0;var ye=Ps(),lr=$y(),kn=Ps();Object.defineProperty(de,"_",{enumerable:!0,get:function(){return kn._}});Object.defineProperty(de,"str",{enumerable:!0,get:function(){return kn.str}});Object.defineProperty(de,"strConcat",{enumerable:!0,get:function(){return kn.strConcat}});Object.defineProperty(de,"nil",{enumerable:!0,get:function(){return kn.nil}});Object.defineProperty(de,"getProperty",{enumerable:!0,get:function(){return kn.getProperty}});Object.defineProperty(de,"stringify",{enumerable:!0,get:function(){return kn.stringify}});Object.defineProperty(de,"regexpCode",{enumerable:!0,get:function(){return kn.regexpCode}});Object.defineProperty(de,"Name",{enumerable:!0,get:function(){return kn.Name}});var ff=$y();Object.defineProperty(de,"Scope",{enumerable:!0,get:function(){return ff.Scope}});Object.defineProperty(de,"ValueScope",{enumerable:!0,get:function(){return ff.ValueScope}});Object.defineProperty(de,"ValueScopeName",{enumerable:!0,get:function(){return ff.ValueScopeName}});Object.defineProperty(de,"varKinds",{enumerable:!0,get:function(){return ff.varKinds}});de.operators={GT:new ye._Code(">"),GTE:new ye._Code(">="),LT:new ye._Code("<"),LTE:new ye._Code("<="),EQ:new ye._Code("==="),NEQ:new ye._Code("!=="),NOT:new ye._Code("!"),OR:new ye._Code("||"),AND:new ye._Code("&&"),ADD:new ye._Code("+")};var Hr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},xy=class extends Hr{constructor(e,r,i){super(),this.varKind=e,this.name=r,this.rhs=i}render({es5:e,_n:r}){let i=e?lr.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Eo(this.rhs,e,r)),this}get names(){return this.rhs instanceof ye._CodeOrName?this.rhs.names:{}}},uf=class extends Hr{constructor(e,r,i){super(),this.lhs=e,this.rhs=r,this.sideEffects=i}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ye.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Eo(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ye.Name?{}:{...this.lhs.names};return df(e,this.rhs)}},Sy=class extends uf{constructor(e,r,i,n){super(e,i,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},ky=class extends Hr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},wy=class extends Hr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Ey=class extends Hr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Ty=class extends Hr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Eo(this.code,e,r),this}get names(){return this.code instanceof ye._CodeOrName?this.code.names:{}}},Is=class extends Hr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,i)=>r+i.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let i=e[r].optimizeNodes();Array.isArray(i)?e.splice(r,1,...i):i?e[r]=i:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:i}=this,n=i.length;for(;n--;){let o=i[n];o.optimizeNames(e,r)||(iC(e,o.names),i.splice(n,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>pi(e,r.names),{})}},Br=class extends Is{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Py=class extends Is{},wo=class extends Br{};wo.kind="else";var di=class t extends Br{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let i=r.optimizeNodes();r=this.else=Array.isArray(i)?new wo(i):i}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(n0(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Eo(this.condition,e,r),this}get names(){let e=super.names;return df(e,this.condition),this.else&&pi(e,this.else.names),e}};di.kind="if";var fi=class extends Br{};fi.kind="for";var Iy=class extends fi{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Eo(this.iteration,e,r),this}get names(){return pi(super.names,this.iteration.names)}},zy=class extends fi{constructor(e,r,i,n){super(),this.varKind=e,this.name=r,this.from=i,this.to=n}render(e){let r=e.es5?lr.varKinds.var:this.varKind,{name:i,from:n,to:o}=this;return`for(${r} ${i}=${n}; ${i}<${o}; ${i}++)`+super.render(e)}get names(){let e=df(super.names,this.from);return df(e,this.to)}},lf=class extends fi{constructor(e,r,i,n){super(),this.loop=e,this.varKind=r,this.name=i,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Eo(this.iterable,e,r),this}get names(){return pi(super.names,this.iterable.names)}},zs=class extends Br{constructor(e,r,i){super(),this.name=e,this.args=r,this.async=i}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};zs.kind="func";var Rs=class extends Is{render(e){return"return "+super.render(e)}};Rs.kind="return";var Ry=class extends Br{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var i,n;return super.optimizeNames(e,r),(i=this.catch)===null||i===void 0||i.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&pi(e,this.catch.names),this.finally&&pi(e,this.finally.names),e}},Os=class extends Br{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Os.kind="catch";var As=class extends Br{render(e){return"finally"+super.render(e)}};As.kind="finally";var Oy=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
99
|
+
`,a=[i],s=[];return r?.layer&&(s.push("m.layer = ?"),a.push(r.layer)),s.length>0&&(o+=" WHERE "+s.join(" AND ")),o+=" ORDER BY fts.rank",o+=" LIMIT ?",a.push(n),this.db.prepare(o).all(...a).map(u=>this.rowToMemory(u))}searchLike(e,r){if(!e||!e.trim())return[];let i=["(what LIKE ? OR why LIKE ?)"],n=`%${e}%`,o=[n,n];r?.layer&&(i.push("layer = ?"),o.push(r.layer));let a="SELECT * FROM memories WHERE "+i.join(" AND ");a+=" ORDER BY created_at DESC, id DESC";let s=r?.limit??50;a+=" LIMIT ?",o.push(s);let u=this.db.prepare(a).all(...o).map(l=>this.rowToMemory(l));return u.length<3&&this.embeddingService?.isReady(),u}async searchWithEmbeddings(e,r){let i=r?.limit??50,n=r?.mode??"auto";if(n==="semantic"){if(!this.embeddingService?.isReady())return[];try{let a=await this.embeddingService.semanticSearch(this.db,e,i),s=[];for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!(r?.layer&&u.layer!==r.layer)&&(s.push(u),s.length>=i))break}return this.logEvent("search_performed","semantic"),s}catch{return[]}}if(n==="keyword")return this.search(e,r);let o=this.search(e,r);if(o.length<3&&this.embeddingService?.isReady())try{let a=await this.embeddingService.semanticSearch(this.db,e,i),s=new Set(o.map(c=>c.id));for(let c of a){if(c.score<.3)continue;let u=this.getByUuid(c.uuid);if(u&&!s.has(u.id)&&!(r?.layer&&u.layer!==r.layer)&&(o.push(u),s.add(u.id),o.length>=i))break}}catch{}return o}pruneOld(e){let r=new Date(Date.now()-e*864e5).toISOString();if(this.memoriesDir){let n=this.db.prepare("SELECT uuid, layer, shared FROM memories WHERE created_at < ?").all(r);for(let o of n)this.deleteMemoryFile(o.uuid,o.layer,o.shared===1)}let i=this.db.prepare("DELETE FROM memories WHERE created_at < ?").run(r);return this.memoriesDir&&this.updateDirHash(),i.changes}close(){this.analytics&&this.analytics.shutdown(),this.db.close()}getProjectRoot(){return this.projectRoot}get hasFileStorage(){return this.memoriesDir!==null}get memoriesPath(){return this.memoriesDir}rowToMemory(e){return{id:e.id,uuid:e.uuid,layer:e.layer,what:e.what,why:e.why,scope:e.scope,context_label:e.context_label,contributor:e.contributor,tags:e.tags?JSON.parse(e.tags):[],source:e.source,shared:e.shared===1,priority:e.priority==="always"?"always":"normal",generated_by:e.generated_by?JSON.parse(e.generated_by):null,derived_from:e.derived_from?JSON.parse(e.derived_from):null,created_at:e.created_at,updated_at:e.updated_at,recalled_count:e.recalled_count,last_recalled_at:e.last_recalled_at}}}});var F$,Z$=qe(()=>{F$={"hooks.read.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-read hard-blocks per file path per session. 0 disables the pre-read hook entirely. 1 is the default and fires a block on the first read of each file that has scoped memories."},"hooks.edit.maxBlocks":{value:1,public:!0,pro:!1,description:"Max pre-edit hard-blocks per file path per session. 0 disables the pre-edit hook entirely. 1 is the default."},"hooks.stop.schedule":{value:[{until:9,every:3},{until:29,every:5},{every:10}],public:!0,pro:!1,description:"Phased interval schedule for the Stop hook's 'worth remembering?' nudge. Each entry = {until, every}. Default ramps from every-3-turns for first 9 turns \u2192 every-5 for turns 10-29 \u2192 every-10 afterwards."},"hooks.search.mode":{value:"soft",public:!0,pro:!1,description:"Pre-search hook mode: 'off' (no nudge), 'soft' (additionalContext only, default), 'block' (hard decision:block envelope)."},"hooks.correction.enabled":{value:!0,public:!0,pro:!1,description:"Enable UserPromptSubmit correction detection. When true, messages like 'no, use X instead' trigger a nudge to call aide_remember."},"hooks.correction.escalate":{value:"off",public:!0,pro:!1,description:"When a correction is detected, optionally write a correction-pending flag so the next Stop fire reminds the agent if the correction wasn't stored. 'off' (default) \u2014 never reminds; correction surfaces only as the soft UserPromptSubmit hint at detection time. 'block' \u2014 flag is written and the next Stop fires decision:block with the reminder, regardless of hooks.stop.mode. Master switch: hooks.correction.enabled=false disables the entire correction system including this. (A 'soft' value existed in spec drafts but was dropped \u2014 Claude Code's Stop hook protocol doesn't accept hookSpecificOutput.additionalContext, so a soft Stop emit is impossible. Use the always-on UserPromptSubmit soft hint as the soft channel; escalate to 'block' only when you want an explicit follow-up reminder.)"},"hooks.stop.mode":{value:"block",public:!0,pro:!1,description:"How the scheduled Stop checkpoint surfaces. 'block' (default) uses decision:block + a softened reason prompt + chrome systemMessage. The Claude Code TUI collapses the 'Stop hook error:' label behind ctrl+o when systemMessage is present, so the brand chrome is the primary visible line. 'off' skips the scheduled checkpoint entirely (zero Stop noise). Frequency is still controlled by hooks.stop.schedule. (A 'soft' mode existed in spec drafts but was dropped \u2014 Claude Code's Stop hook protocol doesn't accept hookSpecificOutput.additionalContext, so 'block' is the only way to deliver text to the agent on Stop.) When a correction-pending flag is set and hooks.correction.escalate='block', that branch wins and the scheduled checkpoint is skipped that turn."},"hooks.precompact.mode":{value:"cleanup",public:!0,pro:!1,description:"PreCompact hook behavior: 'off' preserves tracking files across compaction; 'cleanup' (default) clears recalled-paths/stop-count/correction-pending so the post-compact turn re-blocks cleanly."},"hooks.visible":{value:!0,public:!0,pro:!1,description:"Surface user-facing systemMessage lines when hooks fire (soft recalls, correction detected, session-start injection, Stop checkpoints, etc). Default true so users can see what aide-memory is doing. Set to false to hide all aide-memory systemMessages \u2014 hooks still function (context injection + block enforcement unchanged). Does not affect what Claude sees."},"recall.limit":{value:20,public:!0,pro:!1,description:"Max memories returned per aide_recall call before layer-diversity balancing applies."},"recall.ensureLayerDiversity":{value:!0,public:!0,pro:!1,description:"If true, recall results are swapped to surface under-represented layers up to recall.layerDiversityMinLimit. Ensures each enabled layer gets at least some representation instead of the top-scoring one dominating."},"recall.layerDiversityMinLimit":{value:5,public:!0,pro:!1,description:"Minimum total results below which layer diversity swap kicks in. Above this threshold, natural ranking wins."},"recall.minScopeDepth":{value:1,public:!0,pro:!1,description:"Minimum fixed-prefix segment count a scope needs to surface via per-file path-recall. Scopes below this threshold surface only at SessionStart injection instead. Think of it as 'how specific must a scope be to show up when I open a file?' Default 1 is permissive \u2014 any scope with \u22651 segment (e.g. 'src/**', 'pages/**', 'packages/**') counts. Works across project shapes (src-wrapped, flat Next.js, deep monorepos). Bump to 2 if you have many broad scopes and want per-file recall quieter (broad scopes still surface at SessionStart). Bump to 3+ for very strict per-file recall."},"injection.enabled":{value:!0,public:!0,pro:!1,description:"Master switch for SessionStart dynamic injection. When true (default), the sessionStart handler loads + injects preferences / guidelines / priority:always memories into the agent's starting context; when false, the handler short-circuits before any SQLite read or template render \u2014 zero per-turn overhead from dynamic injection. The rules file still ships (static content) but carries no memory-derived content. Granular per-layer knobs (injection.preferences, injection.guidelines, etc.) only apply when this master switch is true. Flip to false if you want aide-memory's hooks + MCP tools without any session-start context injection."},"injection.preferences":{value:15,public:!0,pro:!1,description:"Max preferences injected at SessionStart. 0/false disables; number = hard cap; 'all' = every preference. Default 15 matches spec memory #297 ('top 15 most-recalled preferences'). Only honored when injection.enabled is true."},"injection.excludeScopedPreferences":{value:!1,public:!0,pro:!1,description:"If true, SessionStart injection skips preferences with a non-null scope \u2014 they surface via Read/Edit path hooks when the agent touches matching paths. Default false preserves current 'inject all preferences regardless of scope' behavior. Set to true for tighter SessionStart token usage when you have many scoped preferences. (NB: renamed from `injection.preferences.excludeScoped` to avoid key collision with `injection.preferences` which is a scalar limit, not an object.)"},"injection.technical":{value:!1,public:!0,pro:!1,description:"Inject technical-layer memories at SessionStart? Default false \u2014 technical context should surface via path hooks when relevant. Set to a number to cap, 'all' for unlimited, true for enabled-with-no-cap."},"injection.area_context":{value:!1,public:!0,pro:!1,description:"Inject area_context-layer memories at SessionStart? Default false \u2014 area context by definition is area-specific and should surface via path hooks."},"injection.guidelines":{value:"all",public:!0,pro:!1,description:"Inject guidelines at SessionStart. 'all' (default) injects every guideline regardless of scope \u2014 guidelines apply broadly so early visibility matters. Set to a number for a cap, or false to disable."},"injection.priorityAlwaysOverride":{value:!0,public:!0,pro:!1,description:"When true (default), any memory with priority='always' is injected at SessionStart regardless of layer-specific injection settings. User-marked 'always' memories surface in the ## Always section (rendered first since 0.4.3 so they survive char-cap truncation)."},"injection.maxChars":{value:1200,public:!0,pro:!1,description:"Overall character cap for the combined SessionStart injection (preferences + technical + area_context + guidelines + always). Applied after all layer sections are concatenated; truncates with '...truncated' suffix. Bump to 2000+ for richer context, drop to 600 for token-conscious sessions. Default 1200 matches the pre-0.4.3 hard-coded MAX_INJECT_CHARS constant."},"memories.hideFromGrep":{value:!0,public:!0,pro:!1,description:"Add an aide-memory-managed block to .ignore so grep/ripgrep/etc skip .aide/memories/ by default. Flipping this live triggers drift-repair on the next hook fire."},"memories.softening.threshold":{value:10,public:!0,pro:!1,description:"Total-memory count below which pre-read/pre-edit hard blocks become soft additionalContext nudges. Keeps small projects from feeling hostile. Default 10 \u2014 once you have 10+ total memories, hard blocking resumes on first-touch."},"memories.defaultShared":{value:!0,public:!0,pro:!1,description:"Default `shared` flag for new memories when the caller doesn't pass one. When true (default), aide_remember without an explicit shared param writes to `.aide/memories/preferences/shared/` (committed to repo). When false, defaults to `personal/` (gitignored). Per-call `shared: true|false` always overrides this default. Flip to false if you want personal-by-default and explicit opt-in for shared memories."}}});function $c(){return iO}function oO(t,e){let r=t;for(let i of e){if(r==null||typeof r!="object"||Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,i))return!1;r=r[i]}return!0}function aO(t,e){let r=t;for(let i of e)r=r[i];return r}function _t(t,e){let i=$c()[e];if(!i)return;let n=i.value;if(i.public!==!0||!t)return n;let o=q$.default.join(t,".aide","config.json");if(!qp.default.existsSync(o))return n;let a;try{a=JSON.parse(qp.default.readFileSync(o,"utf8"))}catch{return n}let s=e.split(".");return oO(a,s)?aO(a,s):n}function V$(){let t=$c(),e={};for(let[r,i]of Object.entries(t))i.public===!0&&(e[r]=i.value);return e}function H$(t){let e={};for(let[r,i]of Object.entries(t)){let n=r.split("."),o=e;for(let a=0;a<n.length-1;a++){let s=n[a],c=o[s];(!c||typeof c!="object"||Array.isArray(c))&&(o[s]={}),o=o[s]}o[n[n.length-1]]=i}return e}var qp,q$,iO,xc=qe(()=>{"use strict";qp=ae(require("fs")),q$=ae(require("path"));Z$();iO=F$});var Ps=v(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.regexpCode=xe.getEsmExportName=xe.getProperty=xe.safeStringify=xe.stringify=xe.strConcat=xe.addCodeArg=xe.str=xe._=xe.nil=xe._Code=xe.Name=xe.IDENTIFIER=xe._CodeOrName=void 0;var Es=class{};xe._CodeOrName=Es;xe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var li=class extends Es{constructor(e){if(super(),!xe.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};xe.Name=li;var Kt=class extends Es{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,i)=>`${r}${i}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,i)=>(i instanceof li&&(r[i.str]=(r[i.str]||0)+1),r),{})}};xe._Code=Kt;xe.nil=new Kt("");function t0(t,...e){let r=[t[0]],i=0;for(;i<e.length;)vy(r,e[i]),r.push(t[++i]);return new Kt(r)}xe._=t0;var yy=new Kt("+");function r0(t,...e){let r=[Ts(t[0])],i=0;for(;i<e.length;)r.push(yy),vy(r,e[i]),r.push(yy,Ts(t[++i]));return WD(r),new Kt(r)}xe.str=r0;function vy(t,e){e instanceof Kt?t.push(...e._items):e instanceof li?t.push(e):t.push(YD(e))}xe.addCodeArg=vy;function WD(t){let e=1;for(;e<t.length-1;){if(t[e]===yy){let r=KD(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function KD(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof li||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof li))return`"${t}${e.slice(1)}`}function XD(t,e){return e.emptyStr()?t:t.emptyStr()?e:r0`${t}${e}`}xe.strConcat=XD;function YD(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Ts(Array.isArray(t)?t.join(","):t)}function QD(t){return new Kt(Ts(t))}xe.stringify=QD;function Ts(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}xe.safeStringify=Ts;function eC(t){return typeof t=="string"&&xe.IDENTIFIER.test(t)?new Kt(`.${t}`):t0`[${t}]`}xe.getProperty=eC;function tC(t){if(typeof t=="string"&&xe.IDENTIFIER.test(t))return new Kt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}xe.getEsmExportName=tC;function rC(t){return new Kt(t.toString())}xe.regexpCode=rC});var $y=v(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.ValueScope=Rt.ValueScopeName=Rt.Scope=Rt.varKinds=Rt.UsedValueState=void 0;var zt=Ps(),_y=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},af;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(af||(Rt.UsedValueState=af={}));Rt.varKinds={const:new zt.Name("const"),let:new zt.Name("let"),var:new zt.Name("var")};var sf=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof zt.Name?e:this.name(e)}name(e){return new zt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,i;if(!((i=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||i===void 0)&&i.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Rt.Scope=sf;var cf=class extends zt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:i}){this.value=e,this.scopePath=(0,zt._)`.${new zt.Name(r)}[${i}]`}};Rt.ValueScopeName=cf;var nC=(0,zt._)`\n`,by=class extends sf{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?nC:zt.nil}}get(){return this._scope}name(e){return new cf(e,this._newName(e))}value(e,r){var i;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,a=(i=r.key)!==null&&i!==void 0?i:r.ref,s=this._values[o];if(s){let l=s.get(a);if(l)return l}else s=this._values[o]=new Map;s.set(a,n);let c=this._scope[o]||(this._scope[o]=[]),u=c.length;return c[u]=r.ref,n.setValue(r,{property:o,itemIndex:u}),n}getValue(e,r){let i=this._values[e];if(i)return i.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,zt._)`${e}${i.scopePath}`})}scopeCode(e=this._values,r,i){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,i)}_reduceValues(e,r,i={},n){let o=zt.nil;for(let a in e){let s=e[a];if(!s)continue;let c=i[a]=i[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,af.Started);let l=r(u);if(l){let d=this.opts.es5?Rt.varKinds.var:Rt.varKinds.const;o=(0,zt._)`${o}${d} ${u} = ${l};${this.opts._n}`}else if(l=n?.(u))o=(0,zt._)`${o}${l}${this.opts._n}`;else throw new _y(u);c.set(u,af.Completed)})}return o}};Rt.ValueScope=by});var ce=v(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.or=de.and=de.not=de.CodeGen=de.operators=de.varKinds=de.ValueScopeName=de.ValueScope=de.Scope=de.Name=de.regexpCode=de.stringify=de.getProperty=de.nil=de.strConcat=de.str=de._=void 0;var ye=Ps(),lr=$y(),kn=Ps();Object.defineProperty(de,"_",{enumerable:!0,get:function(){return kn._}});Object.defineProperty(de,"str",{enumerable:!0,get:function(){return kn.str}});Object.defineProperty(de,"strConcat",{enumerable:!0,get:function(){return kn.strConcat}});Object.defineProperty(de,"nil",{enumerable:!0,get:function(){return kn.nil}});Object.defineProperty(de,"getProperty",{enumerable:!0,get:function(){return kn.getProperty}});Object.defineProperty(de,"stringify",{enumerable:!0,get:function(){return kn.stringify}});Object.defineProperty(de,"regexpCode",{enumerable:!0,get:function(){return kn.regexpCode}});Object.defineProperty(de,"Name",{enumerable:!0,get:function(){return kn.Name}});var ff=$y();Object.defineProperty(de,"Scope",{enumerable:!0,get:function(){return ff.Scope}});Object.defineProperty(de,"ValueScope",{enumerable:!0,get:function(){return ff.ValueScope}});Object.defineProperty(de,"ValueScopeName",{enumerable:!0,get:function(){return ff.ValueScopeName}});Object.defineProperty(de,"varKinds",{enumerable:!0,get:function(){return ff.varKinds}});de.operators={GT:new ye._Code(">"),GTE:new ye._Code(">="),LT:new ye._Code("<"),LTE:new ye._Code("<="),EQ:new ye._Code("==="),NEQ:new ye._Code("!=="),NOT:new ye._Code("!"),OR:new ye._Code("||"),AND:new ye._Code("&&"),ADD:new ye._Code("+")};var Hr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},xy=class extends Hr{constructor(e,r,i){super(),this.varKind=e,this.name=r,this.rhs=i}render({es5:e,_n:r}){let i=e?lr.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Eo(this.rhs,e,r)),this}get names(){return this.rhs instanceof ye._CodeOrName?this.rhs.names:{}}},uf=class extends Hr{constructor(e,r,i){super(),this.lhs=e,this.rhs=r,this.sideEffects=i}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ye.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Eo(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ye.Name?{}:{...this.lhs.names};return df(e,this.rhs)}},Sy=class extends uf{constructor(e,r,i,n){super(e,i,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},ky=class extends Hr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},wy=class extends Hr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Ey=class extends Hr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Ty=class extends Hr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Eo(this.code,e,r),this}get names(){return this.code instanceof ye._CodeOrName?this.code.names:{}}},Is=class extends Hr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,i)=>r+i.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let i=e[r].optimizeNodes();Array.isArray(i)?e.splice(r,1,...i):i?e[r]=i:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:i}=this,n=i.length;for(;n--;){let o=i[n];o.optimizeNames(e,r)||(iC(e,o.names),i.splice(n,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>pi(e,r.names),{})}},Br=class extends Is{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Py=class extends Is{},wo=class extends Br{};wo.kind="else";var di=class t extends Br{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let i=r.optimizeNodes();r=this.else=Array.isArray(i)?new wo(i):i}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(n0(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Eo(this.condition,e,r),this}get names(){let e=super.names;return df(e,this.condition),this.else&&pi(e,this.else.names),e}};di.kind="if";var fi=class extends Br{};fi.kind="for";var Iy=class extends fi{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Eo(this.iteration,e,r),this}get names(){return pi(super.names,this.iteration.names)}},zy=class extends fi{constructor(e,r,i,n){super(),this.varKind=e,this.name=r,this.from=i,this.to=n}render(e){let r=e.es5?lr.varKinds.var:this.varKind,{name:i,from:n,to:o}=this;return`for(${r} ${i}=${n}; ${i}<${o}; ${i}++)`+super.render(e)}get names(){let e=df(super.names,this.from);return df(e,this.to)}},lf=class extends fi{constructor(e,r,i,n){super(),this.loop=e,this.varKind=r,this.name=i,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Eo(this.iterable,e,r),this}get names(){return pi(super.names,this.iterable.names)}},zs=class extends Br{constructor(e,r,i){super(),this.name=e,this.args=r,this.async=i}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};zs.kind="func";var Rs=class extends Is{render(e){return"return "+super.render(e)}};Rs.kind="return";var Ry=class extends Br{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var i,n;return super.optimizeNames(e,r),(i=this.catch)===null||i===void 0||i.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&pi(e,this.catch.names),this.finally&&pi(e,this.finally.names),e}},Os=class extends Br{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Os.kind="catch";var As=class extends Br{render(e){return"finally"+super.render(e)}};As.kind="finally";var Oy=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
100
100
|
`:""},this._extScope=e,this._scope=new lr.Scope({parent:e}),this._nodes=[new Py]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let i=this._extScope.value(e,r);return(this._values[i.prefix]||(this._values[i.prefix]=new Set)).add(i),i}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,i,n){let o=this._scope.toName(r);return i!==void 0&&n&&(this._constants[o.str]=i),this._leafNode(new xy(e,o,i)),o}const(e,r,i){return this._def(lr.varKinds.const,e,r,i)}let(e,r,i){return this._def(lr.varKinds.let,e,r,i)}var(e,r,i){return this._def(lr.varKinds.var,e,r,i)}assign(e,r,i){return this._leafNode(new uf(e,r,i))}add(e,r){return this._leafNode(new Sy(e,de.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ye.nil&&this._leafNode(new Ty(e)),this}object(...e){let r=["{"];for(let[i,n]of e)r.length>1&&r.push(","),r.push(i),(i!==n||this.opts.es5)&&(r.push(":"),(0,ye.addCodeArg)(r,n));return r.push("}"),new ye._Code(r)}if(e,r,i){if(this._blockNode(new di(e)),r&&i)this.code(r).else().code(i).endIf();else if(r)this.code(r).endIf();else if(i)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new di(e))}else(){return this._elseNode(new wo)}endIf(){return this._endBlockNode(di,wo)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Iy(e),r)}forRange(e,r,i,n,o=this.opts.es5?lr.varKinds.var:lr.varKinds.let){let a=this._scope.toName(e);return this._for(new zy(o,a,r,i),()=>n(a))}forOf(e,r,i,n=lr.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let a=r instanceof ye.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ye._)`${a}.length`,s=>{this.var(o,(0,ye._)`${a}[${s}]`),i(o)})}return this._for(new lf("of",n,o,r),()=>i(o))}forIn(e,r,i,n=this.opts.es5?lr.varKinds.var:lr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ye._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new lf("in",n,o,r),()=>i(o))}endFor(){return this._endBlockNode(fi)}label(e){return this._leafNode(new ky(e))}break(e){return this._leafNode(new wy(e))}return(e){let r=new Rs;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Rs)}try(e,r,i){if(!r&&!i)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new Ry;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new Os(o),r(o)}return i&&(this._currNode=n.finally=new As,this.code(i)),this._endBlockNode(Os,As)}throw(e){return this._leafNode(new Ey(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let i=this._nodes.length-r;if(i<0||e!==void 0&&i!==e)throw new Error(`CodeGen: wrong number of nodes: ${i} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ye.nil,i,n){return this._blockNode(new zs(e,r,i)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(zs)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let i=this._currNode;if(i instanceof e||r&&i instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof di))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};de.CodeGen=Oy;function pi(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function df(t,e){return e instanceof ye._CodeOrName?pi(t,e.names):t}function Eo(t,e,r){if(t instanceof ye.Name)return i(t);if(!n(t))return t;return new ye._Code(t._items.reduce((o,a)=>(a instanceof ye.Name&&(a=i(a)),a instanceof ye._Code?o.push(...a._items):o.push(a),o),[]));function i(o){let a=r[o.str];return a===void 0||e[o.str]!==1?o:(delete e[o.str],a)}function n(o){return o instanceof ye._Code&&o._items.some(a=>a instanceof ye.Name&&e[a.str]===1&&r[a.str]!==void 0)}}function iC(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function n0(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ye._)`!${Ay(t)}`}de.not=n0;var oC=i0(de.operators.AND);function aC(...t){return t.reduce(oC)}de.and=aC;var sC=i0(de.operators.OR);function cC(...t){return t.reduce(sC)}de.or=cC;function i0(t){return(e,r)=>e===ye.nil?r:r===ye.nil?e:(0,ye._)`${Ay(e)} ${t} ${Ay(r)}`}function Ay(t){return t instanceof ye.Name?t:(0,ye._)`(${t})`}});var ve=v(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.checkStrictMode=pe.getErrorPath=pe.Type=pe.useFunc=pe.setEvaluated=pe.evaluatedPropsToName=pe.mergeEvaluated=pe.eachItem=pe.unescapeJsonPointer=pe.escapeJsonPointer=pe.escapeFragment=pe.unescapeFragment=pe.schemaRefOrVal=pe.schemaHasRulesButRef=pe.schemaHasRules=pe.checkUnknownRules=pe.alwaysValidSchema=pe.toHash=void 0;var De=ce(),uC=Ps();function lC(t){let e={};for(let r of t)e[r]=!0;return e}pe.toHash=lC;function dC(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(s0(t,e),!c0(e,t.self.RULES.all))}pe.alwaysValidSchema=dC;function s0(t,e=t.schema){let{opts:r,self:i}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=i.RULES.keywords;for(let o in e)n[o]||d0(t,`unknown keyword: "${o}"`)}pe.checkUnknownRules=s0;function c0(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}pe.schemaHasRules=c0;function fC(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}pe.schemaHasRulesButRef=fC;function pC({topSchemaRef:t,schemaPath:e},r,i,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,De._)`${r}`}return(0,De._)`${t}${e}${(0,De.getProperty)(i)}`}pe.schemaRefOrVal=pC;function mC(t){return u0(decodeURIComponent(t))}pe.unescapeFragment=mC;function hC(t){return encodeURIComponent(Ny(t))}pe.escapeFragment=hC;function Ny(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}pe.escapeJsonPointer=Ny;function u0(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}pe.unescapeJsonPointer=u0;function gC(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}pe.eachItem=gC;function o0({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:i}){return(n,o,a,s)=>{let c=a===void 0?o:a instanceof De.Name?(o instanceof De.Name?t(n,o,a):e(n,o,a),a):o instanceof De.Name?(e(n,a,o),o):r(o,a);return s===De.Name&&!(c instanceof De.Name)?i(n,c):c}}pe.mergeEvaluated={props:o0({mergeNames:(t,e,r)=>t.if((0,De._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,De._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,De._)`${r} || {}`).code((0,De._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,De._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,De._)`${r} || {}`),Dy(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:l0}),items:o0({mergeNames:(t,e,r)=>t.if((0,De._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,De._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,De._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,De._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function l0(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,De._)`{}`);return e!==void 0&&Dy(t,r,e),r}pe.evaluatedPropsToName=l0;function Dy(t,e,r){Object.keys(r).forEach(i=>t.assign((0,De._)`${e}${(0,De.getProperty)(i)}`,!0))}pe.setEvaluated=Dy;var a0={};function yC(t,e){return t.scopeValue("func",{ref:e,code:a0[e.code]||(a0[e.code]=new uC._Code(e.code))})}pe.useFunc=yC;var jy;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(jy||(pe.Type=jy={}));function vC(t,e,r){if(t instanceof De.Name){let i=e===jy.Num;return r?i?(0,De._)`"[" + ${t} + "]"`:(0,De._)`"['" + ${t} + "']"`:i?(0,De._)`"/" + ${t}`:(0,De._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,De.getProperty)(t).toString():"/"+Ny(t)}pe.getErrorPath=vC;function d0(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}pe.checkStrictMode=d0});var Jr=v(Cy=>{"use strict";Object.defineProperty(Cy,"__esModule",{value:!0});var ft=ce(),_C={data:new ft.Name("data"),valCxt:new ft.Name("valCxt"),instancePath:new ft.Name("instancePath"),parentData:new ft.Name("parentData"),parentDataProperty:new ft.Name("parentDataProperty"),rootData:new ft.Name("rootData"),dynamicAnchors:new ft.Name("dynamicAnchors"),vErrors:new ft.Name("vErrors"),errors:new ft.Name("errors"),this:new ft.Name("this"),self:new ft.Name("self"),scope:new ft.Name("scope"),json:new ft.Name("json"),jsonPos:new ft.Name("jsonPos"),jsonLen:new ft.Name("jsonLen"),jsonPart:new ft.Name("jsonPart")};Cy.default=_C});var js=v(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.extendErrors=pt.resetErrorsCount=pt.reportExtraError=pt.reportError=pt.keyword$DataError=pt.keywordError=void 0;var _e=ce(),pf=ve(),kt=Jr();pt.keywordError={message:({keyword:t})=>(0,_e.str)`must pass "${t}" keyword validation`};pt.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,_e.str)`"${t}" keyword must be ${e} ($data)`:(0,_e.str)`"${t}" keyword is invalid ($data)`};function bC(t,e=pt.keywordError,r,i){let{it:n}=t,{gen:o,compositeRule:a,allErrors:s}=n,c=m0(t,e,r);i??(a||s)?f0(o,c):p0(n,(0,_e._)`[${c}]`)}pt.reportError=bC;function $C(t,e=pt.keywordError,r){let{it:i}=t,{gen:n,compositeRule:o,allErrors:a}=i,s=m0(t,e,r);f0(n,s),o||a||p0(i,kt.default.vErrors)}pt.reportExtraError=$C;function xC(t,e){t.assign(kt.default.errors,e),t.if((0,_e._)`${kt.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,_e._)`${kt.default.vErrors}.length`,e),()=>t.assign(kt.default.vErrors,null)))}pt.resetErrorsCount=xC;function SC({gen:t,keyword:e,schemaValue:r,data:i,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let a=t.name("err");t.forRange("i",n,kt.default.errors,s=>{t.const(a,(0,_e._)`${kt.default.vErrors}[${s}]`),t.if((0,_e._)`${a}.instancePath === undefined`,()=>t.assign((0,_e._)`${a}.instancePath`,(0,_e.strConcat)(kt.default.instancePath,o.errorPath))),t.assign((0,_e._)`${a}.schemaPath`,(0,_e.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,_e._)`${a}.schema`,r),t.assign((0,_e._)`${a}.data`,i))})}pt.extendErrors=SC;function f0(t,e){let r=t.const("err",e);t.if((0,_e._)`${kt.default.vErrors} === null`,()=>t.assign(kt.default.vErrors,(0,_e._)`[${r}]`),(0,_e._)`${kt.default.vErrors}.push(${r})`),t.code((0,_e._)`${kt.default.errors}++`)}function p0(t,e){let{gen:r,validateName:i,schemaEnv:n}=t;n.$async?r.throw((0,_e._)`new ${t.ValidationError}(${e})`):(r.assign((0,_e._)`${i}.errors`,e),r.return(!1))}var mi={keyword:new _e.Name("keyword"),schemaPath:new _e.Name("schemaPath"),params:new _e.Name("params"),propertyName:new _e.Name("propertyName"),message:new _e.Name("message"),schema:new _e.Name("schema"),parentSchema:new _e.Name("parentSchema")};function m0(t,e,r){let{createErrors:i}=t.it;return i===!1?(0,_e._)`{}`:kC(t,e,r)}function kC(t,e,r={}){let{gen:i,it:n}=t,o=[wC(n,r),EC(t,r)];return TC(t,e,o),i.object(...o)}function wC({errorPath:t},{instancePath:e}){let r=e?(0,_e.str)`${t}${(0,pf.getErrorPath)(e,pf.Type.Str)}`:t;return[kt.default.instancePath,(0,_e.strConcat)(kt.default.instancePath,r)]}function EC({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:i}){let n=i?e:(0,_e.str)`${e}/${t}`;return r&&(n=(0,_e.str)`${n}${(0,pf.getErrorPath)(r,pf.Type.Str)}`),[mi.schemaPath,n]}function TC(t,{params:e,message:r},i){let{keyword:n,data:o,schemaValue:a,it:s}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=s;i.push([mi.keyword,n],[mi.params,typeof e=="function"?e(t):e||(0,_e._)`{}`]),c.messages&&i.push([mi.message,typeof r=="function"?r(t):r]),c.verbose&&i.push([mi.schema,a],[mi.parentSchema,(0,_e._)`${l}${d}`],[kt.default.data,o]),u&&i.push([mi.propertyName,u])}});var g0=v(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.boolOrEmptySchema=To.topBoolOrEmptySchema=void 0;var PC=js(),IC=ce(),zC=Jr(),RC={message:"boolean schema is false"};function OC(t){let{gen:e,schema:r,validateName:i}=t;r===!1?h0(t,!1):typeof r=="object"&&r.$async===!0?e.return(zC.default.data):(e.assign((0,IC._)`${i}.errors`,null),e.return(!0))}To.topBoolOrEmptySchema=OC;function AC(t,e){let{gen:r,schema:i}=t;i===!1?(r.var(e,!1),h0(t)):r.var(e,!0)}To.boolOrEmptySchema=AC;function h0(t,e){let{gen:r,data:i}=t,n={gen:r,keyword:"false schema",data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,PC.reportError)(n,RC,void 0,e)}});var My=v(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.getRules=Po.isJSONType=void 0;var jC=["string","number","integer","boolean","null","object","array"],NC=new Set(jC);function DC(t){return typeof t=="string"&&NC.has(t)}Po.isJSONType=DC;function CC(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Po.getRules=CC});var Uy=v(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.shouldUseRule=wn.shouldUseGroup=wn.schemaHasRulesForType=void 0;function MC({schema:t,self:e},r){let i=e.RULES.types[r];return i&&i!==!0&&y0(t,i)}wn.schemaHasRulesForType=MC;function y0(t,e){return e.rules.some(r=>v0(t,r))}wn.shouldUseGroup=y0;function v0(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(i=>t[i]!==void 0))}wn.shouldUseRule=v0});var Ns=v(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.reportTypeError=mt.checkDataTypes=mt.checkDataType=mt.coerceAndCheckDataType=mt.getJSONTypes=mt.getSchemaTypes=mt.DataType=void 0;var UC=My(),LC=Uy(),ZC=js(),se=ce(),_0=ve(),Io;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Io||(mt.DataType=Io={}));function FC(t){let e=b0(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}mt.getSchemaTypes=FC;function b0(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(UC.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}mt.getJSONTypes=b0;function qC(t,e){let{gen:r,data:i,opts:n}=t,o=VC(e,n.coerceTypes),a=e.length>0&&!(o.length===0&&e.length===1&&(0,LC.schemaHasRulesForType)(t,e[0]));if(a){let s=Zy(e,i,n.strictNumbers,Io.Wrong);r.if(s,()=>{o.length?HC(t,e,o):Fy(t)})}return a}mt.coerceAndCheckDataType=qC;var $0=new Set(["string","number","integer","boolean","null"]);function VC(t,e){return e?t.filter(r=>$0.has(r)||e==="array"&&r==="array"):[]}function HC(t,e,r){let{gen:i,data:n,opts:o}=t,a=i.let("dataType",(0,se._)`typeof ${n}`),s=i.let("coerced",(0,se._)`undefined`);o.coerceTypes==="array"&&i.if((0,se._)`${a} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>i.assign(n,(0,se._)`${n}[0]`).assign(a,(0,se._)`typeof ${n}`).if(Zy(e,n,o.strictNumbers),()=>i.assign(s,n))),i.if((0,se._)`${s} !== undefined`);for(let u of r)($0.has(u)||u==="array"&&o.coerceTypes==="array")&&c(u);i.else(),Fy(t),i.endIf(),i.if((0,se._)`${s} !== undefined`,()=>{i.assign(n,s),BC(t,s)});function c(u){switch(u){case"string":i.elseIf((0,se._)`${a} == "number" || ${a} == "boolean"`).assign(s,(0,se._)`"" + ${n}`).elseIf((0,se._)`${n} === null`).assign(s,(0,se._)`""`);return;case"number":i.elseIf((0,se._)`${a} == "boolean" || ${n} === null
|
|
101
101
|
|| (${a} == "string" && ${n} && ${n} == +${n})`).assign(s,(0,se._)`+${n}`);return;case"integer":i.elseIf((0,se._)`${a} === "boolean" || ${n} === null
|
|
102
102
|
|| (${a} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(s,(0,se._)`+${n}`);return;case"boolean":i.elseIf((0,se._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(s,!1).elseIf((0,se._)`${n} === "true" || ${n} === 1`).assign(s,!0);return;case"null":i.elseIf((0,se._)`${n} === "" || ${n} === 0 || ${n} === false`),i.assign(s,null);return;case"array":i.elseIf((0,se._)`${a} === "string" || ${a} === "number"
|
package/package.json
CHANGED
|
@@ -13,8 +13,8 @@ Six hooks fire automatically. Respond to them as described:
|
|
|
13
13
|
- **SessionStart** -- When a session begins or resumes, the hook may inject preferences + guidelines + priority-always memories as additional context. Read them and let them shape your work.
|
|
14
14
|
- **PreToolUse** -- Before you read/edit/grep a file, the hook may inject: "N memories exist for this path." When you see this nudge, call `aide_recall` with those paths before proceeding.
|
|
15
15
|
- **PostToolUse** -- After you call `aide_recall` / `aide_remember` / `aide_search`, the hook records the recalled IDs so subsequent reads of the same path don't re-block. No agent action required.
|
|
16
|
-
- **UserPromptSubmit** -- Detects
|
|
17
|
-
- **Stop** -- On task completion, the hook
|
|
16
|
+
- **UserPromptSubmit** -- Detects when the user's prompt may contain a correction or convention. When flagged, decide whether it applies to future work in this project; if yes, call `aide_remember` (or `aide_update` if an existing memory needs revision) on the matching layer. If not, respond as normal.
|
|
17
|
+
- **Stop** -- On task completion, the hook surfaces a checkpoint asking whether anything from this turn is worth persisting for future sessions. Review the turn. If something fits a layer (preferences, technical, area_context, or guidelines), call `aide_remember` (or `aide_update` if an existing memory needs revision). Otherwise, stop.
|
|
18
18
|
- **PreCompact** -- Before context compaction, the hook prompts you to save important context. Store any active plans, decisions, or constraints via `aide_remember` (or `aide_update` if an existing memory needs revision) immediately -- after compaction you will only have a summary.
|
|
19
19
|
{{editor_notes}}
|
|
20
20
|
## Proactive saving
|
|
@@ -32,13 +32,19 @@ As conversations grow long, proactively call `aide_remember` (or `aide_update` i
|
|
|
32
32
|
|
|
33
33
|
## When to call aide_remember
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
- A design decision is made during planning or discussion
|
|
37
|
-
- You discover a non-obvious constraint, pattern, or dependency
|
|
38
|
-
- On task completion when the Stop hook prompts you (only if warranted)
|
|
39
|
-
- When the user explicitly asks you to remember something
|
|
35
|
+
If something from the conversation will help in a future session in this project, capture it on the matching layer:
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
| Layer | What goes here |
|
|
38
|
+
|---|---|
|
|
39
|
+
| **preferences** | How the user works — explicit choices and patterns visible in how they structure or approach code |
|
|
40
|
+
| **technical** | Non-obvious facts about the stack, workarounds, the reasoning behind a technical choice |
|
|
41
|
+
| **area_context** | Decisions or patterns specific to a particular code area, including the reasoning behind them |
|
|
42
|
+
| **guidelines** | Team or project-wide rules |
|
|
43
|
+
|
|
44
|
+
## When NOT to call aide_remember
|
|
45
|
+
|
|
46
|
+
- Information already readable directly from the file
|
|
47
|
+
- Secrets, credentials, or user-identifying data
|
|
42
48
|
|
|
43
49
|
## When to call aide_search
|
|
44
50
|
|
|
@@ -76,15 +82,6 @@ Note: aide_forget permanently deletes the memory. There is no archive mode.
|
|
|
76
82
|
|
|
77
83
|
## Formatting memories
|
|
78
84
|
|
|
79
|
-
### Layer selection
|
|
80
|
-
|
|
81
|
-
| Layer | Use when | Example |
|
|
82
|
-
|-------|----------|---------|
|
|
83
|
-
| `preferences` | How the developer likes to work | "Prefers composition over inheritance" |
|
|
84
|
-
| `technical` | Facts about the stack not obvious from code | "WAL mode required for concurrent SQLite access" |
|
|
85
|
-
| `area_context` | Decisions and context for specific code areas | "Dashboard uses skeleton loading, not spinners" |
|
|
86
|
-
| `guidelines` | Team-wide or project-wide principles | "All API responses use camelCase keys" |
|
|
87
|
-
|
|
88
85
|
### Scope
|
|
89
86
|
|
|
90
87
|
Set `scope` to a glob pattern matching the relevant code area:
|