carrick 0.3.161 → 0.3.162

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 (79) hide show
  1. package/dist/contract.d.ts +8 -0
  2. package/dist/contract.js.map +1 -1
  3. package/dist/facts/store.d.ts +12 -0
  4. package/dist/facts/store.js +15 -0
  5. package/dist/facts/store.js.map +1 -1
  6. package/dist/held/daemon.d.ts +8 -0
  7. package/dist/held/daemon.js.map +1 -1
  8. package/dist/held/early.d.ts +1 -1
  9. package/dist/held/early.js +29 -10
  10. package/dist/held/early.js.map +1 -1
  11. package/dist/held/message-rows.d.ts +3 -0
  12. package/dist/held/message-rows.js +41 -0
  13. package/dist/held/message-rows.js.map +1 -0
  14. package/dist/held/place.d.ts +11 -2
  15. package/dist/held/place.js +4 -1
  16. package/dist/held/place.js.map +1 -1
  17. package/dist/held/runtime.d.ts +1 -1
  18. package/dist/held/runtime.js +47 -17
  19. package/dist/held/runtime.js.map +1 -1
  20. package/dist/held/shadow.d.ts +2 -0
  21. package/dist/held/shadow.js.map +1 -1
  22. package/dist/hook/confirm.js +40 -21
  23. package/dist/hook/confirm.js.map +1 -1
  24. package/dist/init/codex.d.ts +1 -1
  25. package/dist/init/codex.js +8 -4
  26. package/dist/init/codex.js.map +1 -1
  27. package/dist/init/doctor.d.ts +10 -13
  28. package/dist/init/doctor.js +26 -92
  29. package/dist/init/doctor.js.map +1 -1
  30. package/dist/init/launcher.d.ts +35 -0
  31. package/dist/init/launcher.js +85 -0
  32. package/dist/init/launcher.js.map +1 -0
  33. package/dist/init/outdated.d.ts +3 -4
  34. package/dist/init/outdated.js +19 -8
  35. package/dist/init/outdated.js.map +1 -1
  36. package/dist/init/remove.js +4 -0
  37. package/dist/init/remove.js.map +1 -1
  38. package/dist/init/repo-copies.d.ts +1 -1
  39. package/dist/init/repo-copies.js +13 -4
  40. package/dist/init/repo-copies.js.map +1 -1
  41. package/dist/init/run.js +17 -26
  42. package/dist/init/run.js.map +1 -1
  43. package/dist/init/self-update.js +7 -4
  44. package/dist/init/self-update.js.map +1 -1
  45. package/dist/init/settings.d.ts +0 -34
  46. package/dist/init/settings.js +11 -45
  47. package/dist/init/settings.js.map +1 -1
  48. package/dist/render.d.ts +6 -0
  49. package/dist/render.js +27 -7
  50. package/dist/render.js.map +1 -1
  51. package/package.json +6 -6
  52. package/plugin/.claude-plugin/plugin.json +1 -1
  53. package/plugin/hooks/carrick-hook.sh +122 -0
  54. package/plugin/hooks/hooks.json +8 -8
  55. package/sidecar/dist/src/capture/anchors.d.ts +2 -2
  56. package/sidecar/dist/src/capture/anchors.js +25 -10
  57. package/sidecar/dist/src/capture/api.d.ts +10 -0
  58. package/sidecar/dist/src/capture/check-classify.d.ts +11 -4
  59. package/sidecar/dist/src/capture/check-classify.js +65 -25
  60. package/sidecar/dist/src/capture/check-fields.d.ts +2 -1
  61. package/sidecar/dist/src/capture/check-fields.js +10 -2
  62. package/sidecar/dist/src/capture/check-probe.d.ts +77 -25
  63. package/sidecar/dist/src/capture/check-probe.js +100 -37
  64. package/sidecar/dist/src/capture/index.d.ts +3 -2
  65. package/sidecar/dist/src/capture/index.js +14 -2
  66. package/sidecar/dist/src/capture/reply-status.d.ts +86 -0
  67. package/sidecar/dist/src/capture/reply-status.js +255 -0
  68. package/sidecar/dist/src/capture/site-node.d.ts +34 -0
  69. package/sidecar/dist/src/capture/site-node.js +258 -0
  70. package/sidecar/dist/src/engine-stamp.json +1 -1
  71. package/sidecar/dist/src/held-shadow.d.ts +23 -2
  72. package/sidecar/dist/src/held-shadow.js +42 -8
  73. package/sidecar/dist/src/stated-params.d.ts +3 -2
  74. package/sidecar/dist/src/type-inferrer.d.ts +15 -55
  75. package/sidecar/dist/src/type-inferrer.js +83 -213
  76. package/sidecar/dist/src/types.d.ts +10 -0
  77. package/sidecar/dist/src/validators.d.ts +150 -28
  78. package/sidecar/dist/src/validators.js +15 -1
  79. package/templates/carrick-hook.sh +122 -0
@@ -26,7 +26,7 @@
26
26
  import * as fs from 'node:fs';
27
27
  import * as path from 'node:path';
28
28
  import { ts } from 'ts-morph';
29
- import { WriteGuard, graphqlComparandLeafRule, graphqlComparandRule, graphqlExpectedRule, graphqlFieldResolverDeclarations, graphqlFieldResolverRule, graphqlGenericDeclarations, graphqlLeafWalkDeclarations, graphqlReachableFields, graphqlRootLeaf, graphqlScalarWireRule, judgeTscPath, jsonWireDeclarations, jsonWireRule, judgeTolerances, fitOptionsOf, judgeFitOptions, wireFormFor, } from './capture/index.js';
29
+ import { WriteGuard, absentBodyApplies, absentBodyRule, graphqlComparandLeafRule, graphqlComparandRule, graphqlExpectedRule, graphqlDeclaredDeclarations, graphqlDeclaredRule, graphqlGenericDeclarations, graphqlLeafWalkDeclarations, graphqlReachableFields, graphqlRootLeaf, graphqlScalarWireRule, judgeTscPath, jsonWireDeclarations, jsonWireRule, judgeTolerances, topTypeDeclarations, fitOptionsOf, judgeFitOptions, wireFormFor, } from './capture/index.js';
30
30
  /** The platform package's executable, `@typescript/typescript-<platform>-<arch>/lib/tsc`. */
31
31
  const NATIVE_TSC = /[\\/]@typescript[\\/]typescript-[^\\/]+[\\/]lib[\\/]tsc(\.exe)?$/;
32
32
  /** `judgeTscPath()` when it is the native executable, else null (no held compiler). */
@@ -203,6 +203,7 @@ export function writeShadow(loader, outDir, graphql) {
203
203
  wire: heldWire(),
204
204
  ...(graphql === undefined ? {} : { graphql: heldGraphql(graphql.types, graphql.roots) }),
205
205
  tolerances: judgeTolerances('__carrick_'),
206
+ message: heldMessageWire(),
206
207
  options: { service: fitOptionsOf(compilerOptions), judge: judgeFitOptions() },
207
208
  native_tsc: nativeTscPath(),
208
209
  };
@@ -223,8 +224,8 @@ export function heldWire() {
223
224
  * `E` the caller's expected type;
224
225
  * - `__carrick_GqlSentS<S, E, R>`: the scalar form, `R` the root's leaf
225
226
  * (`leaves`); it reads `__carrick_GqlTypes` (`types_decl`). A
226
- * declared-void caller states no contract, and is kept; a pair the judge's
227
- * record-field gate abstains on (carrick#1875) is silent too.
227
+ * declared-void caller states no contract, and is kept; where the wire
228
+ * form does not assign, the judge's declared line decides (carrick#4726).
228
229
  *
229
230
  * `scalar` adds the scalar form's lines; they name `__carrick_GqlTypes`, so
230
231
  * they are written only when the table is declared.
@@ -249,11 +250,12 @@ export function heldGraphqlWire(scalar) {
249
250
  `type ${p}GqlComparandLeaf<S, E, R> = ${graphqlComparandLeafRule('S', 'E', relaxed, 'R', p)};`,
250
251
  `type ${p}GqlWireForm<S, E, R> = ${graphqlScalarWireRule(comparand, relaxed, leaf, p)};`,
251
252
  `type ${p}GqlWire<S, E, R> = ${form};`,
252
- // carrick#4708: where the judge's record-field gate reads unverifiable (a
253
- // field resolver nobody read supplies a field), the held form is silent:
254
- // it returns the relaxed expected type, as the void gate returns `E`.
255
- ...graphqlFieldResolverDeclarations(p),
256
- `type ${p}GqlSentS<S, E, R> = ${p}IsVoid<E> extends true ? E : (${graphqlFieldResolverRule(`${p}GqlWire<S, E, R>`, relaxed, leaf, p)}) extends true ? ${relaxed} : ${p}GqlWire<S, E, R>;`,
253
+ // carrick#4726: the judge's declared line. Where the wire form does not
254
+ // assign, the held form sends what the judge's decisive line sends: the
255
+ // wire type with the fields the root record lacks or converts in the type
256
+ // the served schema declares.
257
+ ...graphqlDeclaredDeclarations(p),
258
+ `type ${p}GqlSentS<S, E, R> = ${p}IsVoid<E> extends true ? E : ${graphqlDeclaredRule(`${p}GqlWire<S, E, R>`, relaxed, leaf, p)};`,
257
259
  ];
258
260
  }
259
261
  /**
@@ -279,6 +281,38 @@ export function heldGraphql(types, roots) {
279
281
  leaves,
280
282
  };
281
283
  }
284
+ /**
285
+ * The judge's message rules (a socket payload: the emitter is `sent`, the
286
+ * listener `expected`) as declarations a held check appends beside `tolerances`
287
+ * (prefix `__carrick_`). Every rule is the judge's own text (`check-probe.ts`):
288
+ *
289
+ * - `__carrick_IsAny`, `__carrick_IsUnknown`, `__carrick_IsNever`
290
+ * (`topTypeDeclarations`);
291
+ * - `__carrick_MsgSent<S, E>`, `S` the emitter's payload and `E` the
292
+ * listener's parameter. Where the judge reads a gate unverifiable (a top,
293
+ * bottom or void type on either side) the answer is `E`, so the check is
294
+ * silent; otherwise it is the sent type with the absent body dropped where
295
+ * the listener requires none (`absentBodyRule`, tolerant form, because the
296
+ * listener's `absent_body_tolerated` mark is not stored: silent where the
297
+ * judge without the mark would speak). A socket payload travels as
298
+ * declared (`wireFormFor`), so no wire transform is applied.
299
+ *
300
+ * It reads `__carrick_IsVoid` (`tolerances.declarations`).
301
+ */
302
+ export function heldMessageWire() {
303
+ const p = '__carrick_';
304
+ if (!absentBodyApplies('socket', 'response'))
305
+ throw new Error('the absent-body rule no longer reads a socket payload');
306
+ const wire = wireFormFor('socket', 'response', 'consumer');
307
+ const sent = wire === 'json' ? `${p}Wire<S, E>` : 'S';
308
+ const body = absentBodyRule(sent, 'E', true);
309
+ const top = (t) => `${p}IsAny<${t}> extends true ? true : ${p}IsUnknown<${t}> extends true ? true : ${p}IsNever<${t}> extends true ? true : ${p}IsVoid<${t}>`;
310
+ return [
311
+ ...topTypeDeclarations(p),
312
+ `type ${p}MsgSilent<T> = ${top('T')};`,
313
+ `type ${p}MsgSent<S, E> = ${p}MsgSilent<E> extends true ? E : ${p}MsgSilent<S> extends true ? E : ${body};`,
314
+ ];
315
+ }
282
316
  function safeRealpath(p) {
283
317
  try {
284
318
  return fs.realpathSync(p);
@@ -18,6 +18,7 @@
18
18
  import { Node, type ArrowFunction, type CallExpression, type FunctionDeclaration, type FunctionExpression, type MethodDeclaration, type ParameterDeclaration, type Symbol as TsSymbol, type Type } from 'ts-morph';
19
19
  import { type LabelledMembers } from './library-claims.js';
20
20
  import type { ClaimSlot } from './types.js';
21
+ import type { ReplyStatus } from './capture/index.js';
21
22
  /** A function a handler can be: what the inferrer follows a registration to. */
22
23
  export type HandlerFunction = FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration;
23
24
  /** What a handler's parameters state about the request body. */
@@ -36,9 +37,9 @@ export interface StatedReply {
36
37
  at: Node;
37
38
  }
38
39
  /** The status a send's own chain states, as the inferrer reads it. */
39
- export type ChainStatus = (call: CallExpression) => 'success' | 'error' | 'redirect' | 'variable' | 'undecided' | undefined;
40
+ export type ChainStatus = (call: CallExpression) => ReplyStatus | undefined;
40
41
  /** The status a value states, read as a send's status argument is: `undecided` when it states none. */
41
- export type ValueStatus = (value: Node) => 'success' | 'error' | 'redirect' | 'variable' | 'undecided';
42
+ export type ValueStatus = (value: Node) => ReplyStatus;
42
43
  /** The node a value is read from: `JSON.stringify(x)` is read as `x`. */
43
44
  export type PayloadNode = (value: Node) => Node;
44
45
  export declare class StatedParams {
@@ -227,6 +227,16 @@ export declare class TypeInferrer {
227
227
  * the node it named. Lines do not move (an insertion holds no newline).
228
228
  */
229
229
  private mappedRequest;
230
+ /**
231
+ * Stale-position T2: the request this route row is read with, or why it
232
+ * has no reading. Only a producer route request that carries its handler's
233
+ * lines (`handler_lines`) and is located by text is checked, by the
234
+ * capture's rule (`anchorInHandler`). A node found outside the handler and
235
+ * what its return reaches, whose text names one answer inside them, is
236
+ * read there: the request comes back with that node's line, and is used
237
+ * only if the locator, asked again at that line, finds exactly that node.
238
+ */
239
+ private anchoredRequest;
230
240
  /**
231
241
  * Infer a single type from a request
232
242
  */
@@ -414,7 +424,7 @@ export declare class TypeInferrer {
414
424
  * True when a located call hands back the reply of the registration handler
415
425
  * it sits in (`handsBackHandlerParameter`, `isRegisteredHandler`), is
416
426
  * handed a status-shaped value, read as a chain's status call is read
417
- * (`statusOfValue`, as `chainStatus` reads it), and does not take any
427
+ * (`valueStatus`, as `chainStatus` reads it), and does not take any
418
428
  * value in that slot (`takesAnyValue`): `reply.code(204)`,
419
429
  * `res.status(204)`. Such a call states a status and names no body
420
430
  * (carrick#4300); a send of a number (`reply.send(count)`) keeps its
@@ -423,7 +433,7 @@ export declare class TypeInferrer {
423
433
  private locatedStatusHandsBackReply;
424
434
  /**
425
435
  * The one status-only shape: a call that hands one of the handler's
426
- * parameters back, is handed a status-shaped value (`statusOfValue`), and
436
+ * parameters back, is handed a status-shaped value (`valueStatus`), and
427
437
  * does not take any value in that slot (`takesAnyValue`). Read by the
428
438
  * located-call check and by `returnsHandlerParameterType` (carrick#4341).
429
439
  */
@@ -483,7 +493,7 @@ export declare class TypeInferrer {
483
493
  * expression selects the HANDLER: the function that contains it, on a row
484
494
  * whose line is a route registration. Its returned sends are enumerated
485
495
  * (conditional branches split), each is classified by the status it states
486
- * (`responseSiteStatus`), the error and redirect branches are dropped, and
496
+ * (`replyStatus`), the error and redirect branches are dropped, and
487
497
  * the success bodies are joined exactly as the payload walk joins return
488
498
  * statements.
489
499
  *
@@ -1585,8 +1595,6 @@ export declare class TypeInferrer {
1585
1595
  private envelopeOwnStatus;
1586
1596
  /** The status an envelope literal's `statusCode` or `status` member states. */
1587
1597
  private envelopeLiteralStatus;
1588
- /** The status a value states, classified as a send's status argument is. */
1589
- private statusOfValue;
1590
1598
  /**
1591
1599
  * The value node an object literal gives a member: a property assignment's
1592
1600
  * initializer, or a shorthand's own name.
@@ -1772,56 +1780,8 @@ export declare class TypeInferrer {
1772
1780
  * something other than an HTTP code, so it stays a payload.
1773
1781
  */
1774
1782
  private statesResponseInit;
1775
- /**
1776
- * What a response send states about its HTTP status (carrick#1161).
1777
- *
1778
- * Read in order, and the first that states anything decides:
1779
- *
1780
- * 1. an argument past the body that carries a status: a numeric literal
1781
- * (`send(body, 404)`), an options object (`{ status: 401 }`), or any
1782
- * expression whose TYPE is a status literal or a union of them
1783
- * (`let code: 400 | 500`). A numeric argument whose type is a plain
1784
- * `number` states a status the source does not fix, which is
1785
- * `variable`: the branch fails open into the union and is logged.
1786
- * 2. the send call's own RESULT type, when a member of it is typed as a
1787
- * status literal. A framework that types its sends records the status
1788
- * there, and a redirect helper's default `302` is only visible there.
1789
- * A result whose status member spans success and error codes (the
1790
- * default of a typed `json(body, status?)`) says nothing either way.
1791
- *
1792
- * A status in the FIRST argument is a field of the body and is never read.
1793
- * No method or framework name is consulted anywhere.
1794
- */
1795
- private responseSiteStatus;
1796
- /**
1797
- * The status an earlier call of a send's own chain states: the receiver
1798
- * calls `call` is invoked on (`a.status(401).json(body)` has `a.status(401)`),
1799
- * innermost last. Each receiver call's first argument is read by the rule
1800
- * an argument past a body is, so a numeric literal or a literal-typed value
1801
- * counts and a plain `number` is `variable`. `undefined` when no receiver
1802
- * call states a status. No method name is consulted: a receiver call that
1803
- * is handed no status-shaped value says nothing.
1804
- */
1805
- private chainStatus;
1806
- /**
1807
- * The HTTP status codes an argument states, `'variable'` when it is a
1808
- * status-shaped value the source does not fix, or `undefined` when it says
1809
- * nothing about a status.
1810
- *
1811
- * Read from the AST first: `{ status: 400 }` in an argument position widens
1812
- * to `{ status: number }`, so the literal only survives syntactically. The
1813
- * type read behind it catches `as const`, hoisted option objects and
1814
- * literal-typed variables. Only values in the HTTP range count: an
1815
- * arbitrary number named `status` on a domain object (`{ status: 2 }`)
1816
- * states nothing about transport.
1817
- */
1818
- private statedStatusCodes;
1819
- /**
1820
- * Status codes a send call's result type records: the members (of the
1821
- * result, or of each part of an intersection result) typed as a status
1822
- * literal or a union of them. `undefined` when none is.
1823
- */
1824
- private sendResultStatusCodes;
1783
+ /** The raw checker the shared reply-status reader (`capture/reply-status.ts`) reads with. */
1784
+ private replyChecker;
1825
1785
  /**
1826
1786
  * Peel the wrappers that do not change an expression's payload: parentheses
1827
1787
  * and `await`. Unlike `unwrapExpressionNode` this KEEPS `as`/`satisfies`,