@arbol-ai/maximus 7.4.0 → 8.0.0

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 (135) hide show
  1. package/README.md +36 -38
  2. package/bin/maximus.js +4 -0
  3. package/config/oxfmt.mjs +1 -0
  4. package/config/oxlint.mjs +10 -0
  5. package/dist/analytics/analytics.d.ts +21 -9
  6. package/dist/analytics/analytics.js +19 -5
  7. package/dist/body.d.ts +1 -1
  8. package/dist/body.js +2 -2
  9. package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
  10. package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
  11. package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
  12. package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
  13. package/dist/chunks/define-app-CfVZBt7D.js +336 -0
  14. package/dist/chunks/{errors-D7zG9kx9.js → errors-WfyKhiyk.js} +9 -4
  15. package/dist/chunks/{execution-kVUJPy1A.js → execution-CfZEx_JP.js} +28 -15
  16. package/dist/chunks/generate-C-9FKW0o.js +197 -0
  17. package/dist/chunks/handler-DWTGoduQ.js +140 -0
  18. package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
  19. package/dist/chunks/{http-paths-yKD6TSNJ.js → http-paths-DMBxwpp6.js} +50 -31
  20. package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
  21. package/dist/chunks/names-ncD7A3DV.js +280 -0
  22. package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
  23. package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
  24. package/dist/chunks/pages-DyC0m8Zb.js +14 -0
  25. package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
  26. package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
  27. package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
  28. package/dist/chunks/query-kind-CWKAXEME.js +40 -0
  29. package/dist/chunks/record-DQUDTpEA.js +10 -0
  30. package/dist/chunks/result-CKgZHrnj.js +56 -0
  31. package/dist/chunks/{runtime-DlqA7J38.js → runtime-CVVf5hmp.js} +50 -26
  32. package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
  33. package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
  34. package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
  35. package/dist/chunks/server-CCc7fil4.js +410 -0
  36. package/dist/chunks/src--HZrH1U9.js +568 -0
  37. package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
  38. package/dist/chunks/{types-DQdfRF3f.d.ts → types-BQYB4Ads.d.ts} +993 -341
  39. package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
  40. package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
  41. package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
  42. package/dist/diagnostics.d.ts +6 -4
  43. package/dist/diagnostics.js +2 -2
  44. package/dist/errors.d.ts +2 -2
  45. package/dist/errors.js +2 -2
  46. package/dist/http-paths.d.ts +1 -1
  47. package/dist/http-paths.js +1 -1
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +12 -11
  50. package/dist/internals.d.ts +1 -1
  51. package/dist/internals.js +5 -4
  52. package/dist/mcp/index.d.ts +3 -2
  53. package/dist/mcp/index.js +5 -387
  54. package/dist/postgres/index.d.ts +25 -8
  55. package/dist/postgres/index.js +17 -8
  56. package/dist/project/config.d.ts +110 -72
  57. package/dist/project/config.js +161 -45
  58. package/dist/project/index.d.ts +17 -4
  59. package/dist/project/index.js +44 -9
  60. package/dist/projection.d.ts +14 -13
  61. package/dist/projection.js +8 -32
  62. package/dist/schemas.d.ts +1 -1
  63. package/dist/schemas.js +2 -2
  64. package/dist/standard-failures.d.ts +2 -89
  65. package/dist/tooling/cli.js +149 -105
  66. package/dist/tooling/testing.js +2 -2
  67. package/dist/vite/cloudflare-workers.js +25 -0
  68. package/dist/vite/index.d.ts +157 -0
  69. package/dist/vite/index.js +1477 -0
  70. package/dist/webhooks.d.ts +12 -10
  71. package/dist/webhooks.js +26 -12
  72. package/dist/workers/runtime.d.ts +1 -1
  73. package/dist/workers/runtime.js +1 -1
  74. package/package.json +26 -22
  75. package/skills/maximus/SKILL.md +165 -68
  76. package/skills/maximus/references/deploying.md +73 -0
  77. package/skills/maximus/references/errors-and-results.md +114 -55
  78. package/skills/maximus/references/project.md +202 -0
  79. package/skills/maximus/references/routes-and-tools.md +256 -0
  80. package/skills/maximus/references/testing.md +137 -50
  81. package/skills/maximus/references/transports.md +113 -100
  82. package/skills/maximus/references/writing-code.md +84 -0
  83. package/templates/mcp/mcp/instructions.md.template +2 -0
  84. package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
  85. package/templates/mcp/tests/mcp.test.ts.template +36 -0
  86. package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
  87. package/templates/project/.github/workflows/ci.yml.template +4 -1
  88. package/templates/project/CLAUDE.md.template +41 -25
  89. package/templates/project/README.md.template +54 -48
  90. package/templates/project/middleware/10-response.ts.template +5 -2
  91. package/templates/project/package.json.template +13 -9
  92. package/templates/project/pages/index.ts.template +2 -4
  93. package/templates/project/routes/v1/greeting.get.ts.template +10 -0
  94. package/templates/project/routes/v1/greeting.post.ts.template +12 -0
  95. package/templates/project/tests/greeting.test.ts.template +45 -0
  96. package/templates/project/tsconfig.json.template +8 -6
  97. package/templates/project/vite.config.ts.template +15 -7
  98. package/templates/web/app/main.tsx.template +16 -0
  99. package/templates/web/app/root.tsx.template +17 -0
  100. package/templates/web/app/routes/index.tsx.template +9 -0
  101. package/templates/web/index.html.template +12 -0
  102. package/templates/web/package.json.template +12 -0
  103. package/templates/web/tsconfig.json.template +7 -0
  104. package/templates/web/vite.config.ts.template +22 -0
  105. package/dist/chunks/builder-BiXv7d2v.js +0 -100
  106. package/dist/chunks/define-app-DvD_1jUE.js +0 -625
  107. package/dist/chunks/prepare-project-CMyGSEtI.js +0 -236
  108. package/dist/chunks/prepare-project-MtS0-W_n.js +0 -3
  109. package/dist/chunks/record-DY-lX9w1.js +0 -34
  110. package/dist/chunks/src-N3oyx5QF.js +0 -1091
  111. package/dist/client/client.d.ts +0 -129
  112. package/dist/client/client.js +0 -321
  113. package/dist/tooling/vite.d.ts +0 -3
  114. package/dist/tooling/vite.js +0 -57
  115. package/skills/maximus/references/adding-an-operation.md +0 -179
  116. package/skills/maximus/references/building-a-service.md +0 -167
  117. package/skills/maximus/references/migration-from-v2.md +0 -62
  118. package/skills/maximus/references/migration-to-v5.md +0 -37
  119. package/skills/maximus/references/publishing-and-verification.md +0 -42
  120. package/templates/project/cloudflare.config.ts.template +0 -24
  121. package/templates/project/maximus.config.ts.template +0 -20
  122. package/templates/project/routes/v1/greeting.ts.template +0 -38
  123. package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
  124. package/templates/service/.github/workflows/ci.yml.template +0 -21
  125. package/templates/service/.gitignore.template +0 -9
  126. package/templates/service/CLAUDE.md.template +0 -5
  127. package/templates/service/README.md.template +0 -45
  128. package/templates/service/cloudflare.config.ts.template +0 -30
  129. package/templates/service/package.json.template +0 -36
  130. package/templates/service/src/app.ts.template +0 -30
  131. package/templates/service/src/index.ts.template +0 -13
  132. package/templates/service/tests/contract.test.ts.template +0 -12
  133. package/templates/service/tsconfig.json.template +0 -16
  134. package/templates/service/vite.config.ts.template +0 -13
  135. package/templates/service/vitest.config.ts.template +0 -10
@@ -0,0 +1,280 @@
1
+ // src/project/names.ts
2
+ /** What a method does to one item: `GET /v1/notes/{noteId}` gets a note. */
3
+ const ITEM_VERBS = {
4
+ GET: "get",
5
+ POST: "post",
6
+ PUT: "replace",
7
+ PATCH: "update",
8
+ DELETE: "delete"
9
+ };
10
+ /** What a method does to a collection: `GET /v1/notes` lists notes and `POST /v1/notes` creates one. */
11
+ const COLLECTION_VERBS = {
12
+ GET: "list",
13
+ POST: "create",
14
+ PUT: "replace",
15
+ PATCH: "update",
16
+ DELETE: "delete"
17
+ };
18
+ /**
19
+ * Words the ending rules get wrong: plurals whose singular no rule finds (`diagnoses`), singulars that end
20
+ * in s (`alias`, `diabetes`), and words that are their own plural or name one thing, which a path treats as
21
+ * a singular: `GET /v1/analytics` gets analytics rather than listing them.
22
+ */
23
+ const IRREGULAR_SINGULARS = {
24
+ people: "person",
25
+ children: "child",
26
+ men: "man",
27
+ women: "woman",
28
+ feet: "foot",
29
+ teeth: "tooth",
30
+ analyses: "analysis",
31
+ diagnoses: "diagnosis",
32
+ prognoses: "prognosis",
33
+ hypotheses: "hypothesis",
34
+ syntheses: "synthesis",
35
+ theses: "thesis",
36
+ crises: "crisis",
37
+ indices: "index",
38
+ matrices: "matrix",
39
+ vertices: "vertex",
40
+ appendices: "appendix",
41
+ criteria: "criterion",
42
+ phenomena: "phenomenon",
43
+ aliases: "alias",
44
+ biases: "bias",
45
+ canvases: "canvas",
46
+ statuses: "status",
47
+ campuses: "campus",
48
+ viruses: "virus",
49
+ bonuses: "bonus",
50
+ buses: "bus",
51
+ censuses: "census",
52
+ surpluses: "surplus",
53
+ caches: "cache",
54
+ niches: "niche",
55
+ headaches: "headache",
56
+ movies: "movie",
57
+ cookies: "cookie",
58
+ calories: "calorie",
59
+ selfies: "selfie",
60
+ quizzes: "quiz",
61
+ series: "series",
62
+ species: "species",
63
+ news: "news",
64
+ analytics: "analytics",
65
+ genomics: "genomics",
66
+ logistics: "logistics",
67
+ alias: "alias",
68
+ bias: "bias",
69
+ canvas: "canvas",
70
+ atlas: "atlas",
71
+ gas: "gas",
72
+ pancreas: "pancreas",
73
+ diabetes: "diabetes",
74
+ herpes: "herpes",
75
+ rabies: "rabies",
76
+ scabies: "scabies",
77
+ measles: "measles",
78
+ mumps: "mumps"
79
+ };
80
+ /** Ending rules, in order: the first ending a plural has gives its singular. */
81
+ const SINGULAR_ENDINGS = [
82
+ [/([^aeiou])ies$/, "$1y"],
83
+ [/(ss|sh|ch|x|zz)es$/, "$1"],
84
+ [/(ss|us|is)$/, "$1"],
85
+ [/s$/, ""]
86
+ ];
87
+ /** Words that complete the verb before them: `check-in` checks in, `opt-out` opts out. */
88
+ const PARTICLES = /* @__PURE__ */ new Set([
89
+ "in",
90
+ "out",
91
+ "up",
92
+ "off",
93
+ "on",
94
+ "down",
95
+ "over",
96
+ "back",
97
+ "away"
98
+ ]);
99
+ /** Words that qualify the verb after them: `bulk-delete` deletes in bulk. */
100
+ const VERB_PREFIXES = /* @__PURE__ */ new Set(["bulk", "batch"]);
101
+ /** The singular of an English word: `notes` is `note`, `categories` `category`, `diagnoses` `diagnosis`. */
102
+ function singular(word) {
103
+ const irregular = IRREGULAR_SINGULARS[word];
104
+ if (irregular !== void 0) return irregular;
105
+ for (const [plural, replacement] of SINGULAR_ENDINGS) if (plural.test(word)) return word.replace(plural, replacement);
106
+ return word;
107
+ }
108
+ /** A segment's words in lowercase: `task-lists`, `task_lists` and `taskLists` are `task` and `lists`. */
109
+ function segmentWords(segment) {
110
+ return segment.replaceAll(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean).map((word) => word.toLowerCase());
111
+ }
112
+ /** A segment's words with the last one in the singular: `task-lists` is `task` and `list`. */
113
+ function singularWords(segment) {
114
+ const words = segmentWords(segment);
115
+ const last = words.pop();
116
+ return last === void 0 ? words : [...words, singular(last)];
117
+ }
118
+ /** Whether a segment's last word is a plural its singular differs from. */
119
+ function isPlural(segment) {
120
+ const last = segmentWords(segment).at(-1);
121
+ return last !== void 0 && singular(last) !== last;
122
+ }
123
+ /** Whether a segment is a `{parameter}`. */
124
+ function isParameter(segment) {
125
+ return segment?.startsWith("{") === true;
126
+ }
127
+ /** A path's version and its segments after it: `/v2/notes` is version `v2` and the segment `notes`. */
128
+ function pathParts(path) {
129
+ const segments = path.split("/").filter(Boolean);
130
+ const [first] = segments;
131
+ if (first !== void 0 && /^v[1-9][0-9]*$/.test(first)) return {
132
+ version: first,
133
+ segments: segments.slice(1)
134
+ };
135
+ return {
136
+ version: void 0,
137
+ segments
138
+ };
139
+ }
140
+ /**
141
+ * The words the segments before an operation's target add to it: a segment followed by a parameter names
142
+ * one item, in the singular (`days/{date}` is `day`), `me` is the caller's (`my`), and any other fixed
143
+ * segment stays as it is (`admin`).
144
+ */
145
+ function ownerWords(segments) {
146
+ return segments.flatMap((segment, index) => {
147
+ if (isParameter(segment)) return [];
148
+ if (segment === "me") return ["my"];
149
+ return isParameter(segments[index + 1]) ? singularWords(segment) : segmentWords(segment);
150
+ });
151
+ }
152
+ /**
153
+ * An action's words split around what it acts on: its verb first, with a particle that completes it
154
+ * (`check-in`) or after a prefix that qualifies it (`bulk-delete`), then the rest (`mark-read`).
155
+ */
156
+ function actionWords(action) {
157
+ const words = segmentWords(action);
158
+ const [first = "", second] = words;
159
+ const verbLength = second !== void 0 && (PARTICLES.has(second) || VERB_PREFIXES.has(first)) ? 2 : 1;
160
+ return {
161
+ verb: words.slice(0, verbLength),
162
+ rest: words.slice(verbLength)
163
+ };
164
+ }
165
+ /**
166
+ * The phrase of an operation on the segments after its version. A path that ends in a parameter acts on one
167
+ * item; one that ends in a plural acts on a collection; one that ends in any other word is an action on what
168
+ * precedes it when the method is POST, such as `archive` in `POST /v1/notes/{noteId}/archive`, and a
169
+ * singleton otherwise, such as `summary` in `GET /v1/notes/{noteId}/summary`. A POST to a word that nothing
170
+ * precedes has nothing to act on, so it creates what the word names: `POST /v1/greeting` creates a greeting.
171
+ */
172
+ function operationPhrase(method, segments) {
173
+ const target = segments.at(-1);
174
+ const bare = {
175
+ verb: [method.toLowerCase()],
176
+ object: [],
177
+ one: false,
178
+ rest: []
179
+ };
180
+ if (target === void 0) return bare;
181
+ if (isParameter(target)) {
182
+ const collection = segments.at(-2);
183
+ if (collection === void 0 || isParameter(collection)) return bare;
184
+ const object = [...ownerWords(segments.slice(0, -2)), ...singularWords(collection)];
185
+ return {
186
+ verb: [ITEM_VERBS[method]],
187
+ object,
188
+ one: true,
189
+ rest: []
190
+ };
191
+ }
192
+ const owners = ownerWords(segments.slice(0, -1));
193
+ if (isPlural(target)) {
194
+ const created = method === "POST";
195
+ const words = created ? singularWords(target) : segmentWords(target);
196
+ return {
197
+ verb: [COLLECTION_VERBS[method]],
198
+ object: [...owners, ...words],
199
+ one: created,
200
+ rest: []
201
+ };
202
+ }
203
+ if (method === "POST" && !owners.length) return {
204
+ verb: ["create"],
205
+ object: segmentWords(target),
206
+ one: true,
207
+ rest: []
208
+ };
209
+ if (method === "POST") {
210
+ const { verb, rest } = actionWords(target);
211
+ return {
212
+ verb,
213
+ object: owners.at(-1) === "my" && !rest.length ? [...owners.slice(0, -1), "me"] : owners,
214
+ one: isParameter(segments.at(-2)),
215
+ rest
216
+ };
217
+ }
218
+ return {
219
+ verb: [ITEM_VERBS[method]],
220
+ object: [...owners, ...segmentWords(target)],
221
+ one: false,
222
+ rest: []
223
+ };
224
+ }
225
+ /** Words in camelCase: `get`, `day` and `booking` are `getDayBooking`. */
226
+ function camelCase(words) {
227
+ return words.map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
228
+ }
229
+ /**
230
+ * A route's operation name: `GET /v1/notes` is `listNotes`, `GET /v1/notes/{noteId}` is `getNote`,
231
+ * `POST /v1/notes` is `createNote`, `PATCH /v1/notes/{noteId}` is `updateNote`,
232
+ * `POST /v1/notes/{noteId}/archive` is `archiveNote` and `GET /v1/days/{date}/slots` is `listDaySlots`. A
233
+ * version other than 1 ends the name: `GET /v2/notes` is `listNotesV2`.
234
+ */
235
+ function routeName(method, path) {
236
+ const { version, segments } = pathParts(path);
237
+ const { verb, object, rest } = operationPhrase(method, segments);
238
+ const suffix = version === void 0 || version === "v1" ? "" : version.toUpperCase();
239
+ return `${camelCase([
240
+ ...verb,
241
+ ...object,
242
+ ...rest
243
+ ])}${suffix}`;
244
+ }
245
+ /** Words that take `a` though they start with a vowel, and `an` though they start with a consonant. */
246
+ const ARTICLE_EXCEPTIONS = [
247
+ ["uni", "a"],
248
+ ["use", "a"],
249
+ ["usa", "a"],
250
+ ["eu", "a"],
251
+ ["one", "a"],
252
+ ["hour", "an"],
253
+ ["honest", "an"],
254
+ ["honor", "an"]
255
+ ];
256
+ /** The indefinite article before a word: `a note`, `an invoice`, `a user`, `an hour`. */
257
+ function article(word) {
258
+ const exception = ARTICLE_EXCEPTIONS.find(([prefix]) => word.startsWith(prefix));
259
+ if (exception) return exception[1];
260
+ return /^[aeiou]/.test(word) ? "an" : "a";
261
+ }
262
+ /**
263
+ * A route's title, from its method and path as its name: `Get a note`, `List notes`, `Create a day booking`,
264
+ * `Mark a note read`. A version other than 1 follows it: `List notes (v2)`.
265
+ */
266
+ function routeTitle(method, path) {
267
+ const { version, segments } = pathParts(path);
268
+ const { verb, object, one, rest } = operationPhrase(method, segments);
269
+ const [first] = object;
270
+ const named = one && first !== void 0 ? [article(first), ...object] : object;
271
+ const phrase = [
272
+ ...verb,
273
+ ...named,
274
+ ...rest
275
+ ].join(" ");
276
+ const title = phrase.charAt(0).toUpperCase() + phrase.slice(1);
277
+ return version === void 0 || version === "v1" ? title : `${title} (${version})`;
278
+ }
279
+
280
+ export { routeTitle as n, routeName as t };