carrick 0.3.150 → 0.3.152

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 (84) hide show
  1. package/bin/carrick.mjs +1 -0
  2. package/dist/contract.d.ts +35 -0
  3. package/dist/contract.js.map +1 -1
  4. package/dist/global-install.d.ts +2 -2
  5. package/dist/global-install.js +1 -1
  6. package/dist/global-install.js.map +1 -1
  7. package/dist/hook/bash-targets.d.ts +29 -0
  8. package/dist/hook/bash-targets.js +377 -0
  9. package/dist/hook/bash-targets.js.map +1 -0
  10. package/dist/hook/edit-flow.d.ts +13 -0
  11. package/dist/hook/edit-flow.js +157 -0
  12. package/dist/hook/edit-flow.js.map +1 -0
  13. package/dist/hook/grep-missed.d.ts +19 -0
  14. package/dist/hook/grep-missed.js +129 -0
  15. package/dist/hook/grep-missed.js.map +1 -0
  16. package/dist/hook/late.js +6 -8
  17. package/dist/hook/late.js.map +1 -1
  18. package/dist/hook/post-bash.d.ts +2 -0
  19. package/dist/hook/post-bash.js +109 -0
  20. package/dist/hook/post-bash.js.map +1 -0
  21. package/dist/hook/post-edit.js +3 -136
  22. package/dist/hook/post-edit.js.map +1 -1
  23. package/dist/hook/post-read.js +3 -31
  24. package/dist/hook/post-read.js.map +1 -1
  25. package/dist/hook/read-answer.d.ts +6 -0
  26. package/dist/hook/read-answer.js +45 -0
  27. package/dist/hook/read-answer.js.map +1 -0
  28. package/dist/hook/reuse.d.ts +20 -0
  29. package/dist/hook/reuse.js +36 -1
  30. package/dist/hook/reuse.js.map +1 -1
  31. package/dist/hook/session-start.js +15 -13
  32. package/dist/hook/session-start.js.map +1 -1
  33. package/dist/hook/stop-wait.d.ts +2 -1
  34. package/dist/hook/stop-wait.js +81 -23
  35. package/dist/hook/stop-wait.js.map +1 -1
  36. package/dist/hook/stop.js +3 -5
  37. package/dist/hook/stop.js.map +1 -1
  38. package/dist/hook/upgrade.d.ts +11 -0
  39. package/dist/hook/upgrade.js +81 -0
  40. package/dist/hook/upgrade.js.map +1 -0
  41. package/dist/hook/worktree.d.ts +4 -0
  42. package/dist/hook/worktree.js +9 -0
  43. package/dist/hook/worktree.js.map +1 -1
  44. package/dist/init/agents-section.js +3 -2
  45. package/dist/init/agents-section.js.map +1 -1
  46. package/dist/init/outdated.d.ts +3 -2
  47. package/dist/init/outdated.js +9 -2
  48. package/dist/init/outdated.js.map +1 -1
  49. package/dist/init/repo-copies.d.ts +2 -0
  50. package/dist/init/repo-copies.js +1 -1
  51. package/dist/init/repo-copies.js.map +1 -1
  52. package/dist/init/self-update.d.ts +2 -2
  53. package/dist/init/self-update.js +56 -12
  54. package/dist/init/self-update.js.map +1 -1
  55. package/dist/init/settings.js +6 -0
  56. package/dist/init/settings.js.map +1 -1
  57. package/dist/render.d.ts +28 -10
  58. package/dist/render.js +76 -31
  59. package/dist/render.js.map +1 -1
  60. package/dist/self-upgrade.d.ts +1 -0
  61. package/dist/self-upgrade.js +10 -0
  62. package/dist/self-upgrade.js.map +1 -0
  63. package/dist/upgrade.d.ts +26 -0
  64. package/dist/upgrade.js +86 -0
  65. package/dist/upgrade.js.map +1 -0
  66. package/package.json +6 -6
  67. package/plugin/.claude-plugin/plugin.json +1 -1
  68. package/sidecar/dist/src/capture/anchors.d.ts +7 -0
  69. package/sidecar/dist/src/capture/anchors.js +13 -4
  70. package/sidecar/dist/src/capture/check-classify.js +4 -2
  71. package/sidecar/dist/src/capture/check.js +8 -4
  72. package/sidecar/dist/src/capture/deep-walk.d.ts +14 -8
  73. package/sidecar/dist/src/capture/deep-walk.js +26 -9
  74. package/sidecar/dist/src/capture/index.js +4 -2
  75. package/sidecar/dist/src/capture/self-check.d.ts +7 -0
  76. package/sidecar/dist/src/capture/self-check.js +19 -1
  77. package/sidecar/dist/src/capture/service-config.d.ts +5 -4
  78. package/sidecar/dist/src/capture/service-config.js +15 -12
  79. package/sidecar/dist/src/library-claims.js +157 -26
  80. package/sidecar/dist/src/position-rows.js +25 -3
  81. package/sidecar/dist/src/types.d.ts +32 -1
  82. package/sidecar/dist/src/validators.d.ts +104 -0
  83. package/sidecar/dist/src/validators.js +3 -1
  84. package/templates/skills/carrick-reuse.md +1 -1
@@ -33,8 +33,9 @@ export declare function realPath(p: string): string;
33
33
  * The config each file of one service is typed under (carrick#1604,
34
34
  * carrick#3497 ruling R-N1): the one the TypeScript language service picks.
35
35
  * From the file's directory up to the service root, inclusive, each directory's
36
- * `tsconfig.json`, else `jsconfig.json`, is asked whether its program, or a
37
- * project it references, lists the file; the first that does types it (a
36
+ * `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
37
+ * program, or a project it references, lists the file; the first that does
38
+ * types it (a
38
39
  * solution config hands the file to the reference that lists it). A config
39
40
  * that lists the file nowhere is passed over. The climb stops after a
40
41
  * directory named `node_modules`, as tsserver's does. A file no config inside
@@ -50,7 +51,7 @@ export declare class GoverningConfigs {
50
51
  private readonly serviceConfig;
51
52
  private readonly report;
52
53
  private readonly root;
53
- /** Directory -> the config in it, for every directory a climb visited. */
54
+ /** Directory -> the configs in it, in order, for every directory a climb visited. */
54
55
  private readonly dirConfigs;
55
56
  /** Config -> its projects; undefined for one that cannot be read. */
56
57
  private readonly graphs;
@@ -62,7 +63,7 @@ export declare class GoverningConfigs {
62
63
  constructor(serviceRoot: string, serviceConfig: string | undefined, report?: (diagnostic: string) => void);
63
64
  /** Absolute path of the config that types `file`, or undefined for none. */
64
65
  configFor(file: string): string | undefined;
65
- private configIn;
66
+ private configsIn;
66
67
  /** The project reached from `config` that lists `file`, absolute. */
67
68
  private listingOwner;
68
69
  }
@@ -76,8 +76,9 @@ const FILE_CONFIG_NAMES = ['tsconfig.json', 'jsconfig.json'];
76
76
  * The config each file of one service is typed under (carrick#1604,
77
77
  * carrick#3497 ruling R-N1): the one the TypeScript language service picks.
78
78
  * From the file's directory up to the service root, inclusive, each directory's
79
- * `tsconfig.json`, else `jsconfig.json`, is asked whether its program, or a
80
- * project it references, lists the file; the first that does types it (a
79
+ * `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
80
+ * program, or a project it references, lists the file; the first that does
81
+ * types it (a
81
82
  * solution config hands the file to the reference that lists it). A config
82
83
  * that lists the file nowhere is passed over. The climb stops after a
83
84
  * directory named `node_modules`, as tsserver's does. A file no config inside
@@ -93,7 +94,7 @@ export class GoverningConfigs {
93
94
  serviceConfig;
94
95
  report;
95
96
  root;
96
- /** Directory -> the config in it, for every directory a climb visited. */
97
+ /** Directory -> the configs in it, in order, for every directory a climb visited. */
97
98
  dirConfigs = new Map();
98
99
  /** Config -> its projects; undefined for one that cannot be read. */
99
100
  graphs = new Map();
@@ -115,10 +116,11 @@ export class GoverningConfigs {
115
116
  const from = path.relative(this.root, dir);
116
117
  if (from.startsWith('..') || path.isAbsolute(from))
117
118
  break;
118
- const config = this.configIn(dir);
119
- const owner = config === undefined ? undefined : this.listingOwner(config, absolute);
120
- if (owner !== undefined)
121
- return owner;
119
+ for (const config of this.configsIn(dir)) {
120
+ const owner = this.listingOwner(config, absolute);
121
+ if (owner !== undefined)
122
+ return owner;
123
+ }
122
124
  // tsserver looks in a `node_modules` directory itself, then stops.
123
125
  if (dir === this.root || path.basename(dir) === 'node_modules')
124
126
  break;
@@ -128,12 +130,13 @@ export class GoverningConfigs {
128
130
  return undefined;
129
131
  return this.listingOwner(this.serviceConfig, absolute) ?? this.serviceConfig;
130
132
  }
131
- configIn(dir) {
132
- if (!this.dirConfigs.has(dir)) {
133
- const name = FILE_CONFIG_NAMES.find((n) => fs.existsSync(path.join(dir, n)));
134
- this.dirConfigs.set(dir, name === undefined ? undefined : path.join(dir, name));
133
+ configsIn(dir) {
134
+ let configs = this.dirConfigs.get(dir);
135
+ if (configs === undefined) {
136
+ configs = FILE_CONFIG_NAMES.map((n) => path.join(dir, n)).filter((c) => fs.existsSync(c));
137
+ this.dirConfigs.set(dir, configs);
135
138
  }
136
- return this.dirConfigs.get(dir);
139
+ return configs;
137
140
  }
138
141
  /** The project reached from `config` that lists `file`, absolute. */
139
142
  listingOwner(config, file) {
@@ -727,7 +727,10 @@ export class LibraryClaimsVerifier {
727
727
  const builtAtDefaults = built === undefined ? undefined : atDefaults(check, built);
728
728
  // An adapter's `runs` is read against the request's collections only
729
729
  // when today's reading refuses it (#2474 R6a): `judgeMake` asks.
730
- const collectionsOf = check.claim.kind === 'make' && check.claim.runs !== undefined ? collections : undefined;
730
+ const collectionsOf = (check.claim.kind === 'make' && check.claim.runs !== undefined) ||
731
+ (check.claim.kind === 'scope' && check.claim.merges !== undefined)
732
+ ? collections
733
+ : undefined;
731
734
  const holding = [];
732
735
  const declarations = [];
733
736
  const members = [];
@@ -1109,9 +1112,13 @@ export function fullSurfaceSha256(surfaces) {
1109
1112
  // A member's `handlers` (carrick#2674), a signature's `result_candidates`
1110
1113
  // (carrick#2817) and a member's `scope_receiver` (carrick#2774) are out of
1111
1114
  // the hash at every depth, and so is a member's `runtime_events`
1112
- // (carrick#3032), so a package's key does not change when the lister
1113
- // learns to list them.
1114
- const text = JSON.stringify(listed, (key, value) => key === 'handlers' || key === 'result_candidates' || key === 'scope_receiver' || key === 'runtime_events'
1115
+ // (carrick#3032), and a receiver's `properties` (carrick#3696), so a
1116
+ // package's key does not change when the lister learns to list them.
1117
+ const text = JSON.stringify(listed, (key, value) => key === 'handlers' ||
1118
+ key === 'result_candidates' ||
1119
+ key === 'scope_receiver' ||
1120
+ key === 'runtime_events' ||
1121
+ key === 'properties'
1115
1122
  ? undefined
1116
1123
  : value);
1117
1124
  return crypto.createHash('sha256').update(text).digest('hex');
@@ -2118,7 +2125,7 @@ class DeclarationReader {
2118
2125
  case 'make':
2119
2126
  return this.judgeMake(receiver, claim, built, collections);
2120
2127
  case 'scope':
2121
- return this.judgeScope(receiver, claim, built);
2128
+ return this.judgeScope(receiver, claim, built, collections);
2122
2129
  case 'op':
2123
2130
  return { outcome: this.judgeOp(receiver, claim, rules) };
2124
2131
  case 'reserved':
@@ -2230,19 +2237,33 @@ class DeclarationReader {
2230
2237
  * beside `runs`, `yields` or `mounts` (`claim_invalid`). With `collects`
2231
2238
  * the member takes an object of procedures there (`collectsOutcome`), and
2232
2239
  * its return, the collection, is read as a plain scope's is.
2240
+ *
2241
+ * Merged collections (amendment 9): `merges` is a third way to carry the
2242
+ * scope, alone and as `{ arg, each: true }`. The member's parameter at
2243
+ * `arg`, read through a rest (`parameterAt`), takes what a verified
2244
+ * `collects` scope of the request returns (`collectionSlotOutcome`), and
2245
+ * the return is read as a plain scope's is.
2233
2246
  */
2234
- judgeScope(receiver, claim, built) {
2247
+ judgeScope(receiver, claim, built, collections) {
2235
2248
  if (claim.form === 'decorate')
2236
2249
  return { outcome: this.decorateScopeOutcome(receiver, claim) };
2237
2250
  if ((claim.runs === undefined) !== (claim.yields === undefined))
2238
2251
  return { outcome: unchecked('claim_invalid') };
2239
2252
  if (claim.mounts !== undefined && claim.runs !== undefined)
2240
2253
  return { outcome: unchecked('claim_invalid') };
2241
- if ((claim.name === undefined) === (claim.collects === undefined))
2254
+ const carried = [claim.name, claim.collects, claim.merges].filter(part => part !== undefined).length;
2255
+ if (carried !== 1)
2242
2256
  return { outcome: unchecked('claim_invalid') };
2243
- if (claim.collects !== undefined && (claim.runs !== undefined || claim.mounts !== undefined)) {
2257
+ if ((claim.collects !== undefined || claim.merges !== undefined) &&
2258
+ (claim.runs !== undefined || claim.mounts !== undefined)) {
2259
+ return { outcome: unchecked('claim_invalid') };
2260
+ }
2261
+ const merges = claim.merges;
2262
+ if (merges !== undefined &&
2263
+ (merges.each !== true || merges.key !== undefined || merges.at !== undefined)) {
2244
2264
  return { outcome: unchecked('claim_invalid') };
2245
2265
  }
2266
+ const collected = merges === undefined ? undefined : collections?.();
2246
2267
  const binds = claim.runs !== undefined || claim.mounts !== undefined;
2247
2268
  const layout = this.layout({ name: claim.name, runs: claim.runs, mounts: claim.mounts });
2248
2269
  if ('failure' in layout)
@@ -2250,6 +2271,8 @@ class DeclarationReader {
2250
2271
  const callee = this.ownCallee(receiver, claim.path ?? [], claim.member, 'call');
2251
2272
  if ('failure' in callee)
2252
2273
  return { outcome: callee.failure };
2274
+ if (merges !== undefined && collected === undefined)
2275
+ return { outcome: failed('merges_unbound') };
2253
2276
  const labels = claim.key_labels ?? {};
2254
2277
  const holding = [];
2255
2278
  let best;
@@ -2270,6 +2293,12 @@ class DeclarationReader {
2270
2293
  if (collected)
2271
2294
  result = { rank: 5, outcome: collected };
2272
2295
  }
2296
+ if (result.rank === Infinity && merges !== undefined && collected !== undefined) {
2297
+ const merged = this.mergesNotRest(signature, merges.arg) ??
2298
+ this.collectionSlotOutcome(signature, this.mergedSlotAt(signature, merges.arg), collected, 'merges');
2299
+ if (merged)
2300
+ result = { rank: 5, outcome: merged };
2301
+ }
2273
2302
  if (result.rank === Infinity && !binds && this.returnSaysNothing(this.returnOf(signature, built))) {
2274
2303
  result = { rank: 6, outcome: unchecked('scope_unresolved') };
2275
2304
  }
@@ -2348,22 +2377,57 @@ class DeclarationReader {
2348
2377
  }
2349
2378
  /**
2350
2379
  * An adapter's `runs` slot (#2474 R6a) takes one of `collections`, the
2351
- * types the request's verified `collects` scopes return, read as a mounted
2352
- * instance is (`fitsErased`, then assignability). A slot typed `any`,
2353
- * `unknown`, `{}` or by an unconstrained type parameter says nothing
2354
- * (`runs_untyped`). Undefined when it holds.
2380
+ * types the request's verified `collects` scopes return.
2355
2381
  */
2356
2382
  runsCollectionOutcome(signature, declared, collections) {
2383
+ return this.collectionSlotOutcome(signature, declared, collections, 'runs');
2384
+ }
2385
+ /** A merge's slot at `index` must be a rest parameter (or an element of one): a plain parameter fails `merges_not_rest`. */
2386
+ mergesNotRest(signature, index) {
2387
+ const restIndex = this.restIndexOf(signature);
2388
+ const plain = restIndex === -1 || index < restIndex;
2389
+ return plain && index < signature.getParameters().length ? failed('merges_not_rest') : undefined;
2390
+ }
2391
+ /**
2392
+ * What a merge's rest slot takes at `index` (amendment 9): the element
2393
+ * `parameterAt` reads, and when that is itself a type parameter spread into
2394
+ * the rest (`...routers: [...R]` with `R extends Router[]`), its
2395
+ * constraint's element. Only that spread is unwrapped: a parameter that
2396
+ * takes an array of routers (`routers: Router[]`, `...lists: Router[][]`)
2397
+ * is a merge over an array, which amendment 9 leaves out.
2398
+ */
2399
+ mergedSlotAt(signature, index) {
2400
+ const slot = this.parameterAt(signature, index, true);
2401
+ if (slot === undefined || slot === VARIADIC)
2402
+ return slot;
2403
+ const restIndex = this.restIndexOf(signature);
2404
+ if (restIndex === -1 || index < restIndex || !(slot.flags & ts.TypeFlags.TypeParameter))
2405
+ return slot;
2406
+ const through = this.throughConstraint(slot);
2407
+ if (through !== VARIADIC && this.checker.isArrayType(through)) {
2408
+ return this.checker.getTypeArguments(through)[0];
2409
+ }
2410
+ return slot;
2411
+ }
2412
+ /**
2413
+ * A slot that takes one of `collections`, read as a mounted instance is
2414
+ * (`fitsErased`, then assignability): an adapter's `runs` slot and a merge's
2415
+ * rest slot (amendment 9). A slot typed `any`, `unknown`, `{}` or by an
2416
+ * unconstrained type parameter says nothing (`<reason>_untyped`); one that
2417
+ * takes none of them fails (`<reason>_not_collection`). Undefined when it
2418
+ * holds.
2419
+ */
2420
+ collectionSlotOutcome(signature, declared, collections, reason) {
2357
2421
  if (declared === undefined)
2358
2422
  return failed('param_missing');
2359
2423
  const slot = this.throughConstraint(declared);
2360
2424
  if (slot === VARIADIC)
2361
- return unchecked('runs_untyped');
2425
+ return unchecked(`${reason}_untyped`);
2362
2426
  const parts = this.parts(slot);
2363
2427
  if (parts.length === 0)
2364
- return failed('runs_not_collection');
2428
+ return failed(`${reason}_not_collection`);
2365
2429
  if (parts.some(part => this.isOpenTop(part) || this.isUnconstrained(part) || this.isEmptyObject(part))) {
2366
- return unchecked('runs_untyped');
2430
+ return unchecked(`${reason}_untyped`);
2367
2431
  }
2368
2432
  const own = signature.typeParameters ?? [];
2369
2433
  for (const collection of collections) {
@@ -2373,7 +2437,7 @@ class DeclarationReader {
2373
2437
  if (erased === undefined && this.checker.isTypeAssignableTo(collection, slot))
2374
2438
  return undefined;
2375
2439
  }
2376
- return failed('runs_not_collection');
2440
+ return failed(`${reason}_not_collection`);
2377
2441
  }
2378
2442
  /**
2379
2443
  * `receiver` fits `slot` with the signature's own type parameters
@@ -2864,6 +2928,7 @@ class DeclarationReader {
2864
2928
  decorateScopeOutcome(receiver, claim) {
2865
2929
  if (claim.name === undefined ||
2866
2930
  claim.collects !== undefined ||
2931
+ claim.merges !== undefined ||
2867
2932
  claim.runs !== undefined ||
2868
2933
  claim.yields !== undefined ||
2869
2934
  claim.mounts !== undefined) {
@@ -4163,10 +4228,8 @@ class DeclarationReader {
4163
4228
  if (!made)
4164
4229
  continue;
4165
4230
  // One level below the export, what the member builds must declare a callable member.
4166
- if (maker.member &&
4167
- !this.namedProperties(made).some(member => this.librarySignatures(this.checker.getTypeOfSymbol(member), 'call').length > 0)) {
4231
+ if (maker.member && !this.hasCallableMember(made))
4168
4232
  continue;
4169
- }
4170
4233
  receiverOf(maker.receiver, made);
4171
4234
  }
4172
4235
  }
@@ -4180,16 +4243,21 @@ class DeclarationReader {
4180
4243
  this.listScopeReceivers(pkg, instances, maxEntries, withHandlers, built);
4181
4244
  surface.truncated = dropped;
4182
4245
  this.collectTypes = false;
4246
+ const types = withHandlers || this.listTypes ? this.listTypeReceivers(pkg, typeExports, maxEntries) : undefined;
4247
+ const receiverTypes = this.listTypes ? this.receiverTypes(types ?? []) : undefined;
4248
+ const propertiesLeftOut = this.listReceiverProperties(pkg, instances, maxEntries, withHandlers);
4183
4249
  if (withHandlers)
4184
4250
  surface.handler_types = this.handlerTypes;
4185
- if (withHandlers || this.listTypes)
4186
- surface.types = this.listTypeReceivers(pkg, typeExports, maxEntries);
4251
+ if (types !== undefined)
4252
+ surface.types = types;
4187
4253
  if (withHandlers)
4188
4254
  surface.handler_params_left_out = this.handlerParamsLeftOut;
4189
4255
  if (this.listTypes) {
4190
4256
  surface.types_left_out = this.typesLeftOut;
4191
- surface.receiver_types = this.receiverTypes(surface.types ?? []);
4257
+ surface.receiver_types = receiverTypes;
4192
4258
  }
4259
+ if (propertiesLeftOut > 0)
4260
+ surface.properties_left_out = propertiesLeftOut;
4193
4261
  return surface;
4194
4262
  }
4195
4263
  /**
@@ -4499,6 +4567,66 @@ class DeclarationReader {
4499
4567
  for (const fill of fills)
4500
4568
  fill();
4501
4569
  }
4570
+ /**
4571
+ * The seventh pass (carrick#3696): each own property of an instance
4572
+ * receiver that has no call signature, and whose type has a callable
4573
+ * member, is listed in the receiver's `properties` with those members,
4574
+ * outlined as any receiver's are, from the home an op's `path: [name]`
4575
+ * walks to (`walkHops`). Everything it lists draws on one budget of its
4576
+ * own, spent after every other pass, so `truncated`, the hash, the handler
4577
+ * type ids and `types` are the ones the lister gave before; it notes no
4578
+ * type for `types[]`. Returns what that budget left out. One level: a
4579
+ * property's members list no scope receiver and no properties.
4580
+ */
4581
+ listReceiverProperties(pkg, sources, maxEntries, withHandlers) {
4582
+ let budget = maxEntries;
4583
+ let leftOut = 0;
4584
+ const take = () => {
4585
+ if (budget > 0) {
4586
+ budget -= 1;
4587
+ return true;
4588
+ }
4589
+ leftOut += 1;
4590
+ return false;
4591
+ };
4592
+ const names = [];
4593
+ const handlers = [];
4594
+ const fills = [];
4595
+ for (const source of sources) {
4596
+ if (this.isOpenTop(source.type))
4597
+ continue;
4598
+ const holder = this.surfaceHolder(pkg, source.type, source.home);
4599
+ const listed = [];
4600
+ for (const property of sortedByName(this.namedProperties(source.type))) {
4601
+ const name = property.getName();
4602
+ const walked = this.walkHops(holder, [name]);
4603
+ if ('failure' in walked)
4604
+ continue;
4605
+ const type = walked.holder.type;
4606
+ if (this.checker.getNonNullableType(type).getCallSignatures().length > 0)
4607
+ continue;
4608
+ if (!this.hasCallableMember(type) || !take())
4609
+ continue;
4610
+ this.typeContext = source.export;
4611
+ const outlined = this.outlineReceiver(pkg, source.receiver.receiver, type, walked.holder.home, take, names, handlers, fills);
4612
+ listed.push({ name, own: true, type: this.printed(type), members: outlined.members });
4613
+ }
4614
+ if (listed.length > 0)
4615
+ source.receiver.properties = listed;
4616
+ }
4617
+ for (const run of names)
4618
+ run();
4619
+ if (withHandlers)
4620
+ for (const run of handlers)
4621
+ run();
4622
+ for (const fill of fills)
4623
+ fill();
4624
+ return leftOut;
4625
+ }
4626
+ /** Some named property of `type` has a call signature an installed package or the default library declares. */
4627
+ hasCallableMember(type) {
4628
+ return this.namedProperties(type).some(member => this.librarySignatures(this.checker.getTypeOfSymbol(member), 'call').length > 0);
4629
+ }
4502
4630
  /**
4503
4631
  * The receivers each export of a specifier can make, by receiver id, for
4504
4632
  * the probe statements that build them (see `LibraryClaimsVerifier.listSurface`).
@@ -5600,6 +5728,12 @@ class DeclarationReader {
5600
5728
  parts(type) {
5601
5729
  return (type.isUnion() ? type.types : [type]).filter(part => !isNullish(part));
5602
5730
  }
5731
+ /** The index of the signature's rest parameter, or -1 when it has none. */
5732
+ restIndexOf(signature) {
5733
+ const parameters = signature.getParameters();
5734
+ const declaration = parameters[parameters.length - 1]?.valueDeclaration;
5735
+ return declaration && ts.isParameter(declaration) && declaration.dotDotDotToken ? parameters.length - 1 : -1;
5736
+ }
5603
5737
  /**
5604
5738
  * What the signature has at parameter `index`, reading through a rest
5605
5739
  * parameter; `undefined` when it has none there. A rest typed by a type
@@ -5609,10 +5743,7 @@ class DeclarationReader {
5609
5743
  parameterAt(signature, index, readConstraint = false) {
5610
5744
  const parameters = signature.getParameters();
5611
5745
  const last = parameters[parameters.length - 1];
5612
- const declaration = last?.valueDeclaration;
5613
- const restIndex = declaration && ts.isParameter(declaration) && declaration.dotDotDotToken
5614
- ? parameters.length - 1
5615
- : -1;
5746
+ const restIndex = this.restIndexOf(signature);
5616
5747
  if (restIndex === -1 || index < restIndex) {
5617
5748
  return index < parameters.length ? this.checker.getTypeOfSymbol(parameters[index]) : undefined;
5618
5749
  }
@@ -876,11 +876,29 @@ export class PositionWalker {
876
876
  exportName = key ? key.text : declaration.name.text;
877
877
  initializer = declaration.parent.parent.initializer;
878
878
  }
879
+ let castSpecifier;
880
+ while (initializer &&
881
+ (ts.isParenthesizedExpression(initializer) ||
882
+ ts.isAsExpression(initializer) ||
883
+ ts.isSatisfiesExpression(initializer) ||
884
+ ts.isTypeAssertionExpression(initializer) ||
885
+ ts.isNonNullExpression(initializer))) {
886
+ const type = ts.isNonNullExpression(initializer) || ts.isParenthesizedExpression(initializer) ? undefined : initializer.type;
887
+ if (castSpecifier === undefined && type && ts.isImportTypeNode(type) && type.isTypeOf) {
888
+ const arg = type.argument;
889
+ if (ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal))
890
+ castSpecifier = arg.literal.text;
891
+ }
892
+ initializer = initializer.expression;
893
+ }
879
894
  const specifier = initializer ? this.requireSpecifier(initializer) : undefined;
880
895
  if (specifier === undefined)
881
896
  return undefined;
882
897
  const from = declaration.getSourceFile();
883
- return exportName === undefined ? { specifier, from } : { specifier, from, exportName };
898
+ const binding = exportName === undefined ? { specifier, from } : { specifier, from, exportName };
899
+ if (castSpecifier !== undefined)
900
+ binding.castSpecifier = castSpecifier;
901
+ return binding;
884
902
  }
885
903
  /** `"m"` of a call `require("m")` to the global `require`, else `undefined`. */
886
904
  requireSpecifier(expression) {
@@ -896,8 +914,12 @@ export class PositionWalker {
896
914
  return own ? undefined : argument.text;
897
915
  }
898
916
  exportOfRequired(binding) {
899
- const resolved = ts.resolveModuleName(binding.specifier, binding.from.fileName, this.program.getCompilerOptions(), this.resolutionHost(), undefined, undefined, ts.ModuleKind.CommonJS).resolvedModule;
900
- const target = resolved ? this.program.getSourceFile(resolved.resolvedFileName) : undefined;
917
+ const sourceOf = (specifier) => {
918
+ const resolved = ts.resolveModuleName(specifier, binding.from.fileName, this.program.getCompilerOptions(), this.resolutionHost(), undefined, undefined, ts.ModuleKind.CommonJS).resolvedModule;
919
+ return resolved ? this.program.getSourceFile(resolved.resolvedFileName) : undefined;
920
+ };
921
+ // The require that runs wins; the cast is read only when it names no file.
922
+ const target = sourceOf(binding.specifier) ?? (binding.castSpecifier !== undefined ? sourceOf(binding.castSpecifier) : undefined);
901
923
  if (!target)
902
924
  return undefined;
903
925
  if (binding.exportName === undefined)
@@ -697,7 +697,7 @@ export type LibraryClaim = {
697
697
  member: string;
698
698
  /** Amendment 7: absent is `call`; `decorate` is a class decorator whose name prefixes its methods' ops. */
699
699
  form?: 'call' | 'decorate';
700
- /** Exactly one of `name` and `collects` (#2474 R6a). */
700
+ /** Exactly one of `name`, `collects` and `merges` (#2474 R6a). */
701
701
  name?: NameSlot;
702
702
  path?: string[];
703
703
  on?: ClaimOn;
@@ -716,6 +716,13 @@ export type LibraryClaim = {
716
716
  mounts?: ClaimSlot;
717
717
  /** Procedure routers (#2474 R6a): the member collects procedures by key and returns the collection. */
718
718
  collects?: Collects;
719
+ /**
720
+ * Merged collections (amendment 9 on carrick#2434): the member takes
721
+ * the collections a verified `collects` member returns at `arg` and at
722
+ * every argument after it (`each: true`), and returns one collection
723
+ * serving all their procedures at the same level.
724
+ */
725
+ merges?: ClaimSlot;
719
726
  } | {
720
727
  kind: 'op';
721
728
  op: LibraryOp;
@@ -1354,6 +1361,24 @@ export interface SurfaceReceiver {
1354
1361
  * depth 1, sorted by name (carrick#3050). Absent when none.
1355
1362
  */
1356
1363
  settable?: SurfaceSettable[];
1364
+ /**
1365
+ * Own non-callable properties of an instance receiver whose type has callable
1366
+ * members, each with those members (carrick#3696). Reached only as an op's
1367
+ * `path: [name]` on this receiver, never as `of`. Not `settable` (what a `set`
1368
+ * op may assign on a type receiver). One level, sorted by name, absent when
1369
+ * none, and outside the hash.
1370
+ */
1371
+ properties?: SurfaceProperty[];
1372
+ }
1373
+ /** A property of an instance receiver that `properties` lists (carrick#3696). */
1374
+ export interface SurfaceProperty {
1375
+ name: string;
1376
+ /** As a member's `own`; only `true` is listed. */
1377
+ own: boolean;
1378
+ /** The property's type as the declarations print it, truncated. */
1379
+ type: string;
1380
+ /** Outlined as any receiver's members are; no `scope_receiver` and no `properties` of their own. */
1381
+ members: SurfaceMember[];
1357
1382
  }
1358
1383
  /** A property of a type receiver that `settable` answers `ok` for. */
1359
1384
  export interface SurfaceSettable {
@@ -1391,6 +1416,12 @@ export interface LibrarySurface {
1391
1416
  * (carrick#3050). `truncated` does not count them.
1392
1417
  */
1393
1418
  types_left_out?: number;
1419
+ /**
1420
+ * Entries (properties, their members and signatures) the budget of the
1421
+ * receivers' `properties` left out (carrick#3696); absent when none.
1422
+ * `truncated` does not count them, and it is outside `surface_sha256`.
1423
+ */
1424
+ properties_left_out?: number;
1394
1425
  /**
1395
1426
  * With `types: true`: per export, per receiver the surface lists, the
1396
1427
  * `types` receiver ids its built type and base types are declared by