@askdkc/kiokuko 0.2.7 → 0.2.9

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.
Files changed (185) hide show
  1. package/README.ja.md +17 -22
  2. package/README.ko.md +16 -22
  3. package/README.md +23 -23
  4. package/README.zh-CN.md +14 -20
  5. package/dist/akinator/agent-task.d.ts +2 -0
  6. package/dist/akinator/agent-task.d.ts.map +1 -1
  7. package/dist/akinator/agent-task.js +62 -26
  8. package/dist/akinator/agent-task.js.map +1 -1
  9. package/dist/akinator/domain.d.ts.map +1 -1
  10. package/dist/akinator/domain.js +36 -19
  11. package/dist/akinator/domain.js.map +1 -1
  12. package/dist/cli.d.ts.map +1 -1
  13. package/dist/cli.js +8 -3
  14. package/dist/cli.js.map +1 -1
  15. package/dist/commands/doctor.d.ts.map +1 -1
  16. package/dist/commands/doctor.js +6 -3
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/embeddings.d.ts +9 -0
  19. package/dist/commands/embeddings.d.ts.map +1 -1
  20. package/dist/commands/embeddings.js +58 -1
  21. package/dist/commands/embeddings.js.map +1 -1
  22. package/dist/commands/use.d.ts.map +1 -1
  23. package/dist/commands/use.js +4 -2
  24. package/dist/commands/use.js.map +1 -1
  25. package/dist/config/paths.d.ts +5 -0
  26. package/dist/config/paths.d.ts.map +1 -1
  27. package/dist/config/paths.js +34 -0
  28. package/dist/config/paths.js.map +1 -1
  29. package/dist/embedding/backend.d.ts +1 -1
  30. package/dist/embedding/backend.d.ts.map +1 -1
  31. package/dist/embedding/backend.js +20 -4
  32. package/dist/embedding/backend.js.map +1 -1
  33. package/dist/embedding/config.d.ts +3 -0
  34. package/dist/embedding/config.d.ts.map +1 -1
  35. package/dist/embedding/config.js +17 -0
  36. package/dist/embedding/config.js.map +1 -1
  37. package/dist/embedding/diagnostics.d.ts +1 -1
  38. package/dist/embedding/diagnostics.d.ts.map +1 -1
  39. package/dist/embedding/diagnostics.js +20 -5
  40. package/dist/embedding/diagnostics.js.map +1 -1
  41. package/dist/embedding/document.d.ts +5 -0
  42. package/dist/embedding/document.d.ts.map +1 -1
  43. package/dist/embedding/document.js +20 -0
  44. package/dist/embedding/document.js.map +1 -1
  45. package/dist/embedding/local-model-loader.d.ts +24 -0
  46. package/dist/embedding/local-model-loader.d.ts.map +1 -0
  47. package/dist/embedding/local-model-loader.js +64 -0
  48. package/dist/embedding/local-model-loader.js.map +1 -0
  49. package/dist/embedding/local-transformers-provider.d.ts +17 -0
  50. package/dist/embedding/local-transformers-provider.d.ts.map +1 -0
  51. package/dist/embedding/local-transformers-provider.js +54 -0
  52. package/dist/embedding/local-transformers-provider.js.map +1 -0
  53. package/dist/embedding/model-download.d.ts +32 -0
  54. package/dist/embedding/model-download.d.ts.map +1 -0
  55. package/dist/embedding/model-download.js +41 -0
  56. package/dist/embedding/model-download.js.map +1 -0
  57. package/dist/embedding/model-installation.d.ts +17 -0
  58. package/dist/embedding/model-installation.d.ts.map +1 -0
  59. package/dist/embedding/model-installation.js +71 -0
  60. package/dist/embedding/model-installation.js.map +1 -0
  61. package/dist/embedding/model-manifest.d.ts +18 -0
  62. package/dist/embedding/model-manifest.d.ts.map +1 -0
  63. package/dist/embedding/model-manifest.js +86 -0
  64. package/dist/embedding/model-manifest.js.map +1 -0
  65. package/dist/embedding/presets/local-small.d.ts +8 -0
  66. package/dist/embedding/presets/local-small.d.ts.map +1 -0
  67. package/dist/embedding/presets/local-small.js +67 -0
  68. package/dist/embedding/presets/local-small.js.map +1 -0
  69. package/dist/embedding/presets/manifest.d.ts +27 -0
  70. package/dist/embedding/presets/manifest.d.ts.map +1 -0
  71. package/dist/embedding/presets/manifest.js +5 -0
  72. package/dist/embedding/presets/manifest.js.map +1 -0
  73. package/dist/embedding/profile.d.ts +6 -2
  74. package/dist/embedding/profile.d.ts.map +1 -1
  75. package/dist/embedding/profile.js +36 -0
  76. package/dist/embedding/profile.js.map +1 -1
  77. package/dist/embedding/query-cache.d.ts +6 -0
  78. package/dist/embedding/query-cache.d.ts.map +1 -1
  79. package/dist/embedding/query-cache.js +21 -0
  80. package/dist/embedding/query-cache.js.map +1 -1
  81. package/dist/embedding/runtime.d.ts +2 -1
  82. package/dist/embedding/runtime.d.ts.map +1 -1
  83. package/dist/embedding/runtime.js +39 -5
  84. package/dist/embedding/runtime.js.map +1 -1
  85. package/dist/embedding/settings.d.ts +6 -0
  86. package/dist/embedding/settings.d.ts.map +1 -0
  87. package/dist/embedding/settings.js +69 -0
  88. package/dist/embedding/settings.js.map +1 -0
  89. package/dist/embedding/setup-lock.d.ts +7 -0
  90. package/dist/embedding/setup-lock.d.ts.map +1 -0
  91. package/dist/embedding/setup-lock.js +35 -0
  92. package/dist/embedding/setup-lock.js.map +1 -0
  93. package/dist/embedding/setup-service.d.ts +53 -0
  94. package/dist/embedding/setup-service.d.ts.map +1 -0
  95. package/dist/embedding/setup-service.js +184 -0
  96. package/dist/embedding/setup-service.js.map +1 -0
  97. package/dist/embedding/store.d.ts +3 -1
  98. package/dist/embedding/store.d.ts.map +1 -1
  99. package/dist/embedding/store.js +124 -11
  100. package/dist/embedding/store.js.map +1 -1
  101. package/dist/embedding/types.d.ts +31 -2
  102. package/dist/embedding/types.d.ts.map +1 -1
  103. package/dist/enno-oduno/directives.js +1 -1
  104. package/dist/enno-oduno/directives.js.map +1 -1
  105. package/dist/enno-oduno/instructions.d.ts +1 -1
  106. package/dist/enno-oduno/instructions.d.ts.map +1 -1
  107. package/dist/enno-oduno/instructions.js +1 -1
  108. package/dist/enno-oduno/instructions.js.map +1 -1
  109. package/dist/enno-oduno/schemas.d.ts +9 -0
  110. package/dist/enno-oduno/schemas.d.ts.map +1 -1
  111. package/dist/enno-oduno/schemas.js +11 -0
  112. package/dist/enno-oduno/schemas.js.map +1 -1
  113. package/dist/enno-oduno/service.d.ts +7 -1
  114. package/dist/enno-oduno/service.d.ts.map +1 -1
  115. package/dist/enno-oduno/service.js +52 -1
  116. package/dist/enno-oduno/service.js.map +1 -1
  117. package/dist/enno-oduno/validation-errors.d.ts +2 -1
  118. package/dist/enno-oduno/validation-errors.d.ts.map +1 -1
  119. package/dist/enno-oduno/validation-errors.js +1 -0
  120. package/dist/enno-oduno/validation-errors.js.map +1 -1
  121. package/dist/enno-oduno/verifier.d.ts.map +1 -1
  122. package/dist/enno-oduno/verifier.js +27 -2
  123. package/dist/enno-oduno/verifier.js.map +1 -1
  124. package/dist/mcp/bounded-stdio-transport.d.ts +3 -10
  125. package/dist/mcp/bounded-stdio-transport.d.ts.map +1 -1
  126. package/dist/mcp/bounded-stdio-transport.js +2 -89
  127. package/dist/mcp/bounded-stdio-transport.js.map +1 -1
  128. package/dist/mcp/request-deadline.d.ts +51 -0
  129. package/dist/mcp/request-deadline.d.ts.map +1 -0
  130. package/dist/mcp/request-deadline.js +155 -0
  131. package/dist/mcp/request-deadline.js.map +1 -0
  132. package/dist/mcp/runtime-owner.d.ts.map +1 -1
  133. package/dist/mcp/runtime-owner.js +2 -3
  134. package/dist/mcp/runtime-owner.js.map +1 -1
  135. package/dist/mcp/server.d.ts +2 -0
  136. package/dist/mcp/server.d.ts.map +1 -1
  137. package/dist/mcp/server.js +58 -23
  138. package/dist/mcp/server.js.map +1 -1
  139. package/dist/memory/scoped-memory.d.ts +1 -1
  140. package/dist/memory/scoped-memory.d.ts.map +1 -1
  141. package/dist/memory/scoped-memory.js +5 -1
  142. package/dist/memory/scoped-memory.js.map +1 -1
  143. package/dist/server/http.d.ts +1 -1
  144. package/dist/server/http.d.ts.map +1 -1
  145. package/dist/server/http.js +6 -3
  146. package/dist/server/http.js.map +1 -1
  147. package/dist/skills/discovery-service.d.ts.map +1 -1
  148. package/dist/skills/discovery-service.js +10 -8
  149. package/dist/skills/discovery-service.js.map +1 -1
  150. package/dist/skills/find.d.ts +1 -0
  151. package/dist/skills/find.d.ts.map +1 -1
  152. package/dist/skills/find.js +1 -0
  153. package/dist/skills/find.js.map +1 -1
  154. package/dist/skills/materialization-authority.d.ts +1 -1
  155. package/dist/skills/materialization-authority.d.ts.map +1 -1
  156. package/dist/skills/materialization-authority.js +2 -2
  157. package/dist/skills/materialization-authority.js.map +1 -1
  158. package/dist/skills/providers/skills-sh-compat.d.ts.map +1 -1
  159. package/dist/skills/providers/skills-sh-compat.js +4 -2
  160. package/dist/skills/providers/skills-sh-compat.js.map +1 -1
  161. package/dist/skills/providers/skills-sh-v1.d.ts +2 -2
  162. package/dist/skills/providers/skills-sh-v1.d.ts.map +1 -1
  163. package/dist/skills/providers/skills-sh-v1.js +22 -4
  164. package/dist/skills/providers/skills-sh-v1.js.map +1 -1
  165. package/dist/skills/source/github-fetcher.d.ts.map +1 -1
  166. package/dist/skills/source/github-fetcher.js +8 -4
  167. package/dist/skills/source/github-fetcher.js.map +1 -1
  168. package/dist/skills/types.d.ts +3 -2
  169. package/dist/skills/types.d.ts.map +1 -1
  170. package/docs/agent-file.md +72 -0
  171. package/docs/agent-gateway.md +104 -0
  172. package/docs/architecture.md +12 -0
  173. package/docs/cli-contract.md +35 -0
  174. package/docs/client-compatibility.md +298 -0
  175. package/docs/database.md +11 -0
  176. package/docs/execution-ledger.md +89 -0
  177. package/docs/release-notes-0.1.18.md +103 -0
  178. package/docs/retrieval-evaluation.md +10 -0
  179. package/docs/security.md +11 -0
  180. package/docs/sqlite-driver-adr.md +8 -0
  181. package/migrations/022_embedding_setup_v2.sql +236 -0
  182. package/migrations/down/022_embedding_setup_v2.sql +133 -0
  183. package/package.json +24 -3
  184. package/skills/kiokuko-enno-oduno/SKILL.md +44 -0
  185. package/templates/AGENTS.md +1 -1
@@ -0,0 +1,236 @@
1
+ -- Persist local embedding setup state while retaining the immutable v1
2
+ -- semantic projections. This migration performs no model or network I/O.
3
+
4
+ CREATE TABLE embedding_profiles_v2 (
5
+ profile_id TEXT PRIMARY KEY
6
+ CHECK (length(profile_id) = 64 AND profile_id NOT GLOB '*[^0-9a-f]*'),
7
+ schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version IN (1, 2)),
8
+ provider_kind TEXT NOT NULL
9
+ CHECK (provider_kind IN ('openai-compatible', 'local-transformers')),
10
+ endpoint_fingerprint TEXT
11
+ CHECK (endpoint_fingerprint IS NULL OR (length(endpoint_fingerprint) = 64 AND endpoint_fingerprint NOT GLOB '*[^0-9a-f]*')),
12
+ model TEXT NOT NULL,
13
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
14
+ distance_metric TEXT NOT NULL CHECK (distance_metric = 'cosine'),
15
+ distance_ceiling REAL NOT NULL CHECK (distance_ceiling > 0.0 AND distance_ceiling < 2.0),
16
+ document_template_version INTEGER NOT NULL CHECK (document_template_version > 0),
17
+ query_template_version INTEGER NOT NULL CHECK (query_template_version > 0),
18
+ preset_id TEXT,
19
+ source_model TEXT,
20
+ artifact_repository TEXT,
21
+ model_revision TEXT,
22
+ artifact_manifest_hash TEXT
23
+ CHECK (artifact_manifest_hash IS NULL OR (length(artifact_manifest_hash) = 64 AND artifact_manifest_hash NOT GLOB '*[^0-9a-f]*')),
24
+ inference_engine TEXT,
25
+ inference_engine_version TEXT,
26
+ dtype TEXT,
27
+ pooling TEXT,
28
+ normalize INTEGER CHECK (normalize IS NULL OR normalize IN (0, 1)),
29
+ maximum_tokens INTEGER CHECK (maximum_tokens IS NULL OR maximum_tokens > 0),
30
+ input_contract TEXT,
31
+ query_prefix TEXT,
32
+ document_prefix TEXT,
33
+ created_at TEXT NOT NULL,
34
+ CHECK (
35
+ (schema_version = 1 AND provider_kind = 'openai-compatible'
36
+ AND endpoint_fingerprint IS NOT NULL
37
+ AND preset_id IS NULL AND source_model IS NULL AND artifact_repository IS NULL
38
+ AND model_revision IS NULL AND artifact_manifest_hash IS NULL
39
+ AND inference_engine IS NULL AND inference_engine_version IS NULL
40
+ AND dtype IS NULL AND pooling IS NULL AND normalize IS NULL
41
+ AND maximum_tokens IS NULL AND input_contract IS NULL
42
+ AND query_prefix IS NULL AND document_prefix IS NULL)
43
+ OR
44
+ (schema_version = 2 AND provider_kind = 'local-transformers'
45
+ AND endpoint_fingerprint IS NULL
46
+ AND preset_id IS NOT NULL AND source_model IS NOT NULL
47
+ AND artifact_repository IS NOT NULL AND model_revision IS NOT NULL
48
+ AND artifact_manifest_hash IS NOT NULL AND inference_engine IS NOT NULL
49
+ AND inference_engine_version IS NOT NULL AND dtype IS NOT NULL
50
+ AND pooling IS NOT NULL AND normalize IS NOT NULL
51
+ AND maximum_tokens IS NOT NULL AND input_contract IS NOT NULL
52
+ AND query_prefix IS NOT NULL AND document_prefix IS NOT NULL)
53
+ )
54
+ );
55
+
56
+ INSERT INTO embedding_profiles_v2 (
57
+ profile_id, schema_version, provider_kind, endpoint_fingerprint, model,
58
+ dimensions, distance_metric, distance_ceiling, document_template_version,
59
+ query_template_version, created_at
60
+ )
61
+ SELECT profile_id, 1, provider_kind, endpoint_fingerprint, model,
62
+ dimensions, distance_metric, distance_ceiling, document_template_version,
63
+ query_template_version, created_at
64
+ FROM embedding_profiles;
65
+
66
+ CREATE TABLE embedding_runtime_v2 (
67
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
68
+ active_profile_id TEXT REFERENCES embedding_profiles_v2(profile_id),
69
+ generation INTEGER NOT NULL CHECK (generation > 0),
70
+ activated_at TEXT
71
+ );
72
+
73
+ INSERT INTO embedding_runtime_v2 (singleton, active_profile_id, generation, activated_at)
74
+ SELECT singleton, active_profile_id, generation, activated_at
75
+ FROM embedding_runtime;
76
+
77
+ CREATE TABLE entry_embeddings_v2 (
78
+ entry_id TEXT NOT NULL,
79
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
80
+ revision INTEGER NOT NULL CHECK (revision > 0),
81
+ content_hash TEXT NOT NULL,
82
+ document_hash TEXT NOT NULL CHECK (length(document_hash) = 64 AND document_hash NOT GLOB '*[^0-9a-f]*'),
83
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
84
+ embedding BLOB NOT NULL,
85
+ vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
86
+ created_at TEXT NOT NULL,
87
+ PRIMARY KEY (entry_id, profile_id),
88
+ FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
89
+ CHECK (length(embedding) = dimensions * 4)
90
+ );
91
+
92
+ INSERT INTO entry_embeddings_v2 (
93
+ entry_id, profile_id, revision, content_hash, document_hash, dimensions,
94
+ embedding, vector_hash, created_at
95
+ )
96
+ SELECT entry_id, profile_id, revision, content_hash, document_hash, dimensions,
97
+ embedding, vector_hash, created_at
98
+ FROM entry_embeddings;
99
+
100
+ CREATE TABLE embedding_jobs_v2 (
101
+ entry_id TEXT NOT NULL,
102
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
103
+ revision INTEGER NOT NULL CHECK (revision > 0),
104
+ content_hash TEXT NOT NULL,
105
+ state TEXT NOT NULL CHECK (state IN ('pending', 'leased', 'failed', 'blocked')),
106
+ attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0),
107
+ available_at TEXT NOT NULL,
108
+ lease_id TEXT,
109
+ lease_expires_at TEXT,
110
+ error_code TEXT CHECK (error_code IS NULL OR error_code IN (
111
+ 'timeout', 'rate_limited', 'provider_unavailable', 'invalid_response',
112
+ 'dimension_mismatch', 'secret_blocked', 'profile_changed', 'entry_changed'
113
+ )),
114
+ created_at TEXT NOT NULL,
115
+ updated_at TEXT NOT NULL,
116
+ PRIMARY KEY (entry_id, profile_id),
117
+ FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
118
+ CHECK (
119
+ (state = 'leased' AND lease_id IS NOT NULL AND lease_expires_at IS NOT NULL)
120
+ OR (state <> 'leased' AND lease_id IS NULL AND lease_expires_at IS NULL)
121
+ )
122
+ );
123
+
124
+ INSERT INTO embedding_jobs_v2 (
125
+ entry_id, profile_id, revision, content_hash, state, attempts,
126
+ available_at, lease_id, lease_expires_at, error_code, created_at, updated_at
127
+ )
128
+ SELECT entry_id, profile_id, revision, content_hash, state, attempts,
129
+ available_at, lease_id, lease_expires_at, error_code, created_at, updated_at
130
+ FROM embedding_jobs;
131
+
132
+ CREATE TABLE query_embeddings_v2 (
133
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v2(profile_id) ON DELETE CASCADE,
134
+ query_hash TEXT NOT NULL CHECK (length(query_hash) = 64 AND query_hash NOT GLOB '*[^0-9a-f]*'),
135
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
136
+ embedding BLOB NOT NULL,
137
+ vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
138
+ created_at TEXT NOT NULL,
139
+ last_used_at TEXT NOT NULL,
140
+ PRIMARY KEY (profile_id, query_hash),
141
+ CHECK (length(embedding) = dimensions * 4)
142
+ );
143
+
144
+ INSERT INTO query_embeddings_v2 (
145
+ profile_id, query_hash, dimensions, embedding, vector_hash, created_at, last_used_at
146
+ )
147
+ SELECT profile_id, query_hash, dimensions, embedding, vector_hash, created_at, last_used_at
148
+ FROM query_embeddings;
149
+
150
+ DROP INDEX idx_query_embeddings_lru;
151
+ DROP TABLE query_embeddings;
152
+ DROP INDEX idx_embedding_jobs_claim;
153
+ DROP TABLE embedding_jobs;
154
+ DROP INDEX idx_entry_embeddings_profile_revision;
155
+ DROP TABLE entry_embeddings;
156
+ DROP TABLE embedding_runtime;
157
+ DROP TRIGGER embedding_profiles_immutable_update;
158
+ DROP TABLE embedding_profiles;
159
+
160
+ ALTER TABLE embedding_profiles_v2 RENAME TO embedding_profiles;
161
+ ALTER TABLE embedding_runtime_v2 RENAME TO embedding_runtime;
162
+ ALTER TABLE entry_embeddings_v2 RENAME TO entry_embeddings;
163
+ ALTER TABLE embedding_jobs_v2 RENAME TO embedding_jobs;
164
+ ALTER TABLE query_embeddings_v2 RENAME TO query_embeddings;
165
+
166
+ CREATE TRIGGER embedding_profiles_immutable_update
167
+ BEFORE UPDATE ON embedding_profiles
168
+ BEGIN
169
+ SELECT RAISE(ABORT, 'embedding_profiles are immutable');
170
+ END;
171
+
172
+ CREATE INDEX idx_entry_embeddings_profile_revision
173
+ ON entry_embeddings(profile_id, entry_id, revision);
174
+ CREATE INDEX idx_embedding_jobs_claim
175
+ ON embedding_jobs(profile_id, state, available_at, entry_id);
176
+ CREATE INDEX idx_query_embeddings_lru
177
+ ON query_embeddings(profile_id, last_used_at, query_hash);
178
+
179
+ CREATE TABLE embedding_model_installations (
180
+ installation_id TEXT PRIMARY KEY,
181
+ preset_id TEXT NOT NULL,
182
+ repository_id TEXT NOT NULL,
183
+ revision TEXT NOT NULL,
184
+ artifact_manifest_hash TEXT NOT NULL CHECK (length(artifact_manifest_hash) = 64 AND artifact_manifest_hash NOT GLOB '*[^0-9a-f]*'),
185
+ relative_path TEXT NOT NULL,
186
+ state TEXT NOT NULL CHECK (state IN ('staging', 'verified', 'corrupt', 'missing')),
187
+ total_bytes INTEGER NOT NULL CHECK (total_bytes >= 0),
188
+ installed_at TEXT NOT NULL,
189
+ verified_at TEXT,
190
+ last_checked_at TEXT NOT NULL
191
+ );
192
+
193
+ CREATE TABLE embedding_settings (
194
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
195
+ mode TEXT NOT NULL CHECK (mode IN ('off', 'optional', 'required')),
196
+ provider_kind TEXT CHECK (provider_kind IS NULL OR provider_kind IN ('local-transformers', 'openai-compatible', 'legacy-environment')),
197
+ preset_id TEXT,
198
+ model_installation_id TEXT REFERENCES embedding_model_installations(installation_id),
199
+ vector_backend TEXT NOT NULL CHECK (vector_backend IN ('auto', 'javascript', 'sqlite-vec')),
200
+ batch_size INTEGER NOT NULL CHECK (batch_size BETWEEN 1 AND 64),
201
+ timeout_ms INTEGER NOT NULL CHECK (timeout_ms BETWEEN 100 AND 120000),
202
+ legacy_profile_id TEXT REFERENCES embedding_profiles(profile_id),
203
+ setup_state TEXT NOT NULL CHECK (setup_state IN ('disabled', 'requires_setup', 'installing', 'ready', 'degraded')),
204
+ updated_at TEXT NOT NULL
205
+ );
206
+
207
+ INSERT INTO embedding_settings (
208
+ singleton, mode, provider_kind, preset_id, model_installation_id,
209
+ vector_backend, batch_size, timeout_ms, legacy_profile_id, setup_state, updated_at
210
+ )
211
+ SELECT 1,
212
+ 'off',
213
+ CASE WHEN r.active_profile_id IS NULL THEN NULL ELSE 'legacy-environment' END,
214
+ NULL,
215
+ NULL,
216
+ 'auto',
217
+ 16,
218
+ 30000,
219
+ r.active_profile_id,
220
+ CASE WHEN r.active_profile_id IS NULL THEN 'disabled' ELSE 'requires_setup' END,
221
+ COALESCE(r.activated_at, '1970-01-01T00:00:00.000Z')
222
+ FROM embedding_runtime AS r;
223
+
224
+ CREATE TABLE embedding_setup_runs (
225
+ setup_id TEXT PRIMARY KEY,
226
+ preset_id TEXT NOT NULL,
227
+ phase TEXT NOT NULL CHECK (phase IN ('planned', 'downloading', 'verifying', 'probing', 'activating', 'embedding', 'completed', 'failed')),
228
+ model_installation_id TEXT REFERENCES embedding_model_installations(installation_id),
229
+ active_profile_id TEXT REFERENCES embedding_profiles(profile_id),
230
+ initial_entry_count INTEGER NOT NULL CHECK (initial_entry_count >= 0),
231
+ processed_entry_count INTEGER NOT NULL CHECK (processed_entry_count >= 0),
232
+ failure_code TEXT,
233
+ started_at TEXT NOT NULL,
234
+ updated_at TEXT NOT NULL,
235
+ completed_at TEXT
236
+ );
@@ -0,0 +1,133 @@
1
+ -- Manual rollback for migration 022. Stop every Kiokuko process and make a
2
+ -- full SQLite backup before running this script. Local v2 profiles are not
3
+ -- silently converted to the v1 representation.
4
+
5
+ BEGIN IMMEDIATE;
6
+
7
+ CREATE TEMP TRIGGER embedding_setup_v2_rollback_guard
8
+ BEFORE DELETE ON schema_migrations
9
+ WHEN EXISTS (SELECT 1 FROM embedding_profiles WHERE schema_version = 2)
10
+ BEGIN
11
+ SELECT RAISE(ABORT, 'migration 022 rollback requires removing local v2 profiles explicitly');
12
+ END;
13
+
14
+ CREATE TABLE embedding_profiles_v1 (
15
+ profile_id TEXT PRIMARY KEY CHECK (length(profile_id) = 64 AND profile_id NOT GLOB '*[^0-9a-f]*'),
16
+ provider_kind TEXT NOT NULL CHECK (provider_kind IN ('openai-compatible')),
17
+ endpoint_fingerprint TEXT NOT NULL CHECK (length(endpoint_fingerprint) = 64 AND endpoint_fingerprint NOT GLOB '*[^0-9a-f]*'),
18
+ model TEXT NOT NULL,
19
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
20
+ distance_metric TEXT NOT NULL CHECK (distance_metric = 'cosine'),
21
+ distance_ceiling REAL NOT NULL CHECK (distance_ceiling > 0.0 AND distance_ceiling < 2.0),
22
+ document_template_version INTEGER NOT NULL CHECK (document_template_version > 0),
23
+ query_template_version INTEGER NOT NULL CHECK (query_template_version > 0),
24
+ created_at TEXT NOT NULL
25
+ );
26
+ INSERT INTO embedding_profiles_v1 (
27
+ profile_id, provider_kind, endpoint_fingerprint, model, dimensions,
28
+ distance_metric, distance_ceiling, document_template_version,
29
+ query_template_version, created_at
30
+ )
31
+ SELECT profile_id, provider_kind, endpoint_fingerprint, model, dimensions,
32
+ distance_metric, distance_ceiling, document_template_version,
33
+ query_template_version, created_at
34
+ FROM embedding_profiles;
35
+
36
+ CREATE TABLE embedding_runtime_v1 (
37
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
38
+ active_profile_id TEXT REFERENCES embedding_profiles_v1(profile_id),
39
+ generation INTEGER NOT NULL CHECK (generation > 0),
40
+ activated_at TEXT
41
+ );
42
+ INSERT INTO embedding_runtime_v1 (singleton, active_profile_id, generation, activated_at)
43
+ SELECT singleton, active_profile_id, generation, activated_at FROM embedding_runtime;
44
+
45
+ CREATE TABLE entry_embeddings_v1 (
46
+ entry_id TEXT NOT NULL,
47
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
48
+ revision INTEGER NOT NULL CHECK (revision > 0),
49
+ content_hash TEXT NOT NULL,
50
+ document_hash TEXT NOT NULL CHECK (length(document_hash) = 64 AND document_hash NOT GLOB '*[^0-9a-f]*'),
51
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
52
+ embedding BLOB NOT NULL,
53
+ vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
54
+ created_at TEXT NOT NULL,
55
+ PRIMARY KEY (entry_id, profile_id),
56
+ FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
57
+ CHECK (length(embedding) = dimensions * 4)
58
+ );
59
+ INSERT INTO entry_embeddings_v1 SELECT * FROM entry_embeddings;
60
+
61
+ CREATE TABLE embedding_jobs_v1 (
62
+ entry_id TEXT NOT NULL,
63
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
64
+ revision INTEGER NOT NULL CHECK (revision > 0),
65
+ content_hash TEXT NOT NULL,
66
+ state TEXT NOT NULL CHECK (state IN ('pending', 'leased', 'failed', 'blocked')),
67
+ attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0),
68
+ available_at TEXT NOT NULL,
69
+ lease_id TEXT,
70
+ lease_expires_at TEXT,
71
+ error_code TEXT CHECK (error_code IS NULL OR error_code IN (
72
+ 'timeout', 'rate_limited', 'provider_unavailable', 'invalid_response',
73
+ 'dimension_mismatch', 'secret_blocked', 'profile_changed', 'entry_changed'
74
+ )),
75
+ created_at TEXT NOT NULL,
76
+ updated_at TEXT NOT NULL,
77
+ PRIMARY KEY (entry_id, profile_id),
78
+ FOREIGN KEY (entry_id, revision) REFERENCES entry_revisions(entry_id, revision) ON DELETE CASCADE,
79
+ CHECK (
80
+ (state = 'leased' AND lease_id IS NOT NULL AND lease_expires_at IS NOT NULL)
81
+ OR (state <> 'leased' AND lease_id IS NULL AND lease_expires_at IS NULL)
82
+ )
83
+ );
84
+ INSERT INTO embedding_jobs_v1 SELECT * FROM embedding_jobs;
85
+
86
+ CREATE TABLE query_embeddings_v1 (
87
+ profile_id TEXT NOT NULL REFERENCES embedding_profiles_v1(profile_id) ON DELETE CASCADE,
88
+ query_hash TEXT NOT NULL CHECK (length(query_hash) = 64 AND query_hash NOT GLOB '*[^0-9a-f]*'),
89
+ dimensions INTEGER NOT NULL CHECK (dimensions BETWEEN 2 AND 8192),
90
+ embedding BLOB NOT NULL,
91
+ vector_hash TEXT NOT NULL CHECK (length(vector_hash) = 64 AND vector_hash NOT GLOB '*[^0-9a-f]*'),
92
+ created_at TEXT NOT NULL,
93
+ last_used_at TEXT NOT NULL,
94
+ PRIMARY KEY (profile_id, query_hash),
95
+ CHECK (length(embedding) = dimensions * 4)
96
+ );
97
+ INSERT INTO query_embeddings_v1 SELECT * FROM query_embeddings;
98
+
99
+ DELETE FROM schema_migrations WHERE version = 22 AND name = '022_embedding_setup_v2.sql';
100
+ DROP TRIGGER embedding_setup_v2_rollback_guard;
101
+
102
+ DROP TABLE embedding_setup_runs;
103
+ DROP TABLE embedding_settings;
104
+ DROP TABLE embedding_model_installations;
105
+ DROP INDEX idx_query_embeddings_lru;
106
+ DROP TABLE query_embeddings;
107
+ DROP INDEX idx_embedding_jobs_claim;
108
+ DROP TABLE embedding_jobs;
109
+ DROP INDEX idx_entry_embeddings_profile_revision;
110
+ DROP TABLE entry_embeddings;
111
+ DROP TABLE embedding_runtime;
112
+ DROP TRIGGER embedding_profiles_immutable_update;
113
+ DROP TABLE embedding_profiles;
114
+
115
+ ALTER TABLE embedding_profiles_v1 RENAME TO embedding_profiles;
116
+ ALTER TABLE embedding_runtime_v1 RENAME TO embedding_runtime;
117
+ ALTER TABLE entry_embeddings_v1 RENAME TO entry_embeddings;
118
+ ALTER TABLE embedding_jobs_v1 RENAME TO embedding_jobs;
119
+ ALTER TABLE query_embeddings_v1 RENAME TO query_embeddings;
120
+
121
+ CREATE TRIGGER embedding_profiles_immutable_update
122
+ BEFORE UPDATE ON embedding_profiles
123
+ BEGIN
124
+ SELECT RAISE(ABORT, 'embedding_profiles are immutable');
125
+ END;
126
+ CREATE INDEX idx_entry_embeddings_profile_revision
127
+ ON entry_embeddings(profile_id, entry_id, revision);
128
+ CREATE INDEX idx_embedding_jobs_claim
129
+ ON embedding_jobs(profile_id, state, available_at, entry_id);
130
+ CREATE INDEX idx_query_embeddings_lru
131
+ ON query_embeddings(profile_id, last_used_at, query_hash);
132
+
133
+ COMMIT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdkc/kiokuko",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Model-agnostic external memory for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "dist/",
17
17
  "migrations/",
18
18
  "skills/",
19
+ "docs/",
19
20
  "templates/",
20
21
  "README.md",
21
22
  "README.ja.md",
@@ -32,6 +33,7 @@
32
33
  "test:unit": "node scripts/run-tests.mjs tests/unit",
33
34
  "test:integration": "node scripts/run-tests.mjs tests/integration",
34
35
  "test:sqlite-vec": "node --import tsx tests/ci/sqlite-vec-package-smoke.ts",
36
+ "test:global-install": "node tests/ci/global-install-smoke.mjs",
35
37
  "test:evaluation": "npm run build && node scripts/run-retrieval-evaluation.mjs",
36
38
  "test:benchmark": "npm run build && node scripts/run-retrieval-benchmark.mjs",
37
39
  "test:e2e:codex": "npm run build && node scripts/run-enno-agent-e2e.mjs codex",
@@ -41,7 +43,6 @@
41
43
  "sampledb:generate": "node --import tsx tests/fixtures/sample-database.ts tests/sampledb/kiokuko.sqlite3",
42
44
  "test:sampledb": "npm run build && node --import tsx tests/ci/verify-sample-database.ts",
43
45
  "pack:check": "npm pack --dry-run",
44
- "prepare": "npm run build",
45
46
  "prepublishOnly": "npm run typecheck && npm test && npm run build && npm run pack:check"
46
47
  },
47
48
  "dependencies": {
@@ -52,12 +53,32 @@
52
53
  "yaml": "^2.9.0",
53
54
  "zod": "^4.4.3"
54
55
  },
55
- "optionalDependencies": {
56
+ "overrides": {
57
+ "adm-zip": "0.6.0",
58
+ "sharp": "0.35.4"
59
+ },
60
+ "peerDependencies": {
61
+ "@huggingface/hub": "2.16.1",
62
+ "@huggingface/transformers": "4.2.0",
56
63
  "sqlite-vec": "0.1.9"
57
64
  },
65
+ "peerDependenciesMeta": {
66
+ "@huggingface/hub": {
67
+ "optional": true
68
+ },
69
+ "@huggingface/transformers": {
70
+ "optional": true
71
+ },
72
+ "sqlite-vec": {
73
+ "optional": true
74
+ }
75
+ },
58
76
  "devDependencies": {
77
+ "@huggingface/hub": "2.16.1",
78
+ "@huggingface/transformers": "4.2.0",
59
79
  "@types/node": "^24.0.0",
60
80
  "@types/semver": "^7.8.0",
81
+ "sqlite-vec": "0.1.9",
61
82
  "tsx": "^4.20.3",
62
83
  "typescript": "^5.9.2"
63
84
  }
@@ -34,6 +34,20 @@ phase report require the stored digest plus a complete disposition for every
34
34
  slot; other phase schemas omit those fields. Submitting advice does not advance
35
35
  the main Enno status.
36
36
 
37
+ ### Recovery-only advisory restoration
38
+
39
+ After a successful `enno_advice_submit`, use its complete `advisoryRound` from
40
+ the current context whenever it is still available. Call `enno_advice_read` at
41
+ most once only when the current state is `aggregated` but the contribution
42
+ bodies are missing after session termination or client reroute. The read restores
43
+ a stored current round; it is not advisor fanout, state advancement, or
44
+ confirmation.
45
+
46
+ The read must remain bound to the current run, revision, mutation revision,
47
+ phase, and advisory digest. If it fails, do not infer contributions or invent
48
+ dispositions. Never restore provider/model identity or raw advisor output;
49
+ preserve existing failure codes such as `unsafe_output`.
50
+
37
51
  ## Activation boundary
38
52
 
39
53
  Apply this Skill only when one of these is true:
@@ -119,6 +133,36 @@ action together with the host-retained capability catalog.
119
133
 
120
134
  Review the approved contract rather than the quality of the final prose response.
121
135
 
136
+ Final Review advisory input is evidence for judgment, not a vote. Evaluate each
137
+ slot by its role, concrete evidence, and correspondence to an acceptance
138
+ criterion; never treat agreement count as correctness evidence. Advisor
139
+ disagreement alone is non-blocking and must not trigger replan or user
140
+ confirmation.
141
+
142
+ For each slot, `adopted` means that at least part of its contribution
143
+ concretely affected the current judgment or output. `not_adopted` means its
144
+ content was considered but not used. `unavailable` is reserved for the existing
145
+ failure, timeout, or isolation-unavailable outcomes. Adoption does not approve
146
+ every recommendation; record a short rationale for what evidence was used or
147
+ why it was not used.
148
+
149
+ Only evidence-backed contract blockers may produce replan feedback. Keep at most
150
+ eight blockers, each tied to a violated acceptance criterion or approved
151
+ contract invariant, a repository-relative path, concrete observed evidence,
152
+ impact or regression risk, a bounded Zenki change, and an existing or focused
153
+ verifier that proves the fix. Merge duplicate findings with the same criterion,
154
+ path, observed behavior, and requested change.
155
+
156
+ Do not replan for style or naming preferences, general refactoring or
157
+ maintainability suggestions, unsupported future-risk claims, unrelated existing
158
+ problems, agreement counts, advisor disagreement, or arbitrary test proposals.
159
+ Keep `review.summary` limited to adopted blockers, do not expand approved scope
160
+ or acceptance criteria, and do not ask the user to adjudicate advisors solely
161
+ because they disagree. If fresh final verifier evidence passes and no
162
+ evidence-backed contract blocker remains, accept through the existing
163
+ `enno_finish` flow without extra fanout, LLM calls, verifier runs, or
164
+ confirmation.
165
+
122
166
  Confirm all of the following before acceptance:
123
167
 
124
168
  - every approved WorkUnit completed under the current contract revision;
@@ -14,7 +14,7 @@ Use the Kiokuko MCP tools rather than reading or modifying the SQLite file direc
14
14
 
15
15
  ### Before non-trivial work
16
16
 
17
- At the ideal, planning, and final-review phases, the parent host may fan out exactly three fixed advisor slots. Kiokuko does not launch advisors. The parent host must verify isolated read-only execution; prompt wording is not proof, and a slot that cannot be verified is reported as `unavailable`. Advisor input excludes Enno run identity, workspace, orchestration identity, revisions, and idempotency keys. Only the parent aggregator calls `enno_advice_submit`; results are `host_reported`, without provider/model identity or raw subagent output. Contributions use fixed slots, fixed failure codes, canonical JSON, control-character rejection, repository-relative evidence paths, and 16 KiB per-slot / 48 KiB per-round UTF-8 limits. Secret-shaped completed output becomes `unsafe_output` without persistence or forwarding. The advisory lifecycle is `not_started → fanout_requested → aggregated → consumed`. Aggregated rounds suppress duplicate fanout, expose the stored digest and required slot dispositions, and make the current phase report schema require both the digest and complete dispositions; other phases omit those fields. Final Review is two-phase: `enno_verify_prepare` executes final verifiers outside database transactions with shell disabled and repository-relative cwd, then stores evidence bound to the current contract revision, mutation revision, verifier specification digest, and full repository-state digest. Identical evidence is reused only while all bindings remain current; repository changes or verifier mutation invalidate it. The final advisory fanout is returned only after evidence is prepared. `enno_finish` never spawns a subprocess, rechecks repository state inside its mutation transaction, and decides accept/replan/block from the full stored criteria, WorkUnit, verifier, and repository evidence.
17
+ At the ideal, planning, and final-review phases, the parent host may fan out exactly three fixed advisor slots. Kiokuko does not launch advisors. The parent host must verify isolated read-only execution; prompt wording is not proof, and a slot that cannot be verified is reported as `unavailable`. Advisor input excludes Enno run identity, workspace, orchestration identity, revisions, and idempotency keys. Only the parent aggregator calls `enno_advice_submit`; results are `host_reported`, without provider/model identity or raw subagent output. Contributions use fixed slots, fixed failure codes, canonical JSON, control-character rejection, repository-relative evidence paths, and 16 KiB per-slot / 48 KiB per-round UTF-8 limits. Secret-shaped completed output becomes `unsafe_output` without persistence or forwarding. The advisory lifecycle is `not_started → fanout_requested → aggregated → consumed`. Aggregated rounds suppress duplicate fanout, expose the stored digest and required slot dispositions, and make the current phase report schema require both the digest and complete dispositions; other phases omit those fields. If an aggregated round's contribution bodies are missing after session termination or client reroute, use the recovery-only `enno_advice_read` once with the current identity and digest; do not read on the normal path, rerun advisors, or infer dispositions. Final Review is two-phase: `enno_verify_prepare` executes final verifiers outside database transactions with shell disabled and repository-relative cwd, then stores evidence bound to the current contract revision, mutation revision, verifier specification digest, and full repository-state digest. Identical evidence is reused only while all bindings remain current; repository changes or verifier mutation invalidate it. The final advisory fanout is returned only after evidence is prepared. Final Review must deduplicate evidence-backed contract blockers; disagreement or evidence-free suggestions do not justify replan or user adjudication. `enno_finish` never spawns a subprocess, rechecks repository state inside its mutation transaction, and decides accept/replan/block from the full stored criteria, WorkUnit, verifier, and repository evidence.
18
18
 
19
19
  If plan submission returns `userFacingRecovery`, show only its what-happened, work-state, resolution, and choices in the user's language. For every choice, present its label and recommendation first, then translate and present `whenToChoose` as the intent the choice fits and `whatHappens` as its exact result. Do not expose the machine `action`, internal tool or field names, capability catalog, digest, run identity, revision, presentation version, raw JSON, or reason code. Do not retry, cancel, or create a new task automatically: wait for the user's explicit choice. Continue the same plan only by attaching the complete catalog retained from task preparation; never ask the user to locate or construct that catalog. A plan-review choice asks the user what to change and performs no implementation. For an active planning attempt, a restart choice explicitly cancels it before starting a new `task_prepare` with current capabilities. If the projection says the attempt already ended, do not try to cancel it again; start a new task only after the user chooses restart. A cancel choice creates no replacement and leaves an already-ended attempt unchanged.
20
20