@eyeauras/insight-cli 0.0.0-stage → 0.2.0

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 (174) hide show
  1. package/.cli-package-build.json +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +60 -2
  4. package/SKILL.md +58 -0
  5. package/dist/src/administration-results.d.ts +1 -0
  6. package/dist/src/administration-results.js +84 -0
  7. package/dist/src/administration.d.ts +14 -0
  8. package/dist/src/administration.js +134 -0
  9. package/dist/src/archive-contract.d.ts +6 -0
  10. package/dist/src/archive-contract.js +108 -0
  11. package/dist/src/archive.d.ts +12 -0
  12. package/dist/src/archive.js +116 -0
  13. package/dist/src/arguments.d.ts +14 -0
  14. package/dist/src/arguments.js +62 -0
  15. package/dist/src/artifacts.d.ts +17 -0
  16. package/dist/src/artifacts.js +115 -0
  17. package/dist/src/bin.d.ts +2 -0
  18. package/dist/src/bin.js +4 -0
  19. package/dist/src/cli.d.ts +10 -0
  20. package/dist/src/cli.js +419 -0
  21. package/dist/src/comment-effects.d.ts +3 -0
  22. package/dist/src/comment-effects.js +55 -0
  23. package/dist/src/contexts.d.ts +115 -0
  24. package/dist/src/contexts.js +1078 -0
  25. package/dist/src/coordinator.d.ts +41 -0
  26. package/dist/src/coordinator.js +160 -0
  27. package/dist/src/cross-results.d.ts +14 -0
  28. package/dist/src/cross-results.js +71 -0
  29. package/dist/src/cross.d.ts +3 -0
  30. package/dist/src/cross.js +43 -0
  31. package/dist/src/data-effects.d.ts +3 -0
  32. package/dist/src/data-effects.js +103 -0
  33. package/dist/src/debugger-results.d.ts +4 -0
  34. package/dist/src/debugger-results.js +151 -0
  35. package/dist/src/debugger-supervisor.d.ts +1 -0
  36. package/dist/src/debugger-supervisor.js +136 -0
  37. package/dist/src/debugger.d.ts +21 -0
  38. package/dist/src/debugger.js +267 -0
  39. package/dist/src/documentation-effects.d.ts +5 -0
  40. package/dist/src/documentation-effects.js +56 -0
  41. package/dist/src/extensions.d.ts +64 -0
  42. package/dist/src/extensions.js +289 -0
  43. package/dist/src/function-effects.d.ts +4 -0
  44. package/dist/src/function-effects.js +112 -0
  45. package/dist/src/ghidra.d.ts +50 -0
  46. package/dist/src/ghidra.js +468 -0
  47. package/dist/src/index.d.ts +2 -0
  48. package/dist/src/index.js +1 -0
  49. package/dist/src/initial-model.d.ts +6 -0
  50. package/dist/src/initial-model.js +85 -0
  51. package/dist/src/json.d.ts +2 -0
  52. package/dist/src/json.js +8 -0
  53. package/dist/src/lifecycle.d.ts +49 -0
  54. package/dist/src/lifecycle.js +154 -0
  55. package/dist/src/memory-inputs.d.ts +8 -0
  56. package/dist/src/memory-inputs.js +56 -0
  57. package/dist/src/merge.d.ts +29 -0
  58. package/dist/src/merge.js +66 -0
  59. package/dist/src/model.d.ts +74 -0
  60. package/dist/src/model.js +67 -0
  61. package/dist/src/mutation-effects.d.ts +4 -0
  62. package/dist/src/mutation-effects.js +321 -0
  63. package/dist/src/mutation-inputs.d.ts +2 -0
  64. package/dist/src/mutation-inputs.js +71 -0
  65. package/dist/src/mutations.d.ts +4 -0
  66. package/dist/src/mutations.js +53 -0
  67. package/dist/src/native-inputs.d.ts +28 -0
  68. package/dist/src/native-inputs.js +182 -0
  69. package/dist/src/native-queries.d.ts +2 -0
  70. package/dist/src/native-queries.js +29 -0
  71. package/dist/src/projects.d.ts +31 -0
  72. package/dist/src/projects.js +301 -0
  73. package/dist/src/prototype-cli.d.ts +8 -0
  74. package/dist/src/prototype-cli.js +155 -0
  75. package/dist/src/queries.d.ts +5 -0
  76. package/dist/src/queries.js +84 -0
  77. package/dist/src/query-policy.d.ts +6 -0
  78. package/dist/src/query-policy.js +72 -0
  79. package/dist/src/query-results.d.ts +2 -0
  80. package/dist/src/query-results.js +224 -0
  81. package/dist/src/research.d.ts +184 -0
  82. package/dist/src/research.js +808 -0
  83. package/dist/src/runtime-archives.d.ts +5 -0
  84. package/dist/src/runtime-archives.js +127 -0
  85. package/dist/src/runtime-catalog.d.ts +18 -0
  86. package/dist/src/runtime-catalog.js +27 -0
  87. package/dist/src/runtime-manager.d.ts +101 -0
  88. package/dist/src/runtime-manager.js +444 -0
  89. package/dist/src/runtime-selection.d.ts +13 -0
  90. package/dist/src/runtime-selection.js +25 -0
  91. package/dist/src/saved-materials.d.ts +12 -0
  92. package/dist/src/saved-materials.js +196 -0
  93. package/dist/src/scripts.d.ts +19 -0
  94. package/dist/src/scripts.js +79 -0
  95. package/dist/src/sdk-contracts.d.ts +13 -0
  96. package/dist/src/sdk-contracts.js +37 -0
  97. package/dist/src/sdk-files.d.ts +29 -0
  98. package/dist/src/sdk-files.js +249 -0
  99. package/dist/src/sdk.d.ts +4 -0
  100. package/dist/src/sdk.js +125 -0
  101. package/dist/src/server.d.ts +46 -0
  102. package/dist/src/server.js +460 -0
  103. package/dist/src/store.d.ts +33 -0
  104. package/dist/src/store.js +178 -0
  105. package/dist/src/sync-policy.d.ts +22 -0
  106. package/dist/src/sync-policy.js +123 -0
  107. package/dist/src/transport.d.ts +23 -0
  108. package/dist/src/transport.js +135 -0
  109. package/dist/src/ui-results.d.ts +2 -0
  110. package/dist/src/ui-results.js +80 -0
  111. package/dist/src/ui.d.ts +17 -0
  112. package/dist/src/ui.js +88 -0
  113. package/dist/src/utility.d.ts +14 -0
  114. package/dist/src/utility.js +43 -0
  115. package/dist/src/version-tracking.d.ts +57 -0
  116. package/dist/src/version-tracking.js +200 -0
  117. package/dist/src/workspace.d.ts +199 -0
  118. package/dist/src/workspace.js +564 -0
  119. package/package.json +47 -4
  120. package/references/InsightRepositoryProbe.java +55 -0
  121. package/references/administration.md +34 -0
  122. package/references/archive.md +32 -0
  123. package/references/artifacts.md +47 -0
  124. package/references/debugger.md +40 -0
  125. package/references/extensions-and-sync.md +124 -0
  126. package/references/managed-runtime.md +116 -0
  127. package/references/mutations.json +1424 -0
  128. package/references/native/InsightApplyDocumentation.java +48 -0
  129. package/references/native/InsightArchivePayloads.java +36 -0
  130. package/references/native/InsightBlockTransfer.java +57 -0
  131. package/references/native/InsightEmulation.java +93 -0
  132. package/references/native/InsightExtensions.java +36 -0
  133. package/references/native/InsightFunctionDatabases.java +98 -0
  134. package/references/native/InsightGuiMain.java +32 -0
  135. package/references/native/InsightHeadlessMain.java +10 -0
  136. package/references/native/InsightInitialImport.java +42 -0
  137. package/references/native/InsightInitialJournal.java +48 -0
  138. package/references/native/InsightInitialPublication.java +142 -0
  139. package/references/native/InsightKeytool.java +16 -0
  140. package/references/native/InsightNativeReceipt.java +31 -0
  141. package/references/native/InsightPlugins.java +34 -0
  142. package/references/native/InsightProjectFiles.java +92 -0
  143. package/references/native/InsightPublicationRecovery.java +63 -0
  144. package/references/native/InsightPythonWheels.java +31 -0
  145. package/references/native/InsightResearchQueries.java +188 -0
  146. package/references/native/InsightRuntimeDoctor.java +33 -0
  147. package/references/native/InsightSdkFiles.java +142 -0
  148. package/references/native/InsightSdkScript.java +31 -0
  149. package/references/native/InsightSdkTools.java +338 -0
  150. package/references/native/InsightSdkTypes.java +132 -0
  151. package/references/native/InsightServerAdministration.java +82 -0
  152. package/references/native/InsightServerInit.java +62 -0
  153. package/references/native/InsightServerMain.java +43 -0
  154. package/references/native/InsightServerProbe.java +29 -0
  155. package/references/native/InsightSnapshotFields.java +68 -0
  156. package/references/native/InsightSnapshotInspect.java +189 -0
  157. package/references/native/InsightSnapshotPublisher.java +123 -0
  158. package/references/native/InsightStartDebugger.java +28 -0
  159. package/references/native/InsightStopDebugger.java +20 -0
  160. package/references/native/InsightTraceInspect.java +24 -0
  161. package/references/native/InsightTraceState.java +130 -0
  162. package/references/native/InsightTraceTools.java +114 -0
  163. package/references/native/InsightVersionTracking.java +91 -0
  164. package/references/native-workflows.md +112 -0
  165. package/references/queries.json +1761 -0
  166. package/references/query-semantics.md +96 -0
  167. package/references/recovery.md +53 -0
  168. package/references/research.md +101 -0
  169. package/references/setup.md +49 -0
  170. package/runtime/GhidraMCP-7.0.0.jar +0 -0
  171. package/runtime/GhidraMCP-LICENSE +202 -0
  172. package/runtime/GhidraMCP-NOTICE +10 -0
  173. package/runtime/provenance.json +11 -0
  174. package/skills/insight-re/SKILL.md +108 -0
@@ -0,0 +1,14 @@
1
+ import type { OptionDefinition } from '@eyeauras/cli-factory';
2
+ export interface Parameter {
3
+ name: string;
4
+ type: string;
5
+ required: boolean;
6
+ default?: string;
7
+ semantic?: string;
8
+ allowEmpty?: boolean;
9
+ }
10
+ export declare const key: (name: string) => string;
11
+ export declare const flag: (name: string) => string;
12
+ export declare function parsed(p: Parameter, value: unknown): unknown;
13
+ export declare const selectedOptions: OptionDefinition[];
14
+ export declare function option(p: Parameter): OptionDefinition;
@@ -0,0 +1,62 @@
1
+ import { address } from './research.js';
2
+ import { fail } from './model.js';
3
+ import { parseDomainJson } from './json.js';
4
+ export const key = (name) => name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
5
+ export const flag = (name) => name.replaceAll('_', '-');
6
+ export function parsed(p, value) {
7
+ if (p.type === 'boolean') {
8
+ if (value === true || value === 'true')
9
+ return true;
10
+ if (value === false || value === 'false')
11
+ return false;
12
+ fail('invalid', `${flag(p.name)} must be true or false.`);
13
+ }
14
+ if (p.type === 'integer' || p.type === 'number') {
15
+ if (typeof value !== 'string' && typeof value !== 'number' || typeof value === 'string' && !/^-?\d+(?:\.\d+)?$/.test(value))
16
+ fail('invalid', `${flag(p.name)} must be a finite ${p.type}.`);
17
+ const result = Number(value);
18
+ if (!Number.isFinite(result) || p.type === 'integer' && !Number.isSafeInteger(result))
19
+ fail('invalid', `${flag(p.name)} is outside numeric range.`);
20
+ if (p.name === 'offset' && p.default !== '-1' && result < 0 || p.name === 'limit' && (result < 1 || result > 1000) ||
21
+ p.name === 'length' && (result < (p.default === '0' ? 0 : 1) || result > 65536) || p.name === 'max_steps' && (result < 1 || result > 1000000) ||
22
+ /^(max_steps|max_functions|num_examples|context_instructions|call_context_limit|call_context_lines|depth)$/.test(p.name) && result < 0)
23
+ fail('invalid', `${flag(p.name)} is outside its supported query range.`);
24
+ if (p.name === 'timeout_seconds' && (result < 1 || result > 1800))
25
+ fail('invalid', 'timeout-seconds must be between 1 and 1800.');
26
+ if (p.name === 'max_scan' && (result < 1 || result > 200000) || p.name === 'max_bytes' && (result < 1 || result > 16777216))
27
+ fail('invalid', `${flag(p.name)} is outside its supported work budget.`);
28
+ return result;
29
+ }
30
+ if (['json', 'object', 'array', 'any'].includes(p.type)) {
31
+ let result = value;
32
+ if (typeof value === 'string') {
33
+ if (value.length > 65536)
34
+ fail('limit', 'JSON input exceeds 64 KiB.');
35
+ try {
36
+ result = parseDomainJson(value);
37
+ }
38
+ catch {
39
+ fail('invalid', `${flag(p.name)} requires valid JSON.`);
40
+ }
41
+ }
42
+ if (p.type === 'object' && (!result || Array.isArray(result) || typeof result !== 'object') || p.type === 'array' && !Array.isArray(result))
43
+ fail('invalid', `${flag(p.name)} has the wrong JSON shape.`);
44
+ if (JSON.stringify(result).length > 65536)
45
+ fail('limit', 'JSON input exceeds 64 KiB.');
46
+ return result;
47
+ }
48
+ if (typeof value !== 'string' || value.length > 16000 || value.includes('\0') || !value && p.required && !p.allowEmpty)
49
+ fail('invalid', `${flag(p.name)} needs bounded text.`);
50
+ return p.semantic === 'address' ? address(value) : value;
51
+ }
52
+ export const selectedOptions = [{ flags: '--session <id>', description: 'Select the durable research session', required: true },
53
+ { flags: '--target <id>', description: 'Select the immutable input target', required: true }];
54
+ export function option(p) {
55
+ const value = p.default;
56
+ const defaultValue = value === undefined || value === '' && !p.allowEmpty ? undefined : parsed(p, value);
57
+ return { flags: `--${flag(p.name)} <${p.type === 'json' ? 'json' : p.type}>`,
58
+ description: p.semantic === 'function_ref' ? 'Function name or explicit address' : p.semantic === 'address' ? 'Explicit hexadecimal address' :
59
+ `${flag(p.name)} (${p.type}${p.name === 'limit' ? ', 1–1000' : p.name === 'length' ? ', 1–65536 bytes' : ''})`,
60
+ ...(p.required ? { required: true } : {}), ...(defaultValue === undefined ? {} : { defaultValue }),
61
+ ...(['json', 'object', 'array', 'any'].includes(p.type) ? {} : { parse: (value) => parsed(p, value) }) };
62
+ }
@@ -0,0 +1,17 @@
1
+ export type ArtifactKind = 'input' | 'snapshot';
2
+ export interface Artifact {
3
+ id: string;
4
+ kind: ArtifactKind;
5
+ sha256: string;
6
+ size: number;
7
+ }
8
+ /** Immutable, content-addressed copies of the bytes actually consumed by the facade. */
9
+ export declare class Artifacts {
10
+ readonly directory: string;
11
+ constructor(directory: string);
12
+ path(value: Artifact): string;
13
+ private ownedDirectory;
14
+ private syncDirectory;
15
+ verify(value: Artifact): Promise<string>;
16
+ capture(source: string, kind: ArtifactKind): Promise<Artifact>;
17
+ }
@@ -0,0 +1,115 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { constants } from 'node:fs';
3
+ import { open, mkdir, link, unlink, realpath, lstat } from 'node:fs/promises';
4
+ import { join, resolve } from 'node:path';
5
+ import { fail } from './model.js';
6
+ const maximumBytes = 4 * 1024 * 1024 * 1024;
7
+ /** Immutable, content-addressed copies of the bytes actually consumed by the facade. */
8
+ export class Artifacts {
9
+ directory;
10
+ constructor(directory) {
11
+ this.directory = directory;
12
+ }
13
+ path(value) {
14
+ if (!['input', 'snapshot'].includes(value.kind) || !/^[a-f0-9]{64}$/.test(value.sha256) ||
15
+ value.id !== `${value.kind}:${value.sha256}` || !Number.isSafeInteger(value.size) ||
16
+ value.size < 1 || value.size > maximumBytes)
17
+ fail('artifact', 'Saved artifact reference is malformed.');
18
+ return join(this.directory, 'artifacts', `${value.sha256}.${value.kind === 'snapshot' ? 'gzf' : 'bin'}`);
19
+ }
20
+ async ownedDirectory() {
21
+ const directory = join(this.directory, 'artifacts');
22
+ await mkdir(directory, { recursive: true, mode: 0o700 });
23
+ if ((await lstat(directory)).isSymbolicLink() || await realpath(directory) !== resolve(directory))
24
+ fail('artifact', 'Artifact directory must remain inside its owned profile storage.');
25
+ return directory;
26
+ }
27
+ async syncDirectory(directory) {
28
+ // Directory fsync is unavailable on Windows. The file itself is synced on all platforms.
29
+ if (process.platform === 'win32')
30
+ return;
31
+ const handle = await open(directory, constants.O_RDONLY);
32
+ try {
33
+ await handle.sync();
34
+ }
35
+ finally {
36
+ await handle.close();
37
+ }
38
+ }
39
+ async verify(value) {
40
+ await this.ownedDirectory();
41
+ const path = this.path(value);
42
+ if ((await lstat(path)).isSymbolicLink())
43
+ fail('artifact', 'Saved artifact cannot be replaced by a symbolic link.');
44
+ const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
45
+ try {
46
+ const info = await handle.stat();
47
+ if (!info.isFile() || info.size !== value.size)
48
+ fail('artifact', 'Saved artifact size or type changed.');
49
+ const hash = createHash('sha256');
50
+ let size = 0;
51
+ for await (const chunk of handle.createReadStream({ autoClose: false })) {
52
+ size += chunk.length;
53
+ hash.update(chunk);
54
+ if (size > value.size)
55
+ fail('artifact', 'Saved artifact grew during verification.');
56
+ }
57
+ if (size !== value.size || hash.digest('hex') !== value.sha256)
58
+ fail('artifact', 'Saved artifact contents changed; its original copy is required.');
59
+ return path;
60
+ }
61
+ finally {
62
+ await handle.close();
63
+ }
64
+ }
65
+ async capture(source, kind) {
66
+ if (!['input', 'snapshot'].includes(kind))
67
+ fail('artifact', 'Unsupported artifact kind.');
68
+ const directory = await this.ownedDirectory();
69
+ const temporary = join(directory, 'pending-' + randomUUID());
70
+ const input = await open(source, constants.O_RDONLY);
71
+ let output;
72
+ try {
73
+ const info = await input.stat({ bigint: true });
74
+ if (!info.isFile() || info.size < 1n || info.size > BigInt(maximumBytes))
75
+ fail('limit', 'Input must be a nonempty regular file of at most 4 GiB.');
76
+ output = await open(temporary, 'wx', 0o600);
77
+ const hash = createHash('sha256');
78
+ let size = 0;
79
+ for await (const chunk of input.createReadStream({ autoClose: false })) {
80
+ size += chunk.length;
81
+ if (size > maximumBytes)
82
+ fail('limit', 'Input exceeds 4 GiB.');
83
+ hash.update(chunk);
84
+ await output.writeFile(chunk);
85
+ }
86
+ const after = await input.stat({ bigint: true });
87
+ if (BigInt(size) !== info.size || after.size !== info.size || after.mtimeNs !== info.mtimeNs ||
88
+ after.ctimeNs !== info.ctimeNs)
89
+ fail('inputChanged', 'Input changed while being copied; retry against a stable file.');
90
+ const sha256 = hash.digest('hex');
91
+ const result = { id: `${kind}:${sha256}`, kind, sha256, size };
92
+ await output.chmod(0o400);
93
+ await output.sync();
94
+ await output.close();
95
+ output = undefined;
96
+ // Link publishes without replacing a previous artifact, including a concurrent capture.
97
+ try {
98
+ await link(temporary, this.path(result));
99
+ }
100
+ catch (error) {
101
+ if (error.code !== 'EEXIST')
102
+ throw error;
103
+ }
104
+ await this.verify(result);
105
+ await this.syncDirectory(directory);
106
+ return result;
107
+ }
108
+ finally {
109
+ await input.close();
110
+ await output?.close();
111
+ await unlink(temporary).catch(error => { if (error.code !== 'ENOENT')
112
+ throw error; });
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { runHosted } from '@eyeauras/cli-factory-ipc';
3
+ import { createDefinition } from './cli.js';
4
+ process.exitCode = await runHosted({ entryPoint: import.meta.url, createDefinition });
@@ -0,0 +1,10 @@
1
+ import { type CliDefinition, type CliRuntime, type CommandContext } from '@eyeauras/cli-factory';
2
+ import { Workspace } from './workspace.js';
3
+ import { type ResearchBackend } from './research.js';
4
+ export interface Options {
5
+ runtime?: CliRuntime;
6
+ /** Offline fixture seam; production uses owned native Ghidra contexts. */
7
+ backend?: (workspace: Workspace, context: CommandContext) => ResearchBackend | Promise<ResearchBackend>;
8
+ }
9
+ export declare function createDefinition(options?: Options): CliDefinition;
10
+ export declare const createInsightCli: (options?: Options) => import("@eyeauras/cli-factory").CliApplication;