@h1v35/hivex 0.1.0 → 0.2.1

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/src/cli.ts CHANGED
@@ -3,90 +3,108 @@ import { checkReview } from './review.ts';
3
3
  import { documentCommand } from './documents.ts';
4
4
  import { knowledgeMaintenance } from './knowledge-maintenance.ts';
5
5
  import { knowledgeCommand } from './knowledge.ts';
6
+ import { snapshotCommand } from './snapshot-command.ts';
6
7
  import { diagnostic } from './cli/diagnostic.ts';
7
8
 
8
- async function main(args: string[]) {
9
- if (!args.length || args.includes('--help'))
9
+ const main = async (input: string[]) => {
10
+ if (!input.length || input.includes('--help')) {
10
11
  return {
11
12
  application: 'hivex',
12
- purpose: 'Project decisions, dependencies and exceptions for the responsible agent.',
13
13
  commands: [
14
14
  {
15
+ modelCalls: 0,
15
16
  name: 'sources',
16
17
  usage:
17
18
  'sources [--root <project>] [--limit <count>] [--cursor <continuation>] [--max-bytes <bytes>]',
18
- modelCalls: 0,
19
19
  },
20
20
  {
21
+ modelCalls: 0,
21
22
  name: 'read',
22
23
  usage:
23
24
  'read <document> [--root <project>] [--from <line>] [--to <line>] [--max-bytes <bytes>]',
24
- modelCalls: 0,
25
25
  },
26
26
  {
27
+ modelCalls:
28
+ 'One extraction and one check per batch; retained work resumes within the same budget.',
27
29
  name: 'update',
28
30
  usage:
29
31
  'update [--root <project>] [--max-calls <total>] [--max-input-bytes <total>] [--repair <document> --reason <correction>]',
30
- modelCalls:
31
- 'One extraction and one check per batch; retained work resumes within the same budget.',
32
32
  },
33
33
  {
34
+ modelCalls: 0,
34
35
  name: 'search',
35
36
  usage: 'search <query> [--root <project>] [--limit <count>]',
36
- modelCalls: 0,
37
37
  },
38
38
  {
39
+ modelCalls: 0,
39
40
  name: 'neighbors',
40
41
  usage: 'neighbors <decision-id> [--root <project>] [--limit <count>]',
41
- modelCalls: 0,
42
42
  },
43
43
  {
44
+ modelCalls:
45
+ 'One bounded automatic update/check batch and Luna/max assistance share a total budget; identical retained answers are reused.',
44
46
  name: 'ask',
45
47
  usage:
46
48
  'ask <task> [--root <project>] [--source <document>] [--max-calls <total>] [--max-input-bytes <total>] [--max-context-bytes <bytes>]',
47
- modelCalls:
48
- 'One bounded automatic update/check batch and Luna/max assistance share a total budget; identical retained answers are reused.',
49
49
  },
50
50
  {
51
+ modelCalls:
52
+ 'One automatic update/check batch and a review share one budget. Checking saved versions needs no model.',
51
53
  name: 'review',
52
54
  usage:
53
55
  'review <task> --base <git-ref> [--root <project>] [--source <document>] [--max-calls <total>] [--max-context-bytes <bytes>] | review --check <saved-report.json> [--root <project>]',
54
- modelCalls:
55
- 'One automatic update/check batch and a review share one budget. Checking saved versions needs no model.',
56
56
  },
57
57
  {
58
+ modelCalls: 0,
58
59
  name: 'recover',
59
60
  usage: 'recover [--root <project>] [--acknowledge-uncertain]',
60
- modelCalls: 0,
61
61
  },
62
62
  {
63
+ modelCalls: 0,
63
64
  name: 'prune',
64
65
  usage: 'prune [--root <project>] [--keep-completed <count>] [--keep-caches <count>]',
66
+ },
67
+ {
65
68
  modelCalls: 0,
69
+ name: 'snapshot',
70
+ usage: 'snapshot export | import [--root <project>]',
66
71
  },
67
- { name: 'status', usage: 'status [--root <project>]', modelCalls: 0 },
72
+ { modelCalls: 0, name: 'status', usage: 'status [--root <project>]' },
68
73
  ],
74
+ configuration:
75
+ 'Optional hivex.json with include/exclude/history relative Markdown globs; history sources are focused evidence.',
69
76
  modelOptions: '--codex <native-binary> --deadline-ms <100..1800000> --retry-failed',
70
- configuration: 'Optional hivex.json with include/exclude relative Markdown globs.',
77
+ purpose: 'Project decisions, dependencies and exceptions for the responsible agent.',
71
78
  stage: 'Incremental project knowledge and task/diff assistance for the principal agent.',
72
79
  };
73
- if (args[0] === 'review' && args.includes('--check')) return checkReview(args);
74
- if (args[0] === 'sources' || args[0] === 'read') return documentCommand(args);
75
- if (args[0] === 'recover' || args[0] === 'prune') return knowledgeMaintenance(args);
76
- return knowledgeCommand(args);
77
- }
78
-
79
- try {
80
- const result = await main(process.argv.slice(2));
81
- process.stdout.write(JSON.stringify(result) + '\n');
82
- if (
83
- result &&
84
- typeof result === 'object' &&
85
- 'status' in result &&
86
- (result.status === 'failed' || result.status === 'blocked')
87
- )
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') {
88
102
  process.exitCode = 1;
103
+ }
104
+ };
105
+ try {
106
+ await printResult();
89
107
  } catch (error) {
90
- process.stderr.write(JSON.stringify(diagnostic(error)) + '\n');
108
+ process.stderr.write(`${JSON.stringify(diagnostic(error))}\n`);
91
109
  process.exitCode = 1;
92
110
  }