@eyeauras/insight-cli 0.5.8 → 0.6.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.
Files changed (125) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/SKILL.md +1 -1
  3. package/dist/src/artifacts.d.ts +1 -1
  4. package/dist/src/artifacts.js +3 -3
  5. package/dist/src/cli.js +74 -15
  6. package/dist/src/contexts.d.ts +120 -10
  7. package/dist/src/contexts.js +510 -107
  8. package/dist/src/legacy-migration.d.ts +37 -0
  9. package/dist/src/legacy-migration.js +238 -0
  10. package/dist/src/lifecycle.d.ts +16 -5
  11. package/dist/src/lifecycle.js +43 -6
  12. package/dist/src/merge.d.ts +1 -1
  13. package/dist/src/merge.js +2 -2
  14. package/dist/src/model.d.ts +5 -0
  15. package/dist/src/model.js +2 -0
  16. package/dist/src/native-inputs.js +12 -2
  17. package/dist/src/native-merge-patches.d.ts +6 -0
  18. package/dist/src/native-merge-patches.js +100 -0
  19. package/dist/src/persistent-client.d.ts +8 -2
  20. package/dist/src/persistent-client.js +30 -8
  21. package/dist/src/projects.js +5 -4
  22. package/dist/src/research.d.ts +77 -14
  23. package/dist/src/research.js +99 -123
  24. package/dist/src/sdk-files.js +3 -3
  25. package/dist/src/server.d.ts +5 -1
  26. package/dist/src/server.js +46 -6
  27. package/dist/src/storage-gc.d.ts +23 -0
  28. package/dist/src/storage-gc.js +358 -0
  29. package/dist/src/sync-policy.js +4 -2
  30. package/dist/src/version-tracking.js +2 -1
  31. package/dist/src/workspace.d.ts +35 -2
  32. package/dist/src/workspace.js +91 -7
  33. package/package.json +1 -1
  34. package/references/native/APACHE-2.0.txt +202 -0
  35. package/references/native/HeadlessProgramMergeManager.java +86 -0
  36. package/references/native/InsightGuiMain.java +1 -0
  37. package/references/native/InsightHeadlessMain.java +1 -0
  38. package/references/native/InsightInitialImport.java +1 -1
  39. package/references/native/InsightNativeCheckout.java +214 -0
  40. package/references/native/InsightNativeFingerprint.java +53 -0
  41. package/references/native/InsightNativeMigration.java +155 -0
  42. package/references/native/InsightNativeRead.java +57 -0
  43. package/references/native/InsightNativeView.java +29 -0
  44. package/references/native/InsightOfflineAuthenticator.java +20 -0
  45. package/references/native/InsightSdkFiles.java +4 -0
  46. package/references/native/InsightSnapshotFields.java +17 -11
  47. package/references/native/InsightSnapshotInspect.java +4 -2
  48. package/references/native/NATIVE-MERGE-NOTICE.txt +15 -0
  49. package/references/persistent-client.mjs +30 -8
  50. package/references/persistent.md +47 -7
  51. package/references/recovery.md +50 -12
  52. package/references/research.md +25 -22
  53. package/references/setup.md +13 -3
  54. package/skill-bundle/insight-artifacts/SKILL.md +1 -1
  55. package/skill-bundle/insight-artifacts/references/recovery.md +50 -12
  56. package/skill-bundle/insight-binary/SKILL.md +1 -1
  57. package/skill-bundle/insight-capture/SKILL.md +1 -1
  58. package/skill-bundle/insight-cli/SKILL.md +1 -1
  59. package/skill-bundle/insight-cli/references/persistent-client.mjs +30 -8
  60. package/skill-bundle/insight-cli/references/persistent.md +47 -7
  61. package/skill-bundle/insight-cli/references/recovery.md +50 -12
  62. package/skill-bundle/insight-cli/references/setup.md +13 -3
  63. package/skill-bundle/insight-die/SKILL.md +1 -1
  64. package/skill-bundle/insight-dnspy/SKILL.md +1 -1
  65. package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
  66. package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
  67. package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
  68. package/skill-bundle/insight-frida/SKILL.md +1 -1
  69. package/skill-bundle/insight-ghidra/SKILL.md +8 -1
  70. package/skill-bundle/insight-ghidra/references/persistent-client.mjs +30 -8
  71. package/skill-bundle/insight-ghidra/references/persistent.md +47 -7
  72. package/skill-bundle/insight-ghidra/references/recovery.md +50 -12
  73. package/skill-bundle/insight-ghidra/references/research.md +25 -22
  74. package/skill-bundle/insight-ghidra/references/setup.md +13 -3
  75. package/skill-bundle/insight-ilspy/SKILL.md +1 -1
  76. package/skill-bundle/insight-interop/SKILL.md +1 -1
  77. package/skill-bundle/insight-lldb/SKILL.md +1 -1
  78. package/skill-bundle/insight-llvm/SKILL.md +1 -1
  79. package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
  80. package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
  81. package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
  82. package/skill-bundle/insight-overview/SKILL.md +1 -1
  83. package/skill-bundle/insight-procmon/SKILL.md +1 -1
  84. package/skill-bundle/insight-re/SKILL.md +1 -1
  85. package/skill-bundle/insight-re/references/persistent-client.mjs +30 -8
  86. package/skill-bundle/insight-re/references/persistent.md +47 -7
  87. package/skill-bundle/insight-re/references/recovery.md +50 -12
  88. package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
  89. package/skill-bundle/insight-strace/SKILL.md +1 -1
  90. package/skill-bundle/insight-tshark/SKILL.md +1 -1
  91. package/skill-bundle/insight-windbg/SKILL.md +1 -1
  92. package/skill-bundle/manifest.json +1 -1
  93. package/skills/insight-artifacts/SKILL.md +1 -1
  94. package/skills/insight-artifacts/references/recovery.md +50 -12
  95. package/skills/insight-binary/SKILL.md +1 -1
  96. package/skills/insight-capture/SKILL.md +1 -1
  97. package/skills/insight-die/SKILL.md +1 -1
  98. package/skills/insight-dnspy/SKILL.md +1 -1
  99. package/skills/insight-dotnet-dump/SKILL.md +1 -1
  100. package/skills/insight-dotnet-stack/SKILL.md +1 -1
  101. package/skills/insight-dotnet-trace/SKILL.md +1 -1
  102. package/skills/insight-frida/SKILL.md +1 -1
  103. package/skills/insight-ghidra/SKILL.md +8 -1
  104. package/skills/insight-ghidra/references/persistent-client.mjs +30 -8
  105. package/skills/insight-ghidra/references/persistent.md +47 -7
  106. package/skills/insight-ghidra/references/recovery.md +50 -12
  107. package/skills/insight-ghidra/references/research.md +25 -22
  108. package/skills/insight-ghidra/references/setup.md +13 -3
  109. package/skills/insight-ilspy/SKILL.md +1 -1
  110. package/skills/insight-interop/SKILL.md +1 -1
  111. package/skills/insight-lldb/SKILL.md +1 -1
  112. package/skills/insight-llvm/SKILL.md +1 -1
  113. package/skills/insight-managed-heap/SKILL.md +1 -1
  114. package/skills/insight-managed-metadata/SKILL.md +1 -1
  115. package/skills/insight-mitmproxy/SKILL.md +1 -1
  116. package/skills/insight-overview/SKILL.md +1 -1
  117. package/skills/insight-procmon/SKILL.md +1 -1
  118. package/skills/insight-re/SKILL.md +1 -1
  119. package/skills/insight-re/references/persistent-client.mjs +30 -8
  120. package/skills/insight-re/references/persistent.md +47 -7
  121. package/skills/insight-re/references/recovery.md +50 -12
  122. package/skills/insight-sevenzip/SKILL.md +1 -1
  123. package/skills/insight-strace/SKILL.md +1 -1
  124. package/skills/insight-tshark/SKILL.md +1 -1
  125. package/skills/insight-windbg/SKILL.md +1 -1
@@ -3,7 +3,7 @@ name: insight-tshark
3
3
  description: Inspect an offline PCAP or PCAPNG with insight-cli tshark to identify protocols, HTTP/DNS/TLS fields, packet evidence and reconstructed TCP/UDP streams. Use for captured traffic questions; live acquisition and TLS decryption are separate tasks.
4
4
  ---
5
5
 
6
- # Insight TShark 0.5.8
6
+ # Insight TShark 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-windbg
3
3
  description: Investigate Windows native user-mode minidumps using bounded stacks, threads, registers, modules, memory and disassembly through insight-cli windbg. Use on Windows x64 when a captured runtime state needs native debugger evidence.
4
4
  ---
5
5
 
6
- # Insight WinDbg 0.5.8
6
+ # Insight WinDbg 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@eyeauras/insight-cli",
4
- "version": "0.5.8",
4
+ "version": "0.6.1",
5
5
  "skills": [
6
6
  "insight-cli",
7
7
  "insight-re",
@@ -3,7 +3,7 @@ name: insight-artifacts
3
3
  description: Retain a completed reverse-engineering evidence file or directory as an ordinary checkpoint using insight-cli artifacts save. Use after Ghidra or any external tool; preserve existing project formats and source of truth.
4
4
  ---
5
5
 
6
- # Insight Artifacts 0.5.8
6
+ # Insight Artifacts 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -1,9 +1,17 @@
1
1
  # Continue saved work
2
2
 
3
3
  Retain the session/target returned by initial open. Continue the tuple through
4
- `insight-cli ghidra open --session <id> --target <id> --json`. Saved private snapshots and
5
- pending scalar comparisons persist independently of a backend process. Reopening preserves
6
- private work; it does not silently receive a newer shared version.
4
+ `insight-cli ghidra open --session <id> --target <id> --json`. The native working project, checkout ID/base
5
+ and native change sets persist independently of the worker. Reopening uses that exact project
6
+ without importing a snapshot or silently receiving a newer shared version. Private workers
7
+ have no publisher credentials; service-only Update/check-in temporarily owns the stopped project.
8
+ Legacy detached contexts require explicit migration and remain retained.
9
+
10
+ If native `changes discard` loses its response, retry its original request ID or continue
11
+ the same session/target. Recovery requires a completed native discard journal and matching
12
+ new checkout identity/base and saved buffers, followed by independent server readback.
13
+ It does not repeat discard. An incomplete journal or mismatched checkout stays unknown;
14
+ preserve the project and any `.keep` file.
7
15
 
8
16
  First-import recovery uses the same scoped `ghidra open` or the original request ID/input.
9
17
  Import/analysis writes a private snapshot and completion receipt before any initial publication.
@@ -39,12 +47,12 @@ independent readback. The old project, intent and original session/target remain
39
47
  ## Unresponsive headless backend
40
48
 
41
49
  Continue the same session/target with ordinary `ghidra open` or a research read. When the
42
- backend fails its identity preflight, the facade verifies the acknowledged private snapshot
43
- and independently authenticates the exact worker before retiring it and restoring that snapshot.
50
+ backend fails its identity preflight, the facade verifies the saved-view receipt
51
+ and independently authenticates the exact worker before retiring it and reopening the same native project.
44
52
  This automatic retirement is limited to headless contexts without uncertain mutations, active
45
53
  publication or a connected debugger. A failed health preflight is never permission to repeat a
46
54
  script, save or publication. Journals, original projects and acknowledged pending edits remain.
47
- Lifecycle diagnostics record `backend_unresponsive` followed by snapshot restoration.
55
+ Lifecycle diagnostics record `backend_unresponsive` followed by saved-project reopen.
48
56
 
49
57
  On macOS ARM64 the packaged read-only kernel helper checks the same-user process, executable,
50
58
  private root and digest of its unique context token without entering the JVM. It emits no token,
@@ -102,17 +110,17 @@ for adversarial same-JVM Java, and existing unknown script attempts are not recl
102
110
  their exception strings or an unchanged program snapshot. File/Python scripts retain their
103
111
  existing conservative recovery semantics.
104
112
 
105
- An unknown or partial effect retains its request intent, snapshots and native stage. Open the
113
+ An unknown or partial effect retains its request intent, receipts and native project. Open the
106
114
  same tuple to reconcile supported outcomes. A committed merge is verified against its recorded
107
115
  server version and complete saved buffers through independent read authority; it is never
108
116
  checked in again merely because its response was lost. Until verification succeeds, publication
109
117
  for this shared target is blocked across sessions. Saved private work remains retained.
110
118
 
111
119
  Scalar reconciliation observes and saves an already present effect; it does not execute the
112
- setter again. Supported structural/function edits retain a candidate snapshot after an incomplete
113
- response; continuation can verify every requested effect in that immutable snapshot and adopt it
114
- without replay. If the complete result cannot be established, the candidate and previous saved
115
- private view remain retained. An unproved program/script/external outcome remains unresolved. Preserve the profile
120
+ setter again. Supported structural/function edits can retain a saved-view receipt after an incomplete
121
+ response. For native contexts inspection must still match that receipt on the original saved
122
+ project; the receipt cannot recreate an older DB. Continuation adopts only fully verified effects
123
+ without replay. Unproved native work stays blocked and retained. An unproved program/script/external outcome remains unresolved. Preserve the profile
116
124
  storage and credential store. Do not delete another session's project, stop a process by guessed
117
125
  PID/port, or blindly repeat a script/external action to turn uncertainty into success.
118
126
 
@@ -125,7 +133,17 @@ as disconnected and retains saved program work. It does not recreate the old cur
125
133
  a previous prompt policy. Other unproved live UI effects remain retained until their outcome is
126
134
  established or the original process is known to have ended.
127
135
 
128
- ## Abandon an uncertain private program attempt
136
+ ## Native unknown attempts and legacy abandonment
137
+
138
+ For native contexts the snapshot-based `ghidra abandon` rollback is unsupported: replacing the
139
+ DB from a detached snapshot would lose native ancestry and could discard acknowledged private
140
+ work. Preserve the original project/journal and reconcile provable effects. Do not use discard,
141
+ GC, another request ID or a new server checkout as evidence that an unknown script did nothing.
142
+
143
+ The historical snapshot-based abandonment contract below applies only to its retained legacy
144
+ fixtures, not to native contexts admitted by the primary CLI.
145
+
146
+ ### Historical detached abandonment
129
147
 
130
148
  A post-mutation save timeout does not repeat the script or issue another save in the
131
149
  error handler. Status exposes the original request identity and retained phase/budget.
@@ -150,3 +168,23 @@ result. Earlier saved private edits remain pending. The original changing reques
150
168
  execute again. Abandoning never undoes external effects or establishes what an arbitrary
151
169
  script did; the acknowledgement explicitly accepts that uncertainty. Publication recovery,
152
170
  initial import, UI and debugger attempts use their own protocols and cannot use this command.
171
+
172
+ ## Explicit legacy migration
173
+
174
+ Legacy models require `ghidra migrate --target <target> --dry-run`, then the same
175
+ command without `--dry-run` (Destructive permission). Use `--all` for the profile.
176
+ Close selected workers first. Repeating migration resumes its retained journal; it never
177
+ retries an uncertain native check-in. Independent exact-version readback precedes checkout
178
+ release. Existing native models are unchanged. Detached snapshots with unproved native
179
+ ancestry/change sets are explicitly reported and retained, including private work.
180
+ A verified no-work failed open can be recovered without abandoning an arbitrary effect;
181
+ continue its original session/target with an ordinary new open request afterwards.
182
+
183
+ ## Reclaim redundant storage
184
+
185
+ `ghidra gc --dry-run` reports reclaimable and retained copies by category. `ghidra gc`
186
+ (Destructive permission) removes unreferenced snapshots, duplicate exports, stopped detached
187
+ projects and caches, and releases checkouts Ghidra itself verifies as unchanged. Close workers
188
+ first; it never stops one. Pending, conflicted, uncertain and unverified work is retained with
189
+ a reason. Repeat the command after an interruption. Collection is not recovery: resolve an
190
+ unknown operation first.
@@ -3,7 +3,7 @@ name: insight-binary
3
3
  description: Query structured PE, ELF and thin Mach-O headers, sections, imports and exports, or make an explicitly guarded new PE subsystem copy through insight-cli binary. Use for scoped binary structure, linkage and copy-only header edits without target execution.
4
4
  ---
5
5
 
6
- # Insight Binary 0.5.8
6
+ # Insight Binary 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-capture
3
3
  description: Capture one explicitly authorized native program run, exact stdout/stderr and declared file snapshots through insight-cli capture, then inspect or compare retained reports without replay. Use for controlled input/output research, preserving original files and interrupted or unknown outcomes.
4
4
  ---
5
5
 
6
- # Insight Capture 0.5.8
6
+ # Insight Capture 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-die
3
3
  description: Classify unknown executable or container inputs by format, architecture and compiler/runtime/packer signatures with Detect It Easy before choosing managed or native analysis. Use insight-cli die for static triage and preserve scan uncertainty.
4
4
  ---
5
5
 
6
- # Insight Detect It Easy 0.5.8
6
+ # Insight Detect It Easy 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-dnspy
3
3
  description: Debug a managed Windows EXE at an IL breakpoint and read primitive arguments, or change one expected IL Int32 constant in a new assembly copy through insight-cli dnspy. Use when C# decompilation needs observed execution or a controlled binary edit.
4
4
  ---
5
5
 
6
- # Insight dnSpyEx 0.5.8
6
+ # Insight dnSpyEx 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-dotnet-dump
3
3
  description: Capture a managed heap dump or inspect compatible .NET dumps with SOS to recover waiting stacks, objects, fields and retention evidence.
4
4
  ---
5
5
 
6
- # Insight .NET Dump 0.5.8
6
+ # Insight .NET Dump 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-dotnet-stack
3
3
  description: Inspect live managed thread stacks to identify active or waiting work in an explicitly selected .NET process without taking a dump.
4
4
  ---
5
5
 
6
- # Insight .NET Stack 0.5.8
6
+ # Insight .NET Stack 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-dotnet-trace
3
3
  description: Collect and inspect bounded .NET EventPipe traces to identify sampled thread work, waits or runtime activity; distinguish wall-clock samples from CPU consumption.
4
4
  ---
5
5
 
6
- # Insight .NET Trace 0.5.8
6
+ # Insight .NET Trace 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-frida
3
3
  description: Observe native call arguments/results or inspect runtime modules and exports in an explicitly selected authorized process with bounded Frida scripts. Use insight-cli frida to corroborate static findings with actual execution on macOS ARM64.
4
4
  ---
5
5
 
6
- # Insight Frida 0.5.8
6
+ # Insight Frida 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -3,7 +3,7 @@ name: insight-ghidra
3
3
  description: Inspect or edit native binaries with Ghidra through insight-cli; use isolated contexts, multi-agent merge/refresh, server, GUI or debugger workflows. Choose this for static native behavior and references, not C# recovery from managed IL.
4
4
  ---
5
5
 
6
- # Insight Ghidra 0.5.8
6
+ # Insight Ghidra 0.6.1
7
7
 
8
8
  If local help/status reports AppData or IPC access denied, retry that **read-only probe**
9
9
  with the agent host's normal permission escalation, then use that route for later authorized
@@ -17,6 +17,13 @@ session/cell ID, await that same execution with the host's wait/poll facility un
17
17
  status and read its stdout/stderr. An empty first chunk is not a lost CLI response. Do not
18
18
  start another open or repeat a CPU mutation while the original command is still running.
19
19
 
20
+ Each session/target owns one saved native checkout. Reopen the same selectors to keep its
21
+ project, checkout ID/base and native changes. `refresh` runs Ghidra Update; `merge` runs native
22
+ Update/check-in through the service and drops the project after independent verification.
23
+ Private workers have no repository password. Ordinary save does not export another `.gzf`.
24
+ Conflicts/unknown results retain the copy. Legacy detached contexts need explicit migration;
25
+ Close unchanged work to release its checkout; `ghidra gc --dry-run` reports redundant copies. See [research](references/research.md) and [recovery](references/recovery.md).
26
+
20
27
  For research loops, use the packaged [persistent client](references/persistent.md) and keep
21
28
  one connection across queries. It uses the existing CLI transport and preserves typed errors;
22
29
  lost mutation replies still require request/status recovery.
@@ -10,12 +10,24 @@ export class InsightCommandError extends Error {
10
10
  }
11
11
  export class InsightTransportError extends Error {
12
12
  dispatched;
13
- constructor(message, dispatched) {
13
+ termination;
14
+ constructor(message, dispatched, termination) {
14
15
  super(message);
15
16
  this.dispatched = dispatched;
17
+ this.termination = termination;
16
18
  this.name = 'InsightTransportError';
17
19
  }
18
20
  }
21
+ const transportDiagnostics = [
22
+ ['host_incompatible', 'Host build/protocol mismatch or closing.', 'Factory rejected the host build/protocol or it is closing.'],
23
+ ['host_incompatible', 'Host build mismatch.', 'Factory rejected the host build.'],
24
+ ['host_incompatible', 'Existing host build mismatch or closing.', 'Factory rejected the host build or it is closing.'],
25
+ ['host_closing', 'Host is closing; no command was sent.', 'Factory reports that the host is closing.'],
26
+ ['host_startup_timeout', 'CLI host startup timed out; no command was sent.', 'Factory host startup timed out.'],
27
+ ['invalid_rpc_launch', 'The --json-rpc transport must be started without a CLI command.', 'Start the JSON-RPC transport without CLI command or profile flags.'],
28
+ ['host_build_invalid', 'CLI host could not validate its build.', 'Factory could not validate the installed build.'],
29
+ ['ipc_disconnected', 'IPC invocation failed; command outcome may be unknown. No replay was attempted.', 'Factory lost the IPC invocation; the command outcome may be unknown.']
30
+ ];
19
31
  /** A thin client of Factory's existing stream, with no reconnect or command replay. */
20
32
  export async function connectInsight(options) {
21
33
  const child = spawn(options.executable, [...(options.arguments ?? []), '--json-rpc'], { cwd: options.cwd, env: options.env, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
@@ -23,15 +35,23 @@ export async function connectInsight(options) {
23
35
  let buffer = '', bytes = 0, sequence = 0, accepting = true, failed = false, ended = false;
24
36
  let closePromise, tail = Promise.resolve();
25
37
  const pending = new Map();
26
- // Drain diagnostics without retaining arbitrary stderr, paths, tokens or unbounded output.
27
- child.stderr.resume();
38
+ // Classify fixed transport diagnostics through a bounded window; never expose raw stderr.
39
+ const diagnosticDecoder = new StringDecoder('utf8');
40
+ let diagnosticWindow = '', recognizedDiagnostic;
41
+ let termination;
42
+ child.stderr.on('data', (chunk) => {
43
+ const text = diagnosticWindow + diagnosticDecoder.write(chunk);
44
+ recognizedDiagnostic ??= transportDiagnostics.find(([, message]) => text.includes(message));
45
+ diagnosticWindow = text.slice(-512);
46
+ });
47
+ const transportError = (message, dispatched) => new InsightTransportError(message + (recognizedDiagnostic ? ' ' + recognizedDiagnostic[2] : '') + (termination ? ' (' + (termination.signal ? 'signal ' + termination.signal : 'exit ' + termination.exitCode) + ').' : ''), dispatched, termination);
28
48
  const fail = (message) => {
29
49
  if (failed)
30
50
  return;
31
51
  failed = true;
32
52
  accepting = false;
33
53
  for (const p of pending.values())
34
- p.reject(new InsightTransportError(message, true));
54
+ p.reject(transportError(message, true));
35
55
  pending.clear();
36
56
  child.stdin.destroy();
37
57
  child.stdout.destroy();
@@ -43,12 +63,14 @@ export async function connectInsight(options) {
43
63
  const exited = new Promise((resolve, reject) => {
44
64
  child.once('close', (code, signal) => {
45
65
  ended = true;
66
+ diagnosticWindow = '';
67
+ termination = Object.freeze({ exitCode: code, signal, ...(recognizedDiagnostic ? { reason: recognizedDiagnostic[0] } : {}) });
46
68
  if (code !== 0 || signal || pending.size || buffer.trim()) {
47
69
  fail('Persistent CLI closed without a complete acknowledged response.');
48
- reject(new InsightTransportError('Persistent CLI transport ended unexpectedly.', false));
70
+ reject(transportError('Persistent CLI transport ended unexpectedly.', false));
49
71
  }
50
72
  else if (failed)
51
- reject(new InsightTransportError('Persistent CLI transport failed.', false));
73
+ reject(transportError('Persistent CLI transport failed.', false));
52
74
  else
53
75
  resolve();
54
76
  });
@@ -97,11 +119,11 @@ export async function connectInsight(options) {
97
119
  if (!Array.isArray(argv) || argv.length > 512 || argv.some(x => typeof x !== 'string' || x.includes('\0')) || Buffer.byteLength(JSON.stringify(argv)) > 1024 ** 2)
98
120
  return Promise.reject(new TypeError('argv must be a bounded array of strings without NUL.'));
99
121
  if (!accepting || failed || ended)
100
- return Promise.reject(new InsightTransportError('Persistent CLI connection is closed.', false));
122
+ return Promise.reject(transportError('Persistent CLI connection is closed.', false));
101
123
  const args = [...argv];
102
124
  const request = tail.then(() => {
103
125
  if (failed || ended)
104
- throw new InsightTransportError('Persistent CLI connection was lost before dispatch.', false);
126
+ throw transportError('Persistent CLI connection was lost before dispatch.', false);
105
127
  const id = ++sequence;
106
128
  return new Promise((resolve, reject) => {
107
129
  pending.set(id, { resolve, reject });
@@ -10,8 +10,15 @@ The package exports a small stdio client, independent of the facade's eager impo
10
10
  import {connectInsight, InsightCommandError, InsightTransportError}
11
11
  from '@eyeauras/insight-cli/persistent';
12
12
 
13
- const cli = await connectInsight({executable: 'insight-cli', cwd: projectDirectory});
13
+ const cli = await connectInsight({
14
+ executable: nodeExecutable,
15
+ arguments: [installedBin],
16
+ cwd: projectDirectory
17
+ });
18
+ // If reporting READY, first await a discovery RPC on this connection.
19
+ await cli.execute(['--profile', profile, 'tools', 'list']);
14
20
  const result = await cli.execute([
21
+ '--profile', profile,
15
22
  'ghidra', 'functions', 'inspect', '--session', session, '--target', target,
16
23
  '--function', 'main', '--fields', 'entry_point', '--include-call-context', 'false'
17
24
  ]);
@@ -22,9 +29,35 @@ When package-name resolution is unavailable in the agent host, dynamically impor
22
29
  [`persistent-client.mjs`](persistent-client.mjs) beside this reference by its absolute file URL.
23
30
  It is generated from the same canonical package module. In a persistent REPL retain `cli` as a
24
31
  binding across tool invocations. A new Node process per query does not retain this connection.
25
- For an explicit installed bin, use `{executable: process.execPath, arguments: [installedBin], cwd}`.
26
- `env` optionally supplies the child environment. There is no shell or separate profile/config.
27
- Use existing `--profile` argv flags when selecting a profile explicitly.
32
+ Here `installedBin` is the absolute installed `dist/src/bin.js` path and `nodeExecutable` is
33
+ the Node executable used for this shared installation. Factory includes the Node version,
34
+ platform and architecture in its build identity. Use the same Node version and installed
35
+ artifact as the existing owner; an agent host's `process.execPath` or `PATH` can select a
36
+ different Node installation. `ipc-server status` reports the owner's build; a matching CLI
37
+ package version alone does not establish compatibility. A shared owner does not need to be
38
+ stopped merely to connect a client through the matching Node runtime. An idle owner may
39
+ exit and a later caller may start a new owner with a different Node installation: a previously
40
+ matching executable is not a permanent profile binding. Use one agreed Node runtime across
41
+ the shared clients, and inspect the current owner again after a compatibility failure.
42
+
43
+ The helper appends `--json-rpc` to its launch arguments. Factory requires that transport
44
+ flag to be the entire CLI invocation: `arguments` contains only the installed bin and any
45
+ Node runtime flags, with Node flags before the bin. Put `--profile <name>` in **every**
46
+ `execute(argv)` call as shown above. Adding profile flags to the frontend launch exits with
47
+ usage error before any request is dispatched. `env` optionally supplies the child environment.
48
+ There is no shell or separate profile/config.
49
+
50
+ A consumer that prints `READY` should first await an acknowledged RPC on that same connection,
51
+ as in the metadata call above. `connectInsight()` alone warrants a `SPAWNED` label. Discovery
52
+ confirms that the frontend reached Factory and returned a result; it does not start Ghidra or
53
+ prove native context readiness. Handle its failure before reporting readiness, preserve
54
+ `name`, `message`, `dispatched` and `termination` in the diagnostic receipt, and do not resend
55
+ research calls automatically. A later transport failure still requires ordinary outcome checks.
56
+
57
+ The helper code comes from the module actually imported by the consumer. Merging a newer
58
+ client into source does not update an older installed package or a long-lived imported module.
59
+ Check the installed version and loaded module when new diagnostic fields are absent; keep
60
+ original failure receipts rather than treating a new connection as recovery evidence.
28
61
 
29
62
  `execute(argv)` returns the CLI result unchanged, without a JSON-RPC envelope. Calls are queued
30
63
  in admission order. Native work can be long: await the original promise through the agent host's
@@ -33,6 +66,12 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
33
66
 
34
67
  * `InsightCommandError.rpc` preserves the JSON-RPC error code, message and data, including typed
35
68
  CLI error results. A command failure leaves a healthy connection usable for the next command.
69
+ * `connectInsight()` confirms that the frontend process spawned; it does not perform a
70
+ readiness command or promise compatibility with the current Factory owner.
71
+ * `InsightTransportError.termination`, when the frontend has exited, reports its `exitCode`,
72
+ `signal`, and a recognized `reason` category when available. The error message
73
+ includes the fixed transport explanation and exit information, without raw stderr. These
74
+ observations diagnose transport failure; they do not establish a command's outcome.
36
75
  * `InsightTransportError.dispatched === true` means the request was handed to the stream and its
37
76
  acknowledgment is unavailable; it does not prove execution. Changing commands require their
38
77
  existing request-ID/status recovery. The client never resends them.
@@ -40,9 +79,10 @@ reconnect/retry. Factory permissions, command validation, IDs and native budgets
40
79
  after a transport failure. Reconnection is an explicit new connection, not an implicit replay.
41
80
 
42
81
  The client bounds each response line to four MiB, validates IDs and envelopes, and fails the
43
- connection on malformed, uncorrelated or oversized replies. It drains stderr without retaining
44
- arbitrary native diagnostics in memory. Read command-level diagnostics from their typed results
45
- and the existing profile diagnostic locations.
82
+ connection on malformed, uncorrelated or oversized replies. It classifies recognized Factory
83
+ transport errors from a small rolling stderr window, clears that window on process exit, and
84
+ exposes only fixed explanations and exit metadata. Read command-level diagnostics from their
85
+ typed results and the existing profile diagnostic locations.
46
86
 
47
87
  Finish owned Ghidra contexts with the normal scoped commands, following the project's shared
48
88
  server policy. Then `await cli.close()` drains already admitted requests and ends this stdio
@@ -1,9 +1,17 @@
1
1
  # Continue saved work
2
2
 
3
3
  Retain the session/target returned by initial open. Continue the tuple through
4
- `insight-cli ghidra open --session <id> --target <id> --json`. Saved private snapshots and
5
- pending scalar comparisons persist independently of a backend process. Reopening preserves
6
- private work; it does not silently receive a newer shared version.
4
+ `insight-cli ghidra open --session <id> --target <id> --json`. The native working project, checkout ID/base
5
+ and native change sets persist independently of the worker. Reopening uses that exact project
6
+ without importing a snapshot or silently receiving a newer shared version. Private workers
7
+ have no publisher credentials; service-only Update/check-in temporarily owns the stopped project.
8
+ Legacy detached contexts require explicit migration and remain retained.
9
+
10
+ If native `changes discard` loses its response, retry its original request ID or continue
11
+ the same session/target. Recovery requires a completed native discard journal and matching
12
+ new checkout identity/base and saved buffers, followed by independent server readback.
13
+ It does not repeat discard. An incomplete journal or mismatched checkout stays unknown;
14
+ preserve the project and any `.keep` file.
7
15
 
8
16
  First-import recovery uses the same scoped `ghidra open` or the original request ID/input.
9
17
  Import/analysis writes a private snapshot and completion receipt before any initial publication.
@@ -39,12 +47,12 @@ independent readback. The old project, intent and original session/target remain
39
47
  ## Unresponsive headless backend
40
48
 
41
49
  Continue the same session/target with ordinary `ghidra open` or a research read. When the
42
- backend fails its identity preflight, the facade verifies the acknowledged private snapshot
43
- and independently authenticates the exact worker before retiring it and restoring that snapshot.
50
+ backend fails its identity preflight, the facade verifies the saved-view receipt
51
+ and independently authenticates the exact worker before retiring it and reopening the same native project.
44
52
  This automatic retirement is limited to headless contexts without uncertain mutations, active
45
53
  publication or a connected debugger. A failed health preflight is never permission to repeat a
46
54
  script, save or publication. Journals, original projects and acknowledged pending edits remain.
47
- Lifecycle diagnostics record `backend_unresponsive` followed by snapshot restoration.
55
+ Lifecycle diagnostics record `backend_unresponsive` followed by saved-project reopen.
48
56
 
49
57
  On macOS ARM64 the packaged read-only kernel helper checks the same-user process, executable,
50
58
  private root and digest of its unique context token without entering the JVM. It emits no token,
@@ -102,17 +110,17 @@ for adversarial same-JVM Java, and existing unknown script attempts are not recl
102
110
  their exception strings or an unchanged program snapshot. File/Python scripts retain their
103
111
  existing conservative recovery semantics.
104
112
 
105
- An unknown or partial effect retains its request intent, snapshots and native stage. Open the
113
+ An unknown or partial effect retains its request intent, receipts and native project. Open the
106
114
  same tuple to reconcile supported outcomes. A committed merge is verified against its recorded
107
115
  server version and complete saved buffers through independent read authority; it is never
108
116
  checked in again merely because its response was lost. Until verification succeeds, publication
109
117
  for this shared target is blocked across sessions. Saved private work remains retained.
110
118
 
111
119
  Scalar reconciliation observes and saves an already present effect; it does not execute the
112
- setter again. Supported structural/function edits retain a candidate snapshot after an incomplete
113
- response; continuation can verify every requested effect in that immutable snapshot and adopt it
114
- without replay. If the complete result cannot be established, the candidate and previous saved
115
- private view remain retained. An unproved program/script/external outcome remains unresolved. Preserve the profile
120
+ setter again. Supported structural/function edits can retain a saved-view receipt after an incomplete
121
+ response. For native contexts inspection must still match that receipt on the original saved
122
+ project; the receipt cannot recreate an older DB. Continuation adopts only fully verified effects
123
+ without replay. Unproved native work stays blocked and retained. An unproved program/script/external outcome remains unresolved. Preserve the profile
116
124
  storage and credential store. Do not delete another session's project, stop a process by guessed
117
125
  PID/port, or blindly repeat a script/external action to turn uncertainty into success.
118
126
 
@@ -125,7 +133,17 @@ as disconnected and retains saved program work. It does not recreate the old cur
125
133
  a previous prompt policy. Other unproved live UI effects remain retained until their outcome is
126
134
  established or the original process is known to have ended.
127
135
 
128
- ## Abandon an uncertain private program attempt
136
+ ## Native unknown attempts and legacy abandonment
137
+
138
+ For native contexts the snapshot-based `ghidra abandon` rollback is unsupported: replacing the
139
+ DB from a detached snapshot would lose native ancestry and could discard acknowledged private
140
+ work. Preserve the original project/journal and reconcile provable effects. Do not use discard,
141
+ GC, another request ID or a new server checkout as evidence that an unknown script did nothing.
142
+
143
+ The historical snapshot-based abandonment contract below applies only to its retained legacy
144
+ fixtures, not to native contexts admitted by the primary CLI.
145
+
146
+ ### Historical detached abandonment
129
147
 
130
148
  A post-mutation save timeout does not repeat the script or issue another save in the
131
149
  error handler. Status exposes the original request identity and retained phase/budget.
@@ -150,3 +168,23 @@ result. Earlier saved private edits remain pending. The original changing reques
150
168
  execute again. Abandoning never undoes external effects or establishes what an arbitrary
151
169
  script did; the acknowledgement explicitly accepts that uncertainty. Publication recovery,
152
170
  initial import, UI and debugger attempts use their own protocols and cannot use this command.
171
+
172
+ ## Explicit legacy migration
173
+
174
+ Legacy models require `ghidra migrate --target <target> --dry-run`, then the same
175
+ command without `--dry-run` (Destructive permission). Use `--all` for the profile.
176
+ Close selected workers first. Repeating migration resumes its retained journal; it never
177
+ retries an uncertain native check-in. Independent exact-version readback precedes checkout
178
+ release. Existing native models are unchanged. Detached snapshots with unproved native
179
+ ancestry/change sets are explicitly reported and retained, including private work.
180
+ A verified no-work failed open can be recovered without abandoning an arbitrary effect;
181
+ continue its original session/target with an ordinary new open request afterwards.
182
+
183
+ ## Reclaim redundant storage
184
+
185
+ `ghidra gc --dry-run` reports reclaimable and retained copies by category. `ghidra gc`
186
+ (Destructive permission) removes unreferenced snapshots, duplicate exports, stopped detached
187
+ projects and caches, and releases checkouts Ghidra itself verifies as unchanged. Close workers
188
+ first; it never stops one. Pending, conflicted, uncertain and unverified work is retained with
189
+ a reason. Repeat the command after an interruption. Collection is not recovery: resolve an
190
+ unknown operation first.
@@ -7,11 +7,10 @@ resolution, qualified heuristics, supported emulation ABIs and memory/signature
7
7
  separate outcome for each input. It does not publish. A partial result preserves completed saves;
8
8
  repeating the same request ID retrieves those outcomes without another pass.
9
9
 
10
- `ghidra changes discard --session <id> --target <id>` explicitly removes that context's pending
11
- program edits, retains its former private snapshot and restores its own opening base. It requires
12
- Destructive permission. Other sessions and the shared revision remain unchanged; use explicit
13
- refresh to receive a newer shared base afterward. Close a live debugger before discarding static
14
- edits. The saved trace remains separate from the program's opening snapshot.
10
+ `ghidra changes discard --session <id> --target <id>` requires Destructive permission.
11
+ For native contexts it retains Ghidra's `.keep` when work is dirty, releases the old checkout
12
+ and checks out the current server version in the same project. It does not publish. Close a
13
+ live debugger first. Legacy detached contexts require explicit migration and are retained.
15
14
 
16
15
  Open input with `insight-cli ghidra open ./client.exe --session new --json`. Store the returned
17
16
  `session` and `target` as the explicit scope for every later research call. Names are display
@@ -39,23 +38,25 @@ text) represents a null/absent comment. Successful edits are checked by readback
39
38
  `applied`. A later read sees the local result; another session remains independent. These edits
40
39
  do not publish themselves. Use `ghidra merge` to publish the selected context explicitly.
41
40
 
42
- Another session retains its view until `ghidra refresh`. Refresh receives safe shared changes and
43
- preserves local work. An overlapping field retains original/local/shared values; merge publishes
44
- nothing while any conflict remains. Resolve that field with its ordinary setter,
45
- `--resolve-conflict --expect-shared <observed value>` (or `--expect-shared-null` for an absent
46
- comment). A later shared change invalidates the decision and preserves your work.
47
-
48
- Types, signatures and memory edits are saved as complete private program state. They publish
49
- when the shared base is unchanged. After divergence, unproved structural categories remain a
50
- conflict: retain the old session, open a new session on the current target, and transfer the desired
51
- work through ordinary operations. A script is not replayed as a merge algorithm.
52
-
53
- The editing groups include types/categories/layouts, labels/references, properties/bookmarks,
54
- memory flags, functions/variables/tags and batch comments/documentation. Factory's `Destructive`
55
- gate covers deletion and replacement operations separately from ordinary Update. These broader
56
- edits currently use complete saved-state publication; their grouping does not grant scalar merge
57
- semantics. Boolean fields use explicit values; the no-return setter calls its flag `--non-returning`
58
- to keep it distinct from CLI negation syntax.
41
+ Another session retains its saved native checkout until `ghidra refresh`. The service stops the
42
+ worker and calls native Update on that same project: checkout identity survives, the base advances,
43
+ and local changes merge through Ghidra. Native conflicts reject the whole Update and retain the
44
+ original working copy/base. Status reports the native conflict description. The legacy scalar
45
+ `--resolve-conflict` option is unsupported for native decisions; no coordinator winner is invented.
46
+
47
+ Types, signatures, structures and other analysis edits use Ghidra's stock resolvers and native
48
+ checkout change sets. Divergence alone is not a category conflict. `ghidra merge` performs native
49
+ Update, then journaled check-in. Independent read-only history/exact-version buffer verification
50
+ precedes release/drop of the successful native project. Continued work receives a fresh checkout;
51
+ worker/owner restart before publication reopens the same project without packed-snapshot import.
52
+
53
+ Ordinary saves retain the native DB and lightweight saved-view receipts. Full packed exports are
54
+ for initial import and explicit consumers such as export, cross-program comparison and VT.
55
+ `receivedChanges` on native refresh counts a received program revision transition; pending scalar
56
+ and opaque operation records are diagnostic, not merge semantics. Memory layout and language
57
+ changes still require native exclusive access. The editing groups include types/categories/layouts,
58
+ labels/references, properties/bookmarks, memory flags, functions/variables/tags and documentation.
59
+ Factory's Destructive gate remains separate from ordinary Update.
59
60
 
60
61
  `ghidra scripts list` returns stable `installation:` and `context:` script IDs. Pass an exact ID to
61
62
  `ghidra scripts run --script-name <id>`, or source to `ghidra scripts run-inline --code <source>`.
@@ -95,6 +96,8 @@ with unpublished program edits. A truncated result indicates that another page m
95
96
  `ghidra status` verifies the selected tool and reports saved pending work. `ghidra save` retains
96
97
  private changes without publishing. `ghidra close` saves and releases the owned process; continue
97
98
  with the same open selectors to retain local work. Save/close accept the optional request ID.
99
+ Closing a verified unchanged checkout also releases it (`checkout: released`); the next open uses
100
+ the current shared revision. Any pending or unproved work keeps its checkout (`retained`).
98
101
 
99
102
  The `ghidra ui` commands use the same explicit scope. `cursor --type all` reads address, function,
100
103
  selection and focused program; headless facets return null with an explicit reason. `tools` starts