akm-cli 0.9.16-alpha.1 → 0.9.16
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/CHANGELOG.md +56 -132
- package/dist/assets/hints/cli-hints-full.md +13 -6
- package/dist/assets/tasks/core/index-refresh.yml +1 -1
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +3 -6
- package/dist/cli/retired-commands.js +0 -4
- package/dist/cli/unknown-flags.js +3 -36
- package/dist/commands/env/env-binding.js +4 -4
- package/dist/commands/env/env-cli.js +3 -3
- package/dist/commands/improve/collapse-detector.js +2 -2
- package/dist/commands/improve/consolidate.js +4 -6
- package/dist/commands/improve/improve-cli.js +20 -15
- package/dist/commands/improve/reflect.js +23 -2
- package/dist/commands/lint/base-linter.js +9 -0
- package/dist/commands/lint/env-key-rules.js +2 -2
- package/dist/commands/proposal/propose.js +15 -1
- package/dist/commands/proposal/repository.js +3 -12
- package/dist/commands/proposal/validators/proposal-quality-validators.js +40 -3
- package/dist/commands/proposal/validators/proposal-validators.js +5 -4
- package/dist/commands/read/curate.js +44 -34
- package/dist/commands/read/search.js +35 -54
- package/dist/commands/read/show.js +21 -2
- package/dist/commands/registry-cli.js +5 -5
- package/dist/commands/sources/add-cli.js +59 -16
- package/dist/commands/sources/bundle-cli.js +35 -11
- package/dist/commands/sources/bundle-config-ops.js +30 -0
- package/dist/commands/sources/dangerous-env-audit.js +4 -4
- package/dist/commands/sources/info.js +8 -8
- package/dist/commands/sources/installed-stashes.js +55 -61
- package/dist/commands/sources/source-add.js +39 -38
- package/dist/commands/sources/source-manage.js +34 -12
- package/dist/commands/sources/stash-cli.js +111 -119
- package/dist/commands/sources/stash-skeleton.js +6 -3
- package/dist/commands/tasks/explain.js +4 -1
- package/dist/commands/tasks/tasks-cli.js +31 -9
- package/dist/commands/tasks/tasks.js +239 -194
- package/dist/commands/tasks/validate.js +20 -32
- package/dist/core/activation-policy.js +4 -4
- package/dist/core/adapter/adapters/akm-adapter.js +8 -35
- package/dist/core/adapter/adapters/akm-metadata.js +1 -11
- package/dist/core/adapter/execution-source.js +10 -29
- package/dist/core/asset/asset-placement.js +0 -35
- package/dist/core/config/config-schema.js +64 -8
- package/dist/core/config/config-sources.js +96 -2
- package/dist/core/config/config.js +190 -24
- package/dist/core/config/legacy-source-shape-shim.js +9 -0
- package/dist/core/config/schema/embedding.js +30 -7
- package/dist/core/config/schema/execution.js +23 -0
- package/dist/core/config/schema/experimental.js +1 -1
- package/dist/core/config/schema/scheduler.js +20 -0
- package/dist/core/config/schema/search.js +10 -12
- package/dist/core/config/schema/sources-bundles.js +32 -1
- package/dist/core/content-safety.js +52 -0
- package/dist/core/errors.js +2 -5
- package/dist/core/maintenance-barrier.js +11 -13
- package/dist/core/paths.js +11 -0
- package/dist/core/run-lock.js +2 -5
- package/dist/core/state/migrations.js +1 -26
- package/dist/core/state-db.js +27 -63
- package/dist/core/type-presentation.js +1 -1
- package/dist/core/write-source.js +13 -8
- package/dist/indexer/bundle-identity-guard.js +45 -8
- package/dist/indexer/ensure-index.js +0 -5
- package/dist/indexer/index-db-contention.js +56 -0
- package/dist/indexer/index-rebuild-lock.js +73 -0
- package/dist/indexer/index-written-assets.js +171 -133
- package/dist/indexer/indexer.js +1621 -458
- package/dist/indexer/lookup/adapter-concept-owner.js +5 -19
- package/dist/indexer/materialize-embeddings.js +785 -0
- package/dist/indexer/passes/dir-staleness.js +161 -0
- package/dist/indexer/passes/metadata.js +1 -18
- package/dist/indexer/scan/drain-dir.js +70 -27
- package/dist/indexer/search/db-search.js +89 -373
- package/dist/indexer/search/ranking-contributors.js +16 -21
- package/dist/indexer/search/ranking.js +57 -135
- package/dist/indexer/search/search-source.js +29 -11
- package/dist/integrations/agent/execution-lowering.js +3 -2
- package/dist/integrations/agent/execution-preparation.js +32 -1
- package/dist/integrations/agent/prompts.js +1 -1
- package/dist/integrations/agent/request-lowering.js +3 -2
- package/dist/llm/client.js +3 -11
- package/dist/llm/embedder.js +3 -10
- package/dist/llm/embedders/remote.js +104 -133
- package/dist/llm/feature-gate.js +2 -4
- package/dist/llm/rerank-client.js +3 -3
- package/dist/output/html-render.js +2 -1
- package/dist/output/shapes/passthrough.js +2 -1
- package/dist/output/stdout.js +24 -0
- package/dist/output/text/command-format.js +13 -19
- package/dist/output/text/helpers.js +1 -1
- package/dist/output/text/index.js +2 -5
- package/dist/output/text.js +4 -3
- package/dist/registry/resolve.js +37 -10
- package/dist/scripts/akm-migrate-node.js +15197 -11351
- package/dist/scripts/akm-migrate.js +15514 -11668
- package/dist/setup/semantic-assets.js +2 -2
- package/dist/setup/setup.js +3 -3
- package/dist/setup/steps/connection.js +2 -3
- package/dist/setup/steps/tasks.js +29 -36
- package/dist/sources/providers/git-install.js +17 -11
- package/dist/sources/providers/git-provider.js +12 -5
- package/dist/sources/providers/git-stash.js +38 -16
- package/dist/sources/snapshot-fetchers/website-ingest.js +3 -3
- package/dist/storage/repositories/embedding-salvage-repository.js +184 -0
- package/dist/storage/repositories/index-connection.js +3 -1
- package/dist/storage/repositories/index-entries-repository.js +68 -77
- package/dist/storage/repositories/index-entry-schema.js +25 -16
- package/dist/storage/repositories/index-fts-repository.js +263 -29
- package/dist/storage/repositories/index-meta-repository.js +29 -0
- package/dist/storage/repositories/index-schema.js +122 -115
- package/dist/storage/repositories/index-utility-repository.js +1 -1
- package/dist/storage/repositories/index-vec-repository.js +435 -22
- package/dist/tasks/activation-config.js +90 -0
- package/dist/tasks/backends/cron.js +9 -0
- package/dist/tasks/backends/launchd.js +1 -0
- package/dist/tasks/backends/schtasks.js +2 -0
- package/dist/tasks/embedded.js +4 -5
- package/dist/tasks/scheduler-binding.js +2 -2
- package/dist/tasks/scheduler-sync-preview.js +8 -1
- package/dist/tasks/scheduler-sync.js +19 -10
- package/dist/tasks/source/parse-task-source.js +10 -113
- package/dist/tasks/source/project-v4.js +2 -2
- package/dist/tasks/source/task-source-v4.js +4 -12
- package/dist/tasks/source/task-to-v3.js +4 -12
- package/dist/tasks/source/task-to-v4.js +40 -7
- package/docs/migration/README.md +1 -0
- package/docs/migration/release-notes/0.9.15.md +36 -34
- package/docs/migration/release-notes/0.9.16.md +60 -98
- package/docs/migration/release-notes/README.md +0 -5
- package/docs/migration/v0.9.1-to-v0.9.2.md +6 -9
- package/docs/reference/cli.md +124 -122
- package/docs/reference/configuration.md +137 -133
- package/docs/reference/data-and-telemetry.md +1 -2
- package/docs/reference/tasks.md +34 -29
- package/package.json +1 -1
- package/schemas/akm-config.json +170 -6
- package/schemas/akm-task.json +1 -2
- package/dist/commands/sources/index-status.js +0 -99
- package/dist/core/hash.js +0 -18
- package/dist/indexer/drain.js +0 -306
- package/dist/indexer/embedding-identity.js +0 -20
- package/dist/indexer/enrich.js +0 -260
- package/dist/indexer/reconcile.js +0 -890
- package/dist/indexer/scan/parse-file.js +0 -66
- package/dist/indexer/units/unit.js +0 -159
- package/dist/llm/embedders/provider-limits.js +0 -288
- package/dist/storage/repositories/files-repository.js +0 -181
- package/dist/storage/repositories/units-repository.js +0 -510
package/schemas/akm-config.json
CHANGED
|
@@ -211,6 +211,22 @@
|
|
|
211
211
|
"type": "string",
|
|
212
212
|
"minLength": 1
|
|
213
213
|
},
|
|
214
|
+
"maxInputTokens": {
|
|
215
|
+
"type": "integer",
|
|
216
|
+
"exclusiveMinimum": 0
|
|
217
|
+
},
|
|
218
|
+
"maxTokens": {
|
|
219
|
+
"type": "integer",
|
|
220
|
+
"exclusiveMinimum": 0
|
|
221
|
+
},
|
|
222
|
+
"batchSize": {
|
|
223
|
+
"type": "integer",
|
|
224
|
+
"exclusiveMinimum": 0
|
|
225
|
+
},
|
|
226
|
+
"contextLength": {
|
|
227
|
+
"type": "integer",
|
|
228
|
+
"exclusiveMinimum": 0
|
|
229
|
+
},
|
|
214
230
|
"ollamaOptions": {
|
|
215
231
|
"type": "object",
|
|
216
232
|
"properties": {
|
|
@@ -233,6 +249,20 @@
|
|
|
233
249
|
},
|
|
234
250
|
"additionalProperties": true
|
|
235
251
|
},
|
|
252
|
+
"execution": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"properties": {
|
|
255
|
+
"allowedTools": {
|
|
256
|
+
"type": "array",
|
|
257
|
+
"items": {
|
|
258
|
+
"type": "string",
|
|
259
|
+
"minLength": 1
|
|
260
|
+
},
|
|
261
|
+
"default": []
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"additionalProperties": false
|
|
265
|
+
},
|
|
236
266
|
"index": {
|
|
237
267
|
"type": "object",
|
|
238
268
|
"properties": {
|
|
@@ -457,6 +487,10 @@
|
|
|
457
487
|
"type": "string",
|
|
458
488
|
"minLength": 1
|
|
459
489
|
},
|
|
490
|
+
"credential": {
|
|
491
|
+
"type": "string",
|
|
492
|
+
"minLength": 1
|
|
493
|
+
},
|
|
460
494
|
"writable": {
|
|
461
495
|
"type": "boolean"
|
|
462
496
|
},
|
|
@@ -530,6 +564,10 @@
|
|
|
530
564
|
"search": {
|
|
531
565
|
"type": "object",
|
|
532
566
|
"properties": {
|
|
567
|
+
"minScore": {
|
|
568
|
+
"type": "number",
|
|
569
|
+
"minimum": 0
|
|
570
|
+
},
|
|
533
571
|
"defaultExcludeTypes": {
|
|
534
572
|
"type": "array",
|
|
535
573
|
"items": {
|
|
@@ -577,7 +615,7 @@
|
|
|
577
615
|
},
|
|
578
616
|
"additionalProperties": true
|
|
579
617
|
},
|
|
580
|
-
"
|
|
618
|
+
"curateRerank": {
|
|
581
619
|
"type": "object",
|
|
582
620
|
"properties": {
|
|
583
621
|
"enabled": {
|
|
@@ -603,7 +641,7 @@
|
|
|
603
641
|
"maximum": 50
|
|
604
642
|
}
|
|
605
643
|
},
|
|
606
|
-
"additionalProperties":
|
|
644
|
+
"additionalProperties": false
|
|
607
645
|
}
|
|
608
646
|
},
|
|
609
647
|
"additionalProperties": true
|
|
@@ -1690,6 +1728,42 @@
|
|
|
1690
1728
|
},
|
|
1691
1729
|
"additionalProperties": true
|
|
1692
1730
|
},
|
|
1731
|
+
"scheduler": {
|
|
1732
|
+
"type": "object",
|
|
1733
|
+
"properties": {
|
|
1734
|
+
"enabled": {
|
|
1735
|
+
"type": "array",
|
|
1736
|
+
"items": {
|
|
1737
|
+
"type": "object",
|
|
1738
|
+
"properties": {
|
|
1739
|
+
"kind": {
|
|
1740
|
+
"type": "string",
|
|
1741
|
+
"enum": [
|
|
1742
|
+
"task",
|
|
1743
|
+
"workflow"
|
|
1744
|
+
]
|
|
1745
|
+
},
|
|
1746
|
+
"ref": {
|
|
1747
|
+
"type": "string",
|
|
1748
|
+
"minLength": 1
|
|
1749
|
+
},
|
|
1750
|
+
"sourceId": {
|
|
1751
|
+
"type": "string",
|
|
1752
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
1753
|
+
}
|
|
1754
|
+
},
|
|
1755
|
+
"required": [
|
|
1756
|
+
"kind",
|
|
1757
|
+
"ref",
|
|
1758
|
+
"sourceId"
|
|
1759
|
+
],
|
|
1760
|
+
"additionalProperties": false
|
|
1761
|
+
},
|
|
1762
|
+
"default": []
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
"additionalProperties": false
|
|
1766
|
+
},
|
|
1693
1767
|
"setup": {
|
|
1694
1768
|
"type": "object",
|
|
1695
1769
|
"properties": {},
|
|
@@ -1702,7 +1776,7 @@
|
|
|
1702
1776
|
"type": "boolean"
|
|
1703
1777
|
}
|
|
1704
1778
|
},
|
|
1705
|
-
"additionalProperties":
|
|
1779
|
+
"additionalProperties": false
|
|
1706
1780
|
}
|
|
1707
1781
|
},
|
|
1708
1782
|
"required": [
|
|
@@ -1919,6 +1993,22 @@
|
|
|
1919
1993
|
"type": "string",
|
|
1920
1994
|
"minLength": 1
|
|
1921
1995
|
},
|
|
1996
|
+
"maxInputTokens": {
|
|
1997
|
+
"type": "integer",
|
|
1998
|
+
"exclusiveMinimum": 0
|
|
1999
|
+
},
|
|
2000
|
+
"maxTokens": {
|
|
2001
|
+
"type": "integer",
|
|
2002
|
+
"exclusiveMinimum": 0
|
|
2003
|
+
},
|
|
2004
|
+
"batchSize": {
|
|
2005
|
+
"type": "integer",
|
|
2006
|
+
"exclusiveMinimum": 0
|
|
2007
|
+
},
|
|
2008
|
+
"contextLength": {
|
|
2009
|
+
"type": "integer",
|
|
2010
|
+
"exclusiveMinimum": 0
|
|
2011
|
+
},
|
|
1922
2012
|
"ollamaOptions": {
|
|
1923
2013
|
"type": "object",
|
|
1924
2014
|
"properties": {
|
|
@@ -1941,6 +2031,20 @@
|
|
|
1941
2031
|
},
|
|
1942
2032
|
"additionalProperties": true
|
|
1943
2033
|
},
|
|
2034
|
+
"execution": {
|
|
2035
|
+
"type": "object",
|
|
2036
|
+
"properties": {
|
|
2037
|
+
"allowedTools": {
|
|
2038
|
+
"type": "array",
|
|
2039
|
+
"items": {
|
|
2040
|
+
"type": "string",
|
|
2041
|
+
"minLength": 1
|
|
2042
|
+
},
|
|
2043
|
+
"default": []
|
|
2044
|
+
}
|
|
2045
|
+
},
|
|
2046
|
+
"additionalProperties": false
|
|
2047
|
+
},
|
|
1944
2048
|
"index": {
|
|
1945
2049
|
"type": "object",
|
|
1946
2050
|
"properties": {
|
|
@@ -2165,6 +2269,10 @@
|
|
|
2165
2269
|
"type": "string",
|
|
2166
2270
|
"minLength": 1
|
|
2167
2271
|
},
|
|
2272
|
+
"credential": {
|
|
2273
|
+
"type": "string",
|
|
2274
|
+
"minLength": 1
|
|
2275
|
+
},
|
|
2168
2276
|
"writable": {
|
|
2169
2277
|
"type": "boolean"
|
|
2170
2278
|
},
|
|
@@ -2238,6 +2346,10 @@
|
|
|
2238
2346
|
"search": {
|
|
2239
2347
|
"type": "object",
|
|
2240
2348
|
"properties": {
|
|
2349
|
+
"minScore": {
|
|
2350
|
+
"type": "number",
|
|
2351
|
+
"minimum": 0
|
|
2352
|
+
},
|
|
2241
2353
|
"defaultExcludeTypes": {
|
|
2242
2354
|
"type": "array",
|
|
2243
2355
|
"items": {
|
|
@@ -2285,7 +2397,7 @@
|
|
|
2285
2397
|
},
|
|
2286
2398
|
"additionalProperties": true
|
|
2287
2399
|
},
|
|
2288
|
-
"
|
|
2400
|
+
"curateRerank": {
|
|
2289
2401
|
"type": "object",
|
|
2290
2402
|
"properties": {
|
|
2291
2403
|
"enabled": {
|
|
@@ -2311,7 +2423,7 @@
|
|
|
2311
2423
|
"maximum": 50
|
|
2312
2424
|
}
|
|
2313
2425
|
},
|
|
2314
|
-
"additionalProperties":
|
|
2426
|
+
"additionalProperties": false
|
|
2315
2427
|
}
|
|
2316
2428
|
},
|
|
2317
2429
|
"additionalProperties": true
|
|
@@ -3398,6 +3510,42 @@
|
|
|
3398
3510
|
},
|
|
3399
3511
|
"additionalProperties": true
|
|
3400
3512
|
},
|
|
3513
|
+
"scheduler": {
|
|
3514
|
+
"type": "object",
|
|
3515
|
+
"properties": {
|
|
3516
|
+
"enabled": {
|
|
3517
|
+
"type": "array",
|
|
3518
|
+
"items": {
|
|
3519
|
+
"type": "object",
|
|
3520
|
+
"properties": {
|
|
3521
|
+
"kind": {
|
|
3522
|
+
"type": "string",
|
|
3523
|
+
"enum": [
|
|
3524
|
+
"task",
|
|
3525
|
+
"workflow"
|
|
3526
|
+
]
|
|
3527
|
+
},
|
|
3528
|
+
"ref": {
|
|
3529
|
+
"type": "string",
|
|
3530
|
+
"minLength": 1
|
|
3531
|
+
},
|
|
3532
|
+
"sourceId": {
|
|
3533
|
+
"type": "string",
|
|
3534
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
3535
|
+
}
|
|
3536
|
+
},
|
|
3537
|
+
"required": [
|
|
3538
|
+
"kind",
|
|
3539
|
+
"ref",
|
|
3540
|
+
"sourceId"
|
|
3541
|
+
],
|
|
3542
|
+
"additionalProperties": false
|
|
3543
|
+
},
|
|
3544
|
+
"default": []
|
|
3545
|
+
}
|
|
3546
|
+
},
|
|
3547
|
+
"additionalProperties": false
|
|
3548
|
+
},
|
|
3401
3549
|
"setup": {
|
|
3402
3550
|
"type": "object",
|
|
3403
3551
|
"properties": {},
|
|
@@ -3410,7 +3558,7 @@
|
|
|
3410
3558
|
"type": "boolean"
|
|
3411
3559
|
}
|
|
3412
3560
|
},
|
|
3413
|
-
"additionalProperties":
|
|
3561
|
+
"additionalProperties": false
|
|
3414
3562
|
}
|
|
3415
3563
|
},
|
|
3416
3564
|
"required": [
|
|
@@ -3505,6 +3653,22 @@
|
|
|
3505
3653
|
"type": "string",
|
|
3506
3654
|
"minLength": 1
|
|
3507
3655
|
},
|
|
3656
|
+
"maxInputTokens": {
|
|
3657
|
+
"type": "integer",
|
|
3658
|
+
"exclusiveMinimum": 0
|
|
3659
|
+
},
|
|
3660
|
+
"maxTokens": {
|
|
3661
|
+
"type": "integer",
|
|
3662
|
+
"exclusiveMinimum": 0
|
|
3663
|
+
},
|
|
3664
|
+
"batchSize": {
|
|
3665
|
+
"type": "integer",
|
|
3666
|
+
"exclusiveMinimum": 0
|
|
3667
|
+
},
|
|
3668
|
+
"contextLength": {
|
|
3669
|
+
"type": "integer",
|
|
3670
|
+
"exclusiveMinimum": 0
|
|
3671
|
+
},
|
|
3508
3672
|
"ollamaOptions": {
|
|
3509
3673
|
"type": "object",
|
|
3510
3674
|
"properties": {
|
package/schemas/akm-task.json
CHANGED
|
@@ -179,13 +179,12 @@
|
|
|
179
179
|
"pattern": "^(?:[^\\s:.#/]+//)?commands/(?!\\.{1,2}(?:/|$))[^\\s#\\\\/\\u0000]+(?:/(?!\\.{1,2}(?:/|$))[^\\s#\\\\/\\u0000]+)*$"
|
|
180
180
|
},
|
|
181
181
|
"taskSourceV4ScheduleEntry": {
|
|
182
|
-
"description": "One schedule: list entry
|
|
182
|
+
"description": "One schedule: list entry. Activation is host-local scheduler configuration, never task source; inputs are validated against inputs: at parse time and delivered to the scheduled run's own invocation.",
|
|
183
183
|
"type": "object",
|
|
184
184
|
"required": ["cron"],
|
|
185
185
|
"additionalProperties": false,
|
|
186
186
|
"properties": {
|
|
187
187
|
"cron": { "$ref": "#/definitions/nonemptyLiteral" },
|
|
188
|
-
"enabled": { "type": "boolean" },
|
|
189
188
|
"inputs": { "$ref": "#/definitions/taskSourceV4ScheduleInputs" }
|
|
190
189
|
}
|
|
191
190
|
},
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
-
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
-
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
-
/**
|
|
5
|
-
* `akm index status` — a cheap, read-only snapshot of `index.db`'s current
|
|
6
|
-
* state: files tracked, entries, unit coverage for the active embedding
|
|
7
|
-
* identity, and the last reconcile time. Mirrors `assembleInfo`'s
|
|
8
|
-
* absent/inaccessible handling (`src/commands/sources/info.ts`) so a missing
|
|
9
|
-
* index reads as the ordinary first-run state and an unreadable one is
|
|
10
|
-
* reported, never silently presented as empty (#791).
|
|
11
|
-
*/
|
|
12
|
-
import { classifyPathAccess, describeInaccessiblePath } from "../../core/path-access.js";
|
|
13
|
-
import { getDbPath } from "../../core/paths.js";
|
|
14
|
-
import { error } from "../../core/warn.js";
|
|
15
|
-
import { closeDatabase, openExistingDatabase } from "../../storage/repositories/index-connection.js";
|
|
16
|
-
import { getEntryCount } from "../../storage/repositories/index-entries-repository.js";
|
|
17
|
-
import { getMeta } from "../../storage/repositories/index-meta-repository.js";
|
|
18
|
-
function emptyStatus(indexPath) {
|
|
19
|
-
return {
|
|
20
|
-
indexPath,
|
|
21
|
-
files: 0,
|
|
22
|
-
entries: 0,
|
|
23
|
-
units: { total: 0, withVector: 0, pending: 0 },
|
|
24
|
-
activeIdentity: null,
|
|
25
|
-
lastReconcileAt: null,
|
|
26
|
-
builtAt: null,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function readUnitsStatus(db, identity) {
|
|
30
|
-
// Mirrors `drainEmbeddingQueue`'s own candidate set (`selectAllUnitHashes`,
|
|
31
|
-
// src/indexer/drain.ts) — `unit_texts`, not `entry_units` — so a stale/
|
|
32
|
-
// orphaned unit_texts row is counted here exactly as it will be by the
|
|
33
|
-
// next drain, instead of understating the backlog. (Reconcile prunes the
|
|
34
|
-
// hashes each write itself replaced, and sweeps the whole table at the end
|
|
35
|
-
// of a full run, so orphans are bounded — but "bounded" is not "none", and
|
|
36
|
-
// this count must match the drain either way.)
|
|
37
|
-
const total = db.prepare("SELECT COUNT(DISTINCT unit_hash) AS n FROM unit_texts").get().n;
|
|
38
|
-
const withVector = identity
|
|
39
|
-
? db
|
|
40
|
-
.prepare("SELECT COUNT(DISTINCT ut.unit_hash) AS n FROM unit_texts ut " +
|
|
41
|
-
"JOIN units u ON u.unit_hash = ut.unit_hash AND u.identity = ?")
|
|
42
|
-
.get(identity).n
|
|
43
|
-
: 0;
|
|
44
|
-
return { total, withVector, pending: Math.max(0, total - withVector) };
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Assemble `akm index status`'s envelope.
|
|
48
|
-
*
|
|
49
|
-
* @param options.dbPath - Override the database path (useful for testing)
|
|
50
|
-
*/
|
|
51
|
-
export function assembleIndexStatus(options) {
|
|
52
|
-
const resolvedDbPath = options?.dbPath ?? getDbPath();
|
|
53
|
-
const empty = emptyStatus(resolvedDbPath);
|
|
54
|
-
// "Absent" is the ordinary first-run state; "inaccessible" is a fault that
|
|
55
|
-
// must not present as an empty index (#791).
|
|
56
|
-
const { access, code } = classifyPathAccess(resolvedDbPath);
|
|
57
|
-
if (access === "absent")
|
|
58
|
-
return empty;
|
|
59
|
-
if (access === "inaccessible") {
|
|
60
|
-
const detail = describeInaccessiblePath(resolvedDbPath, code);
|
|
61
|
-
error(`[akm index status] index database is not readable: ${detail}`);
|
|
62
|
-
return { ...empty, unreadable: detail };
|
|
63
|
-
}
|
|
64
|
-
let db;
|
|
65
|
-
try {
|
|
66
|
-
db = openExistingDatabase(resolvedDbPath);
|
|
67
|
-
const files = db.prepare("SELECT COUNT(*) AS n FROM files").get().n;
|
|
68
|
-
const identity = getMeta(db, "embeddingIdentity") ?? null;
|
|
69
|
-
return {
|
|
70
|
-
indexPath: resolvedDbPath,
|
|
71
|
-
files,
|
|
72
|
-
entries: getEntryCount(db),
|
|
73
|
-
units: readUnitsStatus(db, identity),
|
|
74
|
-
activeIdentity: identity,
|
|
75
|
-
lastReconcileAt: getMeta(db, "lastReconcileAt") ?? null,
|
|
76
|
-
builtAt: getMeta(db, "builtAt") ?? null,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
const detail = String(err instanceof Error ? err.message : err);
|
|
81
|
-
error(`[akm index status] failed to read index status from ${resolvedDbPath}: ${detail}`);
|
|
82
|
-
// A path that classified as accessible can still fail to open as a
|
|
83
|
-
// database (corrupt content, a truncated file, an ABI mismatch) — that
|
|
84
|
-
// is exactly the "unreadable, not silently empty" case #791 exists for,
|
|
85
|
-
// just discovered a step later than the access-classification check
|
|
86
|
-
// above rather than by it.
|
|
87
|
-
return { ...empty, unreadable: detail };
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
if (db) {
|
|
91
|
-
try {
|
|
92
|
-
closeDatabase(db);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// Best-effort close; the read already happened.
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
package/dist/core/hash.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
-
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
-
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
-
/**
|
|
5
|
-
* Content addressing for text handed to an embedding provider.
|
|
6
|
-
*
|
|
7
|
-
* `hashEmbeddableText` is the ONE hash function every writer of and lookup
|
|
8
|
-
* against provider-bound text must agree on — a stable, deterministic sha256
|
|
9
|
-
* over the exact bytes sent, so a single-byte content change is never
|
|
10
|
-
* confused with unchanged text. Originally lived in
|
|
11
|
-
* `embedding-salvage-repository.ts` (#955); moved here so a pure
|
|
12
|
-
* text-processing module (`src/indexer/units/unit.ts`, #index-units) is not
|
|
13
|
-
* coupled to a storage repository just to reuse it.
|
|
14
|
-
*/
|
|
15
|
-
import { createHash } from "node:crypto";
|
|
16
|
-
export function hashEmbeddableText(text) {
|
|
17
|
-
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
18
|
-
}
|