@rotorsoft/act-diagram 1.0.12 → 1.0.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/cli/format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAiB7B,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAY3E;AAmFD,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CA+D1E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAoC3E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAqB1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CA4B1E;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,GAChB,MAAM,CAWR;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAwC7E;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,CAQlD,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAG3E;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAazD"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/cli/format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAiB7B,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAY3E;AAmFD,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CA+D1E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAoC3E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAqB1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAkC1E;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,GAChB,MAAM,CAWR;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAwC7E;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,CAQlD,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAG3E;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAazD"}
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import type { FileTab } from "../client/types/index.js";
2
3
  import { build_contract_index } from "./contract-index.js";
3
4
  export type CliArgs = {
4
5
  cwd?: string;
@@ -26,7 +27,7 @@ export type RunDeps = {
26
27
  * Exposed so tests can drive the non-`-q` code path without hanging
27
28
  * on real clack prompts.
28
29
  */
29
- run_interactive?: (idx: ReturnType<typeof build_contract_index>, root_dir: string) => Promise<void>;
30
+ run_interactive?: (idx: ReturnType<typeof build_contract_index>, root_dir: string, files: FileTab[]) => Promise<void>;
30
31
  };
31
32
  export declare function main(deps: RunDeps): Promise<number>;
32
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,oBAAoB,EAAU,MAAM,qBAAqB,CAAC;AAOnE,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAuB3D;AAqBD,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAChB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAC5C,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAsB,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA0FzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAU,MAAM,qBAAqB,CAAC;AAOnE,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAuB3D;AAqBD,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAChB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAC5C,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EAAE,KACb,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAsB,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA6FzD"}
@@ -1,3 +1,4 @@
1
+ import type { FileTab } from "../client/types/index.js";
1
2
  import { type ContractIndex } from "./contract-index.js";
2
- export declare function run_interactive(idx: ContractIndex, root_dir: string): Promise<void>;
3
+ export declare function run_interactive(idx: ContractIndex, root_dir: string, files?: FileTab[]): Promise<void>;
3
4
  //# sourceMappingURL=repl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../../src/cli/repl.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAyL7B,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAef"}
1
+ {"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../../src/cli/repl.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAoM7B,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,OAAO,EAAO,GACpB,OAAO,CAAC,IAAI,CAAC,CAef"}
package/dist/cli/act.js CHANGED
@@ -1632,8 +1632,10 @@ function format_slice(idx, entry) {
1632
1632
  if (!sl) return lines.join("\n");
1633
1633
  if (sl.error) lines.push(` ${red("error: " + sl.error)}`);
1634
1634
  if (sl.states.length > 0) {
1635
+ const by_var = new Map(idx.model.states.map((st) => [st.varName, st.name]));
1636
+ const names = [...new Set(sl.states.map((s) => by_var.get(s) ?? s))];
1635
1637
  lines.push(" states:");
1636
- for (const s of sl.states) lines.push(` - ${amber(s)}`);
1638
+ for (const s of names) lines.push(` - ${amber(s)}`);
1637
1639
  }
1638
1640
  if (sl.projections.length > 0) {
1639
1641
  lines.push(" projections:");
@@ -3133,6 +3135,217 @@ ${r2}
3133
3135
  }
3134
3136
  }).prompt();
3135
3137
 
3138
+ // src/client/lib/navigate.ts
3139
+ function position_at(content, index) {
3140
+ const before = content.slice(0, index);
3141
+ const line = before.split("\n").length;
3142
+ const last_nl = before.lastIndexOf("\n");
3143
+ const col = index - (last_nl >= 0 ? last_nl : 0);
3144
+ return { line, col };
3145
+ }
3146
+ function build_patterns(esc, type) {
3147
+ const state_patterns = [new RegExp(`state\\(\\s*\\{\\s*(${esc})\\s*[}:,]`)];
3148
+ const action_patterns = [new RegExp(`\\.on\\(\\s*\\{\\s*(${esc})\\s*[},:]`)];
3149
+ const event_patterns = [
3150
+ // Match event name inside .emits({ EventName: ... }) — inline declaration
3151
+ new RegExp(`\\.emits\\([\\s\\S]*?(${esc})\\s*:`),
3152
+ // Match event name as key in a schema object: EventName: z.object(...)
3153
+ new RegExp(`(${esc})\\s*:\\s*z\\.object\\(`)
3154
+ ];
3155
+ const reaction_patterns = [
3156
+ // .do(handlerName) or .do(module.handlerName) — handler declaration in builder
3157
+ new RegExp(`\\.do\\(\\s*(?:\\w+\\.)?(${esc})\\b`),
3158
+ // inline function in .do()
3159
+ new RegExp(
3160
+ `\\.on\\(\\s*["'\`][^"'\`]+["'\`]\\s*\\)\\s*\\.do\\(\\s*(?:async\\s+)?function\\s+(${esc})\\b`
3161
+ ),
3162
+ // Fallback: function definition
3163
+ new RegExp(`(?:export\\s+)?async\\s+function\\s+(${esc})\\s*\\(`)
3164
+ ];
3165
+ const projection_patterns = [
3166
+ new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*projection\\s*\\(`),
3167
+ new RegExp(`projection\\(\\s*["'\`](${esc})["'\`]`)
3168
+ ];
3169
+ const guard_patterns = [
3170
+ // Guard definition — prefer jumping to the declaration
3171
+ new RegExp(`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*Invariant)?\\s*=`),
3172
+ new RegExp(`rule\\(\\s*["'\`](${esc})["'\`]`),
3173
+ new RegExp(`description:\\s*["'\`](${esc})["'\`]`),
3174
+ // .given() usage in the state builder — last resort
3175
+ new RegExp(`\\.given\\([\\s\\S]*?(${esc})`)
3176
+ ];
3177
+ const slice_patterns = [
3178
+ new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*slice\\s*\\(`)
3179
+ ];
3180
+ const generic = [
3181
+ new RegExp(
3182
+ `(?:const|let|var)\\s+(${esc})\\s*=\\s*(?:state|slice|projection|act)\\s*\\(`
3183
+ ),
3184
+ new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=`),
3185
+ new RegExp(`\\b(${esc})\\b`)
3186
+ ];
3187
+ switch (type) {
3188
+ case "state":
3189
+ return [...state_patterns, ...generic];
3190
+ case "action":
3191
+ return [...action_patterns, ...generic];
3192
+ case "event":
3193
+ return [...event_patterns, ...generic];
3194
+ case "reaction":
3195
+ return [...reaction_patterns, ...generic];
3196
+ case "projection":
3197
+ return [...projection_patterns, ...generic];
3198
+ case "guard":
3199
+ return [...guard_patterns, ...generic];
3200
+ default:
3201
+ return [
3202
+ ...slice_patterns,
3203
+ ...state_patterns,
3204
+ ...action_patterns,
3205
+ ...event_patterns,
3206
+ ...reaction_patterns,
3207
+ ...projection_patterns,
3208
+ ...guard_patterns,
3209
+ ...generic
3210
+ ];
3211
+ }
3212
+ }
3213
+ function navigate_to_code(files, name, type, target_file) {
3214
+ const stripped = /* @__PURE__ */ new Map();
3215
+ const code = (f) => {
3216
+ let c2 = stripped.get(f.path);
3217
+ if (c2 === void 0) {
3218
+ c2 = strip_non_code(f.content, "nav");
3219
+ stripped.set(f.path, c2);
3220
+ }
3221
+ return c2;
3222
+ };
3223
+ if (type === "file") {
3224
+ const file = files.find((f) => f.path === name || f.path.endsWith(name));
3225
+ if (file) {
3226
+ const act_match = /\bact\s*\(\s*\)/.exec(code(file));
3227
+ if (act_match) {
3228
+ const { line, col } = position_at(file.content, act_match.index);
3229
+ return { file: file.path, line, col };
3230
+ }
3231
+ return { file: file.path, line: 1, col: 1 };
3232
+ }
3233
+ return void 0;
3234
+ }
3235
+ if (target_file) {
3236
+ const file = files.find((f) => f.path === target_file);
3237
+ if (file) {
3238
+ const c2 = code(file);
3239
+ const esc2 = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3240
+ if (type === "event") {
3241
+ const emits_block_re = new RegExp(
3242
+ `\\.emits\\([\\s\\S]*?(${esc2})\\s*[,:}]`
3243
+ );
3244
+ const block_match = emits_block_re.exec(c2);
3245
+ if (block_match) {
3246
+ const name_idx = block_match.index + block_match[0].lastIndexOf(name);
3247
+ const { line, col } = position_at(file.content, name_idx);
3248
+ return { file: file.path, line, col };
3249
+ }
3250
+ const name_re2 = new RegExp(`\\b${esc2}\\b`, "g");
3251
+ if (name_re2.exec(c2)) {
3252
+ const emits_match = /\.emits\s*\(/.exec(c2);
3253
+ if (emits_match) {
3254
+ const { line, col } = position_at(
3255
+ file.content,
3256
+ emits_match.index + 1
3257
+ );
3258
+ return { file: file.path, line, col };
3259
+ }
3260
+ }
3261
+ }
3262
+ if (type === "guard") {
3263
+ const desc_re = new RegExp(`description:\\s*["'\`]${esc2}["'\`]`);
3264
+ const desc_match = desc_re.exec(c2);
3265
+ if (desc_match) {
3266
+ const before = c2.slice(0, desc_match.index);
3267
+ const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
3268
+ let last_decl = null;
3269
+ let m;
3270
+ while ((m = decl_re.exec(before)) !== null) {
3271
+ last_decl = m;
3272
+ }
3273
+ if (last_decl) {
3274
+ const name_idx = last_decl.index + last_decl[0].indexOf(last_decl[1]);
3275
+ const { line: line2, col: col2 } = position_at(file.content, name_idx);
3276
+ return { file: file.path, line: line2, col: col2 };
3277
+ }
3278
+ const { line, col } = position_at(file.content, desc_match.index);
3279
+ return { file: file.path, line, col };
3280
+ }
3281
+ }
3282
+ if (type === "action") {
3283
+ const name_re2 = new RegExp(`\\b${esc2}\\b`, "g");
3284
+ const block_start = c2.indexOf(".on(");
3285
+ if (block_start >= 0) {
3286
+ name_re2.lastIndex = block_start;
3287
+ const match2 = name_re2.exec(c2);
3288
+ if (match2) {
3289
+ const { line, col } = position_at(file.content, match2.index);
3290
+ return { file: file.path, line, col };
3291
+ }
3292
+ }
3293
+ }
3294
+ const name_re = new RegExp(`\\b${esc2}\\b`);
3295
+ const match = name_re.exec(c2);
3296
+ if (match) {
3297
+ const { line, col } = position_at(file.content, match.index);
3298
+ return { file: file.path, line, col };
3299
+ }
3300
+ }
3301
+ return void 0;
3302
+ }
3303
+ const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3304
+ const is_test_file = (p) => /(?:\.spec\.|\.test\.|__tests__)/.test(p) || /\/test\//.test(p);
3305
+ const sorted_files = [...files].sort(
3306
+ (a2, b) => (is_test_file(a2.path) ? 1 : 0) - (is_test_file(b.path) ? 1 : 0)
3307
+ );
3308
+ if (type === "guard") {
3309
+ const desc_re = new RegExp(`description:\\s*["'\`]${esc}["'\`]`);
3310
+ for (const f of sorted_files) {
3311
+ if (!/\.tsx?$/.test(f.path)) continue;
3312
+ const c2 = code(f);
3313
+ const desc_match = desc_re.exec(c2);
3314
+ if (desc_match) {
3315
+ const before = c2.slice(0, desc_match.index);
3316
+ const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
3317
+ let last_decl = null;
3318
+ let m;
3319
+ while ((m = decl_re.exec(before)) !== null) last_decl = m;
3320
+ if (last_decl) {
3321
+ const name_idx = last_decl.index + last_decl[0].indexOf(last_decl[1]);
3322
+ const { line: line2, col: col2 } = position_at(f.content, name_idx);
3323
+ return { file: f.path, line: line2, col: col2 };
3324
+ }
3325
+ const { line, col } = position_at(f.content, desc_match.index);
3326
+ return { file: f.path, line, col };
3327
+ }
3328
+ }
3329
+ }
3330
+ const patterns = build_patterns(esc, type);
3331
+ for (const re of patterns) {
3332
+ for (const f of sorted_files) {
3333
+ if (!/\.tsx?$/.test(f.path)) continue;
3334
+ const c2 = code(f);
3335
+ const global_re = new RegExp(re.source, re.flags + "g");
3336
+ let match;
3337
+ while ((match = global_re.exec(c2)) !== null) {
3338
+ const match_text = match[0];
3339
+ const name_offset_in_match = match_text.lastIndexOf(name);
3340
+ const name_start = match.index + Math.max(0, name_offset_in_match);
3341
+ const { line, col } = position_at(f.content, name_start);
3342
+ return { file: f.path, line, col };
3343
+ }
3344
+ }
3345
+ }
3346
+ return void 0;
3347
+ }
3348
+
3136
3349
  // src/cli/open-editor.ts
3137
3350
  import { spawn } from "child_process";
3138
3351
  import { resolve as resolve2 } from "path";
@@ -3251,7 +3464,7 @@ var label_entry = (e) => {
3251
3464
  const colored = kind_color[e.kind](e.name);
3252
3465
  return `${colored}${qual}${where}`;
3253
3466
  };
3254
- async function pick_from_list(idx, root_dir, message, entries) {
3467
+ async function pick_from_list(idx, root_dir, files, message, entries) {
3255
3468
  if (entries.length === 0) {
3256
3469
  log.warn("nothing to show.");
3257
3470
  return;
@@ -3266,9 +3479,9 @@ async function pick_from_list(idx, root_dir, message, entries) {
3266
3479
  maxItems: 12
3267
3480
  });
3268
3481
  if (isCancel(pick)) return;
3269
- await show_detail(idx, root_dir, pick);
3482
+ await show_detail(idx, root_dir, files, pick);
3270
3483
  }
3271
- async function show_detail(idx, root_dir, entry) {
3484
+ async function show_detail(idx, root_dir, files, entry) {
3272
3485
  log.message(format_detail(idx, entry));
3273
3486
  if (!entry.file) return;
3274
3487
  const editor = pick_editor(process.env);
@@ -3283,7 +3496,11 @@ async function show_detail(idx, root_dir, entry) {
3283
3496
  ]
3284
3497
  });
3285
3498
  if (isCancel(action)) return;
3286
- const result = await open_in_editor(entry.file, entry.line, { root_dir });
3499
+ const nav = navigate_to_code(files, entry.name, entry.kind, entry.file);
3500
+ const line = entry.line ?? nav?.line;
3501
+ const result = await open_in_editor(nav?.file ?? entry.file, line, {
3502
+ root_dir
3503
+ });
3287
3504
  if (!result.ok) log.warn(`editor exited: ${result.reason ?? "unknown"}`);
3288
3505
  }
3289
3506
  var DEFAULT_PATHS = {
@@ -3329,7 +3546,7 @@ async function export_registry(idx, root_dir) {
3329
3546
  );
3330
3547
  }
3331
3548
  }
3332
- async function search_by_name(idx, root_dir) {
3549
+ async function search_by_name(idx, root_dir, files) {
3333
3550
  vim_keys?.pause();
3334
3551
  const q = await text({
3335
3552
  message: `Partial name to search ${dim("(esc to cancel)")}`,
@@ -3343,6 +3560,7 @@ async function search_by_name(idx, root_dir) {
3343
3560
  await pick_from_list(
3344
3561
  idx,
3345
3562
  root_dir,
3563
+ files,
3346
3564
  `${KIND_LABELS[kind]}`,
3347
3565
  list_by_kind(idx, kind)
3348
3566
  );
@@ -3353,15 +3571,15 @@ async function search_by_name(idx, root_dir) {
3353
3571
  log.warn(`no matches for "${q}"`);
3354
3572
  return;
3355
3573
  }
3356
- await pick_from_list(idx, root_dir, `matches for "${q}"`, matches2);
3574
+ await pick_from_list(idx, root_dir, files, `matches for "${q}"`, matches2);
3357
3575
  }
3358
- async function run_interactive(idx, root_dir) {
3576
+ async function run_interactive(idx, root_dir, files = []) {
3359
3577
  vim_keys = enableVimKeys(process.stdin);
3360
3578
  const unsub = vim_keys.on_slash(() => {
3361
3579
  search_requested = true;
3362
3580
  });
3363
3581
  try {
3364
- await drive_interactive(idx, root_dir);
3582
+ await drive_interactive(idx, root_dir, files);
3365
3583
  } finally {
3366
3584
  unsub();
3367
3585
  vim_keys.restore();
@@ -3369,13 +3587,13 @@ async function run_interactive(idx, root_dir) {
3369
3587
  search_requested = false;
3370
3588
  }
3371
3589
  }
3372
- async function drive_interactive(idx, root_dir) {
3590
+ async function drive_interactive(idx, root_dir, files) {
3373
3591
  intro("act \u2014 contracts explorer");
3374
3592
  log.message(format_summary(idx));
3375
3593
  while (true) {
3376
3594
  if (search_requested) {
3377
3595
  search_requested = false;
3378
- await search_by_name(idx, root_dir);
3596
+ await search_by_name(idx, root_dir, files);
3379
3597
  continue;
3380
3598
  }
3381
3599
  const choice = await select({
@@ -3406,6 +3624,7 @@ async function drive_interactive(idx, root_dir) {
3406
3624
  await pick_from_list(
3407
3625
  idx,
3408
3626
  root_dir,
3627
+ files,
3409
3628
  `${KIND_LABELS[choice]}`,
3410
3629
  list_by_kind(idx, choice)
3411
3630
  );
@@ -3525,7 +3744,7 @@ async function main(deps) {
3525
3744
  deps.output.write(format_matches(args.query, uniq_matches) + "\n");
3526
3745
  return 0;
3527
3746
  }
3528
- await (deps.run_interactive ?? run_interactive)(idx, root_dir);
3747
+ await (deps.run_interactive ?? run_interactive)(idx, root_dir, files);
3529
3748
  return 0;
3530
3749
  }
3531
3750
  var isMain = (() => {