k0ntext 3.0.0
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/LICENSE +21 -0
- package/README.md +623 -0
- package/bin/k0ntext.js +12 -0
- package/dist/agents/cleanup-agent.d.ts +39 -0
- package/dist/agents/cleanup-agent.d.ts.map +1 -0
- package/dist/agents/cleanup-agent.js +56 -0
- package/dist/agents/cleanup-agent.js.map +1 -0
- package/dist/agents/performance-agent.d.ts +37 -0
- package/dist/agents/performance-agent.d.ts.map +1 -0
- package/dist/agents/performance-agent.js +91 -0
- package/dist/agents/performance-agent.js.map +1 -0
- package/dist/analyzer/index.d.ts +5 -0
- package/dist/analyzer/index.d.ts.map +1 -0
- package/dist/analyzer/index.js +5 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/analyzer/intelligent-analyzer.d.ts +111 -0
- package/dist/analyzer/intelligent-analyzer.d.ts.map +1 -0
- package/dist/analyzer/intelligent-analyzer.js +537 -0
- package/dist/analyzer/intelligent-analyzer.js.map +1 -0
- package/dist/cli/commands/cleanup.d.ts +3 -0
- package/dist/cli/commands/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/cleanup.js +24 -0
- package/dist/cli/commands/cleanup.js.map +1 -0
- package/dist/cli/commands/export.d.ts +9 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +72 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/import.d.ts +9 -0
- package/dist/cli/commands/import.d.ts.map +1 -0
- package/dist/cli/commands/import.js +62 -0
- package/dist/cli/commands/import.js.map +1 -0
- package/dist/cli/commands/performance.d.ts +9 -0
- package/dist/cli/commands/performance.d.ts.map +1 -0
- package/dist/cli/commands/performance.js +36 -0
- package/dist/cli/commands/performance.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +9 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +82 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +9 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +72 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/generate.d.ts +3 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +194 -0
- package/dist/cli/generate.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +448 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/sync.d.ts +26 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +163 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/config/cleanup-config.d.ts +26 -0
- package/dist/config/cleanup-config.d.ts.map +1 -0
- package/dist/config/cleanup-config.js +21 -0
- package/dist/config/cleanup-config.js.map +1 -0
- package/dist/db/client.d.ts +284 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +688 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +6 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +6 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +41 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +226 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/embeddings/index.d.ts +5 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +5 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/openrouter.d.ts +133 -0
- package/dist/embeddings/openrouter.d.ts.map +1 -0
- package/dist/embeddings/openrouter.js +455 -0
- package/dist/embeddings/openrouter.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +257 -0
- package/dist/mcp.js.map +1 -0
- package/docs/ARCHIVE/MIGRATE_TO_NEW_REPO.md +222 -0
- package/docs/ARCHIVE/MIGRATE_TO_UNIFIED.md +220 -0
- package/docs/CLEANUP.md +76 -0
- package/docs/MCP_QUICKSTART.md +219 -0
- package/docs/QUICKSTART.md +119 -0
- package/docs/TROUBLESHOOTING.md +611 -0
- package/package.json +100 -0
- package/skills/context-optimize/SKILL.md +86 -0
- package/skills/implement/SKILL.md +150 -0
- package/skills/plan/SKILL.md +143 -0
- package/skills/research/SKILL.md +103 -0
- package/skills/validate/SKILL.md +62 -0
- package/skills/verify-docs/SKILL.md +77 -0
- package/src/agents/cleanup-agent.ts +96 -0
- package/src/agents/performance-agent.ts +117 -0
- package/src/analyzer/index.ts +10 -0
- package/src/analyzer/intelligent-analyzer.ts +640 -0
- package/src/cli/commands/cleanup.ts +26 -0
- package/src/cli/commands/export.ts +82 -0
- package/src/cli/commands/import.ts +73 -0
- package/src/cli/commands/performance.ts +40 -0
- package/src/cli/commands/validate.ts +98 -0
- package/src/cli/commands/watch.ts +83 -0
- package/src/cli/generate.ts +219 -0
- package/src/cli/index.ts +510 -0
- package/src/cli/sync.ts +194 -0
- package/src/config/cleanup-config.ts +42 -0
- package/src/db/client.ts +949 -0
- package/src/db/index.ts +19 -0
- package/src/db/schema.ts +241 -0
- package/src/embeddings/index.ts +11 -0
- package/src/embeddings/openrouter.ts +592 -0
- package/src/index.ts +57 -0
- package/src/mcp.ts +354 -0
- package/templates/AI_CONTEXT.md.template +245 -0
- package/templates/base/README.md +260 -0
- package/templates/base/RPI_WORKFLOW_PLAN.md +325 -0
- package/templates/base/agents/api-developer.md +76 -0
- package/templates/base/agents/context-engineer.md +525 -0
- package/templates/base/agents/core-architect.md +76 -0
- package/templates/base/agents/database-ops.md +76 -0
- package/templates/base/agents/deployment-ops.md +76 -0
- package/templates/base/agents/integration-hub.md +76 -0
- package/templates/base/analytics/README.md +114 -0
- package/templates/base/automation/config.json +58 -0
- package/templates/base/automation/generators/code-mapper.js +308 -0
- package/templates/base/automation/generators/index-builder.js +321 -0
- package/templates/base/automation/hooks/post-commit.sh +83 -0
- package/templates/base/automation/hooks/pre-commit.sh +103 -0
- package/templates/base/ci-templates/README.md +108 -0
- package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
- package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
- package/templates/base/commands/analytics.md +238 -0
- package/templates/base/commands/auto-sync.md +172 -0
- package/templates/base/commands/collab.md +194 -0
- package/templates/base/commands/context-optimize.md +226 -0
- package/templates/base/commands/help.md +485 -0
- package/templates/base/commands/rpi-implement.md +164 -0
- package/templates/base/commands/rpi-plan.md +147 -0
- package/templates/base/commands/rpi-research.md +145 -0
- package/templates/base/commands/session-resume.md +144 -0
- package/templates/base/commands/session-save.md +112 -0
- package/templates/base/commands/validate-all.md +77 -0
- package/templates/base/commands/verify-docs-current.md +86 -0
- package/templates/base/config/base.json +57 -0
- package/templates/base/config/environments/development.json +13 -0
- package/templates/base/config/environments/production.json +17 -0
- package/templates/base/config/environments/staging.json +13 -0
- package/templates/base/config/local.json.example +21 -0
- package/templates/base/context/.meta/generated-at.json +18 -0
- package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
- package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
- package/templates/base/context/FILE_OWNERSHIP.md +57 -0
- package/templates/base/context/INTEGRATION_POINTS.md +92 -0
- package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
- package/templates/base/context/TESTING_MAP.md +95 -0
- package/templates/base/context/WORKFLOW_INDEX.md +129 -0
- package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
- package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
- package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
- package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
- package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
- package/templates/base/knowledge/README.md +98 -0
- package/templates/base/knowledge/sessions/README.md +88 -0
- package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
- package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
- package/templates/base/knowledge/shared/decisions/README.md +49 -0
- package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
- package/templates/base/knowledge/shared/patterns/README.md +62 -0
- package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
- package/templates/base/plans/PLAN_TEMPLATE.md +316 -0
- package/templates/base/plans/active/.gitkeep +0 -0
- package/templates/base/plans/completed/.gitkeep +0 -0
- package/templates/base/research/RESEARCH_TEMPLATE.md +245 -0
- package/templates/base/research/active/.gitkeep +0 -0
- package/templates/base/research/completed/.gitkeep +0 -0
- package/templates/base/schemas/agent.schema.json +141 -0
- package/templates/base/schemas/anchors.schema.json +54 -0
- package/templates/base/schemas/automation.schema.json +93 -0
- package/templates/base/schemas/command.schema.json +134 -0
- package/templates/base/schemas/hashes.schema.json +40 -0
- package/templates/base/schemas/manifest.schema.json +117 -0
- package/templates/base/schemas/plan.schema.json +136 -0
- package/templates/base/schemas/research.schema.json +115 -0
- package/templates/base/schemas/roles.schema.json +34 -0
- package/templates/base/schemas/session.schema.json +77 -0
- package/templates/base/schemas/settings.schema.json +244 -0
- package/templates/base/schemas/staleness.schema.json +53 -0
- package/templates/base/schemas/team-config.schema.json +42 -0
- package/templates/base/schemas/workflow.schema.json +126 -0
- package/templates/base/session/checkpoints/.gitkeep +2 -0
- package/templates/base/session/current/state.json +20 -0
- package/templates/base/session/history/.gitkeep +2 -0
- package/templates/base/settings.json +3 -0
- package/templates/base/standards/COMPATIBILITY.md +219 -0
- package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
- package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
- package/templates/base/standards/README.md +66 -0
- package/templates/base/sync/anchors.json +6 -0
- package/templates/base/sync/hashes.json +6 -0
- package/templates/base/sync/staleness.json +10 -0
- package/templates/base/team/README.md +168 -0
- package/templates/base/team/config.json +79 -0
- package/templates/base/team/roles.json +145 -0
- package/templates/base/tools/bin/claude-context.js +151 -0
- package/templates/base/tools/lib/anchor-resolver.js +276 -0
- package/templates/base/tools/lib/config-loader.js +363 -0
- package/templates/base/tools/lib/detector.js +350 -0
- package/templates/base/tools/lib/diagnose.js +206 -0
- package/templates/base/tools/lib/drift-detector.js +373 -0
- package/templates/base/tools/lib/errors.js +199 -0
- package/templates/base/tools/lib/index.js +36 -0
- package/templates/base/tools/lib/init.js +192 -0
- package/templates/base/tools/lib/logger.js +230 -0
- package/templates/base/tools/lib/placeholder.js +201 -0
- package/templates/base/tools/lib/session-manager.js +354 -0
- package/templates/base/tools/lib/validate.js +521 -0
- package/templates/base/tools/package.json +49 -0
- package/templates/handlebars/aider-config.hbs +146 -0
- package/templates/handlebars/antigravity.hbs +377 -0
- package/templates/handlebars/claude.hbs +183 -0
- package/templates/handlebars/cline.hbs +62 -0
- package/templates/handlebars/continue-config.hbs +116 -0
- package/templates/handlebars/copilot.hbs +130 -0
- package/templates/handlebars/partials/gotcha-list.hbs +11 -0
- package/templates/handlebars/partials/header.hbs +3 -0
- package/templates/handlebars/partials/workflow-summary.hbs +16 -0
- package/templates/handlebars/windsurf-rules.hbs +69 -0
- package/templates/hooks/post-commit.hbs +28 -0
- package/templates/hooks/pre-commit.hbs +46 -0
package/src/db/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Module Index
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { DatabaseClient, type ContextItem, type GraphEdge, type GitCommit, type SyncState, type AIToolConfig, type SearchResult } from './client.js';
|
|
6
|
+
export {
|
|
7
|
+
SCHEMA_SQL,
|
|
8
|
+
VECTOR_SCHEMA_SQL,
|
|
9
|
+
SCHEMA_VERSION,
|
|
10
|
+
RELATION_TYPES,
|
|
11
|
+
CONTEXT_TYPES,
|
|
12
|
+
SYNC_STATUSES,
|
|
13
|
+
AI_TOOLS,
|
|
14
|
+
AI_TOOL_FOLDERS,
|
|
15
|
+
type RelationType,
|
|
16
|
+
type ContextType,
|
|
17
|
+
type SyncStatus,
|
|
18
|
+
type AITool
|
|
19
|
+
} from './schema.js';
|
package/src/db/schema.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Schema
|
|
3
|
+
*
|
|
4
|
+
* SQLite + sqlite-vec schema for AI context storage.
|
|
5
|
+
* Supports vector embeddings, knowledge graph, and sync state.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const SCHEMA_VERSION = '1.0.0';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Core database schema SQL
|
|
12
|
+
*/
|
|
13
|
+
export const SCHEMA_SQL = `
|
|
14
|
+
-- Schema version tracking
|
|
15
|
+
CREATE TABLE IF NOT EXISTS schema_version (
|
|
16
|
+
version TEXT PRIMARY KEY,
|
|
17
|
+
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- Core context storage
|
|
21
|
+
CREATE TABLE IF NOT EXISTS context_items (
|
|
22
|
+
id TEXT PRIMARY KEY,
|
|
23
|
+
type TEXT NOT NULL CHECK (type IN ('workflow', 'agent', 'command', 'code', 'commit', 'knowledge', 'config', 'doc', 'tool_config')),
|
|
24
|
+
name TEXT NOT NULL,
|
|
25
|
+
content TEXT NOT NULL,
|
|
26
|
+
metadata JSON,
|
|
27
|
+
file_path TEXT,
|
|
28
|
+
content_hash TEXT,
|
|
29
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
30
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
-- Indexes for context_items
|
|
34
|
+
CREATE INDEX IF NOT EXISTS idx_context_items_type ON context_items(type);
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_context_items_name ON context_items(name);
|
|
36
|
+
CREATE INDEX IF NOT EXISTS idx_context_items_file_path ON context_items(file_path);
|
|
37
|
+
CREATE INDEX IF NOT EXISTS idx_context_items_content_hash ON context_items(content_hash);
|
|
38
|
+
|
|
39
|
+
-- Knowledge graph with typed relations
|
|
40
|
+
CREATE TABLE IF NOT EXISTS knowledge_graph (
|
|
41
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
42
|
+
source_id TEXT NOT NULL,
|
|
43
|
+
target_id TEXT NOT NULL,
|
|
44
|
+
relation_type TEXT NOT NULL CHECK (relation_type IN (
|
|
45
|
+
'uses', 'implements', 'depends_on', 'references', 'tests',
|
|
46
|
+
'documents', 'extends', 'contains', 'calls', 'imports',
|
|
47
|
+
'configures', 'authenticates', 'validates', 'transforms'
|
|
48
|
+
)),
|
|
49
|
+
weight REAL DEFAULT 1.0,
|
|
50
|
+
metadata JSON,
|
|
51
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
52
|
+
FOREIGN KEY (source_id) REFERENCES context_items(id) ON DELETE CASCADE,
|
|
53
|
+
FOREIGN KEY (target_id) REFERENCES context_items(id) ON DELETE CASCADE,
|
|
54
|
+
UNIQUE(source_id, target_id, relation_type)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
-- Indexes for knowledge_graph
|
|
58
|
+
CREATE INDEX IF NOT EXISTS idx_kg_source ON knowledge_graph(source_id);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_kg_target ON knowledge_graph(target_id);
|
|
60
|
+
CREATE INDEX IF NOT EXISTS idx_kg_relation ON knowledge_graph(relation_type);
|
|
61
|
+
|
|
62
|
+
-- Git commits tracking
|
|
63
|
+
CREATE TABLE IF NOT EXISTS git_commits (
|
|
64
|
+
sha TEXT PRIMARY KEY,
|
|
65
|
+
message TEXT NOT NULL,
|
|
66
|
+
author_name TEXT,
|
|
67
|
+
author_email TEXT,
|
|
68
|
+
timestamp TEXT NOT NULL,
|
|
69
|
+
files_changed JSON,
|
|
70
|
+
stats JSON,
|
|
71
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
-- Indexes for git_commits
|
|
75
|
+
CREATE INDEX IF NOT EXISTS idx_git_commits_timestamp ON git_commits(timestamp);
|
|
76
|
+
CREATE INDEX IF NOT EXISTS idx_git_commits_author ON git_commits(author_email);
|
|
77
|
+
|
|
78
|
+
-- AI tool configurations (claude, cline, copilot, etc.)
|
|
79
|
+
CREATE TABLE IF NOT EXISTS ai_tool_configs (
|
|
80
|
+
id TEXT PRIMARY KEY,
|
|
81
|
+
tool_name TEXT NOT NULL,
|
|
82
|
+
config_path TEXT NOT NULL,
|
|
83
|
+
content TEXT NOT NULL,
|
|
84
|
+
content_hash TEXT,
|
|
85
|
+
last_sync TEXT NOT NULL DEFAULT (datetime('now')),
|
|
86
|
+
status TEXT DEFAULT 'synced' CHECK (status IN ('synced', 'pending', 'conflict', 'error')),
|
|
87
|
+
metadata JSON
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
-- Indexes for ai_tool_configs
|
|
91
|
+
CREATE INDEX IF NOT EXISTS idx_ai_tool_configs_tool ON ai_tool_configs(tool_name);
|
|
92
|
+
CREATE INDEX IF NOT EXISTS idx_ai_tool_configs_status ON ai_tool_configs(status);
|
|
93
|
+
|
|
94
|
+
-- Sync state for shadow file generation and tool sync
|
|
95
|
+
CREATE TABLE IF NOT EXISTS sync_state (
|
|
96
|
+
id TEXT PRIMARY KEY,
|
|
97
|
+
tool TEXT NOT NULL,
|
|
98
|
+
content_hash TEXT,
|
|
99
|
+
last_sync TEXT NOT NULL DEFAULT (datetime('now')),
|
|
100
|
+
file_path TEXT,
|
|
101
|
+
status TEXT DEFAULT 'synced' CHECK (status IN ('synced', 'pending', 'conflict', 'error')),
|
|
102
|
+
metadata JSON
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
-- Indexes for sync_state
|
|
106
|
+
CREATE INDEX IF NOT EXISTS idx_sync_state_tool ON sync_state(tool);
|
|
107
|
+
CREATE INDEX IF NOT EXISTS idx_sync_state_status ON sync_state(status);
|
|
108
|
+
|
|
109
|
+
-- Embedding queue for async processing
|
|
110
|
+
CREATE TABLE IF NOT EXISTS embedding_queue (
|
|
111
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
112
|
+
context_id TEXT NOT NULL,
|
|
113
|
+
status TEXT DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'completed', 'failed')),
|
|
114
|
+
error_message TEXT,
|
|
115
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
116
|
+
processed_at TEXT,
|
|
117
|
+
FOREIGN KEY (context_id) REFERENCES context_items(id) ON DELETE CASCADE
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
-- Index for embedding_queue
|
|
121
|
+
CREATE INDEX IF NOT EXISTS idx_embedding_queue_status ON embedding_queue(status);
|
|
122
|
+
|
|
123
|
+
-- Analytics and usage tracking
|
|
124
|
+
CREATE TABLE IF NOT EXISTS usage_analytics (
|
|
125
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
126
|
+
query TEXT,
|
|
127
|
+
tool_name TEXT,
|
|
128
|
+
result_count INTEGER,
|
|
129
|
+
latency_ms INTEGER,
|
|
130
|
+
timestamp TEXT NOT NULL DEFAULT (datetime('now'))
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
-- Index for analytics
|
|
134
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_timestamp ON usage_analytics(timestamp);
|
|
135
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_tool ON usage_analytics(tool_name);
|
|
136
|
+
|
|
137
|
+
-- Performance metrics tracking
|
|
138
|
+
CREATE TABLE IF NOT EXISTS performance_metrics (
|
|
139
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
140
|
+
metric_name TEXT NOT NULL,
|
|
141
|
+
metric_value REAL NOT NULL,
|
|
142
|
+
metric_unit TEXT,
|
|
143
|
+
recorded_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
144
|
+
metadata JSON
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
-- Index for performance metrics
|
|
148
|
+
CREATE INDEX IF NOT EXISTS idx_performance_metrics_name ON performance_metrics(metric_name);
|
|
149
|
+
CREATE INDEX IF NOT EXISTS idx_performance_metrics_timestamp ON performance_metrics(recorded_at);
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* sqlite-vec virtual table schema
|
|
154
|
+
* Note: This is created separately after loading the extension
|
|
155
|
+
*/
|
|
156
|
+
export const VECTOR_SCHEMA_SQL = `
|
|
157
|
+
-- Vector embeddings using sqlite-vec
|
|
158
|
+
-- Dimension: 1536 for OpenRouter text-embedding-3-small compatible models
|
|
159
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS embeddings USING vec0(
|
|
160
|
+
context_id TEXT PRIMARY KEY,
|
|
161
|
+
embedding FLOAT[1536]
|
|
162
|
+
);
|
|
163
|
+
`;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Relationship types in the knowledge graph
|
|
167
|
+
*/
|
|
168
|
+
export const RELATION_TYPES = [
|
|
169
|
+
'uses',
|
|
170
|
+
'implements',
|
|
171
|
+
'depends_on',
|
|
172
|
+
'references',
|
|
173
|
+
'tests',
|
|
174
|
+
'documents',
|
|
175
|
+
'extends',
|
|
176
|
+
'contains',
|
|
177
|
+
'calls',
|
|
178
|
+
'imports',
|
|
179
|
+
'configures',
|
|
180
|
+
'authenticates',
|
|
181
|
+
'validates',
|
|
182
|
+
'transforms'
|
|
183
|
+
] as const;
|
|
184
|
+
|
|
185
|
+
export type RelationType = typeof RELATION_TYPES[number];
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Context item types - extended to include docs and tool configs
|
|
189
|
+
*/
|
|
190
|
+
export const CONTEXT_TYPES = [
|
|
191
|
+
'workflow',
|
|
192
|
+
'agent',
|
|
193
|
+
'command',
|
|
194
|
+
'code',
|
|
195
|
+
'commit',
|
|
196
|
+
'knowledge',
|
|
197
|
+
'config',
|
|
198
|
+
'doc', // For markdown documentation files
|
|
199
|
+
'tool_config' // For AI tool-specific configurations (.claude, .gemini, etc.)
|
|
200
|
+
] as const;
|
|
201
|
+
|
|
202
|
+
export type ContextType = typeof CONTEXT_TYPES[number];
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Sync status types
|
|
206
|
+
*/
|
|
207
|
+
export const SYNC_STATUSES = ['synced', 'pending', 'conflict', 'error'] as const;
|
|
208
|
+
|
|
209
|
+
export type SyncStatus = typeof SYNC_STATUSES[number];
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Supported AI tools
|
|
213
|
+
*/
|
|
214
|
+
export const AI_TOOLS = [
|
|
215
|
+
'claude',
|
|
216
|
+
'copilot',
|
|
217
|
+
'cline',
|
|
218
|
+
'antigravity',
|
|
219
|
+
'windsurf',
|
|
220
|
+
'aider',
|
|
221
|
+
'continue',
|
|
222
|
+
'cursor',
|
|
223
|
+
'gemini'
|
|
224
|
+
] as const;
|
|
225
|
+
|
|
226
|
+
export type AITool = typeof AI_TOOLS[number];
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* AI tool folder mappings
|
|
230
|
+
*/
|
|
231
|
+
export const AI_TOOL_FOLDERS: Record<AITool, string[]> = {
|
|
232
|
+
claude: ['.claude', 'CLAUDE.md', 'AI_CONTEXT.md'],
|
|
233
|
+
copilot: ['.github/copilot-instructions.md'],
|
|
234
|
+
cline: ['.clinerules', '.cline'],
|
|
235
|
+
antigravity: ['.agent'],
|
|
236
|
+
windsurf: ['.windsurf'],
|
|
237
|
+
aider: ['.aider', '.aider.conf.yml'],
|
|
238
|
+
continue: ['.continue'],
|
|
239
|
+
cursor: ['.cursor', '.cursorrules'],
|
|
240
|
+
gemini: ['.gemini']
|
|
241
|
+
};
|