@percher/core 0.2.5 → 0.3.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 (206) hide show
  1. package/dist/ai-files-manifest.d.ts +28 -0
  2. package/dist/ai-files-manifest.d.ts.map +1 -0
  3. package/dist/ai-files-manifest.js +96 -0
  4. package/dist/ai-files-manifest.js.map +1 -0
  5. package/dist/commands/account.d.ts +51 -0
  6. package/dist/commands/account.d.ts.map +1 -0
  7. package/dist/commands/account.js +88 -0
  8. package/dist/commands/account.js.map +1 -0
  9. package/dist/commands/ai-files.d.ts +73 -0
  10. package/dist/commands/ai-files.d.ts.map +1 -0
  11. package/dist/commands/ai-files.js +179 -0
  12. package/dist/commands/ai-files.js.map +1 -0
  13. package/dist/commands/billing.d.ts +1 -1
  14. package/dist/commands/billing.d.ts.map +1 -1
  15. package/dist/commands/billing.js +1 -1
  16. package/dist/commands/billing.js.map +1 -1
  17. package/dist/commands/continue.d.ts +48 -0
  18. package/dist/commands/continue.d.ts.map +1 -0
  19. package/dist/commands/continue.js +121 -0
  20. package/dist/commands/continue.js.map +1 -0
  21. package/dist/commands/create.d.ts +1 -1
  22. package/dist/commands/create.d.ts.map +1 -1
  23. package/dist/commands/create.js +1 -1
  24. package/dist/commands/create.js.map +1 -1
  25. package/dist/commands/dashboard.d.ts +15 -0
  26. package/dist/commands/dashboard.d.ts.map +1 -0
  27. package/dist/commands/dashboard.js +33 -0
  28. package/dist/commands/dashboard.js.map +1 -0
  29. package/dist/commands/data-export.d.ts +21 -0
  30. package/dist/commands/data-export.d.ts.map +1 -0
  31. package/dist/commands/data-export.js +36 -0
  32. package/dist/commands/data-export.js.map +1 -0
  33. package/dist/commands/data.d.ts +1 -1
  34. package/dist/commands/data.d.ts.map +1 -1
  35. package/dist/commands/data.js +1 -1
  36. package/dist/commands/data.js.map +1 -1
  37. package/dist/commands/delete.d.ts +1 -1
  38. package/dist/commands/delete.d.ts.map +1 -1
  39. package/dist/commands/delete.js +1 -1
  40. package/dist/commands/delete.js.map +1 -1
  41. package/dist/commands/deploys.d.ts +2 -2
  42. package/dist/commands/deploys.d.ts.map +1 -1
  43. package/dist/commands/deploys.js +21 -5
  44. package/dist/commands/deploys.js.map +1 -1
  45. package/dist/commands/dev.d.ts +1 -9
  46. package/dist/commands/dev.d.ts.map +1 -1
  47. package/dist/commands/dev.js +77 -23
  48. package/dist/commands/dev.js.map +1 -1
  49. package/dist/commands/diagnose.d.ts +1 -1
  50. package/dist/commands/diagnose.d.ts.map +1 -1
  51. package/dist/commands/diagnose.js +1 -1
  52. package/dist/commands/diagnose.js.map +1 -1
  53. package/dist/commands/doctor.d.ts +63 -1
  54. package/dist/commands/doctor.d.ts.map +1 -1
  55. package/dist/commands/doctor.js +792 -10
  56. package/dist/commands/doctor.js.map +1 -1
  57. package/dist/commands/domains.d.ts +1 -1
  58. package/dist/commands/domains.d.ts.map +1 -1
  59. package/dist/commands/domains.js +1 -1
  60. package/dist/commands/domains.js.map +1 -1
  61. package/dist/commands/env-scan.d.ts +2 -0
  62. package/dist/commands/env-scan.d.ts.map +1 -0
  63. package/dist/commands/env-scan.js +92 -0
  64. package/dist/commands/env-scan.js.map +1 -0
  65. package/dist/commands/env.d.ts +1 -1
  66. package/dist/commands/env.d.ts.map +1 -1
  67. package/dist/commands/env.js +1 -1
  68. package/dist/commands/env.js.map +1 -1
  69. package/dist/commands/export.d.ts +1 -1
  70. package/dist/commands/export.js +1 -1
  71. package/dist/commands/generate.d.ts +1 -1
  72. package/dist/commands/generate.d.ts.map +1 -1
  73. package/dist/commands/generate.js +14 -9
  74. package/dist/commands/generate.js.map +1 -1
  75. package/dist/commands/github.d.ts +60 -0
  76. package/dist/commands/github.d.ts.map +1 -0
  77. package/dist/commands/github.js +112 -0
  78. package/dist/commands/github.js.map +1 -0
  79. package/dist/commands/import-project.d.ts +1 -1
  80. package/dist/commands/import-project.d.ts.map +1 -1
  81. package/dist/commands/import-project.js +1 -1
  82. package/dist/commands/import-project.js.map +1 -1
  83. package/dist/commands/init.d.ts +1 -1
  84. package/dist/commands/init.d.ts.map +1 -1
  85. package/dist/commands/init.js +1 -1
  86. package/dist/commands/init.js.map +1 -1
  87. package/dist/commands/insights.d.ts +1 -1
  88. package/dist/commands/insights.d.ts.map +1 -1
  89. package/dist/commands/insights.js +1 -1
  90. package/dist/commands/insights.js.map +1 -1
  91. package/dist/commands/login.d.ts +1 -1
  92. package/dist/commands/login.d.ts.map +1 -1
  93. package/dist/commands/login.js +1 -1
  94. package/dist/commands/login.js.map +1 -1
  95. package/dist/commands/logs.d.ts +1 -1
  96. package/dist/commands/logs.d.ts.map +1 -1
  97. package/dist/commands/logs.js +1 -1
  98. package/dist/commands/logs.js.map +1 -1
  99. package/dist/commands/mcp.d.ts +1 -1
  100. package/dist/commands/mcp.d.ts.map +1 -1
  101. package/dist/commands/mcp.js +1 -1
  102. package/dist/commands/mcp.js.map +1 -1
  103. package/dist/commands/open.d.ts +1 -1
  104. package/dist/commands/open.d.ts.map +1 -1
  105. package/dist/commands/open.js +1 -1
  106. package/dist/commands/open.js.map +1 -1
  107. package/dist/commands/publish-failure.d.ts +31 -0
  108. package/dist/commands/publish-failure.d.ts.map +1 -0
  109. package/dist/commands/publish-failure.js +142 -0
  110. package/dist/commands/publish-failure.js.map +1 -0
  111. package/dist/commands/publish-node.d.ts +13 -0
  112. package/dist/commands/publish-node.d.ts.map +1 -0
  113. package/dist/commands/publish-node.js +38 -0
  114. package/dist/commands/publish-node.js.map +1 -0
  115. package/dist/commands/publish.d.ts +87 -3
  116. package/dist/commands/publish.d.ts.map +1 -1
  117. package/dist/commands/publish.js +589 -156
  118. package/dist/commands/publish.js.map +1 -1
  119. package/dist/commands/push.d.ts +45 -8
  120. package/dist/commands/push.d.ts.map +1 -1
  121. package/dist/commands/push.js +215 -22
  122. package/dist/commands/push.js.map +1 -1
  123. package/dist/commands/redeploy.d.ts +28 -0
  124. package/dist/commands/redeploy.d.ts.map +1 -0
  125. package/dist/commands/redeploy.js +417 -0
  126. package/dist/commands/redeploy.js.map +1 -0
  127. package/dist/commands/rename.d.ts +1 -1
  128. package/dist/commands/rename.d.ts.map +1 -1
  129. package/dist/commands/rename.js +1 -1
  130. package/dist/commands/rename.js.map +1 -1
  131. package/dist/commands/reproduce.d.ts +64 -0
  132. package/dist/commands/reproduce.d.ts.map +1 -0
  133. package/dist/commands/reproduce.js +211 -0
  134. package/dist/commands/reproduce.js.map +1 -0
  135. package/dist/commands/reset-superuser.d.ts +14 -3
  136. package/dist/commands/reset-superuser.d.ts.map +1 -1
  137. package/dist/commands/reset-superuser.js +11 -2
  138. package/dist/commands/reset-superuser.js.map +1 -1
  139. package/dist/commands/restore.d.ts +79 -0
  140. package/dist/commands/restore.d.ts.map +1 -0
  141. package/dist/commands/restore.js +164 -0
  142. package/dist/commands/restore.js.map +1 -0
  143. package/dist/commands/resume.d.ts +1 -1
  144. package/dist/commands/resume.d.ts.map +1 -1
  145. package/dist/commands/resume.js +1 -1
  146. package/dist/commands/resume.js.map +1 -1
  147. package/dist/commands/rollback.d.ts +20 -8
  148. package/dist/commands/rollback.d.ts.map +1 -1
  149. package/dist/commands/rollback.js +11 -6
  150. package/dist/commands/rollback.js.map +1 -1
  151. package/dist/commands/unsuspend.d.ts +35 -0
  152. package/dist/commands/unsuspend.d.ts.map +1 -0
  153. package/dist/commands/unsuspend.js +27 -0
  154. package/dist/commands/unsuspend.js.map +1 -0
  155. package/dist/commands/versions.d.ts +1 -1
  156. package/dist/commands/versions.d.ts.map +1 -1
  157. package/dist/commands/versions.js +1 -1
  158. package/dist/commands/versions.js.map +1 -1
  159. package/dist/commands/wait-deploy.d.ts +92 -0
  160. package/dist/commands/wait-deploy.d.ts.map +1 -0
  161. package/dist/commands/wait-deploy.js +225 -0
  162. package/dist/commands/wait-deploy.js.map +1 -0
  163. package/dist/env-scan-source.d.ts +39 -0
  164. package/dist/env-scan-source.d.ts.map +1 -0
  165. package/dist/env-scan-source.js +332 -0
  166. package/dist/env-scan-source.js.map +1 -0
  167. package/dist/error-classifier.d.ts.map +1 -1
  168. package/dist/error-classifier.js +67 -4
  169. package/dist/error-classifier.js.map +1 -1
  170. package/dist/errors.d.ts +8 -1
  171. package/dist/errors.d.ts.map +1 -1
  172. package/dist/errors.js +2 -0
  173. package/dist/errors.js.map +1 -1
  174. package/dist/index.d.ts +14 -1
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +13 -0
  177. package/dist/index.js.map +1 -1
  178. package/dist/plans.d.ts +11 -0
  179. package/dist/plans.d.ts.map +1 -1
  180. package/dist/plans.js +10 -0
  181. package/dist/plans.js.map +1 -1
  182. package/dist/poll-deployment.d.ts +47 -0
  183. package/dist/poll-deployment.d.ts.map +1 -0
  184. package/dist/poll-deployment.js +57 -0
  185. package/dist/poll-deployment.js.map +1 -0
  186. package/dist/recovery.d.ts +356 -0
  187. package/dist/recovery.d.ts.map +1 -0
  188. package/dist/recovery.js +299 -0
  189. package/dist/recovery.js.map +1 -0
  190. package/dist/stream-utils.d.ts +21 -0
  191. package/dist/stream-utils.d.ts.map +1 -0
  192. package/dist/stream-utils.js +41 -0
  193. package/dist/stream-utils.js.map +1 -0
  194. package/dist/templates/ai-files/claude-md.d.ts +7 -0
  195. package/dist/templates/ai-files/claude-md.d.ts.map +1 -0
  196. package/dist/templates/ai-files/claude-md.js +78 -0
  197. package/dist/templates/ai-files/claude-md.js.map +1 -0
  198. package/dist/templates/ai-files/cursor-percher-mdc.d.ts +7 -0
  199. package/dist/templates/ai-files/cursor-percher-mdc.d.ts.map +1 -0
  200. package/dist/templates/ai-files/cursor-percher-mdc.js +111 -0
  201. package/dist/templates/ai-files/cursor-percher-mdc.js.map +1 -0
  202. package/dist/templates/ai-files/index.d.ts +8 -0
  203. package/dist/templates/ai-files/index.d.ts.map +1 -0
  204. package/dist/templates/ai-files/index.js +4 -0
  205. package/dist/templates/ai-files/index.js.map +1 -0
  206. package/package.json +5 -5
@@ -0,0 +1,299 @@
1
+ // ── Builders ─────────────────────────────────────────────────────────
2
+ //
3
+ // All recovery construction goes through these. Each builder enforces
4
+ // the required fields for its branch, so a typo or missing field is
5
+ // caught at compile time rather than producing an inline literal that
6
+ // silently violates the contract (e.g. ask_user without prompt).
7
+ /** Success / no-op recovery. `url` is the current live URL when known. */
8
+ export function recoveryNone(opts = {}) {
9
+ return {
10
+ retryable: false,
11
+ nextAction: "none",
12
+ reasonCode: opts.reasonCode ?? "none",
13
+ ...(opts.url !== undefined ? { url: opts.url } : {}),
14
+ };
15
+ }
16
+ /** Authentication required — agent should call `percher_login`. */
17
+ export function recoveryLogin(opts = {}) {
18
+ return {
19
+ retryable: false,
20
+ nextAction: "open_login",
21
+ suggestedTool: "percher_login",
22
+ args: {},
23
+ reasonCode: opts.reasonCode ?? "auth_required",
24
+ };
25
+ }
26
+ /** Wait on an in-flight deploy — agent should call `percher_wait_for_deploy`. */
27
+ export function recoveryWait(opts) {
28
+ return {
29
+ retryable: false,
30
+ nextAction: "wait_deploy",
31
+ suggestedTool: "percher_wait_for_deploy",
32
+ args: {
33
+ app: opts.app,
34
+ deployId: opts.deployId,
35
+ timeoutSeconds: opts.timeoutSeconds ?? 30,
36
+ },
37
+ reasonCode: opts.reasonCode,
38
+ };
39
+ }
40
+ /** Route to `percher_doctor` for an ambiguous failure that needs diagnosis. */
41
+ export function recoveryDoctor(opts) {
42
+ const args = {};
43
+ if (opts.app !== undefined)
44
+ args.app = opts.app;
45
+ if (opts.deployId !== undefined)
46
+ args.deployId = opts.deployId;
47
+ if (opts.mode !== undefined)
48
+ args.mode = opts.mode;
49
+ return {
50
+ retryable: false,
51
+ nextAction: "run_doctor",
52
+ suggestedTool: "percher_doctor",
53
+ args,
54
+ reasonCode: opts.reasonCode,
55
+ ...(opts.alternativeActions !== undefined
56
+ ? { alternativeActions: opts.alternativeActions }
57
+ : {}),
58
+ };
59
+ }
60
+ /** Build/runtime needs env keys — agent should call `percher_env_set`. */
61
+ export function recoveryEnv(opts) {
62
+ const args = {};
63
+ if (opts.app !== undefined)
64
+ args.app = opts.app;
65
+ if (opts.keys.length > 0)
66
+ args.keys = opts.keys;
67
+ return {
68
+ retryable: false,
69
+ nextAction: "set_env_vars",
70
+ suggestedTool: "percher_env_set",
71
+ args,
72
+ reasonCode: opts.reasonCode ?? "missing_env",
73
+ };
74
+ }
75
+ /**
76
+ * `percher.toml` is invalid or missing — agent should fix the file
77
+ * directly. `problems` carries the structured issue list (file,
78
+ * line/column, message) so the agent can apply edits without parsing
79
+ * a free-text error.
80
+ */
81
+ export function recoveryFixConfig(opts) {
82
+ return {
83
+ retryable: false,
84
+ nextAction: "fix_config",
85
+ problems: opts.problems,
86
+ reasonCode: opts.reasonCode ?? "config_invalid",
87
+ };
88
+ }
89
+ /**
90
+ * Build failed and the API extracted at least one structured problem
91
+ * with file/line data — agent should patch the offending file(s).
92
+ */
93
+ export function recoveryFixProblems(opts) {
94
+ return {
95
+ retryable: false,
96
+ nextAction: "fix_problems",
97
+ problems: opts.problems,
98
+ reasonCode: opts.reasonCode ?? "build_failed",
99
+ ...(opts.alternativeActions !== undefined
100
+ ? { alternativeActions: opts.alternativeActions }
101
+ : {}),
102
+ };
103
+ }
104
+ /** Transient infra failure — agent can re-issue the same call. */
105
+ export function recoveryRetry(opts) {
106
+ return {
107
+ retryable: true,
108
+ nextAction: "retry",
109
+ suggestedTool: opts.suggestedTool,
110
+ args: opts.args,
111
+ reasonCode: opts.reasonCode,
112
+ };
113
+ }
114
+ /**
115
+ * Human-input required. `prompt` MUST be a concrete question — agents
116
+ * surface it verbatim, so empty/placeholder strings violate the
117
+ * contract.
118
+ */
119
+ export function recoveryAsk(opts) {
120
+ if (!opts.prompt || opts.prompt.trim().length === 0) {
121
+ throw new Error("recoveryAsk requires a non-empty prompt");
122
+ }
123
+ return {
124
+ retryable: opts.retryable ?? false,
125
+ nextAction: "ask_user",
126
+ prompt: opts.prompt,
127
+ ...(opts.options !== undefined ? { options: opts.options } : {}),
128
+ reasonCode: opts.reasonCode,
129
+ };
130
+ }
131
+ /**
132
+ * Legacy `inspect_build_log` recovery — kept for the build-failure
133
+ * paths that haven't migrated to `run_doctor` yet. FUTURE12 Phase 4
134
+ * will replace these emit sites with `recoveryDoctor`.
135
+ */
136
+ export function recoveryInspectBuildLog(opts) {
137
+ const args = opts.deployId
138
+ ? { id: opts.deployId, app: opts.app }
139
+ : { latestFailed: true, app: opts.app };
140
+ return {
141
+ retryable: false,
142
+ nextAction: "inspect_build_log",
143
+ suggestedTool: "percher_deploys_inspect",
144
+ args,
145
+ reasonCode: opts.reasonCode ?? "build_failed",
146
+ ...(opts.alternativeActions !== undefined
147
+ ? { alternativeActions: opts.alternativeActions }
148
+ : {}),
149
+ };
150
+ }
151
+ // ── Legacy const exports ─────────────────────────────────────────────
152
+ //
153
+ // Kept as concrete values so existing call-sites compile until they
154
+ // migrate to the builders directly. Each is just the corresponding
155
+ // builder evaluated with default reasonCode.
156
+ /** Recovery on the success path. */
157
+ export const RECOVERY_NONE = recoveryNone();
158
+ /** Recovery for the unauthenticated path. */
159
+ export const RECOVERY_NEEDS_LOGIN = recoveryLogin();
160
+ /**
161
+ * Convert a `BuildProblem` into the lossless `RecoveryProblem` shape.
162
+ * Drops fields that aren't part of the recovery contract (severity,
163
+ * code) — those still ride on `error.problems` for the CLI's pretty
164
+ * printer. `hint` is folded into the message because it carries the
165
+ * actionable next step (especially for problems without a line, like
166
+ * malformed package.json) and the recovery contract has no separate
167
+ * hint slot.
168
+ *
169
+ * Exported so doctor (Phase 2c fix_problems path) can reuse the
170
+ * same hint-preserving mapping rather than re-implementing it.
171
+ */
172
+ export function buildProblemToRecoveryProblem(p) {
173
+ // p.file is optional on BuildProblem but the caller filters to
174
+ // file-bearing problems before reaching here.
175
+ const file = p.file ?? "";
176
+ const message = p.hint && p.hint.length > 0 ? `${p.message}\nHint: ${p.hint}` : p.message;
177
+ return {
178
+ file,
179
+ ...(typeof p.line === "number" ? { line: p.line } : {}),
180
+ ...(typeof p.column === "number" ? { column: p.column } : {}),
181
+ message,
182
+ };
183
+ }
184
+ /**
185
+ * Map an `ErrorClass` to a recovery action. Conservative by default —
186
+ * unknown classes resolve to `ask_user` so an agent never blindly retries
187
+ * something we haven't classified.
188
+ */
189
+ export function recoveryFromErrorClass(errorClass, failure = {}) {
190
+ switch (errorClass) {
191
+ case "missing_env":
192
+ return recoveryEnv({
193
+ keys: failure.missingEnvVars ?? [],
194
+ reasonCode: "missing_env",
195
+ });
196
+ case "infra_unavailable":
197
+ return recoveryRetry({
198
+ suggestedTool: "percher_publish",
199
+ args: failure.publishInput ?? {},
200
+ reasonCode: "infra_unavailable",
201
+ });
202
+ case "config_invalid":
203
+ return recoveryFixConfig({
204
+ problems: [
205
+ {
206
+ file: "percher.toml",
207
+ message: "percher.toml failed validation — fix the file and re-run.",
208
+ },
209
+ ],
210
+ reasonCode: "config_invalid",
211
+ });
212
+ case "build_failed":
213
+ case "missing_dependency":
214
+ case "health_check_timeout":
215
+ case "port_mismatch":
216
+ case "permission_denied":
217
+ case "runtime_crash":
218
+ case "oom_killed": {
219
+ // FUTURE1 Phase 2.3: when the API parser extracted at least one
220
+ // problem WITH a file location, give the agent a structured
221
+ // `fix_problems` recovery instead of routing through doctor.
222
+ // Problems without a file (missing-module by bare name,
223
+ // missing-build-env) are still actionable by hint but the agent
224
+ // has nothing to open — let doctor classify those so it can pull
225
+ // the build log and decide between set_env_vars / ask_user / etc.
226
+ const fileProblems = (failure.problems ?? []).filter((p) => p.file);
227
+ const reproduceAlt = failure.deployId
228
+ ? {
229
+ action: "reproduce_locally",
230
+ suggestedTool: "percher_reproduce",
231
+ args: { deployId: failure.deployId, app: failure.appName },
232
+ when: "after the primary path didn't surface a clear fix and the user has nixpacks installed locally",
233
+ }
234
+ : undefined;
235
+ if (fileProblems.length > 0) {
236
+ return recoveryFixProblems({
237
+ problems: fileProblems.map(buildProblemToRecoveryProblem),
238
+ reasonCode: "build_failed",
239
+ ...(reproduceAlt
240
+ ? {
241
+ alternativeActions: [
242
+ {
243
+ ...reproduceAlt,
244
+ when: "after fixing the file-located problems didn't make the build pass and the user has nixpacks installed locally",
245
+ },
246
+ ],
247
+ }
248
+ : {}),
249
+ });
250
+ }
251
+ // FUTURE12 Phase 4: route ambiguous build failures through
252
+ // `percher_doctor` instead of straight to `inspect_build_log`.
253
+ // Doctor's deploy-mode dispatch (Phase 2c) fetches the build
254
+ // log, runs `classifyError`, and returns a more specific
255
+ // recovery (`set_env_vars` when missing env keys are extracted,
256
+ // `fix_problems` when structured BuildProblems with file
257
+ // locations are extracted, falling back to `inspect_build_log`
258
+ // only when classification yields nothing). Publish/wait don't
259
+ // always have the build log when they hit this path, so handing
260
+ // off to doctor closes the loop with one consistent contract for
261
+ // agents.
262
+ //
263
+ // `inspect_build_log` is preserved as an `alternativeAction` so
264
+ // agents that want the raw log can still opt in after doctor's
265
+ // primary recovery doesn't help. Reproduce-locally chains after
266
+ // that for users with nixpacks installed.
267
+ const inspectAlt = {
268
+ action: "inspect_build_log",
269
+ suggestedTool: "percher_deploys_inspect",
270
+ args: failure.deployId
271
+ ? { id: failure.deployId, app: failure.appName }
272
+ : { latestFailed: true, app: failure.appName },
273
+ when: "after percher_doctor's recovery didn't yield a fix and you want to read the raw build log directly",
274
+ };
275
+ const alternativeActions = [inspectAlt];
276
+ if (reproduceAlt) {
277
+ alternativeActions.push({
278
+ ...reproduceAlt,
279
+ when: "after percher_doctor + percher_deploys_inspect didn't surface a clear fix and the user has nixpacks installed locally",
280
+ });
281
+ }
282
+ return recoveryDoctor({
283
+ app: failure.appName,
284
+ deployId: failure.deployId,
285
+ mode: "deploy",
286
+ reasonCode: "build_failed",
287
+ alternativeActions,
288
+ });
289
+ }
290
+ default:
291
+ // Exhaustiveness fallback. New `ErrorClass` values land here until a
292
+ // mapping is added — better than misclassifying as `retry`.
293
+ return recoveryAsk({
294
+ prompt: "Unexpected failure — Percher couldn't classify this error. Try `percher doctor` for diagnostics, or surface the error to the user.",
295
+ reasonCode: "unknown",
296
+ });
297
+ }
298
+ }
299
+ //# sourceMappingURL=recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAyQA,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,iEAAiE;AAEjE,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,OAAkD,EAAE;IAC/E,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM;QACrC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,OAAoC,EAAE;IAClE,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,YAAY;QACxB,aAAa,EAAE,eAAe;QAC9B,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,eAAe;KAC/C,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,IAK5B;IACC,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,aAAa;QACzB,aAAa,EAAE,yBAAyB;QACxC,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,EAAE;SAC1C;QACD,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,cAAc,CAAC,IAM9B;IACC,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,IAAI,IAAI,CAAC,GAAG,K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AI,EAAE,oGAAoG;aAC3G,CAAC;YACF,MAAM,kBAAkB,GAA0B,CAAC,UAAU,CAAC,CAAC;YAC/D,IAAI,YAAY,EAAE,CAAC;gBACjB,kBAAkB,CAAC,IAAI,CAAC;oBACtB,GAAG,YAAY;oBACf,IAAI,EAAE,uHAAuH;iBAC9H,CAAC,CAAC;YACL,CAAC;YACD,OAAO,cAAc,CAAC;gBACpB,GAAG,EAAE,OAAO,CAAC,OAAO;gBACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,cAAc;gBAC1B,kBAAkB;aACnB,CAAC,CAAC;QACL,CAAC;QAED;YACE,qEAAqE;YACrE,4DAA4D;YAC5D,OAAO,WAAW,CAAC;gBACjB,MAAM,EACJ,oIAAoI;gBACtI,UAAU,EAAE,SAAS;aACtB,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Cross-runtime streaming file write.
3
+ *
4
+ * Both the CLI and MCP server advertise Node.js compatibility
5
+ * (`npx percher`, `npx -y @percher/mcp`). The core package must not
6
+ * call Bun globals directly.
7
+ *
8
+ * In Bun: Bun.write(path, Response) streams to disk natively and
9
+ * returns the byte count — zero intermediate allocation.
10
+ *
11
+ * In Node.js 18+: we use Readable.fromWeb() + pipeline() to pipe the
12
+ * Web ReadableStream from the fetch Response to a fs.createWriteStream.
13
+ * The byte count is read back from fs.stat after the pipeline finishes.
14
+ */
15
+ /**
16
+ * Node.js fallback — exported for direct testing so we don't need to
17
+ * mask the read-only Bun global in tests.
18
+ */
19
+ export declare function writeResponseToFileNode(res: Response, filePath: string): Promise<number>;
20
+ export declare function writeResponseToFile(res: Response, filePath: string): Promise<number>;
21
+ //# sourceMappingURL=stream-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-utils.d.ts","sourceRoot":"","sources":["../src/stream-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB9F;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ1F"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Cross-runtime streaming file write.
3
+ *
4
+ * Both the CLI and MCP server advertise Node.js compatibility
5
+ * (`npx percher`, `npx -y @percher/mcp`). The core package must not
6
+ * call Bun globals directly.
7
+ *
8
+ * In Bun: Bun.write(path, Response) streams to disk natively and
9
+ * returns the byte count — zero intermediate allocation.
10
+ *
11
+ * In Node.js 18+: we use Readable.fromWeb() + pipeline() to pipe the
12
+ * Web ReadableStream from the fetch Response to a fs.createWriteStream.
13
+ * The byte count is read back from fs.stat after the pipeline finishes.
14
+ */
15
+ /**
16
+ * Node.js fallback — exported for direct testing so we don't need to
17
+ * mask the read-only Bun global in tests.
18
+ */
19
+ export async function writeResponseToFileNode(res, filePath) {
20
+ if (!res.body)
21
+ throw new Error("Server returned empty response body");
22
+ const { createWriteStream } = await import("node:fs");
23
+ const { stat } = await import("node:fs/promises");
24
+ const { Readable } = await import("node:stream");
25
+ const { pipeline } = await import("node:stream/promises");
26
+ const fileStream = createWriteStream(filePath);
27
+ // fromWeb converts a WHATWG ReadableStream to a Node.js Readable.
28
+ // The cast is needed because TypeScript's Node typedefs require
29
+ // stream.web.ReadableStream but fetch returns the global ReadableStream.
30
+ const nodeReadable = Readable.fromWeb(res.body);
31
+ await pipeline(nodeReadable, fileStream);
32
+ const { size } = await stat(filePath);
33
+ return size;
34
+ }
35
+ export async function writeResponseToFile(res, filePath) {
36
+ if (typeof Bun !== "undefined") {
37
+ return Bun.write(filePath, res);
38
+ }
39
+ return writeResponseToFileNode(res, filePath);
40
+ }
41
+ //# sourceMappingURL=stream-utils.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_MD: {
2
+ id: "claude-md";
3
+ path: string;
4
+ version: string;
5
+ content: string;
6
+ };
7
+ //# sourceMappingURL=claude-md.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-md.d.ts","sourceRoot":"","sources":["../../../src/templates/ai-files/claude-md.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;CA4ErB,CAAC"}
@@ -0,0 +1,78 @@
1
+ export const CLAUDE_MD = {
2
+ id: "claude-md",
3
+ path: "CLAUDE.md",
4
+ version: "1.0.0",
5
+ content: `# CLAUDE.md — Percher publishing instructions
6
+
7
+ This project is hosted on **Percher** (https://percher.app). Apps run
8
+ at \`<name>.percher.run\`.
9
+
10
+ ## Publishing
11
+
12
+ \`\`\`bash
13
+ bunx percher publish
14
+ \`\`\`
15
+
16
+ This single command:
17
+ - Auto-generates \`percher.toml\` if missing
18
+ - Logs in via device-code if not already authenticated
19
+ - Packages, uploads, builds, deploys
20
+ - Returns the live URL
21
+
22
+ ## Setting secrets
23
+
24
+ Never put secret values in \`percher.toml\` or anywhere in source.
25
+
26
+ \`\`\`bash
27
+ # from a file:
28
+ bunx percher env set DATABASE_URL --from-file ./secret.txt
29
+
30
+ # from stdin (CI / scripts):
31
+ echo "$MY_SECRET" | bunx percher env set DATABASE_URL --from-stdin
32
+
33
+ # interactive (you type, no echo):
34
+ bunx percher env set DATABASE_URL
35
+ \`\`\`
36
+
37
+ ## Daily commands
38
+
39
+ | Command | What it does |
40
+ | -------------------------------- | --------------------------------------------- |
41
+ | \`bunx percher publish\` | Build + deploy this project. |
42
+ | \`bunx percher dev\` | Watch files, redeploy on change, stream logs. |
43
+ | \`bunx percher logs\` | Tail runtime logs. |
44
+ | \`bunx percher logs --build\` | Show last failed build's full log. |
45
+ | \`bunx percher deploys\` | List recent deploys with status. |
46
+ | \`bunx percher rollback <sha>\` | Roll back to a previous version. |
47
+ | \`bunx percher doctor\` | Diagnose config / connectivity. |
48
+ | \`bunx percher env list\` | Show env vars (values masked). |
49
+
50
+ ## MCP
51
+
52
+ For MCP-aware editors (Claude Code, Cursor, Windsurf), run
53
+ \`bunx percher mcp\` to print a paste-ready config block.
54
+
55
+ ## When the build fails
56
+
57
+ Don't guess. Run:
58
+
59
+ \`\`\`bash
60
+ bunx percher logs --build
61
+ \`\`\`
62
+
63
+ The output ends with the actual compiler/builder error. Show it back,
64
+ fix the root cause, and retry.
65
+
66
+ ## Don'ts
67
+
68
+ - Don't add \`percher.toml\` fields not in the documented schema.
69
+ - Don't commit secrets — use \`percher env set\`.
70
+ - Don't use \`--no-verify\` or other bypass flags on git operations.
71
+ - Don't \`rm -rf\` the \`.percher/\` directory — it tracks managed
72
+ AI-files. Use \`bunx percher ai-files remove\` instead.
73
+
74
+ This file is managed by \`bunx percher ai-files\`. Run
75
+ \`bunx percher ai-files update\` to pull updates.
76
+ `,
77
+ };
78
+ //# sourceMappingURL=claude-md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-md.js","sourceRoot":"","sources":["../../../src/templates/ai-files/claude-md.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,WAAoB;IACxB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEV;CACA,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const CURSOR_PERCHER_MDC: {
2
+ id: "cursor-percher-mdc";
3
+ path: string;
4
+ version: string;
5
+ content: string;
6
+ };
7
+ //# sourceMappingURL=cursor-percher-mdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-percher-mdc.d.ts","sourceRoot":"","sources":["../../../src/templates/ai-files/cursor-percher-mdc.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;CA6G9B,CAAC"}
@@ -0,0 +1,111 @@
1
+ export const CURSOR_PERCHER_MDC = {
2
+ id: "cursor-percher-mdc",
3
+ path: ".cursor/rules/percher.mdc",
4
+ version: "1.0.0",
5
+ content: `---
6
+ description: How to publish this project to Percher
7
+ globs: ["percher.toml", "**/*.{ts,tsx,js,jsx,py}"]
8
+ alwaysApply: false
9
+ ---
10
+
11
+ # Publishing to Percher
12
+
13
+ Percher hosts AI-built web apps. The user says "publish my app" → it's
14
+ live at \`name.percher.run\`.
15
+
16
+ ## Quick reference
17
+
18
+ - **CLI:** \`bunx percher\` (or \`npx percher\`)
19
+ - **Config:** \`percher.toml\` in project root
20
+ - **Deploy:** \`bunx percher publish\` — handles auth, config, build, deploy
21
+ - **Dashboard:** https://percher.app
22
+
23
+ ## Before deploying
24
+
25
+ 1. Check \`percher.toml\` exists. If not, run \`bunx percher init\` (or just
26
+ run \`publish\` — it auto-generates one).
27
+ 2. Make sure secrets are set: \`bunx percher env set KEY --from-stdin\`
28
+ (or \`KEY=VALUE\` for non-secrets).
29
+ 3. For secrets, never use \`KEY=VALUE\` — use \`--from-stdin\`,
30
+ \`--from-file <path>\`, or bare \`KEY\` (interactive prompt).
31
+
32
+ ## Common percher.toml shapes
33
+
34
+ \`\`\`toml
35
+ # Next.js
36
+ [app]
37
+ name = "my-app"
38
+ runtime = "node"
39
+ framework = "nextjs"
40
+ [build]
41
+ command = "bun run build"
42
+ output = ".next"
43
+ [web]
44
+ port = 3000
45
+ health = "/api/health"
46
+ [data]
47
+ mode = "pocketbase"
48
+ \`\`\`
49
+
50
+ \`\`\`toml
51
+ # Static (Vite, plain HTML)
52
+ [app]
53
+ name = "my-app"
54
+ runtime = "static"
55
+ [build]
56
+ command = "bun run build"
57
+ output = "dist"
58
+ \`\`\`
59
+
60
+ ## Build-time public env vars
61
+
62
+ Frameworks like Next/Vite/Astro bake \`*_PUBLIC_*\` values into the bundle
63
+ at build time. Vars matching the public-prefix conventions
64
+ (\`NEXT_PUBLIC_*\`, \`VITE_*\`, \`PUBLIC_*\`, \`REACT_APP_*\`, \`VUE_APP_*\`,
65
+ \`EXPO_PUBLIC_*\`) auto-forward to the build container — just \`bunx percher
66
+ env set NEXT_PUBLIC_API_URL=…\` and it lands in the bundle on the next
67
+ deploy. No TOML changes needed.
68
+
69
+ Server-secret build tokens that DON'T match a prefix (Sentry source-map
70
+ upload, private npm registries) require explicit opt-in:
71
+
72
+ \`\`\`toml
73
+ [build]
74
+ pass_env = ["SENTRY_AUTH_TOKEN", "NPM_TOKEN"]
75
+ \`\`\`
76
+
77
+ Values still come from \`bunx percher env set …\`; the TOML only declares
78
+ which non-prefix keys leak into the build.
79
+
80
+ ## Outbound HTTPS
81
+
82
+ Apps reach the public internet through a forward proxy. Bun's \`fetch\`
83
+ and Node 24+ \`fetch\` (with \`NODE_USE_ENV_PROXY=1\`, set automatically)
84
+ honor it. Node ≤22 needs:
85
+
86
+ \`\`\`ts
87
+ import { ProxyAgent, setGlobalDispatcher } from "undici";
88
+ if (process.env.HTTPS_PROXY) {
89
+ setGlobalDispatcher(new ProxyAgent(process.env.HTTPS_PROXY));
90
+ }
91
+ \`\`\`
92
+
93
+ ## When something fails
94
+
95
+ - \`bunx percher logs\` — runtime logs
96
+ - \`bunx percher logs --build\` — last failed build's log
97
+ - \`bunx percher doctor\` — connectivity + config check
98
+ - \`bunx percher deploys --limit 5\` — recent deploys + status
99
+
100
+ ## Rules
101
+
102
+ 1. Never put real secrets in \`percher.toml\`. Use \`bunx percher env set\`.
103
+ 2. Never invent \`percher.toml\` fields. Stick to documented schema.
104
+ 3. Always add a \`/health\` endpoint when the framework has a server.
105
+ 4. \`percher.toml\` is the source of truth — read from it, don't guess.
106
+
107
+ This file is managed by \`bunx percher ai-files\`. Run
108
+ \`bunx percher ai-files update\` to pull updates.
109
+ `,
110
+ };
111
+ //# sourceMappingURL=cursor-percher-mdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-percher-mdc.js","sourceRoot":"","sources":["../../../src/templates/ai-files/cursor-percher-mdc.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,EAAE,EAAE,oBAA6B;IACjC,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGV;CACA,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface AiFileTemplate {
2
+ id: string;
3
+ path: string;
4
+ version: string;
5
+ content: string;
6
+ }
7
+ export declare const AI_FILE_TEMPLATES: readonly AiFileTemplate[];
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/ai-files/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAAoC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { CLAUDE_MD } from "./claude-md";
2
+ import { CURSOR_PERCHER_MDC } from "./cursor-percher-mdc";
3
+ export const AI_FILE_TEMPLATES = [CLAUDE_MD, CURSOR_PERCHER_MDC];
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/ai-files/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS1D,MAAM,CAAC,MAAM,iBAAiB,GAA8B,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percher/core",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Core logic and CLI commands for the Percher hosting platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,11 +29,11 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
- "@percher/client": "^0.2.0",
33
- "@percher/toml": "^0.1.1",
34
- "ignore": "^6.0.2",
32
+ "@percher/client": "^0.2.7",
33
+ "@percher/toml": "^0.1.3",
34
+ "ignore": "^7.0.5",
35
35
  "tar-stream": "^3.1.7",
36
- "zod": "^3.23.8"
36
+ "zod": "^4.3.6"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/tar-stream": "^3.1.3",