carrick 0.3.161 → 0.3.163

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/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 +89 -11
  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 +75 -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/init/task-skills.d.ts +1 -1
  49. package/dist/init/task-skills.js +1 -0
  50. package/dist/init/task-skills.js.map +1 -1
  51. package/dist/render.d.ts +6 -0
  52. package/dist/render.js +27 -7
  53. package/dist/render.js.map +1 -1
  54. package/package.json +6 -6
  55. package/plugin/.claude-plugin/plugin.json +1 -1
  56. package/plugin/hooks/carrick-hook.sh +122 -0
  57. package/plugin/hooks/hooks.json +8 -8
  58. package/sidecar/dist/src/capture/anchors.d.ts +2 -2
  59. package/sidecar/dist/src/capture/anchors.js +25 -10
  60. package/sidecar/dist/src/capture/api.d.ts +10 -0
  61. package/sidecar/dist/src/capture/check-classify.d.ts +11 -4
  62. package/sidecar/dist/src/capture/check-classify.js +65 -25
  63. package/sidecar/dist/src/capture/check-fields.d.ts +2 -1
  64. package/sidecar/dist/src/capture/check-fields.js +10 -2
  65. package/sidecar/dist/src/capture/check-probe.d.ts +82 -25
  66. package/sidecar/dist/src/capture/check-probe.js +106 -37
  67. package/sidecar/dist/src/capture/index.d.ts +3 -2
  68. package/sidecar/dist/src/capture/index.js +14 -2
  69. package/sidecar/dist/src/capture/reply-status.d.ts +86 -0
  70. package/sidecar/dist/src/capture/reply-status.js +255 -0
  71. package/sidecar/dist/src/capture/site-node.d.ts +34 -0
  72. package/sidecar/dist/src/capture/site-node.js +258 -0
  73. package/sidecar/dist/src/engine-stamp.json +1 -1
  74. package/sidecar/dist/src/held-shadow.d.ts +23 -2
  75. package/sidecar/dist/src/held-shadow.js +42 -8
  76. package/sidecar/dist/src/stated-params.d.ts +3 -2
  77. package/sidecar/dist/src/type-inferrer.d.ts +91 -55
  78. package/sidecar/dist/src/type-inferrer.js +350 -218
  79. package/sidecar/dist/src/types.d.ts +10 -0
  80. package/sidecar/dist/src/validators.d.ts +150 -28
  81. package/sidecar/dist/src/validators.js +15 -1
  82. package/templates/carrick-hook.sh +122 -0
  83. package/templates/skills/carrick-audit.md +97 -0
  84. package/templates/skills/carrick-census.md +73 -87
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: carrick-audit
3
+ description: Use when the ask is what is wrong in this codebase, what to clean up, or a health check of the project. Reads what the Carrick index already flags on main (type mismatches between endpoints and their callers, functions written twice), proves each item in source, and returns a fix list. It reads a lot of source, so it uses many tokens; narrow it to one service where you can.
4
+ ---
5
+
6
+ # What the index flags on main, proven in source
7
+
8
+ {{SCOPE_NOTE}}
9
+
10
+ Cost: this skill opens source for every item it reads. Ten type mismatches and
11
+ ten groups of similar functions took between 130,000 and 230,000 tokens on a
12
+ project of six services and 2,200 files. Before reading, tell the user how many items each
13
+ section holds and offer to narrow to one service or cap the count.
14
+
15
+ The index states the leads. Your work is to prove or drop each one in source.
16
+ Class nothing from the index's own words alone.
17
+
18
+ ## 1. The counts
19
+
20
+ ```
21
+ get_project_map({{SCOPE}})
22
+ ```
23
+
24
+ Note the counts under FOUND ON MAIN: type mismatches and similar functions.
25
+
26
+ ## 2. Type mismatches
27
+
28
+ ```
29
+ get_findings({{SCOPE}}, kind: "type_mismatch")
30
+ ```
31
+
32
+ Page until the last page. For each finding, read the producer's handler, the
33
+ consumer's call site and the code that uses its result. Where the finding does
34
+ not show both types, narrow the pair:
35
+
36
+ ```
37
+ get_contract_pair({{SCOPE}}, consumer_service: "<consumer>", producer_service: "<producer>", method: "<METHOD>", path: "<path>")
38
+ ```
39
+
40
+ Before you class a finding REAL, grep for a second producer of the same path in
41
+ another router or under another prefix. Where one exists, read which one the
42
+ consumer calls.
43
+
44
+ Class each finding:
45
+
46
+ - **REAL**: the consumer reads a field the producer does not send, or a value
47
+ the producer can send breaks the consumer, such as a null passed to code that
48
+ needs a string. Name the field and the line that breaks.
49
+ - **TYPE-ONLY**: the two types disagree, but no value the producer sends can
50
+ break the consumer: a string column holding a fixed set of values against a
51
+ union of those values, a null the database never writes (a default, a check
52
+ that blocks it), a null where every read is guarded. Say which.
53
+ - **FALSE**: the index is wrong about one side: the field is sent, or the type is
54
+ misread.
55
+ - **CAN'T TELL**: the value comes from somewhere you cannot read, such as a JSON
56
+ column or an outside service. Say where.
57
+
58
+ The fields a finding names are leads. The field that breaks may be another
59
+ one; name the one that does. Where it is not one the finding names, class the
60
+ finding by the field that breaks and list the named fields beside it as
61
+ TYPE-ONLY.
62
+
63
+ ## 3. Functions written twice
64
+
65
+ ```
66
+ get_findings({{SCOPE}}, kind: "similar_functions")
67
+ ```
68
+
69
+ Page until the last page, or to the cap the user agreed, and state the cap.
70
+ Read every member of each group at its file and line, and diff the bodies.
71
+ Class each member against the first:
72
+
73
+ - **DUPLICATE**: same contract, nothing to name apart.
74
+ - **VARIANT**: same contract, and a difference you can name in a clause.
75
+ - **FALSE POSITIVE**: different contracts.
76
+
77
+ Where the members sit in separate apps, check their package.json files for a
78
+ package they already share. Where one exists, the fix is to move the function
79
+ there and import it; where none does, say so: the fix is a new shared package.
80
+
81
+ ## 4. Report
82
+
83
+ One table per section, with the class column never empty, and the counts read
84
+ against the counts from step 1 and any cap.
85
+
86
+ Then a fix list: every REAL and DUPLICATE, most harmful first, each with
87
+ file:line and the change in one line ("send createdAt from
88
+ formatTaskResponse"; "move validateName into a shared package and delete the
89
+ two copies"). TYPE-ONLY items go in a short list after it, as optional tidying.
90
+
91
+ Not covered yet: calls that reach no route and endpoints nobody calls. Say so in
92
+ the report.
93
+
94
+ ## 5. Act
95
+
96
+ Change nothing yet. Ask the user which items on the fix list to apply, and apply
97
+ only those.
@@ -1,117 +1,103 @@
1
1
  ---
2
2
  name: carrick-census
3
- description: Use for every place that does X questions, such as every service that reads this environment variable, every handler that checks a permission, or every client of this queue. Pages the Carrick intent index under two wordings and reports what it read and what it could not see.
3
+ description: Use when the ask is which endpoints do X, such as every route that checks an admin role, every endpoint that sends an email or writes to a table, and which apps call them, and before changing a shared helper, to see which endpoints and apps depend on it. Finds the helper by meaning, walks the call graph up to the endpoints, and names each endpoint's callers in other services.
4
4
  ---
5
5
 
6
- # Every place that does X
6
+ # Which endpoints do X, and who calls them
7
7
 
8
8
  {{SCOPE_NOTE}}
9
9
 
10
- The index produces the list. Your work is to open each row and confirm what it
11
- does.
10
+ Grep finds the lines that do X. This skill answers what grep cannot: which
11
+ endpoints reach those lines, and which apps call those endpoints. Grep for the
12
+ raw lines as well; the two answers go side by side.
12
13
 
13
- ## 1. Two wordings
14
+ ## 1. Find the shared function that does X
14
15
 
15
- Ask in two wordings. One says what the code is for, the other says how it does
16
- it. A purpose wording misses a helper whose description names only its
17
- mechanism, and a mechanism wording misses one described only by its job.
16
+ Ask in two wordings, one for what the code is for and one for how it does it:
18
17
 
19
18
  ```
20
19
  search_by_intent({{SCOPE}}, query: "<what it is for>", also_phrased_as: ["<how it does it>"], compact: true, top_k: 20)
21
20
  ```
22
21
 
23
- `compact: true` returns locator-only rows, which is the shape a census needs.
24
- One answer holds both wordings, deduped, with `phrasings` naming them and
25
- `matched_phrasings` on each row saying which ones reached it. Page it while
26
- `has_more` is true:
22
+ Where the answer carries no `phrasings`, run the second wording as its own
23
+ search.
27
24
 
28
- ```
29
- search_by_intent({{SCOPE}}, query: "<the same query>", also_phrased_as: ["<the same second wording>"], compact: true, top_k: 20, offset: <next_offset>)
30
- ```
31
-
32
- Where the answer carries no `phrasings`, or the field comes back refused, the
33
- server answering takes one wording per call. Run the second wording as its own
34
- paged search.
35
-
36
- Stop when `has_more` is false. Lower `similarity_threshold` where the tail of a
37
- page is still on topic.
38
-
39
- ## 2. Union
40
-
41
- One answer over both wordings is already deduped, and `matched_phrasings` says
42
- which wordings reached each row. Two answers are joined here, on `file_path` and
43
- `line_number`, and a row both wordings found is one row. Either way keep
44
- `retrieved_by` and `similarity`, and keep which wording found each row. A row
45
- only one wording reached is the row a single search would have lost.
46
-
47
- ## 3. Receipt
48
-
49
- Report these numbers before the list, per query where the field is per query:
25
+ Read each row at `file_path` from `line_number` to `end_line`. Keep the rows that
26
+ do X, and among them find the lowest: the function the others call to do it,
27
+ such as the function that builds the mail client and sends, or the role check
28
+ itself. Stop paging when a page holds no row that does X. Do not change
29
+ `similarity_threshold` while paging: a new threshold is a new list, so start it
30
+ again at offset 0.
50
31
 
51
- - rows read, which is the count you paged to;
52
- - `total_candidates`, the exact size of the ranked list for that query;
53
- - `hidden_by_threshold` where the answer carries it: how many rows the floor
54
- removed, and `best` where it names the closest of them. A count above zero is
55
- the case for one more search at a lower `similarity_threshold`;
56
- - `hidden_by_lexical_floor` where the answer carries it: how many rows matched a
57
- word of the query but too little of its word weight to rank, and `best` where
58
- it names the nearest of them, with the weight it reached against the bar it
59
- had to clear. A lower `similarity_threshold` does not reach these rows. The
60
- search that does names the identifier or the rare term itself;
61
- - `total_without_intent`, which is index-wide: functions carrying no intent
62
- text, which the search ranked on their name, signature and body tokens
63
- alone, so a query that names one finds it and a query that describes what
64
- it does without naming it does not;
65
- - `total_intent_carried_forward` where the response states it, which are intents
66
- describing the code as of an earlier scan.
32
+ Where the question names an identifier (a function, an env var, a table, a
33
+ header, a package), grep for it too. For each grep hit inside a function, find
34
+ that function with `list_function_intents({{SCOPE}}, file: "<file>", compact: true)`:
35
+ the row whose line span holds the hit.
67
36
 
68
- Then say what the index does not hold for this question. It covers each repo's
69
- main branch, so a change on a branch is outside it. It indexes functions that
70
- carry an intent, so a match inside a config file, a template or generated output
71
- is outside it as well.
37
+ ## 2. Walk up to the endpoints
72
38
 
73
- ## 4. Confirm
39
+ For each shared function from step 1, one call:
74
40
 
75
- Read each row at `file_path`, from `line_number` to `end_line`. Keep the rows
76
- that do the thing, and drop the rest with one line each saying what they turned
77
- out to be. `role` on a row says what the scan joined it to, such as a route
78
- handler or a client, and a route handler for a different operation is not a hit.
79
-
80
- ## 5. Follow helpers to callers
41
+ ```
42
+ get_callers({{SCOPE}}, function_name: "<name>", file: "<file>", depth: 3)
43
+ ```
81
44
 
82
- The rows from step 4 are often the mechanism: a helper that others call to do
83
- the thing. The places that do X are then its callers. For each kept row that is
84
- a helper, run:
45
+ Each row is a function that holds a call, and its `chain` runs from it down to
46
+ the function you asked about. Sort every row into one of these:
47
+
48
+ - **Route handler.** Confirm it with
49
+ `get_api_endpoints({{SCOPE}}, service: "<service>", path_contains: "<path fragment>")`:
50
+ the endpoint whose `file_location` and `handler_span` hold the row is the one.
51
+ Take the path from that endpoint, never from the handler's name.
52
+ - **GraphQL resolvers.** A row named `queryFields_handler` or
53
+ `mutationFields_handler` spans a whole file of resolvers. Read the source at
54
+ `call_site_line` to name the field, then confirm it with
55
+ `get_operation({{SCOPE}}, method: "QUERY" or "MUTATION", path: "<field>")`.
56
+ A `call_entries` above 1 means more than one field in that file makes the
57
+ call: read every call in the span, not only `call_site_line`.
58
+ - **Middleware.** A `use_handler` row gates a router. Grep that router's file
59
+ for `.route(` and `.use(` to find what is mounted behind it, list those routes
60
+ with `get_api_endpoints` and `path_contains` on the outermost mount path (one
61
+ call also returns the routers mounted under it), and give the count.
62
+ - **Uses the check without gating on it.** A handler that only branches on the
63
+ result, or lets some callers past it, is not a gate. List it apart, under
64
+ "uses X without enforcing it", with file:line and what it does instead.
65
+ - **Dead end.** A chain whose top is an anonymous callback (a name like
66
+ `andThen_handler`), a class method, a webhook or event registry, or `<module>`
67
+ (top-level code, whose result is passed around as a value the index does not
68
+ follow). Grep the repo for the top function's name and follow its importers,
69
+ one hop at a time, until you reach the router or registration call that runs
70
+ it. If that finds the route, add it, marked "found by grep". If not, list it under
71
+ "chains that stop", with file:line and where it stops.
72
+
73
+ Rows under `unfollowed_calls` may also call the function: read each one in
74
+ source and keep it if it does.
75
+
76
+ ## 3. Who calls each endpoint
85
77
 
86
78
  ```
87
- get_callers({{SCOPE}}, function_name: "<helper>", file: "<file>", depth: 1)
79
+ get_operation({{SCOPE}}, method: "<METHOD>", path: "<path>")
88
80
  ```
89
81
 
90
- or grep for the helper's name where the index returns nothing. A function passed
91
- as a value is not counted, so grep before you treat zero callers as none. Report
92
- the callers as the places that do X, each with `call_site_line` where the row
93
- carries it, and list the helper itself apart as the mechanism.
94
-
95
- Where the question names an identifier, such as an environment variable, a
96
- table or a header, grep the source for that identifier as well and merge the two
97
- lists on file and line. A match inside a config file, a template or generated
98
- output reaches you only this way. Mark each row with how it was found: index,
99
- callers, grep.
82
+ Read `consumers` only: service and `call_file_location`. Skip `unread_sites`.
83
+ Where more than 10 endpoints were reached, do this for the 10 the question
84
+ cares about most and say how many were not looked up.
100
85
 
101
- ## 6. Report
86
+ ## 4. Report
102
87
 
103
- | file:line | function | what it does | found by |
88
+ | endpoint | how it does X (call chain) | called by (service, file:line) | found by |
104
89
  |---|---|---|---|
105
- | src/billing/charge.ts:88 | chargeCard | reads the billing key | purpose, mechanism |
90
+ | GET /bills/:billId/file | handler → isAdminUser | web: src/pages/BillPage.tsx:40 | index |
106
91
 
107
- Close with the receipt from step 3, and the helpers followed in step 5, so the list is read against what was
108
- searched.
92
+ Then, apart from the table:
109
93
 
110
- ## 7. Act
94
+ - chains that stop, each with file:line and where it stops;
95
+ - handlers that use X without enforcing it, each with file:line;
96
+ - the lines that do X but reach no endpoint (scripts, top-level code, frontend
97
+ pages), from grep, each with file:line;
98
+ - for a question about frontend code only (pages, components), say that the
99
+ table stays empty because the index holds no route list for frontend routers,
100
+ and that the answer is the grep list plus the callers of the shared function;
101
+ - the counts: shared functions followed, endpoints reached, callers listed.
111
102
 
112
- Change nothing unless you were asked to. Offer one issue per finding that needs
113
- work, and file the ones accepted:
114
-
115
- ```
116
- gh issue create --title "<concept>: <n> places, <m> need changing" --body "<the table, and the receipt>"
117
- ```
103
+ Change nothing unless you were asked to.