@h1v35/hivex 0.2.0 → 0.2.2
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/README.md +55 -163
- package/docs/CONTEXT.md +20 -36
- package/docs/README.md +6 -12
- package/docs/adr/0003-independent-bun-installation.md +5 -19
- package/docs/adr/0010-practical-knowledge-assistance.md +28 -81
- package/docs/adr/0011-shared-knowledge-and-selective-history.md +16 -43
- package/docs/guidelines/engineering.md +74 -0
- package/docs/procedures/self-hosted-runner.md +7 -0
- package/package.json +32 -11
- package/skills/hivex/SKILL.md +28 -92
- package/skills/hivex/references/markdown.md +12 -42
- package/src/cli/diagnostic.ts +21 -11
- package/src/cli.ts +46 -36
- package/src/documents.ts +502 -320
- package/src/errors.ts +8 -6
- package/src/implementation.ts +185 -87
- package/src/ingestion-units.ts +107 -64
- package/src/knowledge-maintenance.ts +35 -22
- package/src/knowledge-model.ts +386 -268
- package/src/knowledge-serialization.ts +239 -0
- package/src/knowledge-snapshot.ts +100 -77
- package/src/knowledge-store.ts +634 -453
- package/src/knowledge.ts +1001 -758
- package/src/markdown.ts +107 -45
- package/src/model/connection.ts +134 -76
- package/src/model/failure.ts +46 -23
- package/src/model/invoke.ts +346 -166
- package/src/model/profile.ts +201 -103
- package/src/model/rpc-error.ts +21 -0
- package/src/model/server.ts +151 -82
- package/src/model/thread.ts +24 -14
- package/src/model/transcript.ts +87 -46
- package/src/ordering.ts +9 -0
- package/src/retrieval/lexical.ts +64 -41
- package/src/review.ts +83 -55
- package/src/runtime.d.ts +4 -0
- package/src/snapshot-command.ts +82 -43
- package/src/source-relocation.ts +222 -0
- package/docs/engineering.md +0 -174
|
@@ -2,56 +2,69 @@ import { parseArgs } from 'node:util';
|
|
|
2
2
|
import { HivexError } from './errors.ts';
|
|
3
3
|
import { KnowledgeStore } from './knowledge-store.ts';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const defaultKeepCompleted = 8;
|
|
6
|
+
const defaultKeepCaches = 64;
|
|
7
7
|
|
|
8
|
-
function retention(value: string | undefined, name: string, fallback: number) {
|
|
9
|
-
if (value === undefined)
|
|
8
|
+
const retention = function retention(value: string | undefined, name: string, fallback: number) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
return fallback;
|
|
11
|
+
}
|
|
10
12
|
const number = Number(value);
|
|
11
|
-
if (!Number.
|
|
13
|
+
if (!Number.isSafeInteger(number) || number < 0 || number > 4096) {
|
|
12
14
|
throw new HivexError({
|
|
13
15
|
code: 'INVALID_ARGUMENT',
|
|
14
16
|
message: `${name} must be an integer between 0 and 4096`,
|
|
15
17
|
});
|
|
18
|
+
}
|
|
16
19
|
return number;
|
|
17
|
-
}
|
|
20
|
+
};
|
|
18
21
|
|
|
19
|
-
export function knowledgeMaintenance(
|
|
22
|
+
export const knowledgeMaintenance = function knowledgeMaintenance(argumentsList: string[]) {
|
|
20
23
|
const parsed = parseArgs({
|
|
21
|
-
args,
|
|
22
24
|
allowPositionals: true,
|
|
23
|
-
|
|
25
|
+
args: argumentsList,
|
|
24
26
|
options: {
|
|
25
|
-
root: { type: 'string' },
|
|
26
|
-
'keep-completed': { type: 'string' },
|
|
27
|
-
'keep-caches': { type: 'string' },
|
|
28
27
|
'acknowledge-uncertain': { type: 'boolean' },
|
|
28
|
+
'keep-caches': { type: 'string' },
|
|
29
|
+
'keep-completed': { type: 'string' },
|
|
30
|
+
root: { type: 'string' },
|
|
29
31
|
},
|
|
32
|
+
strict: true,
|
|
30
33
|
});
|
|
31
|
-
const command = parsed.positionals
|
|
32
|
-
if (
|
|
34
|
+
const [command] = parsed.positionals;
|
|
35
|
+
if (
|
|
36
|
+
command === undefined ||
|
|
37
|
+
command === '' ||
|
|
38
|
+
!['recover', 'prune'].includes(command) ||
|
|
39
|
+
parsed.positionals.length !== 1
|
|
40
|
+
) {
|
|
33
41
|
throw new HivexError({
|
|
34
42
|
code: 'INVALID_ARGUMENT',
|
|
35
43
|
message:
|
|
36
44
|
'Use recover [--acknowledge-uncertain] or prune [--keep-completed <count>] [--keep-caches <count>]',
|
|
37
45
|
});
|
|
46
|
+
}
|
|
38
47
|
if (
|
|
39
48
|
command === 'recover' &&
|
|
40
49
|
(parsed.values['keep-completed'] !== undefined || parsed.values['keep-caches'] !== undefined)
|
|
41
|
-
)
|
|
50
|
+
) {
|
|
42
51
|
throw new HivexError({
|
|
43
52
|
code: 'INVALID_ARGUMENT',
|
|
44
53
|
message: 'recover does not accept retention options',
|
|
45
54
|
});
|
|
46
|
-
|
|
55
|
+
}
|
|
56
|
+
if (command === 'prune' && parsed.values['acknowledge-uncertain'] === true) {
|
|
47
57
|
throw new HivexError({
|
|
48
58
|
code: 'INVALID_ARGUMENT',
|
|
49
59
|
message: 'prune does not accept --acknowledge-uncertain',
|
|
50
60
|
});
|
|
61
|
+
}
|
|
51
62
|
|
|
52
63
|
const root = parsed.values.root ?? process.cwd();
|
|
53
|
-
using store = new KnowledgeStore(root
|
|
54
|
-
|
|
64
|
+
using store = new KnowledgeStore(root, {
|
|
65
|
+
update: command === 'prune',
|
|
66
|
+
});
|
|
67
|
+
if (command === 'recover') {
|
|
55
68
|
return {
|
|
56
69
|
command,
|
|
57
70
|
modelCalls: 0,
|
|
@@ -59,18 +72,18 @@ export function knowledgeMaintenance(args: string[]) {
|
|
|
59
72
|
acknowledgeUncertain: parsed.values['acknowledge-uncertain'] ?? false,
|
|
60
73
|
}),
|
|
61
74
|
};
|
|
75
|
+
}
|
|
62
76
|
|
|
63
|
-
using _lease = store.updateLease();
|
|
64
77
|
return {
|
|
65
78
|
command,
|
|
66
79
|
modelCalls: 0,
|
|
67
80
|
...store.prune({
|
|
81
|
+
keepCaches: retention(parsed.values['keep-caches'], '--keep-caches', defaultKeepCaches),
|
|
68
82
|
keepCompleted: retention(
|
|
69
83
|
parsed.values['keep-completed'],
|
|
70
84
|
'--keep-completed',
|
|
71
|
-
|
|
85
|
+
defaultKeepCompleted
|
|
72
86
|
),
|
|
73
|
-
keepCaches: retention(parsed.values['keep-caches'], '--keep-caches', DEFAULT_KEEP_CACHES),
|
|
74
87
|
}),
|
|
75
88
|
};
|
|
76
|
-
}
|
|
89
|
+
};
|