diff --git a/src/lib/commercial/BudgetManager.svelte b/src/lib/commercial/BudgetManager.svelte new file mode 100644 index 0000000..dc5590a --- /dev/null +++ b/src/lib/commercial/BudgetManager.svelte @@ -0,0 +1,238 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+ {#if loading} +
Loading budget data...
+ {:else if error} +
{error}
+ {:else} + +
Budget Governor
+ {#if budget} +
+
+
+
+
+ {fmtK(budget.used)} / {fmtK(budget.limit)} tokens + {budget.percent.toFixed(1)}% +
+
+ Remaining: {fmtK(budget.remaining)} + Resets: {budget.resetDate} +
+
+ +
+ + +
+ {/if} + + +
Smart Model Router
+
+ {#each PROFILES as p} + + {/each} +
+ + {#if recommendation} +
+ Recommended: + {recommendation.model} + {recommendation.reason} + Cost factor: {recommendation.estimatedCostFactor.toFixed(2)}x +
+ {/if} + {/if} +
+ + diff --git a/src/lib/commercial/CodeIntelligence.svelte b/src/lib/commercial/CodeIntelligence.svelte new file mode 100644 index 0000000..976045f --- /dev/null +++ b/src/lib/commercial/CodeIntelligence.svelte @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+ {#if loading} +
Loading code intelligence...
+ {:else if error} +
{error}
+ {:else} + +
+
Git Context
+ {#if gitCtx} +
+ {gitCtx.branch} + {#if gitCtx.hasUnstaged}unstaged changes{/if} + +
+ + {#if gitCtx.lastCommits.length > 0} +
+ {#each gitCtx.lastCommits.slice(0, 5) as c} +
{shortHash(c.hash)}{c.message}
+ {/each} +
+ {/if} + {#if gitCtx.modifiedFiles.length > 0} +
+ {gitCtx.modifiedFiles.length} modified + {#each gitCtx.modifiedFiles.slice(0, 8) as f}{shortPath(f)}{/each} + {#if gitCtx.modifiedFiles.length > 8}+{gitCtx.modifiedFiles.length - 8} more{/if} +
+ {/if} + + {#if gitInjected} +
{gitInjected}
+ {/if} + {/if} +
+ + +
+
Branch Policy
+ {#if policy} +
+ {policy.allowed ? 'Allowed' : 'Blocked'} + {policy.branch} + {#if policy.matchedPolicy} + Policy: {policy.matchedPolicy} + {/if} + {policy.reason} +
+ {/if} +
+ + +
+
Symbol Graph
+
+ + {#if scanResult} + + {scanResult.filesScanned} files, {scanResult.symbolsFound} symbols ({scanResult.durationMs}ms) + + {/if} +
+ +
+ e.key === 'Enter' && searchSymbols()} + /> + +
+ + {#if symbols.length > 0} +
+ {#each symbols as sym} +
+ {sym.kind} + {sym.name} + {shortPath(sym.filePath)}:{sym.lineNumber} +
+ {/each} +
+ {/if} +
+ {/if} +
+ + diff --git a/src/lib/commercial/ProjectMemory.svelte b/src/lib/commercial/ProjectMemory.svelte new file mode 100644 index 0000000..649fa3f --- /dev/null +++ b/src/lib/commercial/ProjectMemory.svelte @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+
+
+ e.key === 'Enter' && doSearch()} + /> + +
+
+ + + +
+
+ + {#if showAddForm} +
+ +
+ + + +
+
+ {/if} + + {#if injectedPreview} +
+
+ Injected Context Preview + +
+
{injectedPreview}
+
+ {/if} + + {#if error} +
{error}
+ {/if} + + {#if loading} +
Loading memories...
+ {:else if memories.length === 0} +
No memories found.
+ {:else} +
+ {#each memories as mem (mem.id)} +
+
+ {mem.source} + {fmtDate(mem.createdAt)} + +
+
{mem.content.length > 200 ? mem.content.slice(0, 200) + '...' : mem.content}
+ +
+ {/each} +
+ {/if} +
+ + diff --git a/src/lib/commercial/pro-bridge.ts b/src/lib/commercial/pro-bridge.ts index 593ccde..f64bb10 100644 --- a/src/lib/commercial/pro-bridge.ts +++ b/src/lib/commercial/pro-bridge.ts @@ -150,3 +150,43 @@ export const proMarketplaceUpdate = (pluginId: string) => export const proStatus = () => invoke('plugin:agor-pro|pro_status'); + +// --- Budget Governor --- + +export interface BudgetStatus { limit: number; used: number; remaining: number; percent: number; resetDate: string; } +export interface BudgetDecision { allowed: boolean; reason: string; remaining: number; } +export const proBudgetSet = (projectId: string, monthlyLimitTokens: number) => invoke('plugin:agor-pro|pro_budget_set', { projectId, monthlyLimitTokens }); +export const proBudgetGet = (projectId: string) => invoke('plugin:agor-pro|pro_budget_get', { projectId }); +export const proBudgetCheck = (projectId: string, estimatedTokens: number) => invoke('plugin:agor-pro|pro_budget_check', { projectId, estimatedTokens }); +export const proBudgetLogUsage = (projectId: string, sessionId: string, tokensUsed: number) => invoke('plugin:agor-pro|pro_budget_log_usage', { projectId, sessionId, tokensUsed }); +export const proBudgetList = () => invoke>('plugin:agor-pro|pro_budget_list'); + +// --- Smart Model Router --- + +export interface ModelRecommendation { model: string; reason: string; estimatedCostFactor: number; } +export const proRouterRecommend = (projectId: string, role: string, promptLength: number, provider: string) => invoke('plugin:agor-pro|pro_router_recommend', { projectId, role, promptLength, provider }); +export const proRouterSetProfile = (projectId: string, profile: string) => invoke('plugin:agor-pro|pro_router_set_profile', { projectId, profile }); +export const proRouterGetProfile = (projectId: string) => invoke('plugin:agor-pro|pro_router_get_profile', { projectId }); + +// --- Persistent Memory --- + +export interface MemoryFragment { id: number; projectId: string; content: string; source: string; trust: string; confidence: number; createdAt: number; ttlDays: number; tags: string; } +export const proMemoryAdd = (projectId: string, content: string, source: string, tags: string) => invoke('plugin:agor-pro|pro_memory_add', { projectId, content, source, tags }); +export const proMemoryList = (projectId: string, limit: number) => invoke('plugin:agor-pro|pro_memory_list', { projectId, limit }); +export const proMemorySearch = (projectId: string, query: string) => invoke('plugin:agor-pro|pro_memory_search', { projectId, query }); +export const proMemoryDelete = (id: number) => invoke('plugin:agor-pro|pro_memory_delete', { id }); +export const proMemoryInject = (projectId: string, maxTokens: number) => invoke('plugin:agor-pro|pro_memory_inject', { projectId, maxTokens }); + +// --- Git Context --- + +export interface GitContext { branch: string; lastCommits: Array<{hash: string; message: string; author: string; timestamp: number}>; modifiedFiles: string[]; hasUnstaged: boolean; } +export interface PolicyDecision { allowed: boolean; branch: string; matchedPolicy: string | null; reason: string; } +export const proGitContext = (projectPath: string) => invoke('plugin:agor-pro|pro_git_context', { projectPath }); +export const proGitInject = (projectPath: string, maxTokens: number) => invoke('plugin:agor-pro|pro_git_inject', { projectPath, maxTokens }); +export const proBranchCheck = (projectPath: string) => invoke('plugin:agor-pro|pro_branch_check', { projectPath }); + +// --- Symbols --- + +export interface Symbol { name: string; kind: string; filePath: string; lineNumber: number; } +export const proSymbolsScan = (projectPath: string) => invoke<{filesScanned: number; symbolsFound: number; durationMs: number}>('plugin:agor-pro|pro_symbols_scan', { projectPath }); +export const proSymbolsSearch = (projectPath: string, query: string) => invoke('plugin:agor-pro|pro_symbols_search', { projectPath, query });