@eyeauras/insight-cli 0.9.2 → 0.9.3

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 (80) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/README.md +5 -5
  3. package/SKILL.md +1 -1
  4. package/dist/src/cli.js +29 -6
  5. package/dist/src/core/coordinator.d.ts +37 -5
  6. package/dist/src/core/coordinator.js +103 -42
  7. package/dist/src/core/legacy-import.js +2 -2
  8. package/dist/src/hub/admin.d.ts +15 -0
  9. package/dist/src/hub/admin.js +10 -1
  10. package/dist/src/hub/client.d.ts +3 -1
  11. package/dist/src/hub/client.js +4 -0
  12. package/dist/src/hub/commands.d.ts +2 -1
  13. package/dist/src/hub/commands.js +33 -4
  14. package/dist/src/hub/contract.d.ts +27 -0
  15. package/dist/src/hub/ledger-store.d.ts +40 -2
  16. package/dist/src/hub/ledger-store.js +38 -8
  17. package/dist/src/hub/ledger.js +26 -3
  18. package/dist/src/hub/server.js +33 -1
  19. package/dist/src/hub/store.d.ts +29 -0
  20. package/dist/src/hub/store.js +109 -14
  21. package/dist/src/native/contract.d.ts +4 -3
  22. package/dist/src/native/ghidra.d.ts +1 -1
  23. package/dist/src/native/ghidra.js +4 -2
  24. package/dist/src/research.js +2 -0
  25. package/dist/src/work/client.d.ts +6 -3
  26. package/dist/src/work/client.js +12 -9
  27. package/dist/src/work/commands.js +33 -25
  28. package/dist/src/work/model.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/references/native/InsightWcOps.java +42 -5
  31. package/skill-bundle/insight-artifacts/SKILL.md +1 -1
  32. package/skill-bundle/insight-binary/SKILL.md +1 -1
  33. package/skill-bundle/insight-capture/SKILL.md +1 -1
  34. package/skill-bundle/insight-cli/SKILL.md +1 -1
  35. package/skill-bundle/insight-die/SKILL.md +1 -1
  36. package/skill-bundle/insight-dnspy/SKILL.md +1 -1
  37. package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
  38. package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
  39. package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
  40. package/skill-bundle/insight-frida/SKILL.md +1 -1
  41. package/skill-bundle/insight-ghidra/SKILL.md +6 -4
  42. package/skill-bundle/insight-ilspy/SKILL.md +1 -1
  43. package/skill-bundle/insight-interop/SKILL.md +1 -1
  44. package/skill-bundle/insight-lldb/SKILL.md +1 -1
  45. package/skill-bundle/insight-llvm/SKILL.md +1 -1
  46. package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
  47. package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
  48. package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
  49. package/skill-bundle/insight-overview/SKILL.md +1 -1
  50. package/skill-bundle/insight-procmon/SKILL.md +1 -1
  51. package/skill-bundle/insight-re/SKILL.md +1 -1
  52. package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
  53. package/skill-bundle/insight-strace/SKILL.md +1 -1
  54. package/skill-bundle/insight-tshark/SKILL.md +1 -1
  55. package/skill-bundle/insight-windbg/SKILL.md +1 -1
  56. package/skill-bundle/manifest.json +1 -1
  57. package/skills/insight-artifacts/SKILL.md +1 -1
  58. package/skills/insight-binary/SKILL.md +1 -1
  59. package/skills/insight-capture/SKILL.md +1 -1
  60. package/skills/insight-die/SKILL.md +1 -1
  61. package/skills/insight-dnspy/SKILL.md +1 -1
  62. package/skills/insight-dotnet-dump/SKILL.md +1 -1
  63. package/skills/insight-dotnet-stack/SKILL.md +1 -1
  64. package/skills/insight-dotnet-trace/SKILL.md +1 -1
  65. package/skills/insight-frida/SKILL.md +1 -1
  66. package/skills/insight-ghidra/SKILL.md +6 -4
  67. package/skills/insight-ilspy/SKILL.md +1 -1
  68. package/skills/insight-interop/SKILL.md +1 -1
  69. package/skills/insight-lldb/SKILL.md +1 -1
  70. package/skills/insight-llvm/SKILL.md +1 -1
  71. package/skills/insight-managed-heap/SKILL.md +1 -1
  72. package/skills/insight-managed-metadata/SKILL.md +1 -1
  73. package/skills/insight-mitmproxy/SKILL.md +1 -1
  74. package/skills/insight-overview/SKILL.md +1 -1
  75. package/skills/insight-procmon/SKILL.md +1 -1
  76. package/skills/insight-re/SKILL.md +1 -1
  77. package/skills/insight-sevenzip/SKILL.md +1 -1
  78. package/skills/insight-strace/SKILL.md +1 -1
  79. package/skills/insight-tshark/SKILL.md +1 -1
  80. package/skills/insight-windbg/SKILL.md +1 -1
@@ -14,8 +14,46 @@ export const projectName = (value) => {
14
14
  invalid('Project name must be 1-128 letters, digits, spaces, dots, dashes or underscores.');
15
15
  return value;
16
16
  };
17
- const project = (r) => ({ id: String(r.id), name: String(r.name), repository: String(r.repository), createdAt: String(r.created_at) });
18
- const target = (r) => ({ id: String(r.id), projectId: String(r.project_id), sha256: String(r.sha256), name: String(r.name), size: Number(r.size), createdAt: String(r.created_at), createdBy: String(r.created_by) });
17
+ const project = (r, tags) => ({ id: String(r.id), name: String(r.name), repository: String(r.repository), createdAt: String(r.created_at),
18
+ description: r.description === null || r.description === undefined ? null : String(r.description), tags });
19
+ /** A project description: trimmed, 1-1000 characters without control characters other than newlines; empty clears it (null). */
20
+ export function projectDescription(value) {
21
+ if (value === null)
22
+ return null;
23
+ if (typeof value !== 'string')
24
+ invalid('description must be a string or null.');
25
+ const text = value.trim();
26
+ if (!text)
27
+ return null;
28
+ if (text.length > 1000 || /[\0-\x09\x0b-\x1f\x7f]/.test(text))
29
+ invalid('description must be at most 1000 characters without control characters.');
30
+ return text;
31
+ }
32
+ const target = (r, tags) => ({ id: String(r.id), projectId: String(r.project_id), sha256: String(r.sha256), name: String(r.name), size: Number(r.size),
33
+ createdAt: String(r.created_at), createdBy: String(r.created_by), versionLabel: r.version_label === null || r.version_label === undefined ? null : String(r.version_label), tags });
34
+ /**
35
+ * A target's human-readable build version: trimmed, case kept, 1-128 printable characters; empty clears it (null).
36
+ * It names the binary's product build, not a Ghidra version.
37
+ */
38
+ export function versionLabel(value) {
39
+ if (value === null)
40
+ return null;
41
+ if (typeof value !== 'string')
42
+ invalid('versionLabel must be a string or null.');
43
+ const label = value.trim();
44
+ if (!label)
45
+ return null;
46
+ if (label.length > 128 || /[\0-\x1f\x7f]/.test(label))
47
+ invalid('versionLabel must be at most 128 printable characters.');
48
+ return label;
49
+ }
50
+ /** A target tag: trimmed and lower-cased, 1-64 of a-z 0-9 . _ - + : starting with a letter or digit. */
51
+ export function targetTag(value) {
52
+ const tag = typeof value === 'string' ? value.trim().toLowerCase() : '';
53
+ if (!/^[a-z0-9][a-z0-9._+:-]{0,63}$/.test(tag))
54
+ invalid(`Tag ${JSON.stringify(value)} must be 1-64 of a-z 0-9 . _ - + : starting with a letter or digit.`);
55
+ return tag;
56
+ }
19
57
  export class HubStore {
20
58
  dataRoot;
21
59
  db;
@@ -28,10 +66,18 @@ export class HubStore {
28
66
  CREATE TABLE IF NOT EXISTS projects(id TEXT PRIMARY KEY,name TEXT NOT NULL UNIQUE,repository TEXT NOT NULL UNIQUE,created_at TEXT NOT NULL);
29
67
  CREATE TABLE IF NOT EXISTS targets(id TEXT PRIMARY KEY,project_id TEXT NOT NULL REFERENCES projects(id),sha256 TEXT NOT NULL,name TEXT NOT NULL,
30
68
  size INTEGER NOT NULL,created_at TEXT NOT NULL,created_by TEXT NOT NULL,UNIQUE(project_id,sha256));
31
- PRAGMA user_version=2;`);
69
+ CREATE TABLE IF NOT EXISTS target_tags(target_id TEXT NOT NULL REFERENCES targets(id) ON DELETE CASCADE,tag TEXT NOT NULL,PRIMARY KEY(target_id,tag));
70
+ CREATE TABLE IF NOT EXISTS project_tags(project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,tag TEXT NOT NULL,PRIMARY KEY(project_id,tag));
71
+ PRAGMA user_version=4;`);
32
72
  // Version 2: a project is active, frozen by an export, or moved to another hub (tombstone).
33
73
  if (!this.db.prepare('SELECT name FROM pragma_table_info(?) WHERE name=?').get('projects', 'state'))
34
74
  this.db.exec("ALTER TABLE projects ADD COLUMN state TEXT NOT NULL DEFAULT 'active';ALTER TABLE projects ADD COLUMN moved_to TEXT;");
75
+ // Version 3 (#182): a target's optional version label; its tags are rows of target_tags. Existing targets have neither.
76
+ if (!this.db.prepare('SELECT name FROM pragma_table_info(?) WHERE name=?').get('targets', 'version_label'))
77
+ this.db.exec('ALTER TABLE targets ADD COLUMN version_label TEXT;');
78
+ // Version 4 (#186): a project's optional description; its tags are rows of project_tags.
79
+ if (!this.db.prepare('SELECT name FROM pragma_table_info(?) WHERE name=?').get('projects', 'description'))
80
+ this.db.exec('ALTER TABLE projects ADD COLUMN description TEXT;');
35
81
  this.db.prepare('INSERT OR IGNORE INTO meta(key,value) VALUES(?,?)').run('hubId', randomUUID());
36
82
  this.hubId = String(this.db.prepare('SELECT value FROM meta WHERE key=?').get('hubId').value);
37
83
  }
@@ -53,24 +99,66 @@ export class HubStore {
53
99
  this.db.prepare('INSERT INTO meta(key,value) VALUES(?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value')
54
100
  .run('runtime', JSON.stringify({ java: runtime.java, ghidraHome: runtime.ghidraHome, fingerprint: runtime.fingerprint }));
55
101
  }
56
- projects() { return this.db.prepare('SELECT * FROM projects ORDER BY created_at,name').all().map(project); }
57
- projectByName(name) { const r = this.db.prepare('SELECT * FROM projects WHERE name=?').get(name); return r ? project(r) : undefined; }
102
+ projects() {
103
+ const tags = new Map();
104
+ for (const r of this.db.prepare('SELECT project_id,tag FROM project_tags ORDER BY tag').all())
105
+ tags.set(String(r.project_id), [...tags.get(String(r.project_id)) ?? [], String(r.tag)]);
106
+ return this.db.prepare('SELECT * FROM projects ORDER BY created_at,name').all().map(r => project(r, tags.get(String(r.id)) ?? []));
107
+ }
108
+ projectTags(id) { return this.db.prepare('SELECT tag FROM project_tags WHERE project_id=? ORDER BY tag').all(id).map(t => String(t.tag)); }
109
+ projectByName(name) { const r = this.db.prepare('SELECT * FROM projects WHERE name=?').get(name); return r ? project(r, this.projectTags(String(r.id))) : undefined; }
58
110
  project(id) { const r = this.db.prepare('SELECT * FROM projects WHERE id=?').get(id); if (!r)
59
- throw hubError('hub.not_found', 'Project ' + id + ' does not exist on this hub.'); return project(r); }
111
+ throw hubError('hub.not_found', 'Project ' + id + ' does not exist on this hub.'); return project(r, this.projectTags(id)); }
112
+ /** Sets or clears the description and adds or removes tags of a project in one transaction. */
113
+ updateProject(id, change) {
114
+ return this.transaction(() => {
115
+ this.project(id);
116
+ if ('description' in change)
117
+ this.db.prepare('UPDATE projects SET description=? WHERE id=?').run(change.description ?? null, id);
118
+ const add = this.db.prepare('INSERT OR IGNORE INTO project_tags(project_id,tag) VALUES(?,?)'), remove = this.db.prepare('DELETE FROM project_tags WHERE project_id=? AND tag=?');
119
+ for (const tag of change.addTags ?? [])
120
+ add.run(id, tag);
121
+ for (const tag of change.removeTags ?? [])
122
+ remove.run(id, tag);
123
+ return this.project(id);
124
+ });
125
+ }
60
126
  /** A fresh project identity; its repository must exist before insertProject records it. */
61
- static newProject(name) { const id = randomBytes(16).toString('hex'); return { id, name, repository: 'insight_' + id, createdAt: new Date().toISOString() }; }
127
+ static newProject(name) { const id = randomBytes(16).toString('hex'); return { id, name, repository: 'insight_' + id, createdAt: new Date().toISOString(), description: null, tags: [] }; }
62
128
  insertProject(p) {
63
129
  const { changes } = this.db.prepare('INSERT INTO projects(id,name,repository,created_at) VALUES(?,?,?,?) ON CONFLICT(name) DO NOTHING').run(p.id, p.name, p.repository, p.createdAt);
64
130
  // Nothing inserted: another request created the name first.
65
131
  return Number(changes) === 1 ? p : this.projectByName(p.name);
66
132
  }
67
133
  // Targets of a project: callers look the project up once (the routes through gate, admin through projectRef).
68
- targets(projectId) { return this.db.prepare('SELECT * FROM targets WHERE project_id=? ORDER BY created_at,id').all(projectId).map(target); }
134
+ targets(projectId) {
135
+ const tags = new Map();
136
+ for (const r of this.db.prepare('SELECT g.target_id,g.tag FROM target_tags g JOIN targets t ON t.id=g.target_id WHERE t.project_id=? ORDER BY g.tag').all(projectId))
137
+ tags.set(String(r.target_id), [...tags.get(String(r.target_id)) ?? [], String(r.tag)]);
138
+ return this.db.prepare('SELECT * FROM targets WHERE project_id=? ORDER BY created_at,id').all(projectId).map(r => target(r, tags.get(String(r.id)) ?? []));
139
+ }
69
140
  target(projectId, id) {
70
141
  const r = this.db.prepare('SELECT * FROM targets WHERE project_id=? AND id=?').get(projectId, id);
71
142
  if (!r)
72
143
  throw hubError('hub.not_found', 'Target ' + id + ' does not exist in project ' + projectId + '.');
73
- return target(r);
144
+ return target(r, this.db.prepare('SELECT tag FROM target_tags WHERE target_id=? ORDER BY tag').all(id).map(t => String(t.tag)));
145
+ }
146
+ /**
147
+ * Sets or clears the version label and adds or removes tags in one transaction; identity, binary, Ghidra history and
148
+ * Work references are untouched. A tag added or removed by another client stays as that client left it.
149
+ */
150
+ updateTarget(projectId, id, change) {
151
+ return this.transaction(() => {
152
+ this.target(projectId, id);
153
+ if ('versionLabel' in change)
154
+ this.db.prepare('UPDATE targets SET version_label=? WHERE id=?').run(change.versionLabel ?? null, id);
155
+ const add = this.db.prepare('INSERT OR IGNORE INTO target_tags(target_id,tag) VALUES(?,?)'), remove = this.db.prepare('DELETE FROM target_tags WHERE target_id=? AND tag=?');
156
+ for (const tag of change.addTags ?? [])
157
+ add.run(id, tag);
158
+ for (const tag of change.removeTags ?? [])
159
+ remove.run(id, tag);
160
+ return this.target(projectId, id);
161
+ });
74
162
  }
75
163
  /** State of a project, or undefined when no project has this id. */
76
164
  findProjectState(id) {
@@ -87,10 +175,17 @@ export class HubStore {
87
175
  /** Activates an imported project with its target ids in one transaction. */
88
176
  importProject(p, targets) {
89
177
  this.transaction(() => {
90
- this.db.prepare('INSERT INTO projects(id,name,repository,created_at) VALUES(?,?,?,?)').run(p.id, p.name, p.repository, p.createdAt);
91
- const insert = this.db.prepare('INSERT INTO targets(id,project_id,sha256,name,size,created_at,created_by) VALUES(?,?,?,?,?,?,?)');
92
- for (const t of targets)
93
- insert.run(t.id, p.id, t.sha256, t.name, t.size, t.createdAt, t.createdBy);
178
+ this.db.prepare('INSERT INTO projects(id,name,repository,created_at,description) VALUES(?,?,?,?,?)').run(p.id, p.name, p.repository, p.createdAt, p.description ?? null);
179
+ for (const g of p.tags ?? [])
180
+ this.db.prepare('INSERT INTO project_tags(project_id,tag) VALUES(?,?)').run(p.id, g);
181
+ const insert = this.db.prepare('INSERT INTO targets(id,project_id,sha256,name,size,created_at,created_by,version_label) VALUES(?,?,?,?,?,?,?,?)');
182
+ const tag = this.db.prepare('INSERT INTO target_tags(target_id,tag) VALUES(?,?)');
183
+ // A bundle of an older hub has neither field.
184
+ for (const t of targets) {
185
+ insert.run(t.id, p.id, t.sha256, t.name, t.size, t.createdAt, t.createdBy, t.versionLabel ?? null);
186
+ for (const g of t.tags ?? [])
187
+ tag.run(t.id, g);
188
+ }
94
189
  });
95
190
  }
96
191
  removeTarget(projectId, id) { return Number(this.db.prepare('DELETE FROM targets WHERE project_id=? AND id=?').run(projectId, id).changes) === 1; }
@@ -110,7 +205,7 @@ export class HubStore {
110
205
  }
111
206
  /** Idempotent by sha256 within the project; the id is derived from both, so it is stable across hubs. The project must exist (foreign key). */
112
207
  registerTarget(projectId, input) {
113
- const t = { id: targetId(projectId, input.sha256), projectId, sha256: input.sha256, name: input.name, size: input.size, createdAt: new Date().toISOString(), createdBy: input.createdBy };
208
+ const t = { id: targetId(projectId, input.sha256), projectId, sha256: input.sha256, name: input.name, size: input.size, createdAt: new Date().toISOString(), createdBy: input.createdBy, versionLabel: null, tags: [] };
114
209
  const { changes } = this.db.prepare('INSERT INTO targets(id,project_id,sha256,name,size,created_at,created_by) VALUES(?,?,?,?,?,?,?) ON CONFLICT DO NOTHING')
115
210
  .run(t.id, projectId, t.sha256, t.name, t.size, t.createdAt, t.createdBy);
116
211
  // Nothing inserted: the target exists (a repeat, or a concurrent registration).
@@ -119,10 +119,11 @@ export interface NativeGhidra {
119
119
  /** Drops local changes: undo checkout and check out the latest version again. Caller stops the worker first. */
120
120
  discard(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
121
121
  /**
122
- * Undoes the checkout and deletes the working copy. Refuses a modified copy with `native.modified` unless force;
123
- * `modified` says whether forced release dropped unpublished changes.
122
+ * Undoes the checkout and deletes the working copy. Refuses, with `native.modified` unless force, a copy with
123
+ * unpublished changes or files only it holds (context scripts, other local project files); `modified` says whether a
124
+ * forced release dropped unpublished changes. `preview` refuses or answers the same and changes nothing.
124
125
  */
125
- release(repository: RepositoryRef, copy: WorkingCopy, force: boolean): Promise<{
126
+ release(repository: RepositoryRef, copy: WorkingCopy, force: boolean, preview?: boolean): Promise<{
126
127
  modified: boolean;
127
128
  }>;
128
129
  /** Stops the layer's long-lived Ghidra JVM after its running operations (owner shutdown, runtime change). Optional for fakes. */
@@ -52,7 +52,7 @@ export declare class JvmNativeGhidra implements NativeGhidra {
52
52
  version: number;
53
53
  }>;
54
54
  discard(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
55
- release(repository: RepositoryRef, copy: WorkingCopy, force: boolean): Promise<{
55
+ release(repository: RepositoryRef, copy: WorkingCopy, force: boolean, preview?: boolean): Promise<{
56
56
  modified: boolean;
57
57
  }>;
58
58
  }
@@ -69,8 +69,10 @@ export class JvmNativeGhidra {
69
69
  }
70
70
  async update(repository, copy) { return versionResult(await this.copy('update', repository, copy), ['updated', 'current']); }
71
71
  async discard(repository, copy) { return checkoutStatus(await this.copy('discard', repository, copy)); }
72
- async release(repository, copy, force) {
73
- const result = await this.copy('release', repository, copy, { force });
72
+ async release(repository, copy, force, preview = false) {
73
+ const result = await this.copy('release', repository, copy, { force, preview });
74
+ if (preview)
75
+ return { modified: result.modified === true };
74
76
  await rm(resolve(copy.root), { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
75
77
  return { modified: result.modified === true };
76
78
  }
@@ -167,6 +167,7 @@ export class Research {
167
167
  }
168
168
  /** Installation, managed extension and context scripts (`ghidra_scripts` in the working copy). */
169
169
  async scripts(selected, filter, limit, offset) {
170
+ await this.core.use(selected);
170
171
  const native = await this.native();
171
172
  if (!native.ghidraHome)
172
173
  fail('configuration', 'The native layer does not expose its installation.');
@@ -176,6 +177,7 @@ export class Research {
176
177
  async peer(selected, other, action) {
177
178
  if (other !== 'base' && other.session === selected.session && other.target === selected.target)
178
179
  fail('invalid', 'Select two different contexts, or omit --other-target to compare with the base version.');
180
+ await this.core.use(selected);
179
181
  const directory = await this.core.copyScratch(selected), gzf = join(directory, 'peer.gzf');
180
182
  try {
181
183
  if (other === 'base')
@@ -50,14 +50,17 @@ export declare class WorkHubs {
50
50
  private cached;
51
51
  /** The ledger of the profile hub project, creating the hub project when absent (that needs Ghidra Server). For changes only. */
52
52
  open(c: CommandContext): Promise<LedgerClient>;
53
- /** The hub and, when the profile hub project exists, its ledger. Reads never create a hub project or start Ghidra Server. */
54
- find(c: CommandContext): Promise<{
53
+ /**
54
+ * The hub and, when the hub project exists, its ledger; `name` defaults to the profile hub project. Reads never create
55
+ * a hub project or start Ghidra Server.
56
+ */
57
+ find(c: CommandContext, name?: string): Promise<{
55
58
  hub: HttpHubClient;
56
59
  ledger?: LedgerClient;
57
60
  }>;
58
61
  /** Downloads a hub blob; blobs belong to the hub, not to a project, so no hub project is needed (or created). */
59
62
  download(c: CommandContext, sha256: string, destination: string): Promise<void>;
60
63
  /** The ledger of an existing profile hub project; work.notFound when there is none yet. */
61
- read(c: CommandContext): Promise<LedgerClient>;
64
+ read(c: CommandContext, name?: string): Promise<LedgerClient>;
62
65
  }
63
66
  export {};
@@ -132,32 +132,35 @@ export class WorkHubs {
132
132
  }
133
133
  }
134
134
  ledger(c, hub, project) {
135
- const key = this.key(c) + '\0' + hubProjectName(c);
135
+ const key = this.key(c) + '\0' + project.name;
136
136
  const ledger = new LedgerClient(hub, hub.url, hub.client, project, { reconnect: () => this.client(c, true), stale: () => { if (this.ledgers.get(key) === ledger)
137
137
  this.ledgers.delete(key); } });
138
138
  this.ledgers.set(key, ledger);
139
139
  return ledger;
140
140
  }
141
- cached(c) { return this.ledgers.get(this.key(c) + '\0' + hubProjectName(c)); }
141
+ cached(c, name = hubProjectName(c)) { return this.ledgers.get(this.key(c) + '\0' + name); }
142
142
  /** The ledger of the profile hub project, creating the hub project when absent (that needs Ghidra Server). For changes only. */
143
143
  async open(c) {
144
144
  return this.cached(c) ?? this.withHub(c, async (hub) => this.ledger(c, hub, await hub.project(hubProjectName(c))));
145
145
  }
146
- /** The hub and, when the profile hub project exists, its ledger. Reads never create a hub project or start Ghidra Server. */
147
- async find(c) {
148
- const known = this.cached(c);
146
+ /**
147
+ * The hub and, when the hub project exists, its ledger; `name` defaults to the profile hub project. Reads never create
148
+ * a hub project or start Ghidra Server.
149
+ */
150
+ async find(c, name = hubProjectName(c)) {
151
+ const known = this.cached(c, name);
149
152
  if (known)
150
153
  return { hub: known.hub, ledger: known };
151
154
  return this.withHub(c, async (hub) => {
152
- const project = await hub.existingProject(hubProjectName(c));
155
+ const project = await hub.existingProject(name);
153
156
  return { hub, ...(project ? { ledger: this.ledger(c, hub, project) } : {}) };
154
157
  });
155
158
  }
156
159
  /** Downloads a hub blob; blobs belong to the hub, not to a project, so no hub project is needed (or created). */
157
160
  download(c, sha256, destination) { return this.withHub(c, hub => hub.getBlob(sha256, destination)); }
158
161
  /** The ledger of an existing profile hub project; work.notFound when there is none yet. */
159
- async read(c) {
160
- const { ledger } = await this.find(c);
161
- return ledger ?? fail('notFound', `Hub project ${hubProjectName(c)} does not exist yet, so it has no work projects; work create starts one.`);
162
+ async read(c, name = hubProjectName(c)) {
163
+ const { ledger } = await this.find(c, name);
164
+ return ledger ?? fail('notFound', `Hub project ${name} does not exist yet, so it has no plans; work create starts one.`);
162
165
  }
163
166
  }
@@ -16,7 +16,10 @@ import { packageVersion } from '../package-version.js';
16
16
  import { saveDashboard } from './dashboard.js';
17
17
  import { WorkHubs, hubProjectName } from './client.js';
18
18
  import { legacyRows } from './legacy.js';
19
- const project = { flags: '--project <id>', description: 'Work project in the profile hub project', required: true };
19
+ /** A plan (work ledger) of the hub project; --project always names the hub project (#186). */
20
+ const project = { flags: '--plan <id>', description: 'Plan in the hub project', required: true };
21
+ const hubProject = { flags: '--project <name>', description: 'Hub project (default: the profile hub project)' };
22
+ const tagList = (value) => value === undefined ? undefined : String(value).split(',').map(t => t.trim()).filter(Boolean);
20
23
  const file = { flags: '--file <path>', description: 'Bounded JSON input, uploaded to the hub before use', required: true };
21
24
  const task = { flags: '--task <id>', description: 'Assigned work item', required: true };
22
25
  const worker = { flags: '--worker <id>', description: 'Cooperative worker label, not authenticated identity', required: true };
@@ -195,51 +198,56 @@ export function workCommands(access, connect = connectHub) {
195
198
  }, { permission: Permission.Update, options: [...options, { flags: '--refresh-dashboard', description: 'Also regenerate the profile HTML view' }] });
196
199
  const upload = (l, c, path, max) => l.upload(resolve(c.cwd, string(path)), max);
197
200
  return [command('work', 'Shared strict-reconstruction ledger on the hub: fenced assignments, packages, review and read-only progress views', [
198
- command('timing', 'Measure reconstruction and independent review from recorded hub events', ({ options: o }, c) => call(c, 'timing', { project: identifier(o.project), tasks: o.tasks === undefined ? undefined : String(o.tasks).split(',') }), { permission: Permission.ReadOnly, options: [project, { flags: '--tasks <ids>', description: 'Comma-separated reconstruction IDs; default latest ten' }] }),
199
- command('context', 'Identify the CLI, profile, hub project and selected work project', async ({ options: o }, c) => {
200
- const { hub, ledger } = await hubs.find(c), selected = o.project === undefined ? undefined : identifier(o.project);
201
+ command('timing', 'Measure reconstruction and independent review from recorded hub events', ({ options: o }, c) => call(c, 'timing', { project: identifier(o.plan), tasks: o.tasks === undefined ? undefined : String(o.tasks).split(',') }), { permission: Permission.ReadOnly, options: [project, { flags: '--tasks <ids>', description: 'Comma-separated reconstruction IDs; default latest ten' }] }),
202
+ command('context', 'Identify the CLI, profile, hub project and selected plan', async ({ options: o }, c) => {
203
+ const { hub, ledger } = await hubs.find(c), selected = o.plan === undefined ? undefined : identifier(o.plan);
201
204
  if (!ledger && selected !== undefined)
202
- fail('notFound', `Hub project ${hubProjectName(c)} does not exist yet, so work project ${selected} does not either.`);
205
+ fail('notFound', `Hub project ${hubProjectName(c)} does not exist yet, so plan ${selected} does not either.`);
203
206
  // Before the first work create the hub project may not exist: hubProject.id is then null.
204
207
  return { cliVersion: packageVersion, profile: c.profile.name, hub: hub.url, client: hub.client, hubProject: { id: ledger?.project.id ?? null, name: ledger?.project.name ?? hubProjectName(c) }, workSchema: 3,
205
208
  project: ledger ? await ledger.call('context', { project: selected }) : null, registrationOrder: ['import', 'plan', 'claim'], atomicAssignment: 'next' };
206
209
  }, { permission: Permission.ReadOnly, options: [{ ...project, required: false }] }),
207
- command('projects', 'List work projects in the profile hub project', async (_, c) => {
208
- const { ledger } = await hubs.find(c);
209
- return { projects: ledger ? await ledger.call('projects', {}) : [] };
210
- }, { permission: Permission.ReadOnly }),
211
- changing('create', 'Bind a work project to a hub target', [project, { flags: '--target <id>', required: true, description: 'Hub target id (ghidra targets list)' },
212
- { flags: '--name <name>', required: true, description: 'Display name' }], async (l, o) => ({ project: identifier(o.project), body: { project: o.project, target: o.target, name: o.name } })),
213
- changing('import', 'Add bounded function definitions; never promote unwind regions', [project, file, epoch], async (l, o, c) => ({ project: identifier(o.project), body: { project: o.project, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
214
- changing('import-graph', 'Add dependencies; new evidence conservatively invalidates affected scopes', [project, file, epoch], async (l, o, c) => ({ project: identifier(o.project), body: { project: o.project, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
215
- changing('revise-definition', 'Retain a definition revision and invalidate affected assignments', [project, functionId, file, epoch, { flags: '--expect-version <n>', description: 'Current function/package version', required: true }], async (l, o, c) => ({ project: identifier(o.project), body: { project: o.project, function: o.function, expectVersion: o.expectVersion, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
216
- read('history', 'Page retained package and definition versions', [project, functionId, pageLimit, { flags: '--after-version <n>', description: 'Exclusive retained version', defaultValue: 0 }], o => ({ project: o.project, function: o.function, afterVersion: o.afterVersion, limit: o.limit })),
210
+ command('list', 'List the plans of a hub project with their target, version label and tags; --target and --tags select', async ({ options: o }, c) => {
211
+ const { ledger } = await hubs.find(c, o.project === undefined ? undefined : String(o.project));
212
+ const tags = (tagList(o.tags) ?? []).map(t => t.toLowerCase()), rows = ledger ? await ledger.call('list', {}) : [];
213
+ return { items: rows.filter(r => (o.target === undefined || r.target === String(o.target)) && tags.every(t => r.tags.includes(t))) };
214
+ }, { permission: Permission.ReadOnly, options: [hubProject, { flags: '--target <id>', description: 'Only plans of this target' }, { flags: '--tags <tags>', description: 'Only plans with all these tags, comma separated' }] }),
215
+ command('show', 'One plan in full: target, version label, tags and the stored plan with its inventory sources', async ({ options: o }, c) => (await hubs.read(c, o.project === undefined ? undefined : String(o.project))).call('show', { project: identifier(o.plan) }), { permission: Permission.ReadOnly, options: [project, hubProject] }),
216
+ command('set', 'Rename a plan or add and remove its tags (metadata only: no revision, no effect on planning)', async ({ options: o }, c) => (await hubs.read(c, o.project === undefined ? undefined : String(o.project))).call('set', { project: identifier(o.plan),
217
+ ...(o.name === undefined ? {} : { name: o.name }), ...(o.addTags === undefined ? {} : { addTags: tagList(o.addTags) }), ...(o.removeTags === undefined ? {} : { removeTags: tagList(o.removeTags) }) }), { permission: Permission.Update, options: [project, hubProject, { flags: '--name <name>', description: 'New display name' },
218
+ { flags: '--add-tags <tags>', description: 'Tags to add, comma separated (lower-cased; a-z 0-9 . _ - + :)' }, { flags: '--remove-tags <tags>', description: 'Tags to remove, comma separated' }] }),
219
+ changing('create', 'Create a plan over a hub target', [project, { flags: '--target <id>', required: true, description: 'Hub target id (hub targets list)' },
220
+ { flags: '--name <name>', required: true, description: 'Display name' }, { flags: '--tags <tags>', description: 'Tags, comma separated' }], async (l, o) => ({ project: identifier(o.plan), body: { project: o.plan, target: o.target, name: o.name, ...(o.tags === undefined ? {} : { tags: tagList(o.tags) }) } })),
221
+ changing('import', 'Add bounded function definitions; never promote unwind regions', [project, file, epoch], async (l, o, c) => ({ project: identifier(o.plan), body: { project: o.plan, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
222
+ changing('import-graph', 'Add dependencies; new evidence conservatively invalidates affected scopes', [project, file, epoch], async (l, o, c) => ({ project: identifier(o.plan), body: { project: o.plan, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
223
+ changing('revise-definition', 'Retain a definition revision and invalidate affected assignments', [project, functionId, file, epoch, { flags: '--expect-version <n>', description: 'Current function/package version', required: true }], async (l, o, c) => ({ project: identifier(o.plan), body: { project: o.plan, function: o.function, expectVersion: o.expectVersion, epoch: o.epoch, artifact: await upload(l, c, o.file) } })),
224
+ read('history', 'Page retained package and definition versions', [project, functionId, pageLimit, { flags: '--after-version <n>', description: 'Exclusive retained version', defaultValue: 0 }], o => ({ project: o.plan, function: o.function, afterVersion: o.afterVersion, limit: o.limit })),
217
225
  command('import-legacy', 'Copy this profile\'s pre-hub ledger into the profile hub project; ids and fences are kept, the source file is untouched', async ({ options: o }, c) => importLegacy(await hubs.open(c), join(analysisDirectory(c), 'workspace'), o.dryRun === true, o.allowMissing === true), { permission: Permission.Update, options: [{ flags: '--dry-run', description: 'Report what would be imported without writing to the hub' },
218
226
  { flags: '--allow-missing', description: 'Import even though some ledger attachments are missing from the profile (they stay missing on the hub)' }] }),
219
- read('brief', 'Current consistent overview with bounded rows and explicit limits', [project, pageLimit], o => ({ project: o.project, limit: o.limit })),
220
- read('events', 'Keyset page of project events', [project, pageLimit, { flags: '--after <seq>', description: 'Exclusive project event sequence', defaultValue: 0 }], o => ({ project: o.project, after: o.after, limit: o.limit })),
227
+ read('brief', 'Current consistent overview with bounded rows and explicit limits', [project, pageLimit], o => ({ project: o.plan, limit: o.limit })),
228
+ read('events', 'Keyset page of project events', [project, pageLimit, { flags: '--after <seq>', description: 'Exclusive project event sequence', defaultValue: 0 }], o => ({ project: o.plan, after: o.after, limit: o.limit })),
221
229
  command('export', 'Write a consistent project checkpoint to a new JSONL file', async ({ options: o }, c) => {
222
- const path = resolve(c.cwd, string(o.output)), exported = await call(c, 'export', { project: identifier(o.project) });
230
+ const path = resolve(c.cwd, string(o.output)), exported = await call(c, 'export', { project: identifier(o.plan) });
223
231
  const text = exported.records.map(r => JSON.stringify(r) + '\n').join('');
224
232
  await writeFile(path, text, { flag: 'wx', mode: 0o600 });
225
233
  return { path, project: exported.project, revision: exported.revision, records: exported.records.length, sha256: createHash('sha256').update(text).digest('hex'),
226
234
  artifacts: 'Attachments stay on the hub; work evidence downloads one.' };
227
235
  }, { permission: Permission.ReadOnly, options: [project, { flags: '--output <path>', description: 'New JSONL checkpoint; attachment payloads stay on the hub', required: true }] }),
228
- read('functions', 'Keyset page of functions; retain revision when paging', [project, pageLimit, { flags: '--after-rva <hex>', description: 'Exclusive RVA cursor, 0x-prefixed' }], o => ({ project: o.project, afterRva: o.afterRva === undefined ? undefined : rva(o.afterRva), limit: o.limit })),
229
- read('graph', 'Keyset page of dependency nodes or edges', [project, pageLimit, { flags: '--kind <kind>', description: 'nodes or edges', defaultValue: 'edges' }, { flags: '--after <id>', description: 'Exclusive ID cursor' }], o => ({ project: o.project, kind: o.kind, after: o.after, limit: o.limit })),
236
+ read('functions', 'Keyset page of functions; retain revision when paging', [project, pageLimit, { flags: '--after-rva <hex>', description: 'Exclusive RVA cursor, 0x-prefixed' }], o => ({ project: o.plan, afterRva: o.afterRva === undefined ? undefined : rva(o.afterRva), limit: o.limit })),
237
+ read('graph', 'Keyset page of dependency nodes or edges', [project, pageLimit, { flags: '--kind <kind>', description: 'nodes or edges', defaultValue: 'edges' }, { flags: '--after <id>', description: 'Exclusive ID cursor' }], o => ({ project: o.plan, kind: o.kind, after: o.after, limit: o.limit })),
230
238
  changing('reopen-review', 'Withdraw the current approval and require another review; retain its history', [project, functionId, epoch,
231
239
  { flags: '--source-sha256 <sha>', description: 'Exact current reconstruction hash', required: true },
232
240
  { flags: '--expect-version <n>', description: 'Observed package version, including its passport', required: true },
233
- { flags: '--reason <text>', description: 'Retained evidence/reason for reopening approval', required: true }], async (l, o) => ({ project: identifier(o.project), body: { project: o.project, function: o.function, sourceSha256: o.sourceSha256, expectVersion: o.expectVersion, reason: o.reason, epoch: o.epoch } })),
241
+ { flags: '--reason <text>', description: 'Retained evidence/reason for reopening approval', required: true }], async (l, o) => ({ project: identifier(o.plan), body: { project: o.plan, function: o.function, sourceSha256: o.sourceSha256, expectVersion: o.expectVersion, reason: o.reason, epoch: o.epoch } })),
234
242
  changing('plan', 'Reserve a small nonoverlapping reconstruction or independent-review slice', [project, revision, epoch,
235
243
  { flags: '--count <n>', description: 'Maximum functions, 1..50', defaultValue: 10 }, kindOption,
236
244
  { flags: '--functions <ids>', description: 'Optional comma-separated exact function IDs; for discover, the roots' },
237
- { flags: '--after-rva <hex>', description: 'Continue beyond a bounded frontier' }, ...traversal], async (l, o) => ({ project: identifier(o.project), body: { project: o.project, expectRevision: o.expectRevision, count: o.count, kind: o.kind, functions: list(o.functions),
245
+ { flags: '--after-rva <hex>', description: 'Continue beyond a bounded frontier' }, ...traversal], async (l, o) => ({ project: identifier(o.plan), body: { project: o.plan, expectRevision: o.expectRevision, count: o.count, kind: o.kind, functions: list(o.functions),
238
246
  afterRva: o.afterRva === undefined ? undefined : rva(o.afterRva), epoch: o.epoch, discover: traversalOf(o) } })),
239
247
  changing('claim', 'Claim queued or expired work and obtain a fresh fence; claiming your own current lease returns it', [task, worker, ttl], async (l, o) => ({ body: { task: o.task, worker: o.worker, ttl: o.ttl } })),
240
248
  changing('next', 'Plan and claim the next slice atomically; returns a lease token', [project, epoch, worker, ttl,
241
249
  { flags: '--count <n>', description: 'Maximum functions, 1..50', defaultValue: 10 }, kindOption,
242
- { flags: '--functions <ids>', description: 'Optional exact function IDs, e.g. the retry list of work.taskCancelled; for discover, the roots' }, ...traversal], async (l, o) => ({ project: identifier(o.project), body: { project: o.project, worker: o.worker, count: o.count, kind: o.kind, ttl: o.ttl, epoch: o.epoch, functions: list(o.functions), discover: traversalOf(o) } })),
250
+ { flags: '--functions <ids>', description: 'Optional exact function IDs, e.g. the retry list of work.taskCancelled; for discover, the roots' }, ...traversal], async (l, o) => ({ project: identifier(o.plan), body: { project: o.plan, worker: o.worker, count: o.count, kind: o.kind, ttl: o.ttl, epoch: o.epoch, functions: list(o.functions), discover: traversalOf(o) } })),
243
251
  changing('heartbeat', 'Extend a still-current lease on the hub clock', [...held, ttl], async (l, o) => ({ body: { ...leaseOf(o), ttl: o.ttl } })),
244
252
  changing('release', 'Return a current lease to the queue, keeping its reserved scope', held, async (l, o) => ({ body: leaseOf(o) })),
245
253
  changing('cancel', 'Cancel an outstanding task and fence it off before replanning', [task, revision, epoch, { flags: '--reason <text>', description: 'Retained cancellation reason', required: true }], async (l, o) => ({ body: { task: o.task, expectRevision: o.expectRevision, reason: o.reason, epoch: o.epoch } })),
@@ -274,11 +282,11 @@ export function workCommands(access, connect = connectHub) {
274
282
  changing('compare', 'Compare supplied observation corpora exactly; never certify universal 1:1', [project, epoch,
275
283
  { flags: '--function <id>', description: 'Exact function ID', required: true }, { flags: '--source-sha256 <sha>', description: 'Current reconstruction hash', required: true },
276
284
  { flags: '--original <path>', description: 'Original observations JSON', required: true }, { flags: '--reconstruction <path>', description: 'Reconstruction observations JSON', required: true },
277
- { flags: '--layout <path>', description: 'Retained observation-layout JSON named by every outcome hash', required: true }], async (l, o, c) => ({ project: identifier(o.project), body: { project: o.project, function: o.function, sourceSha256: o.sourceSha256, epoch: optionalEpoch(o),
285
+ { flags: '--layout <path>', description: 'Retained observation-layout JSON named by every outcome hash', required: true }], async (l, o, c) => ({ project: identifier(o.plan), body: { project: o.plan, function: o.function, sourceSha256: o.sourceSha256, epoch: optionalEpoch(o),
278
286
  original: await upload(l, c, o.original), reconstruction: await upload(l, c, o.reconstruction), layout: await upload(l, c, o.layout) } })),
279
287
  command('certify', 'Fail closed: no supported exhaustive/formal verifier is available', (_, c) => call(c, 'certify', {}), { permission: Permission.Update }),
280
288
  command('dashboard', 'Generate a consistent self-contained read-only HTML projection', ({ options: o }, c) => {
281
- const id = identifier(o.project);
289
+ const id = identifier(o.plan);
282
290
  return access(c, w => saveDashboard(w, () => call(c, 'brief', { project: id, limit: 200 }), id, o.output === undefined ? undefined : resolve(c.cwd, string(o.output))));
283
291
  }, { permission: Permission.ReadOnly, options: [project, { flags: '--output <path>', description: 'Optional new snapshot HTML file; existing files are never overwritten' }] }),
284
292
  command('evidence', 'Download and locate a retained content-addressed work attachment', async ({ options: o }, c) => {
@@ -62,6 +62,8 @@ export interface Project {
62
62
  sources: Attachment[];
63
63
  };
64
64
  createdAt: number;
65
+ /** Shared tags (#186), lower-case and sorted; absent on plans created before. */
66
+ tags?: string[];
65
67
  }
66
68
  export interface Task {
67
69
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eyeauras/insight-cli",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "type": "module",
5
5
  "description": "Agent-facing durable sessions and isolated Ghidra research contexts",
6
6
  "main": "./dist/src/index.js",
@@ -23,6 +23,7 @@ import ghidra.framework.store.LockException;
23
23
  import ghidra.program.database.ProgramDB;
24
24
  import ghidra.program.model.listing.Program;
25
25
  import ghidra.util.task.*;
26
+ import java.io.IOException;
26
27
  import java.io.PrintStream;
27
28
  import java.nio.charset.StandardCharsets;
28
29
  import java.nio.file.*;
@@ -374,13 +375,43 @@ public final class InsightWcOps {
374
375
  }
375
376
  return Map.of("state","updated","version",file.getCheckoutStatus().getCheckoutVersion());
376
377
  }
378
+ /**
379
+ * What only this copy holds besides its checkout, which release would delete: context scripts, and the project's
380
+ * private files (server files are not in it) other than the checked-out program and the keep files Ghidra makes of
381
+ * it on Update (`<name>.keep`, `<name>.keep.<n>`). A program saved with Save As, or the program left as a private file
382
+ * after its server checkout was ended, is such a file. A read error refuses the release.
383
+ */
384
+ static List<String> localFiles(Project project,Path root,String path,boolean checkedOut)throws IOException {
385
+ var found=scripts(root);
386
+ var keep=java.util.regex.Pattern.compile(java.util.regex.Pattern.quote(path+".keep")+"(\\.[1-9][0-9]*)?");
387
+ localFiles(((DefaultProjectData)project.getProjectData()).getPrivateFileSystem(),"/",found,item->checkedOut&&item.equals(path)||keep.matcher(item).matches());
388
+ return found;
389
+ }
390
+ static void localFiles(ghidra.framework.store.FileSystem fs,String folder,List<String> found,java.util.function.Predicate<String> checkout)throws IOException {
391
+ String prefix=folder.equals("/")?"/":folder+"/";
392
+ for(String name:fs.getItemNames(folder))if(!checkout.test(prefix+name))found.add(prefix+name);
393
+ for(String name:fs.getFolderNames(folder))localFiles(fs,prefix+name,found,checkout);
394
+ }
395
+ /** The copy's context scripts (`<root>/ghidra_scripts`). */
396
+ static List<String> scripts(Path root)throws IOException {
397
+ var found=new ArrayList<String>();
398
+ try(var scripts=Files.list(root.resolve("ghidra_scripts"))){scripts.forEach(p->found.add("ghidra_scripts/"+p.getFileName()));}
399
+ catch(NoSuchFileException absent){/* no context scripts */}
400
+ return found;
401
+ }
402
+ static Refusal holdsLocalFiles(List<String> local){
403
+ return new Refusal("modified","The working copy holds files that are not on the server ("+String.join(", ",local)+"); move them, or release with force");
404
+ }
377
405
  static Map<String,Object> copy(JsonObject q,String operation)throws Exception {
378
406
  String path=text(q,"programPath");ProjectLocator locator=locator(q);boolean present=locator.getMarkerFile().exists();
379
407
  if(operation.equals("status")&&!present){
380
408
  RepositoryAdapter repository=repository(q);try{return status(repository,null,path);}finally{repository.disconnect();}
381
409
  }
382
410
  if(operation.equals("release")&&!present){
383
- // Nothing local is left; end what an interrupted checkout or release may have left on the server.
411
+ // No project is left; end what an interrupted checkout or release may have left on the server. Context scripts
412
+ // in the directory stop an unforced release like in a full copy; a preview (gc --dry-run) changes nothing.
413
+ if(!q.get("force").getAsBoolean()){var local=scripts(Path.of(text(q,"root")));if(!local.isEmpty())throw holdsLocalFiles(local);}
414
+ if(q.has("preview")&&q.get("preview").getAsBoolean())return Map.of("state","releasable","modified",false);
384
415
  RepositoryAdapter repository=repository(q);
385
416
  try{if(repository.getItem(parent(path),leaf(path))!=null)endStrayCheckouts(repository,locator,path,-1);return Map.of("state","released","modified",false);}
386
417
  finally{repository.disconnect();}
@@ -405,14 +436,20 @@ public final class InsightWcOps {
405
436
  if(file==null)throw new Refusal("not_found","Program "+path+" does not exist in repository "+repository.getName());
406
437
  if(operation.equals("status"))return status(repository,file,path);
407
438
  if(operation.equals("release")){
439
+ // `preview` answers what this release would do (gc --dry-run) and changes nothing.
440
+ boolean force=q.get("force").getAsBoolean(),preview=q.has("preview")&&q.get("preview").getAsBoolean();
441
+ if(!force){
442
+ var local=localFiles(project,Path.of(text(q,"root")),path,file.isCheckedOut());
443
+ if(!local.isEmpty())throw holdsLocalFiles(local);
444
+ }
408
445
  boolean modified=false;
409
446
  if(file.isCheckedOut()){
410
447
  modified=file.modifiedSinceCheckout()||file.canRecover();
411
- if(modified&&!q.get("force").getAsBoolean())
448
+ if(modified&&!force)
412
449
  throw new Refusal("modified","The working copy has unpublished changes; publish or discard them, or release with force");
413
- undoCheckout(project,file,path);
414
- }else endStrayCheckouts(repository,locator,path,-1);
415
- return Map.of("state","released","modified",modified);
450
+ if(!preview)undoCheckout(project,file,path);
451
+ }else if(!preview)endStrayCheckouts(repository,locator,path,-1);
452
+ return Map.of("state",preview?"releasable":"released","modified",modified);
416
453
  }
417
454
  if(operation.equals("discard")&&file.isCheckedOut()){undoCheckout(project,file,path);file=file(project,path);}
418
455
  if(!file.isCheckedOut()){
@@ -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.9.2
6
+ # Insight Artifacts 0.9.3
7
7
 
8
8
  Commands: `insight-cli artifacts --help`. `insight-cli tools show artifacts --json`
9
9
  lists tasks, inputs, platforms and readiness.
@@ -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.9.2
6
+ # Insight Binary 0.9.3
7
7
 
8
8
  Commands: `insight-cli binary --help`. `insight-cli tools show binary --json`
9
9
  lists tasks, inputs, platforms and readiness.
@@ -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.9.2
6
+ # Insight Capture 0.9.3
7
7
 
8
8
  Commands: `insight-cli capture --help`. `insight-cli tools show capture --json`
9
9
  lists tasks, inputs, platforms and readiness.
@@ -3,7 +3,7 @@ name: insight-cli
3
3
  description: Choose and prepare reverse-engineering capabilities from the insight-cli toolbox for binary, managed-code and runtime investigations. Use to discover the appropriate tool or its packaged skill before installing native runtimes.
4
4
  ---
5
5
 
6
- # insight-cli 0.9.2
6
+ # insight-cli 0.9.3
7
7
 
8
8
  Discover capabilities with `insight-cli tools list --json` and `insight-cli tools show <tool> --json`;
9
9
  each tool names its skill (`insight-cli skill <name>`). Update permission is required for tool preparation,
@@ -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.9.2
6
+ # Insight Detect It Easy 0.9.3
7
7
 
8
8
  Commands: `insight-cli die --help`. `insight-cli tools show die --json`
9
9
  lists tasks, inputs, platforms and readiness.
@@ -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.9.2
6
+ # Insight dnSpyEx 0.9.3
7
7
 
8
8
  Commands: `insight-cli dnspy --help`. `insight-cli tools show dnspy --json`
9
9
  lists tasks, inputs, platforms and readiness.
@@ -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.9.2
6
+ # Insight .NET Dump 0.9.3
7
7
 
8
8
  Commands: `insight-cli dotnet-dump --help`. `insight-cli tools show dotnet-dump --json`
9
9
  lists tasks, inputs, platforms and readiness.