@gabrywu/knowledge-bank 0.1.2-alpha.227 → 0.1.2-alpha.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e,{dirname as n}from"path";import t from"os";import i,{readFileSync as s,existsSync as o,mkdirSync as r}from"fs";import{exec as a}from"child_process";import{fileURLToPath as l}from"url";import c from"better-sqlite3";const d={logging:{level:"DEBUG"},db:{file:e.join(t.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:e.join(t.homedir(),".knowledge-bank","tmp")};let E=null;function T(){if(null===E){const n=process.env.KNOWLEDGE_CONF_DIR||e.join(t.homedir(),".knowledge-bank"),s=e.join(n,"config.json");E={...d,...i.existsSync(s)?JSON.parse(i.readFileSync(s,"utf-8")):{}}}return E}const g=T(),_={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},m=Object.values(_);class N{constructor(e={}){this.isDev=void 0!==e.isDev?e.isDev:this.detectEnvironment(),this._rootDir=null,this._packageFile=null,this._marketplaceRepo=null}detectEnvironment(){const n=l(import.meta.url),t=e.dirname(n),s=i.existsSync(e.join(t,"..","..","src")),o=t.includes("dist"),r=e.join(t,"..","..","package.json"),a=e.join(t,"..","package.json");return s&&!o||!i.existsSync(a)&&i.existsSync(r)}getRootDir(){if(this._rootDir)return this._rootDir;const n=l(import.meta.url),t=e.dirname(n);if(this.isDev)this._rootDir=e.join(t,"..","..");else if(t.includes("dist")){const e=t.indexOf("dist");this._rootDir=t.substring(0,e-1)}else if(t.includes("src"))this._rootDir=e.join(t,"..","..");else{let n=t;for(;n!==e.dirname(n);){const t=e.join(n,"package.json");if(i.existsSync(t)){this._rootDir=n;break}n=e.dirname(n)}this._rootDir||(this._rootDir=e.dirname(t))}return this._rootDir}getPackageFile(){if(this._packageFile)return this._packageFile;const n=this.getRootDir();if(this._packageFile=e.join(n,"package.json"),!i.existsSync(this._packageFile)){const n=e.join(process.cwd(),"package.json");if(!i.existsSync(n))throw new Error(`package.json not found at ${this._packageFile} or ${n}`);this._packageFile=n}return this._packageFile}getMarketplaceRepo(){if(this._marketplaceRepo)return this._marketplaceRepo;const n=this.getRootDir();if(this.isDev){const t=e.join(n,"dist","claude-marketplace"),s=e.join(n,"src","claude-marketplace");if(i.existsSync(t))this._marketplaceRepo=t;else{if(!i.existsSync(s))throw new Error(`Marketplace directory not found at ${t} or ${s}`);this._marketplaceRepo=s}}else if(this._marketplaceRepo=e.join(n,"dist","claude-marketplace"),!i.existsSync(this._marketplaceRepo))throw new Error(`Marketplace directory not found at ${this._marketplaceRepo}`);return this._marketplaceRepo}getWebViewsPath(){const n=this.getRootDir();return this.isDev?e.join(n,"src","web","views"):e.join(n,"dist","web","views")}getWebPublicPath(){const n=this.getRootDir();return this.isDev?e.join(n,"src","web","public"):e.join(n,"dist","web","public")}}const u=new N,p=()=>u.getPackageFile(),w=()=>u.getMarketplaceRepo(),k=()=>u.getWebViewsPath(),R=()=>u.getWebPublicPath();function h(e){return new N({isDev:e})}new class{constructor(n,s){this.loggerName=s;const o=g.logging.path||e.join(t.homedir(),".knowledge-bank","logs");i.mkdirSync(o,{recursive:!0}),this.loggerFile=e.join(o,`${n}.log`),this.logLevel=g.logging.level.toUpperCase()||_.INFO}formatMessage(e,n,t=null){const i=`${(new Date).toISOString().replace("T","-").split(".")[0]} ${this.loggerName} ${e}: ${n}`;return null===t?i:`${i} - ${JSON.stringify(t)}`}isLogLevelEnabled(e){const n=m.indexOf(this.logLevel);return m.indexOf(e)>=n}writeMessage(e,n,t){if(this.isLogLevelEnabled(e)){const s=this.formatMessage(e,n,t);i.appendFileSync(this.loggerFile,`${s}\n`,"utf8")}}logInfo(e,n=null){this.writeMessage(_.INFO,e,n)}logError(e,n=null){if(n instanceof Error){const t={message:n.message,stack:n.stack,name:n.name,...n.cause&&{cause:n.cause},...Object.getOwnPropertyNames(n).reduce((e,t)=>(["message","stack","name"].includes(t)||(e[t]=n[t]),e),{})};this.writeMessage(_.ERROR,e,t)}else this.writeMessage(_.ERROR,e,n)}logWarn(e,n=null){this.writeMessage(_.WARN,e,n)}logDebug(e,n=null){this.writeMessage(_.DEBUG,e,n)}}("common","common");const I=u.getPackageFile(),f=u.getMarketplaceRepo();function O(){return new Promise((e,n)=>{a("claude plugin marketplace list --json",(t,i,s)=>{if(t)n(t);else{s&&console.error(s);try{const n=i.trim()?JSON.parse(i):[];e(n)}catch(e){n(e)}}})})}JSON.parse(s(I,"utf8")),e.join(t.homedir(),".claude","settings.local.json");const S={DRAFT:"draft",SUGGESTED:"suggested",VERIFIED:"verified"},L={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Basic information\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n content TEXT NOT NULL,\n\n -- Classification dimensions\n scope TEXT NOT NULL CHECK(scope IN (${["personal","project","organization"].map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${["developer","architect","reviewer","ai"].map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL ,\n status TEXT NOT NULL DEFAULT '${S.DRAFT}' CHECK(status IN (${Object.values(S).map(e=>`'${e}'`).join(", ")})),\n\n -- Source tracking\n source_file TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n `,session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT UNIQUE NOT NULL,\n\n -- Session basic information\n cwd TEXT NOT NULL,\n cwd_updated_at INTEGER NOT NULL,\n git_url TEXT,\n git_branch TEXT,\n git_commit_id TEXT,\n user_name TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n -- Session duration (seconds, calculated on session end)\n duration INTEGER,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session_event:"\n CREATE TABLE IF NOT EXISTS session_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\n exit_code INTEGER NOT NULL DEFAULT 0,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",knowledge_item_fts:"\n CREATE VIRTUAL TABLE IF NOT EXISTS knowledge_item_fts USING fts5(\n title, summary, content,\n content='knowledge_item',\n content_rowid='id',\n tokenize='trigram'\n )\n "},D={knowledge_item_fts_insert:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_insert AFTER INSERT ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n ",knowledge_item_fts_delete:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_delete AFTER DELETE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n END\n ",knowledge_item_fts_update:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_update AFTER UPDATE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n "},F={idx_knowledge_scope:"CREATE INDEX IF NOT EXISTS idx_knowledge_scope ON knowledge_item(scope)",idx_knowledge_type:"CREATE INDEX IF NOT EXISTS idx_knowledge_type ON knowledge_item(knowledge_type)",idx_knowledge_status:"CREATE INDEX IF NOT EXISTS idx_knowledge_status ON knowledge_item(status)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_session_cwd:"CREATE INDEX IF NOT EXISTS idx_session_cwd ON session(cwd)",idx_session_event_session:"CREATE INDEX IF NOT EXISTS idx_session_event_session ON session_event(session_id)",idx_session_event_name:"CREATE INDEX IF NOT EXISTS idx_session_event_name ON session_event(name)"};function X(e){Object.values(L).forEach(n=>{e.prepare(n).run()}),Object.values(F).forEach(n=>{e.prepare(n).run()}),Object.values(D).forEach(n=>{e.prepare(n).run()})}const b=T(),y=new class{constructor(){this.dbFile=b.db.file,this.initialized=!1}initialize(){if(!this.initialized){const e=n(this.dbFile);o(e)||r(e,{recursive:!0})}return this.initialized=!0,this}_createConnection(){const e=new c(this.dbFile);return b.db.configs.forEach(n=>{e.pragma(n)}),e}withConnection(e){let n=null;try{return n=this.initialize()._createConnection(),e(n)}finally{n&&(n.close(),n=null)}}static install(){y.withConnection(e=>{X(e)})}},j=T();async function v(){O().then(e=>e.find(e=>"knowledge-bank"===e.name)).then(async e=>{e||await new Promise((e,n)=>{a(`claude plugin marketplace add ${f}`,(t,i,s)=>{t?n(t):(s&&console.error(s),console.log(i),e())})}),await new Promise((e,n)=>{a("claude plugin install core@knowledge-bank",(t,i,s)=>{t?n(t):(s&&console.error(s),console.log(i),e())})})}).then(async()=>{i.existsSync(j.tmp)||i.mkdirSync(j.tmp,{recursive:!0}),y.withConnection(e=>{X(e)})}).catch(e=>{console.error("Error during installation:",e)})}async function A(){O().then(e=>e.find(e=>"knowledge-bank"===e.name)).then(async e=>{e?(await new Promise((e,n)=>{a("claude plugin uninstall core@knowledge-bank",(t,i,s)=>{t?n(t):(s&&console.error(s),console.log(i),e())})}),await new Promise((e,n)=>{a("claude plugin marketplace remove knowledge-bank",(t,i,s)=>{t?n(t):(s&&console.error(s),console.log(i),e())})})):console.log("knowledge-bank plugin is not installed.")}).catch(e=>{console.error("Error during uninstallation:",e)})}class U extends Error{constructor(e,n=1){super(e),this.name="CLIError",this.exitCode=n}}export{U as CLIError,N as PathResolver,h as createPathResolver,w as getMarketplaceRepo,p as getPackageFile,R as getWebPublicPath,k as getWebViewsPath,v as install,u as pathResolver,A as uninstall};
1
+ import e,{dirname as n}from"path";import i from"os";import s,{readFileSync as t,existsSync as o,mkdirSync as r}from"fs";import{exec as a}from"child_process";import{fileURLToPath as l}from"url";import E from"better-sqlite3";const c={logging:{level:"DEBUG"},db:{file:e.join(i.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:e.join(i.homedir(),".knowledge-bank","tmp")};let d=null;function T(){if(null===d){const n=process.env.KNOWLEDGE_CONF_DIR||e.join(i.homedir(),".knowledge-bank"),t=e.join(n,"config.json");d={...c,...s.existsSync(t)?JSON.parse(s.readFileSync(t,"utf-8")):{}}}return d}const _=T(),N={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},g=Object.values(N);class m{constructor(e={}){this.isDev=void 0!==e.isDev?e.isDev:this.detectEnvironment(),this._rootDir=null,this._packageFile=null,this._marketplaceRepo=null}detectEnvironment(){const n=l(import.meta.url),i=e.dirname(n),t=s.existsSync(e.join(i,"..","..","src")),o=i.includes("dist"),r=e.join(i,"..","..","package.json"),a=e.join(i,"..","package.json");return t&&!o||!s.existsSync(a)&&s.existsSync(r)}getRootDir(){if(this._rootDir)return this._rootDir;const n=l(import.meta.url),i=e.dirname(n);if(this.isDev)this._rootDir=e.join(i,"..","..");else if(i.includes("dist")){const e=i.indexOf("dist");this._rootDir=i.substring(0,e-1)}else if(i.includes("src"))this._rootDir=e.join(i,"..","..");else{let n=i;for(;n!==e.dirname(n);){const i=e.join(n,"package.json");if(s.existsSync(i)){this._rootDir=n;break}n=e.dirname(n)}this._rootDir||(this._rootDir=e.dirname(i))}return this._rootDir}getPackageFile(){if(this._packageFile)return this._packageFile;const n=this.getRootDir();if(this._packageFile=e.join(n,"package.json"),!s.existsSync(this._packageFile)){const n=e.join(process.cwd(),"package.json");if(!s.existsSync(n))throw new Error(`package.json not found at ${this._packageFile} or ${n}`);this._packageFile=n}return this._packageFile}getMarketplaceRepo(){if(this._marketplaceRepo)return this._marketplaceRepo;const n=this.getRootDir();if(this.isDev){const i=e.join(n,"dist","claude-marketplace"),t=e.join(n,"src","claude-marketplace");if(s.existsSync(i))this._marketplaceRepo=i;else{if(!s.existsSync(t))throw new Error(`Marketplace directory not found at ${i} or ${t}`);this._marketplaceRepo=t}}else if(this._marketplaceRepo=e.join(n,"dist","claude-marketplace"),!s.existsSync(this._marketplaceRepo))throw new Error(`Marketplace directory not found at ${this._marketplaceRepo}`);return this._marketplaceRepo}getWebViewsPath(){const n=this.getRootDir();return this.isDev?e.join(n,"src","web","views"):e.join(n,"dist","web","views")}getWebPublicPath(){const n=this.getRootDir();return this.isDev?e.join(n,"src","web","public"):e.join(n,"dist","web","public")}}const u=new m,p=()=>u.getPackageFile(),I=()=>u.getMarketplaceRepo(),R=()=>u.getWebViewsPath(),w=()=>u.getWebPublicPath();function O(e){return new m({isDev:e})}new class{constructor(n,t){this.loggerName=t;const o=_.logging.path||e.join(i.homedir(),".knowledge-bank","logs");s.mkdirSync(o,{recursive:!0}),this.loggerFile=e.join(o,`${n}.log`),this.logLevel=_.logging.level.toUpperCase()||N.INFO}formatMessage(e,n,i=null){const s=`${(new Date).toISOString().replace("T","-").split(".")[0]} ${this.loggerName} ${e}: ${n}`;return null===i?s:`${s} - ${JSON.stringify(i)}`}isLogLevelEnabled(e){const n=g.indexOf(this.logLevel);return g.indexOf(e)>=n}writeMessage(e,n,i){if(this.isLogLevelEnabled(e)){const t=this.formatMessage(e,n,i);s.appendFileSync(this.loggerFile,`${t}\n`,"utf8")}}logInfo(e,n=null){this.writeMessage(N.INFO,e,n)}logError(e,n=null){if(n instanceof Error){const i={message:n.message,stack:n.stack,name:n.name,...n.cause&&{cause:n.cause},...Object.getOwnPropertyNames(n).reduce((e,i)=>(["message","stack","name"].includes(i)||(e[i]=n[i]),e),{})};this.writeMessage(N.ERROR,e,i)}else this.writeMessage(N.ERROR,e,n)}logWarn(e,n=null){this.writeMessage(N.WARN,e,n)}logDebug(e,n=null){this.writeMessage(N.DEBUG,e,n)}}("common","common");const k=u.getPackageFile(),h=u.getMarketplaceRepo();function f(){return new Promise((e,n)=>{a("claude plugin marketplace list --json",(i,s,t)=>{if(i)n(i);else{t&&console.error(t);try{const n=s.trim()?JSON.parse(s):[];e(n)}catch(e){n(e)}}})})}JSON.parse(t(k,"utf8")),e.join(i.homedir(),".claude","settings.local.json");const S={DRAFT:"draft",SUGGESTED:"suggested",VERIFIED:"verified"},L={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Basic information\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n content TEXT NOT NULL,\n\n -- Classification dimensions\n scope TEXT NOT NULL CHECK(scope IN (${["personal","project","organization"].map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${["developer","architect","reviewer","ai"].map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL ,\n status TEXT NOT NULL DEFAULT '${S.DRAFT}' CHECK(status IN (${Object.values(S).map(e=>`'${e}'`).join(", ")})),\n\n -- Source tracking\n source_file TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n `,session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT UNIQUE NOT NULL,\n\n -- Session basic information\n cwd TEXT NOT NULL,\n cwd_updated_at INTEGER NOT NULL,\n git_url TEXT,\n git_branch TEXT,\n git_commit_id TEXT,\n user_name TEXT,\n\n -- First user prompt for the session\n first_user_prompt TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n -- Session duration (seconds, calculated on session end)\n duration INTEGER,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session_event:"\n CREATE TABLE IF NOT EXISTS session_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\n exit_code INTEGER NOT NULL DEFAULT 0,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",session_detail:"\n CREATE TABLE IF NOT EXISTS session_detail (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- UUID is the unique key for each transcript entry\n uuid TEXT UNIQUE NOT NULL,\n\n -- Top-level JSON fields as table columns\n type TEXT,\n parentUuid TEXT,\n isSidechain INTEGER, -- SQLite boolean as INTEGER\n userType TEXT,\n cwd TEXT,\n version TEXT,\n gitBranch TEXT,\n parentToolUseID TEXT,\n toolUseID TEXT,\n timestamp TEXT,\n isMeta INTEGER, -- SQLite boolean as INTEGER\n messageId TEXT,\n isSnapshotUpdate INTEGER, -- SQLite boolean as INTEGER\n\n -- Other fields stored as JSON strings\n data TEXT, -- JSON string\n message TEXT, -- JSON string\n snapshot TEXT, -- JSON string\n usage TEXT, -- JSON string\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",knowledge_item_fts:"\n CREATE VIRTUAL TABLE IF NOT EXISTS knowledge_item_fts USING fts5(\n title, summary, content,\n content='knowledge_item',\n content_rowid='id',\n tokenize='trigram'\n )\n "},X={knowledge_item_fts_insert:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_insert AFTER INSERT ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n ",knowledge_item_fts_delete:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_delete AFTER DELETE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n END\n ",knowledge_item_fts_update:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_update AFTER UPDATE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n "},F={idx_knowledge_scope:"CREATE INDEX IF NOT EXISTS idx_knowledge_scope ON knowledge_item(scope)",idx_knowledge_type:"CREATE INDEX IF NOT EXISTS idx_knowledge_type ON knowledge_item(knowledge_type)",idx_knowledge_status:"CREATE INDEX IF NOT EXISTS idx_knowledge_status ON knowledge_item(status)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_session_cwd:"CREATE INDEX IF NOT EXISTS idx_session_cwd ON session(cwd)",idx_session_event_session:"CREATE INDEX IF NOT EXISTS idx_session_event_session ON session_event(session_id)",idx_session_event_name:"CREATE INDEX IF NOT EXISTS idx_session_event_name ON session_event(name)",idx_session_detail_session:"CREATE INDEX IF NOT EXISTS idx_session_detail_session ON session_detail(session_id)",idx_session_detail_uuid:"CREATE INDEX IF NOT EXISTS idx_session_detail_uuid ON session_detail(uuid)",idx_session_detail_type:"CREATE INDEX IF NOT EXISTS idx_session_detail_type ON session_detail(type)"};function D(e){Object.values(L).forEach(n=>{e.prepare(n).run()}),Object.values(F).forEach(n=>{e.prepare(n).run()}),Object.values(X).forEach(n=>{e.prepare(n).run()})}const U=T(),y=new class{constructor(){this.dbFile=U.db.file,this.initialized=!1}initialize(){if(!this.initialized){const e=n(this.dbFile);o(e)||r(e,{recursive:!0})}return this.initialized=!0,this}_createConnection(){const e=new E(this.dbFile);return U.db.configs.forEach(n=>{e.pragma(n)}),e}withConnection(e){let n=null;try{return n=this.initialize()._createConnection(),e(n)}finally{n&&(n.close(),n=null)}}static install(){y.withConnection(e=>{D(e)})}},A=T();async function b(){f().then(e=>e.find(e=>"knowledge-bank"===e.name)).then(async e=>{e||await new Promise((e,n)=>{a(`claude plugin marketplace add ${h}`,(i,s,t)=>{i?n(i):(t&&console.error(t),console.log(s),e())})}),await new Promise((e,n)=>{a("claude plugin install core@knowledge-bank",(i,s,t)=>{i?n(i):(t&&console.error(t),console.log(s),e())})})}).then(async()=>{s.existsSync(A.tmp)||s.mkdirSync(A.tmp,{recursive:!0}),y.withConnection(e=>{D(e)})}).catch(e=>{console.error("Error during installation:",e)})}async function v(){f().then(e=>e.find(e=>"knowledge-bank"===e.name)).then(async e=>{e?(await new Promise((e,n)=>{a("claude plugin uninstall core@knowledge-bank",(i,s,t)=>{i?n(i):(t&&console.error(t),console.log(s),e())})}),await new Promise((e,n)=>{a("claude plugin marketplace remove knowledge-bank",(i,s,t)=>{i?n(i):(t&&console.error(t),console.log(s),e())})})):console.log("knowledge-bank plugin is not installed.")}).catch(e=>{console.error("Error during uninstallation:",e)})}export{m as PathResolver,O as createPathResolver,I as getMarketplaceRepo,p as getPackageFile,w as getWebPublicPath,R as getWebViewsPath,b as install,u as pathResolver,v as uninstall};