@nostale/cli 0.1.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 +36 -0
- package/assets/docker-compose.server.yml +70 -0
- package/dist/commands/config/generation.js +23 -0
- package/dist/commands/config/providers.js +138 -0
- package/dist/commands/config/sources.js +145 -0
- package/dist/commands/config/templates.js +117 -0
- package/dist/commands/config/tokens.js +83 -0
- package/dist/commands/config.js +43 -0
- package/dist/commands/doctor.js +98 -0
- package/dist/commands/setup.js +5 -0
- package/dist/commands/start.js +23 -0
- package/dist/commands/status.js +17 -0
- package/dist/commands/stop.js +16 -0
- package/dist/index.js +23 -0
- package/dist/lib/api-config.js +21 -0
- package/dist/lib/env-writer.js +41 -0
- package/dist/lib/http.js +117 -0
- package/dist/lib/install-root.js +75 -0
- package/dist/lib/paths.js +12 -0
- package/dist/lib/ports.js +19 -0
- package/dist/lib/process-manager.js +151 -0
- package/dist/lib/repo-root.js +34 -0
- package/dist/lib/wizard.js +267 -0
- package/dist/tui/prompts.js +54 -0
- package/package.json +69 -0
- package/services/mcp-server/index.cjs +48326 -0
- package/services/migrations/001_init_rag_v1.sql +128 -0
- package/services/migrations/002_doc_lifecycle.sql +96 -0
- package/services/migrations/004_mcp_tokens.sql +11 -0
- package/services/migrations/005_settings.sql +28 -0
- package/services/migrations/006_document_sources.sql +14 -0
- package/services/migrations/007_generation_settings.sql +9 -0
- package/services/migrations/008_llm_provider_configs_unique.sql +5 -0
- package/services/wasm/tree-sitter-c.wasm +0 -0
- package/services/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/services/wasm/tree-sitter-cpp.wasm +0 -0
- package/services/wasm/tree-sitter-dart.wasm +0 -0
- package/services/wasm/tree-sitter-go.wasm +0 -0
- package/services/wasm/tree-sitter-java.wasm +0 -0
- package/services/wasm/tree-sitter-javascript.wasm +0 -0
- package/services/wasm/tree-sitter-kotlin.wasm +0 -0
- package/services/wasm/tree-sitter-php.wasm +0 -0
- package/services/wasm/tree-sitter-python.wasm +0 -0
- package/services/wasm/tree-sitter-rust.wasm +0 -0
- package/services/wasm/tree-sitter-tsx.wasm +0 -0
- package/services/wasm/tree-sitter-typescript.wasm +0 -0
- package/services/wasm/tree-sitter.wasm +0 -0
- package/services/wiki-api/index.cjs +82370 -0
- package/services/wiki-web/.output/nitro.json +15 -0
- package/services/wiki-web/.output/public/_nuxt/68caad34b1e80fa12b3a.4Cpu5VkB.woff +0 -0
- package/services/wiki-web/.output/public/_nuxt/6b042d50787d4a81d659.D7JGeKLp.svg +1835 -0
- package/services/wiki-web/.output/public/_nuxt/9065bfe481020b04b68a.CMveUrS1.woff2 +0 -0
- package/services/wiki-web/.output/public/_nuxt/B5j-AdCY.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/BAgZ2ZFT.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/BcxnhBGC.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/BeIDAJKt.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/BebqDWPm.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/CFx_Wb7e.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/CSEkmdhK.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/CXYMfke_.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/Cap3hpB7.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/Ckd7UvSj.js +3 -0
- package/services/wiki-web/.output/public/_nuxt/D0DJQL09.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/DRDlUXmk.js +66 -0
- package/services/wiki-web/.output/public/_nuxt/DW42QLqA.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/DdDtdYim.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/Dm1y7TW1.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/DptiLPkM.js +4 -0
- package/services/wiki-web/.output/public/_nuxt/QFl-TMXl.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/_id_.JvKV2jiN.css +1 -0
- package/services/wiki-web/.output/public/_nuxt/a9c9056a643325579e2a.CCNAgZDa.ttf +0 -0
- package/services/wiki-web/.output/public/_nuxt/bojElwT6.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/builds/latest.json +1 -0
- package/services/wiki-web/.output/public/_nuxt/builds/meta/f68e5546-2919-478b-b4ad-702826e8383c.json +1 -0
- package/services/wiki-web/.output/public/_nuxt/d495aba62101f856c80f.DJ4Lg1TH.eot +0 -0
- package/services/wiki-web/.output/public/_nuxt/entry.isoIPAS3.css +1 -0
- package/services/wiki-web/.output/public/_nuxt/f8QtLg7g.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/nhMvlSQm.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/pFBugkEL.js +1 -0
- package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-latin-ext-wght-normal.DmpS2jIq.woff2 +0 -0
- package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-latin-wght-normal.eXO_dkmS.woff2 +0 -0
- package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-vietnamese-wght-normal.qRpaaN48.woff2 +0 -0
- package/services/wiki-web/.output/public/favicon.svg +6 -0
- package/services/wiki-web/.output/public/robots.txt +2 -0
- package/services/wiki-web/.output/server/chunks/_/error-500.mjs +19 -0
- package/services/wiki-web/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/services/wiki-web/.output/server/chunks/build/client.precomputed.mjs +4 -0
- package/services/wiki-web/.output/server/chunks/build/client.precomputed.mjs.map +1 -0
- package/services/wiki-web/.output/server/chunks/nitro/nitro.mjs +5352 -0
- package/services/wiki-web/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/services/wiki-web/.output/server/chunks/routes/api-proxy/_...path_.mjs +34 -0
- package/services/wiki-web/.output/server/chunks/routes/api-proxy/_...path_.mjs.map +1 -0
- package/services/wiki-web/.output/server/chunks/routes/renderer.mjs +369 -0
- package/services/wiki-web/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/services/wiki-web/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/services/wiki-web/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/services/wiki-web/.output/server/index.mjs +10 -0
- package/services/wiki-web/.output/server/index.mjs.map +1 -0
- package/services/wiki-web/.output/server/node_modules/@babel/parser/lib/index.js +14599 -0
- package/services/wiki-web/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6759 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/services/wiki-web/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/services/wiki-web/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1899 -0
- package/services/wiki-web/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/services/wiki-web/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6940 -0
- package/services/wiki-web/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/services/wiki-web/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1822 -0
- package/services/wiki-web/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/services/wiki-web/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +896 -0
- package/services/wiki-web/.output/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/services/wiki-web/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +604 -0
- package/services/wiki-web/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/services/wiki-web/.output/server/node_modules/devalue/index.js +4 -0
- package/services/wiki-web/.output/server/node_modules/devalue/package.json +40 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/parse.js +283 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/stringify.js +401 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/uneval.js +552 -0
- package/services/wiki-web/.output/server/node_modules/devalue/src/utils.js +160 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/services/wiki-web/.output/server/node_modules/entities/package.json +120 -0
- package/services/wiki-web/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/services/wiki-web/.output/server/node_modules/estree-walker/package.json +37 -0
- package/services/wiki-web/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/services/wiki-web/.output/server/node_modules/hookable/package.json +53 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/package.json +71 -0
- package/services/wiki-web/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/services/wiki-web/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/services/wiki-web/.output/server/node_modules/ufo/package.json +48 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/server.mjs +180 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.B3VbJo7Y.mjs +207 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.CaI5ZD4O.mjs +182 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/services/wiki-web/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/services/wiki-web/.output/server/node_modules/unhead/package.json +105 -0
- package/services/wiki-web/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/services/wiki-web/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/services/wiki-web/.output/server/node_modules/vue/index.js +7 -0
- package/services/wiki-web/.output/server/node_modules/vue/index.mjs +1 -0
- package/services/wiki-web/.output/server/node_modules/vue/package.json +112 -0
- package/services/wiki-web/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/services/wiki-web/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +249 -0
- package/services/wiki-web/.output/server/node_modules/vue-bundle-renderer/package.json +57 -0
- package/services/wiki-web/.output/server/package.json +26 -0
- package/services/wiki-worker/index.cjs +66661 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
PRAGMA foreign_keys = ON;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE documents (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
project TEXT NOT NULL,
|
|
6
|
+
repo_group TEXT NOT NULL,
|
|
7
|
+
doc_type TEXT NOT NULL CHECK (doc_type IN (
|
|
8
|
+
'product_spec', 'technical_design', 'code_index',
|
|
9
|
+
'code_module', 'schema', 'graph', 'meta'
|
|
10
|
+
)),
|
|
11
|
+
source_path TEXT NOT NULL,
|
|
12
|
+
title TEXT NOT NULL,
|
|
13
|
+
module TEXT,
|
|
14
|
+
feature TEXT,
|
|
15
|
+
language TEXT,
|
|
16
|
+
content_hash TEXT NOT NULL,
|
|
17
|
+
version_tag TEXT,
|
|
18
|
+
raw_metadata TEXT NOT NULL DEFAULT '{}',
|
|
19
|
+
ingested_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
20
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
21
|
+
UNIQUE (project, source_path, content_hash)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE INDEX documents_project_idx ON documents (project);
|
|
25
|
+
CREATE INDEX documents_doc_type_idx ON documents (doc_type);
|
|
26
|
+
CREATE INDEX documents_module_idx ON documents (module);
|
|
27
|
+
CREATE INDEX documents_feature_idx ON documents (feature);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE chunks (
|
|
30
|
+
id TEXT PRIMARY KEY,
|
|
31
|
+
document_id TEXT NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
|
|
32
|
+
chunk_index INTEGER NOT NULL CHECK (chunk_index >= 0),
|
|
33
|
+
heading_path TEXT NOT NULL DEFAULT '[]',
|
|
34
|
+
section_title TEXT,
|
|
35
|
+
content TEXT NOT NULL,
|
|
36
|
+
content_hash TEXT NOT NULL,
|
|
37
|
+
token_count INTEGER NOT NULL DEFAULT 0,
|
|
38
|
+
char_count INTEGER NOT NULL DEFAULT 0,
|
|
39
|
+
start_line INTEGER,
|
|
40
|
+
end_line INTEGER,
|
|
41
|
+
priority INTEGER NOT NULL DEFAULT 50 CHECK (priority BETWEEN 0 AND 100),
|
|
42
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
43
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
44
|
+
UNIQUE (document_id, chunk_index)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
CREATE INDEX chunks_document_id_idx ON chunks (document_id);
|
|
48
|
+
CREATE INDEX chunks_priority_idx ON chunks (priority DESC);
|
|
49
|
+
|
|
50
|
+
CREATE VIRTUAL TABLE chunks_fts USING fts5(
|
|
51
|
+
content, section_title, content='chunks', content_rowid='rowid'
|
|
52
|
+
);
|
|
53
|
+
CREATE TRIGGER chunks_fts_ai AFTER INSERT ON chunks BEGIN
|
|
54
|
+
INSERT INTO chunks_fts(rowid, content, section_title) VALUES (new.rowid, new.content, new.section_title);
|
|
55
|
+
END;
|
|
56
|
+
CREATE TRIGGER chunks_fts_ad AFTER DELETE ON chunks BEGIN
|
|
57
|
+
INSERT INTO chunks_fts(chunks_fts, rowid, content, section_title) VALUES ('delete', old.rowid, old.content, old.section_title);
|
|
58
|
+
END;
|
|
59
|
+
CREATE TRIGGER chunks_fts_au AFTER UPDATE ON chunks BEGIN
|
|
60
|
+
INSERT INTO chunks_fts(chunks_fts, rowid, content, section_title) VALUES ('delete', old.rowid, old.content, old.section_title);
|
|
61
|
+
INSERT INTO chunks_fts(rowid, content, section_title) VALUES (new.rowid, new.content, new.section_title);
|
|
62
|
+
END;
|
|
63
|
+
|
|
64
|
+
CREATE TABLE embeddings (
|
|
65
|
+
chunk_id TEXT PRIMARY KEY REFERENCES chunks(id) ON DELETE CASCADE,
|
|
66
|
+
embedding FLOAT32(1536) NOT NULL,
|
|
67
|
+
model_name TEXT NOT NULL,
|
|
68
|
+
dim INTEGER NOT NULL CHECK (dim > 0),
|
|
69
|
+
embedded_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
CREATE INDEX embeddings_vec_idx ON embeddings (libsql_vector_idx(embedding));
|
|
73
|
+
CREATE INDEX embeddings_model_name_idx ON embeddings (model_name);
|
|
74
|
+
|
|
75
|
+
CREATE TABLE chunk_entities (
|
|
76
|
+
id TEXT PRIMARY KEY,
|
|
77
|
+
chunk_id TEXT NOT NULL REFERENCES chunks(id) ON DELETE CASCADE,
|
|
78
|
+
entity_type TEXT NOT NULL CHECK (entity_type IN ('symbol', 'route', 'table', 'column')),
|
|
79
|
+
entity_name TEXT NOT NULL,
|
|
80
|
+
entity_value TEXT,
|
|
81
|
+
confidence REAL,
|
|
82
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
CREATE INDEX chunk_entities_chunk_id_idx ON chunk_entities (chunk_id);
|
|
86
|
+
|
|
87
|
+
CREATE TABLE graph_nodes (
|
|
88
|
+
id TEXT PRIMARY KEY,
|
|
89
|
+
project TEXT NOT NULL,
|
|
90
|
+
node_type TEXT NOT NULL,
|
|
91
|
+
node_name TEXT NOT NULL,
|
|
92
|
+
source_path TEXT,
|
|
93
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
94
|
+
UNIQUE (project, node_type, node_name)
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
CREATE INDEX graph_nodes_source_path_idx ON graph_nodes (project, source_path);
|
|
98
|
+
|
|
99
|
+
CREATE TABLE graph_edges (
|
|
100
|
+
id TEXT PRIMARY KEY,
|
|
101
|
+
project TEXT NOT NULL,
|
|
102
|
+
from_node_id TEXT NOT NULL REFERENCES graph_nodes(id),
|
|
103
|
+
to_node_id TEXT NOT NULL REFERENCES graph_nodes(id),
|
|
104
|
+
edge_type TEXT NOT NULL,
|
|
105
|
+
weight REAL,
|
|
106
|
+
source_path TEXT,
|
|
107
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
108
|
+
UNIQUE (project, source_path, edge_type, from_node_id, to_node_id)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
-- Index berikut menopang query blast-radius incremental sync (lihat 10-incremental-sync.md):
|
|
112
|
+
-- "file mana saja yang mereferensikan simbol dari file yang berubah?"
|
|
113
|
+
CREATE INDEX graph_edges_to_node_id_idx ON graph_edges (to_node_id);
|
|
114
|
+
CREATE INDEX graph_edges_source_path_idx ON graph_edges (project, source_path);
|
|
115
|
+
|
|
116
|
+
CREATE TABLE retrieval_logs (
|
|
117
|
+
id TEXT PRIMARY KEY,
|
|
118
|
+
query_text TEXT NOT NULL,
|
|
119
|
+
project_filter TEXT,
|
|
120
|
+
module_filter TEXT,
|
|
121
|
+
route TEXT NOT NULL,
|
|
122
|
+
topk_returned INTEGER NOT NULL,
|
|
123
|
+
candidate_count INTEGER NOT NULL,
|
|
124
|
+
retrieved_chunk_ids TEXT NOT NULL DEFAULT '[]',
|
|
125
|
+
answer_confidence REAL,
|
|
126
|
+
latency_ms INTEGER,
|
|
127
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
128
|
+
);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
CREATE TABLE source_files (
|
|
2
|
+
project TEXT NOT NULL,
|
|
3
|
+
file_path TEXT NOT NULL,
|
|
4
|
+
content_hash TEXT NOT NULL,
|
|
5
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
6
|
+
PRIMARY KEY (project, file_path)
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
CREATE TABLE doc_artifacts (
|
|
10
|
+
id TEXT PRIMARY KEY,
|
|
11
|
+
project TEXT NOT NULL,
|
|
12
|
+
doc_kind TEXT NOT NULL CHECK (doc_kind IN ('prd', 'tdd')),
|
|
13
|
+
module TEXT NOT NULL,
|
|
14
|
+
feature TEXT NOT NULL,
|
|
15
|
+
file_path TEXT NOT NULL,
|
|
16
|
+
status TEXT NOT NULL DEFAULT 'draft'
|
|
17
|
+
CHECK (status IN ('draft', 'needs_review', 'approved', 'stale', 'regenerating')),
|
|
18
|
+
current_version INTEGER NOT NULL DEFAULT 1,
|
|
19
|
+
source_content_hash TEXT NOT NULL,
|
|
20
|
+
open_questions_count INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
22
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
23
|
+
UNIQUE (project, doc_kind, module, feature)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE INDEX doc_artifacts_project_idx ON doc_artifacts (project);
|
|
27
|
+
CREATE INDEX doc_artifacts_status_idx ON doc_artifacts (status);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE agent_runs (
|
|
30
|
+
id TEXT PRIMARY KEY,
|
|
31
|
+
agent_key TEXT NOT NULL CHECK (agent_key IN (
|
|
32
|
+
'feature-discovery', 'tdd-writer', 'prd-writer',
|
|
33
|
+
'documentation-audit', 'gap-summary', 'traceability-matrix'
|
|
34
|
+
)),
|
|
35
|
+
project TEXT NOT NULL,
|
|
36
|
+
target_module TEXT,
|
|
37
|
+
target_feature TEXT,
|
|
38
|
+
trigger_source TEXT NOT NULL CHECK (trigger_source IN ('webhook', 'ci', 'manual', 'staleness_scan', 'schedule')),
|
|
39
|
+
triggered_by_user_id TEXT,
|
|
40
|
+
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed')),
|
|
41
|
+
llm_provider TEXT NOT NULL,
|
|
42
|
+
llm_model TEXT NOT NULL,
|
|
43
|
+
input_token_count INTEGER,
|
|
44
|
+
output_token_count INTEGER,
|
|
45
|
+
error_message TEXT,
|
|
46
|
+
started_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
47
|
+
finished_at TEXT
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
CREATE INDEX agent_runs_project_idx ON agent_runs (project);
|
|
51
|
+
CREATE INDEX agent_runs_started_at_idx ON agent_runs (started_at DESC);
|
|
52
|
+
|
|
53
|
+
CREATE TABLE doc_versions (
|
|
54
|
+
id TEXT PRIMARY KEY,
|
|
55
|
+
doc_artifact_id TEXT NOT NULL REFERENCES doc_artifacts(id) ON DELETE CASCADE,
|
|
56
|
+
version_number INTEGER NOT NULL,
|
|
57
|
+
content TEXT NOT NULL,
|
|
58
|
+
content_hash TEXT NOT NULL,
|
|
59
|
+
generated_by TEXT NOT NULL,
|
|
60
|
+
agent_run_id TEXT REFERENCES agent_runs(id),
|
|
61
|
+
reviewer_note TEXT,
|
|
62
|
+
reviewed_by_user_id TEXT,
|
|
63
|
+
reviewed_at TEXT,
|
|
64
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
65
|
+
UNIQUE (doc_artifact_id, version_number)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
CREATE INDEX doc_versions_created_at_idx ON doc_versions (created_at);
|
|
69
|
+
|
|
70
|
+
CREATE TABLE traceability_links (
|
|
71
|
+
id TEXT PRIMARY KEY,
|
|
72
|
+
project TEXT NOT NULL,
|
|
73
|
+
feature TEXT NOT NULL,
|
|
74
|
+
tdd_artifact_id TEXT REFERENCES doc_artifacts(id),
|
|
75
|
+
prd_artifact_id TEXT REFERENCES doc_artifacts(id),
|
|
76
|
+
code_source_paths TEXT NOT NULL DEFAULT '[]',
|
|
77
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
CREATE TABLE repo_sync_state (
|
|
81
|
+
project TEXT PRIMARY KEY,
|
|
82
|
+
source_type TEXT NOT NULL CHECK (source_type IN ('github_app', 'deploy_key', 'local_path')),
|
|
83
|
+
git_url TEXT,
|
|
84
|
+
github_app_installation_id TEXT,
|
|
85
|
+
deploy_key_secret_ref TEXT,
|
|
86
|
+
local_path TEXT,
|
|
87
|
+
default_branch TEXT NOT NULL DEFAULT 'main',
|
|
88
|
+
latest_known_commit TEXT,
|
|
89
|
+
last_synced_commit TEXT,
|
|
90
|
+
last_synced_at TEXT,
|
|
91
|
+
webhook_secret TEXT,
|
|
92
|
+
CHECK (
|
|
93
|
+
(source_type = 'local_path' AND local_path IS NOT NULL)
|
|
94
|
+
OR (source_type IN ('github_app', 'deploy_key') AND git_url IS NOT NULL)
|
|
95
|
+
)
|
|
96
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE mcp_access_tokens (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
user_id TEXT NOT NULL,
|
|
4
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
5
|
+
label TEXT,
|
|
6
|
+
last_used_at TEXT,
|
|
7
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
8
|
+
revoked_at TEXT
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
CREATE INDEX mcp_access_tokens_user_id_idx ON mcp_access_tokens (user_id);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
CREATE TABLE llm_provider_configs (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
provider TEXT NOT NULL CHECK (provider IN ('anthropic', 'openai_compatible')),
|
|
4
|
+
label TEXT NOT NULL,
|
|
5
|
+
api_key_encrypted TEXT NOT NULL,
|
|
6
|
+
base_url TEXT,
|
|
7
|
+
default_model TEXT NOT NULL,
|
|
8
|
+
is_active INTEGER NOT NULL DEFAULT 1 CHECK (is_active IN (0, 1)),
|
|
9
|
+
created_by_user_id TEXT,
|
|
10
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
11
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE TABLE document_templates (
|
|
15
|
+
id TEXT PRIMARY KEY,
|
|
16
|
+
project TEXT,
|
|
17
|
+
doc_kind TEXT NOT NULL CHECK (doc_kind IN ('prd', 'tdd')),
|
|
18
|
+
name TEXT NOT NULL,
|
|
19
|
+
sections TEXT NOT NULL,
|
|
20
|
+
system_prompt_override TEXT,
|
|
21
|
+
is_active INTEGER NOT NULL DEFAULT 1 CHECK (is_active IN (0, 1)),
|
|
22
|
+
created_by_user_id TEXT,
|
|
23
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
24
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
25
|
+
UNIQUE (project, doc_kind, name)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX document_templates_lookup_idx ON document_templates (project, doc_kind, is_active);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE TABLE document_sources (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
project TEXT NOT NULL,
|
|
4
|
+
source_type TEXT NOT NULL CHECK (source_type IN ('document_folder', 'document_upload')),
|
|
5
|
+
folder_path TEXT,
|
|
6
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
7
|
+
last_synced_at TEXT,
|
|
8
|
+
CHECK (
|
|
9
|
+
(source_type = 'document_folder' AND folder_path IS NOT NULL)
|
|
10
|
+
OR (source_type = 'document_upload' AND folder_path IS NULL)
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX document_sources_project_idx ON document_sources (project);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- M17: per-project toggle for whether sync runs the feature-discovery/tdd-writer/prd-writer
|
|
2
|
+
-- agents after ingestion. Deliberately a new table, not a column on repo_sync_state: a
|
|
3
|
+
-- document-only project (M15/M16's document_sources) never gets a repo_sync_state row, so a
|
|
4
|
+
-- cross-cutting setting living there would be silently inapplicable to exactly the milestone's
|
|
5
|
+
-- own stated primary use case. Same reasoning already used for document_sources in M15.
|
|
6
|
+
CREATE TABLE project_settings (
|
|
7
|
+
project TEXT PRIMARY KEY,
|
|
8
|
+
auto_generate_docs INTEGER NOT NULL DEFAULT 1 CHECK (auto_generate_docs IN (0, 1))
|
|
9
|
+
);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- upsertLlmProviderConfig was a plain INSERT with no natural-key lookup, so every
|
|
2
|
+
-- "edit"/"deactivate" call created a new row instead of updating the existing one
|
|
3
|
+
-- (found during M18's CLI parity work). This unique index lets the fixed upsert use
|
|
4
|
+
-- ON CONFLICT safely, including under concurrent inserts racing the same (provider, label).
|
|
5
|
+
CREATE UNIQUE INDEX llm_provider_configs_provider_label_idx ON llm_provider_configs (provider, label);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|