@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.
Files changed (39) hide show
  1. package/README.md +55 -163
  2. package/docs/CONTEXT.md +20 -36
  3. package/docs/README.md +6 -12
  4. package/docs/adr/0003-independent-bun-installation.md +5 -19
  5. package/docs/adr/0010-practical-knowledge-assistance.md +28 -81
  6. package/docs/adr/0011-shared-knowledge-and-selective-history.md +16 -43
  7. package/docs/guidelines/engineering.md +74 -0
  8. package/docs/procedures/self-hosted-runner.md +7 -0
  9. package/package.json +32 -11
  10. package/skills/hivex/SKILL.md +28 -92
  11. package/skills/hivex/references/markdown.md +12 -42
  12. package/src/cli/diagnostic.ts +21 -11
  13. package/src/cli.ts +46 -36
  14. package/src/documents.ts +502 -320
  15. package/src/errors.ts +8 -6
  16. package/src/implementation.ts +185 -87
  17. package/src/ingestion-units.ts +107 -64
  18. package/src/knowledge-maintenance.ts +35 -22
  19. package/src/knowledge-model.ts +386 -268
  20. package/src/knowledge-serialization.ts +239 -0
  21. package/src/knowledge-snapshot.ts +100 -77
  22. package/src/knowledge-store.ts +634 -453
  23. package/src/knowledge.ts +1001 -758
  24. package/src/markdown.ts +107 -45
  25. package/src/model/connection.ts +134 -76
  26. package/src/model/failure.ts +46 -23
  27. package/src/model/invoke.ts +346 -166
  28. package/src/model/profile.ts +201 -103
  29. package/src/model/rpc-error.ts +21 -0
  30. package/src/model/server.ts +151 -82
  31. package/src/model/thread.ts +24 -14
  32. package/src/model/transcript.ts +87 -46
  33. package/src/ordering.ts +9 -0
  34. package/src/retrieval/lexical.ts +64 -41
  35. package/src/review.ts +83 -55
  36. package/src/runtime.d.ts +4 -0
  37. package/src/snapshot-command.ts +82 -43
  38. package/src/source-relocation.ts +222 -0
  39. package/docs/engineering.md +0 -174
package/src/cli.ts CHANGED
@@ -6,95 +6,105 @@ import { knowledgeCommand } from './knowledge.ts';
6
6
  import { snapshotCommand } from './snapshot-command.ts';
7
7
  import { diagnostic } from './cli/diagnostic.ts';
8
8
 
9
- async function main(args: string[]) {
10
- if (!args.length || args.includes('--help'))
9
+ const main = async (input: string[]) => {
10
+ if (!input.length || input.includes('--help')) {
11
11
  return {
12
12
  application: 'hivex',
13
- purpose: 'Project decisions, dependencies and exceptions for the responsible agent.',
14
13
  commands: [
15
14
  {
15
+ modelCalls: 0,
16
16
  name: 'sources',
17
17
  usage:
18
18
  'sources [--root <project>] [--limit <count>] [--cursor <continuation>] [--max-bytes <bytes>]',
19
- modelCalls: 0,
20
19
  },
21
20
  {
21
+ modelCalls: 0,
22
22
  name: 'read',
23
23
  usage:
24
24
  'read <document> [--root <project>] [--from <line>] [--to <line>] [--max-bytes <bytes>]',
25
- modelCalls: 0,
26
25
  },
27
26
  {
27
+ modelCalls:
28
+ 'One extraction and one check per batch; retained work resumes within the same budget.',
28
29
  name: 'update',
29
30
  usage:
30
31
  'update [--root <project>] [--max-calls <total>] [--max-input-bytes <total>] [--repair <document> --reason <correction>]',
31
- modelCalls:
32
- 'One extraction and one check per batch; retained work resumes within the same budget.',
33
32
  },
34
33
  {
34
+ modelCalls: 0,
35
35
  name: 'search',
36
36
  usage: 'search <query> [--root <project>] [--limit <count>]',
37
- modelCalls: 0,
38
37
  },
39
38
  {
39
+ modelCalls: 0,
40
40
  name: 'neighbors',
41
41
  usage: 'neighbors <decision-id> [--root <project>] [--limit <count>]',
42
- modelCalls: 0,
43
42
  },
44
43
  {
44
+ modelCalls:
45
+ 'One bounded automatic update/check batch and Luna/max assistance share a total budget; identical retained answers are reused.',
45
46
  name: 'ask',
46
47
  usage:
47
48
  'ask <task> [--root <project>] [--source <document>] [--max-calls <total>] [--max-input-bytes <total>] [--max-context-bytes <bytes>]',
48
- modelCalls:
49
- 'One bounded automatic update/check batch and Luna/max assistance share a total budget; identical retained answers are reused.',
50
49
  },
51
50
  {
51
+ modelCalls:
52
+ 'One automatic update/check batch and a review share one budget. Checking saved versions needs no model.',
52
53
  name: 'review',
53
54
  usage:
54
55
  'review <task> --base <git-ref> [--root <project>] [--source <document>] [--max-calls <total>] [--max-context-bytes <bytes>] | review --check <saved-report.json> [--root <project>]',
55
- modelCalls:
56
- 'One automatic update/check batch and a review share one budget. Checking saved versions needs no model.',
57
56
  },
58
57
  {
58
+ modelCalls: 0,
59
59
  name: 'recover',
60
60
  usage: 'recover [--root <project>] [--acknowledge-uncertain]',
61
- modelCalls: 0,
62
61
  },
63
62
  {
63
+ modelCalls: 0,
64
64
  name: 'prune',
65
65
  usage: 'prune [--root <project>] [--keep-completed <count>] [--keep-caches <count>]',
66
- modelCalls: 0,
67
66
  },
68
67
  {
69
- name: 'snapshot',
70
- usage: 'snapshot export | import [--root <project>]',
71
68
  modelCalls: 0,
69
+ name: 'snapshot',
70
+ usage: 'snapshot export | import | relocate <from> <to> [--root <project>]',
72
71
  },
73
- { name: 'status', usage: 'status [--root <project>]', modelCalls: 0 },
72
+ { modelCalls: 0, name: 'status', usage: 'status [--root <project>]' },
74
73
  ],
75
- modelOptions: '--codex <native-binary> --deadline-ms <100..1800000> --retry-failed',
76
74
  configuration:
77
75
  'Optional hivex.json with include/exclude/history relative Markdown globs; history sources are focused evidence.',
76
+ modelOptions: '--codex <native-binary> --deadline-ms <100..1800000> --retry-failed',
77
+ purpose: 'Project decisions, dependencies and exceptions for the responsible agent.',
78
78
  stage: 'Incremental project knowledge and task/diff assistance for the principal agent.',
79
79
  };
80
- if (args[0] === 'review' && args.includes('--check')) return checkReview(args);
81
- if (args[0] === 'sources' || args[0] === 'read') return documentCommand(args);
82
- if (args[0] === 'snapshot') return snapshotCommand(args);
83
- if (args[0] === 'recover' || args[0] === 'prune') return knowledgeMaintenance(args);
84
- return knowledgeCommand(args);
85
- }
86
-
87
- try {
88
- const result = await main(process.argv.slice(2));
89
- process.stdout.write(JSON.stringify(result) + '\n');
90
- if (
91
- result &&
92
- typeof result === 'object' &&
93
- 'status' in result &&
94
- (result.status === 'failed' || result.status === 'blocked')
95
- )
80
+ }
81
+ if (input[0] === 'review' && input.includes('--check')) {
82
+ return checkReview(input);
83
+ }
84
+ if (input[0] === 'sources' || input[0] === 'read') {
85
+ return documentCommand(input);
86
+ }
87
+ if (input[0] === 'snapshot') {
88
+ return snapshotCommand(input);
89
+ }
90
+ if (input[0] === 'recover' || input[0] === 'prune') {
91
+ return knowledgeMaintenance(input);
92
+ }
93
+ return await knowledgeCommand(input);
94
+ };
95
+ const printResult = async () => {
96
+ const result: unknown = await main(process.argv.slice(2));
97
+ process.stdout.write(`${JSON.stringify(result)}\n`);
98
+ if (result === null || typeof result !== 'object' || !('status' in result)) {
99
+ return;
100
+ }
101
+ if (result.status === 'failed' || result.status === 'blocked') {
96
102
  process.exitCode = 1;
103
+ }
104
+ };
105
+ try {
106
+ await printResult();
97
107
  } catch (error) {
98
- process.stderr.write(JSON.stringify(diagnostic(error)) + '\n');
108
+ process.stderr.write(`${JSON.stringify(diagnostic(error))}\n`);
99
109
  process.exitCode = 1;
100
110
  }