@jini-ai/agent-plugins 0.7.2 → 0.7.3-next.2

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 (236) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/NOTICE +2 -0
  3. package/README.md +11 -15
  4. package/calendly/plugin.json +3 -3
  5. package/cloudflare/lib/forms.mjs +9 -10
  6. package/cloudflare/lib/target.mjs +1 -1
  7. package/cloudflare/plugin.json +3 -3
  8. package/cloudflare/worker/forms-receiver.mjs +9 -9
  9. package/composio/plugin.json +3 -3
  10. package/core/persistent-state.js +227 -163
  11. package/dist/admin-surfaces/connections/connections.d.ts +11 -6
  12. package/dist/admin-surfaces/connections/connections.js +102 -85
  13. package/dist/admin-surfaces/node.d.ts +27 -0
  14. package/dist/admin-surfaces/node.js +32 -0
  15. package/dist/admin-surfaces/plugin-state.js +21 -18
  16. package/dist/admin-surfaces/surface-client.d.ts +4 -0
  17. package/dist/admin-surfaces/surface-client.js +124 -117
  18. package/dist/admin-surfaces/surface-handlers.js +21 -17
  19. package/dist/admin-surfaces/theme.d.ts +5 -1
  20. package/dist/admin-surfaces/theme.js +3 -3
  21. package/dist/connect/access-token-tool.d.ts +3 -1
  22. package/dist/connect/access-token-tool.js +3 -2
  23. package/dist/connect/apply-connect-defaults.js +2 -2
  24. package/dist/connect/apply-tool-renames.js +9 -8
  25. package/dist/connect/connect-tool.d.ts +2 -0
  26. package/dist/connect/connect-tool.js +3 -2
  27. package/dist/connect/credential-cards.js +3 -2
  28. package/dist/connect/credential-save-tool.d.ts +14 -11
  29. package/dist/connect/credential-save-tool.js +128 -121
  30. package/dist/connect/enable-access.d.ts +2 -2
  31. package/dist/connect/enable-access.js +6 -6
  32. package/dist/connect/executable/register.js +40 -34
  33. package/dist/connect/federate-mcp.d.ts +21 -11
  34. package/dist/connect/federate-mcp.js +28 -21
  35. package/dist/connect/grant-signed-in-defaults.js +3 -3
  36. package/dist/connect/import-access-token.js +2 -1
  37. package/dist/connect/index.d.ts +1 -0
  38. package/dist/connect/index.js +1 -0
  39. package/dist/connect/plugin-credential-card.js +2 -1
  40. package/dist/connect/plugin-host/index.d.ts +10 -5
  41. package/dist/connect/plugin-host/index.js +113 -100
  42. package/dist/connect/ports.d.ts +1 -1
  43. package/dist/connect/row-update.d.ts +22 -0
  44. package/dist/connect/row-update.js +18 -0
  45. package/dist/connect/switch-on-saved-token.d.ts +4 -2
  46. package/dist/connect/switch-on-saved-token.js +1 -1
  47. package/dist/connect/token-map.d.ts +44 -0
  48. package/dist/connect/token-map.js +49 -0
  49. package/dist/core/identity-namespace.js +5 -0
  50. package/dist/folder-zip.d.ts +3 -1
  51. package/dist/folder-zip.js +2 -2
  52. package/dist/lifecycle/activation.d.ts +4 -4
  53. package/dist/lifecycle/activation.js +4 -5
  54. package/dist/lifecycle/automatic-use.js +236 -210
  55. package/dist/lifecycle/bundled-digests.d.ts +75 -12
  56. package/dist/lifecycle/bundled-digests.js +213 -212
  57. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  58. package/dist/lifecycle/bundled-source-archive.js +263 -264
  59. package/dist/lifecycle/capability-projection.d.ts +1 -1
  60. package/dist/lifecycle/capability-projection.js +1 -1
  61. package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
  62. package/dist/lifecycle/credential-card-metadata.js +27 -3
  63. package/dist/lifecycle/exports.js +9 -4
  64. package/dist/lifecycle/fetch-archive.d.ts +1 -1
  65. package/dist/lifecycle/fetch-archive.js +1 -1
  66. package/dist/lifecycle/host-tools/identity.js +3 -2
  67. package/dist/lifecycle/host-tools/ports.d.ts +2 -0
  68. package/dist/lifecycle/host-tools/search-tool.d.ts +4 -2
  69. package/dist/lifecycle/host-tools/search-tool.js +9 -8
  70. package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
  71. package/dist/lifecycle/host-tools/skill-tool.js +16 -8
  72. package/dist/lifecycle/index.d.ts +118 -110
  73. package/dist/lifecycle/index.js +45 -12
  74. package/dist/lifecycle/install-errors.d.ts +1 -1
  75. package/dist/lifecycle/install-from-url.d.ts +1 -1
  76. package/dist/lifecycle/install-from-url.js +1 -1
  77. package/dist/lifecycle/install.d.ts +7 -2
  78. package/dist/lifecycle/install.js +414 -396
  79. package/dist/lifecycle/installed-package-index.js +45 -42
  80. package/dist/lifecycle/layout.d.ts +1 -1
  81. package/dist/lifecycle/layout.js +1 -1
  82. package/dist/lifecycle/mail/catalog.d.ts +8 -32
  83. package/dist/lifecycle/mail/catalog.js +25 -20
  84. package/dist/lifecycle/mail/contribution.d.ts +2 -2
  85. package/dist/lifecycle/mail/contribution.js +34 -34
  86. package/dist/lifecycle/mail/selection.js +6 -2
  87. package/dist/lifecycle/manifest.d.ts +3 -3
  88. package/dist/lifecycle/manifest.js +4 -4
  89. package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
  90. package/dist/lifecycle/mcp-provisioning.js +3 -3
  91. package/dist/lifecycle/package-paths.d.ts +1 -1
  92. package/dist/lifecycle/package-paths.js +1 -1
  93. package/dist/lifecycle/persistent-state.js +1 -2
  94. package/dist/lifecycle/ports.d.ts +5 -1
  95. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
  96. package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
  97. package/dist/lifecycle/retire-bundled.d.ts +1 -52
  98. package/dist/lifecycle/retire-bundled.js +134 -84
  99. package/dist/lifecycle/search.d.ts +2 -1
  100. package/dist/lifecycle/search.js +1 -1
  101. package/dist/lifecycle/seed-bundled.d.ts +1 -1
  102. package/dist/lifecycle/seed-bundled.js +154 -155
  103. package/dist/lifecycle/set-enabled.d.ts +1 -1
  104. package/dist/lifecycle/set-enabled.js +1 -1
  105. package/dist/lifecycle/skill-file-reader.js +53 -50
  106. package/dist/lifecycle/tools/projection.d.ts +4 -7
  107. package/dist/lifecycle/tools/projection.js +109 -108
  108. package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
  109. package/dist/lifecycle/trusted-plugin-files.js +1 -1
  110. package/dist/lifecycle/uninstall.d.ts +1 -1
  111. package/dist/lifecycle/uninstall.js +237 -241
  112. package/dist/lifecycle/update-store.js +20 -17
  113. package/dist/lifecycle/update.js +287 -281
  114. package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
  115. package/dist/lifecycle/yauzl-archive-reader.js +8 -2
  116. package/dist/manifest.d.ts +11 -3
  117. package/dist/manifest.js +9 -9
  118. package/fly/jini-credential-schemes.json +11 -0
  119. package/fly/plugin.json +3 -4
  120. package/github/plugin.json +3 -3
  121. package/github/source-control/backup-push.mjs +11 -11
  122. package/github/source-control/commit-site.mjs +23 -13
  123. package/github/source-control/github.mjs +12 -6
  124. package/github/source-control/write-files.mjs +27 -28
  125. package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
  126. package/github-pages/plugin.json +3 -3
  127. package/github-pages/targets/github-pages.mjs +3 -3
  128. package/google-login/plugin.json +3 -3
  129. package/google-workspace/README.md +14 -14
  130. package/google-workspace/form-destinations/README.md +3 -3
  131. package/google-workspace/form-destinations/dedupe.mjs +1 -1
  132. package/google-workspace/form-destinations/mapping.mjs +8 -9
  133. package/google-workspace/form-destinations/sheets.mjs +1 -1
  134. package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
  135. package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
  136. package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
  137. package/google-workspace/lib/auth.mjs +2 -2
  138. package/google-workspace/lib/form-destination-settings.mjs +1 -1
  139. package/google-workspace/lib/picker-flow.mjs +2 -2
  140. package/google-workspace/lib/request-policy.mjs +1 -1
  141. package/google-workspace/lib/surface-actions.mjs +1 -1
  142. package/google-workspace/plugin.json +3 -3
  143. package/google-workspace/tools/sheets/README.md +3 -3
  144. package/google-workspace/tools/sheets-admin/README.md +3 -3
  145. package/google-workspace/ui/README.md +4 -4
  146. package/google-workspace/ui/connection-panel.mjs +51 -51
  147. package/google-workspace/ui/destination-panel.mjs +34 -34
  148. package/google-workspace/ui/dom.mjs +15 -16
  149. package/google-workspace/ui/picker-flow.mjs +2 -2
  150. package/google-workspace/ui/picker.mjs +19 -19
  151. package/google-workspace/ui/surface-client.mjs +96 -69
  152. package/higgsfield-media/plugin.json +3 -3
  153. package/jev/plugin.json +3 -3
  154. package/kuinetic/CHANGELOG.md +12 -0
  155. package/kuinetic/mcp.json +4 -0
  156. package/kuinetic/plugin.json +27 -0
  157. package/kuinetic/skills/kuinetic/SKILL.md +120 -0
  158. package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
  159. package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
  160. package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
  161. package/meilisearch/plugin.json +5 -5
  162. package/netlify/plugin.json +3 -3
  163. package/netlify/targets/netlify.mjs +14 -4
  164. package/opentelemetry/plugin.json +3 -3
  165. package/package.json +27 -22
  166. package/posthog/plugin.json +3 -3
  167. package/railway/plugin.json +3 -3
  168. package/render/plugin.json +3 -3
  169. package/resend/NOTES.md +2 -2
  170. package/resend/adapters/resend.mjs +1 -1
  171. package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
  172. package/resend/lib/domains.mjs +8 -8
  173. package/resend/plugin.json +3 -3
  174. package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
  175. package/s3-compatible/jini-object-stores.json +29 -0
  176. package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
  177. package/s3-compatible/plugin.json +3 -3
  178. package/s3-compatible/targets/s3-compatible.mjs +25 -25
  179. package/sentry/plugin.json +3 -3
  180. package/shadcn-ui/CHANGELOG.md +7 -0
  181. package/shadcn-ui/LICENSE +201 -0
  182. package/shadcn-ui/NOTICE +10 -0
  183. package/shadcn-ui/mcp.json +4 -0
  184. package/shadcn-ui/plugin.json +26 -0
  185. package/shopify/plugin.json +3 -3
  186. package/site-compliance/plugin.json +3 -3
  187. package/site-import/plugin.json +3 -3
  188. package/supabase/mcp.json +1 -4
  189. package/supabase/plugin.json +3 -3
  190. package/ui-ux-design/CHANGELOG.md +13 -0
  191. package/ui-ux-design/NOTICE +2 -0
  192. package/ui-ux-design/README.md +17 -7
  193. package/ui-ux-design/plugin.json +6 -3
  194. package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
  195. package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
  196. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
  197. package/vercel/NOTES.md +1 -1
  198. package/vercel/object-stores/vercel-blob.mjs +12 -2
  199. package/vercel/plugin.json +3 -3
  200. package/vercel/targets/vercel.mjs +3 -3
  201. package/wordpress/plugin.json +3 -3
  202. package/dist/lifecycle/node.d.ts +0 -11
  203. package/dist/lifecycle/node.js +0 -38
  204. package/fly/tovu-credential-schemes.json +0 -11
  205. package/github/deployments/github.mjs +0 -415
  206. package/s3-compatible/tovu-object-stores.json +0 -29
  207. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
  208. /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
  209. /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  210. /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  211. /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  212. /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  213. /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  214. /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
  215. /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
  216. /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  217. /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
  218. /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
  219. /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  220. /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  221. /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  222. /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  223. /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  224. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
  225. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
  226. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
  227. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
  228. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
  229. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
  230. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
  231. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
  232. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
  233. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
  234. /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
  235. /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  236. /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
@@ -15,7 +15,7 @@
15
15
  * `install.ts`'s hardening logic.
16
16
  *
17
17
  * ---------------------------------------------------------------------------
18
- * Symlink detection — the one thing this file has to get right that yauzl doesn't do for you
18
+ * Unix entry classification — symlinks, FIFOs and other special types are refused kinds
19
19
  * ---------------------------------------------------------------------------
20
20
  * The base ZIP spec has no first-class symlink concept. The de facto convention (Info-ZIP, Python's
21
21
  * `zipfile`, and this module's own `yazl`-based test fixtures all follow it) is: when an entry's
@@ -57,5 +57,5 @@ export interface YauzlPort {
57
57
  import type { AgentPluginArchiveReaderPort } from "./install.js";
58
58
  export declare function createYauzlAgentPluginArchiveReader({ yauzl }: {
59
59
  readonly yauzl: YauzlPort;
60
- }): AgentPluginArchiveReaderPort;
60
+ }, _optional?: Record<string, never>): AgentPluginArchiveReaderPort;
61
61
  //# sourceMappingURL=yauzl-archive-reader.d.ts.map
@@ -3,6 +3,9 @@
3
3
  */
4
4
  const S_IFMT = 0xf000;
5
5
  const S_IFLNK = 0xa000;
6
+ const S_IFIFO = 0x1000;
7
+ const S_IFDIR = 0x4000;
8
+ const S_IFREG = 0x8000;
6
9
  /**
7
10
  * "Version made by" host-system byte for Unix, per the ZIP spec's APPNOTE.TXT §4.4.2.2.
8
11
  */
@@ -11,7 +14,7 @@ const UNIX_HOST_SYSTEM = 3;
11
14
  * Any bit in the standard rwx-for-owner/group/other executable mask.
12
15
  */
13
16
  const EXECUTABLE_MODE_MASK = 0o111;
14
- export function createYauzlAgentPluginArchiveReader({ yauzl }) {
17
+ export function createYauzlAgentPluginArchiveReader({ yauzl }, _optional = {}) {
15
18
  return {
16
19
  async *entries({ archive }) {
17
20
  /**
@@ -50,8 +53,11 @@ function archiveEntryFor(zipfile, entry) {
50
53
  * module's header. `install.ts` rejects every symlink entry unconditionally.
51
54
  */
52
55
  const unixMode = readUnixMode(entry);
53
- if (unixMode !== null && (unixMode & S_IFMT) === S_IFLNK)
56
+ const fileType = unixMode === null ? 0 : unixMode & S_IFMT;
57
+ if (fileType === S_IFLNK)
54
58
  return { kind: "symlink", entryPath: entry.fileName };
59
+ if (![0, S_IFREG, S_IFDIR].includes(fileType))
60
+ return { kind: fileType === S_IFIFO ? "fifo" : "device", entryPath: entry.fileName };
55
61
  // File mode defines links even when a hostile filename masquerades as a directory.
56
62
  if (entry.fileName.endsWith("/"))
57
63
  return { kind: "directory", entryPath: entry.fileName };
@@ -37,7 +37,11 @@ export interface PluginManifest {
37
37
  readonly extensions?: Readonly<Record<string, unknown>>;
38
38
  readonly [key: string]: unknown;
39
39
  }
40
- export declare function isPluginManifest(value: unknown): value is PluginManifest;
40
+ export declare function isPluginManifest(required: {
41
+ readonly value: unknown;
42
+ }, _optional?: Record<string, never>): required is {
43
+ readonly value: PluginManifest;
44
+ };
41
45
  export type McpServerEntry = {
42
46
  readonly type: 'stdio';
43
47
  readonly command: string;
@@ -57,7 +61,11 @@ export interface McpManifest {
57
61
  readonly $schema?: string;
58
62
  readonly mcpServers: Readonly<Record<string, McpServerEntry>>;
59
63
  }
60
- export declare function isMcpManifest(value: unknown): value is McpManifest;
64
+ export declare function isMcpManifest(required: {
65
+ readonly value: unknown;
66
+ }, _optional?: Record<string, never>): required is {
67
+ readonly value: McpManifest;
68
+ };
61
69
  /** Object-argument facade for the legacy structural validator.
62
70
  * Hosts inject identityNamespace; the default is `jini`, with a legacy-key fallback. */
63
71
  export declare function validatePluginManifest(required: {
@@ -68,5 +76,5 @@ export declare function validatePluginManifest(required: {
68
76
  /** Object-argument facade for the legacy structural validator. */
69
77
  export declare function validateMcpManifest(required: {
70
78
  readonly value: unknown;
71
- }): boolean;
79
+ }, _optional?: Record<string, never>): boolean;
72
80
  //# sourceMappingURL=manifest.d.ts.map
package/dist/manifest.js CHANGED
@@ -17,25 +17,25 @@ export const AGENT_PLUGINS_MCP_SCHEMA_URL = 'https://agent-plugins.org/schemas/1
17
17
  export const PLUGIN_MANIFEST_FILENAME = 'plugin.json';
18
18
  export const PLUGIN_SKILLS_DIRNAME = 'skills';
19
19
  export const PLUGIN_MCP_MANIFEST_FILENAME = 'mcp.json';
20
- export function isPluginManifest(value) {
21
- if (typeof value !== 'object' || value === null)
20
+ export function isPluginManifest(required, _optional = {}) {
21
+ if (typeof required.value !== 'object' || required.value === null)
22
22
  return false;
23
- const name = value.name;
23
+ const name = required.value.name;
24
24
  return typeof name === 'string' && name.trim().length > 0;
25
25
  }
26
- export function isMcpManifest(value) {
27
- if (typeof value !== 'object' || value === null)
26
+ export function isMcpManifest(required, _optional = {}) {
27
+ if (typeof required.value !== 'object' || required.value === null)
28
28
  return false;
29
- const servers = value.mcpServers;
29
+ const servers = required.value.mcpServers;
30
30
  return typeof servers === 'object' && servers !== null && !Array.isArray(servers);
31
31
  }
32
32
  /** Object-argument facade for the legacy structural validator.
33
33
  * Hosts inject identityNamespace; the default is `jini`, with a legacy-key fallback. */
34
34
  export function validatePluginManifest(required, optional = {}) {
35
- return isPluginManifest(required.value) && validatePluginIdentity({ manifest: required.value, namespace: resolveAgentPluginIdentityNamespace(required, optional) }).errors.length === 0;
35
+ return isPluginManifest(required) && validatePluginIdentity({ manifest: required.value, namespace: resolveAgentPluginIdentityNamespace(required, optional) }).errors.length === 0;
36
36
  }
37
37
  /** Object-argument facade for the legacy structural validator. */
38
- export function validateMcpManifest(required) {
39
- return isMcpManifest(required.value);
38
+ export function validateMcpManifest(required, _optional = {}) {
39
+ return isMcpManifest(required);
40
40
  }
41
41
  //# sourceMappingURL=manifest.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "schemes": [
4
+ {
5
+ "id": "fly-io",
6
+ "prefix": "FlyV1",
7
+ "scheme": "FlyV1",
8
+ "note": "Fly.io tokens (e.g. FlyV1fm2_..., a macaroon) carry their own Authorization scheme word. Verified live 2026-09-03 against the endpoint shape https://api.machines.dev/v1/apps/<app-name>/machines with two independently generated tokens: 'Authorization: Bearer FlyV1fm2_...' (whole token) returned 401 {\"error\":\"Authenticate: token validation error\"}; 'Authorization: FlyV1 fm2_...' (FlyV1 moved to the scheme, remainder as the value) returned 200 with real machine data. Both tokens behaved identically, so it is a scheme problem, not scope or expiry. The 401's WWW-Authenticate header (Basic realm=\"api.machines.dev\") does not name the real scheme, so it cannot be derived from the server's challenge and must be declared here."
9
+ }
10
+ ]
11
+ }
package/fly/plugin.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "fly",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "description": "Deploys the host's server to fly.io: one machine only for volume-backed state, secrets never in fly.toml, deploying ships code, not content. Contributes Fly operations, server config generation and the FlyV1 credential scheme.",
6
- "author": "Tovu",
6
+ "author": "Jini",
7
7
  "license": "Apache-2.0",
8
8
  "extensions": {
9
9
  "jini": {
@@ -19,8 +19,7 @@
19
19
  { "env": "FLY_MACHINE_ID", "facts": { "nativeToolsRestricted": true } },
20
20
  { "env": "FLY_ALLOC_ID", "facts": { "nativeToolsRestricted": true } }
21
21
  ],
22
- "deploymentAdvice": "Set TOVU_RUNTIME_MODE=production (fly.toml and docker-compose.yml already do).",
23
- "id": "tovu/fly",
22
+ "id": "jini/fly",
24
23
  "provides": [
25
24
  "deploy-ops:fly",
26
25
  "deploy-config:fly",
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "github",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "Everything a host's assistant needs to work against a GitHub repository through the workspace's own saved credentials, with no git, no gh CLI, and no token ever passing through the assistant: writing and updating files in one atomic commit, dispatching and following a GitHub Actions run, reading a failed run's logs, committing the site's rendered static export, backing up the site itself (database, media, themes, plugins, settings) to a private repository, and deploying the host's server through its GitHub Actions deploy workflow (the `github-actions` deployment ops platform). Encodes the rules that generic GitHub knowledge gets wrong here — a 204 dispatch means queued and never deployed, a workflow only fires on the branch its own trigger names, a repository secret is the human's step and never the assistant's, a 403 on an org-wide listing is a normal app-scoped-token boundary rather than a broken credential, and editing an existing file means diffing the MODIFIED files and not only the added and deleted ones.",
6
- "author": "Tovu",
6
+ "author": "Jini",
7
7
  "license": "Apache-2.0",
8
8
  "extensions": {
9
9
  "jini": {
10
10
  "vendorAliases": ["github_pat_"],
11
11
  "displayName": "GitHub",
12
12
  "summary": "Lets the assistant save your site's files to GitHub, run builds there, and back up your whole site.",
13
- "id": "tovu/github",
13
+ "id": "jini/github",
14
14
  "provides": [
15
15
  "source-control",
16
16
  "site-backup",
@@ -80,7 +80,7 @@ function treeEntry(entry) {
80
80
  }
81
81
 
82
82
  /** @param {GitDataClient} git */
83
- export function createBackupPusher(git) {
83
+ export function createBackupPusher(git, _optional = {}) {
84
84
  /** @param {{ json: any, name: string }} required */
85
85
  function checkBackupPrivacy({ json, name }, _options = {}) {
86
86
  const fallbackVisibility = json.private === true ? "private" : "public";
@@ -112,8 +112,8 @@ export function createBackupPusher(git) {
112
112
  if (typeof permissions === "object" && permissions !== null && permissions.push === false) {
113
113
  return { ok: false, code: "no-push-permission", message: `this credential can read ${name} but cannot push to it` };
114
114
  }
115
- const defaultBranch = extractStringField(json, "default_branch");
116
- const htmlUrl = extractStringField(json, "html_url");
115
+ const defaultBranch = extractStringField({ value: json, field: "default_branch" });
116
+ const htmlUrl = extractStringField({ value: json, field: "html_url" });
117
117
  if (!defaultBranch || !htmlUrl) return { ok: false, code: PROVIDER_ERROR, message: "GitHub repository lookup response did not include a default branch or URL" };
118
118
  return { ok: true, defaultBranch, htmlUrl };
119
119
  }
@@ -121,16 +121,16 @@ export function createBackupPusher(git) {
121
121
  /** GitHub answers 409 for the ref of an EMPTY repository. @param {Target} target @param {string} branch */
122
122
  async function readBranchTip(target, branch) {
123
123
  const name = `${target.owner}/${target.repo}`;
124
- const refResult = await git.send(target, { method: "GET", url: `${repoPathOf(target)}/git/ref/heads/${encPath(branch)}` });
124
+ const refResult = await git.send(target, { method: "GET", url: `${repoPathOf(target)}/git/ref/heads/${encPath({ path: branch })}` });
125
125
  if (refResult.kind !== "response") return git.nonResponseFailure(refResult);
126
126
  const refResponse = refResult.response;
127
127
  if (refResponse.status === 409) {
128
128
  return { ok: false, code: "repo-empty", message: `repository ${name} is empty. Add a first commit (for example a README) on GitHub, then back up again.` };
129
129
  }
130
130
  if (refResponse.status === 404) return { ok: false, code: "branch-not-found", message: `branch '${branch}' does not exist in ${name}` };
131
- if (!isOk(refResponse)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage(refResponse, "GitHub branch lookup failed") };
131
+ if (!isOk(refResponse)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage({ response: refResponse, fallback: "GitHub branch lookup failed" }) };
132
132
  const refBody = parseJsonBody(refResponse);
133
- const parentCommitSha = refBody.ok ? extractStringField(refBody.json?.object, "sha") : "";
133
+ const parentCommitSha = refBody.ok ? extractStringField({ value: refBody.json?.object, field: "sha" }) : "";
134
134
  if (!parentCommitSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub branch lookup response did not include a sha" };
135
135
 
136
136
  return readBackupParentTree({ target, parentCommitSha });
@@ -140,7 +140,7 @@ export function createBackupPusher(git) {
140
140
  async function readBackupParentTree({ target, parentCommitSha }, _options = {}) {
141
141
  const commitJson = await git.getJson(target, `${repoPathOf(target)}/git/commits/${enc(parentCommitSha)}`, "GitHub parent-commit lookup failed");
142
142
  if (!commitJson.ok) return commitJson;
143
- const baseTreeSha = commitJson.found ? extractStringField(commitJson.json.tree, "sha") : "";
143
+ const baseTreeSha = commitJson.found ? extractStringField({ value: commitJson.json.tree, field: "sha" }) : "";
144
144
  if (!baseTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub parent-commit lookup did not return a tree sha" };
145
145
  return { ok: true, parentCommitSha, baseTreeSha };
146
146
  }
@@ -154,7 +154,7 @@ export function createBackupPusher(git) {
154
154
  const tip = await readBranchTip(input, branch);
155
155
  if (!tip.ok) return tip;
156
156
 
157
- const folderJson = await git.getJson(input, `${repoPathOf(input)}/contents/${encPath(input.folder)}?ref=${enc(branch)}`, "GitHub folder lookup failed");
157
+ const folderJson = await git.getJson(input, `${repoPathOf(input)}/contents/${encPath({ path: input.folder })}?ref=${enc(branch)}`, "GitHub folder lookup failed");
158
158
  if (!folderJson.ok) return folderJson;
159
159
  if (folderJson.found && !Array.isArray(folderJson.json)) {
160
160
  return { ok: false, code: "folder-is-file", message: `'${input.folder}' exists on branch '${branch}' but is not a folder — refusing to replace it` };
@@ -189,7 +189,7 @@ export function createBackupPusher(git) {
189
189
  "GitHub folder tree creation failed"
190
190
  );
191
191
  if (!folderTree.ok) return folderTree;
192
- folderTreeSha = extractStringField(folderTree.json, "sha");
192
+ folderTreeSha = extractStringField({ value: folderTree.json, field: "sha" });
193
193
  if (!folderTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub folder tree creation response did not include a sha" };
194
194
  }
195
195
  return { ok: true, sha: /** @type {string} */ (folderTreeSha) };
@@ -213,7 +213,7 @@ export function createBackupPusher(git) {
213
213
  "GitHub tree creation failed"
214
214
  );
215
215
  if (!rootTree.ok) return rootTree;
216
- const rootTreeSha = extractStringField(rootTree.json, "sha");
216
+ const rootTreeSha = extractStringField({ value: rootTree.json, field: "sha" });
217
217
  if (!rootTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub tree creation response did not include a sha" };
218
218
 
219
219
  const commit = await git.postJson(
@@ -223,7 +223,7 @@ export function createBackupPusher(git) {
223
223
  "GitHub commit creation failed"
224
224
  );
225
225
  if (!commit.ok) return commit;
226
- const commitSha = extractStringField(commit.json, "sha");
226
+ const commitSha = extractStringField({ value: commit.json, field: "sha" });
227
227
  if (!commitSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub commit creation response did not include a sha" };
228
228
 
229
229
  const ref = await git.updateRef(input, input.branch, commitSha);
@@ -13,7 +13,7 @@ import { createHash } from "node:crypto";
13
13
  * reported `diverged`, never overwritten.
14
14
  * - The parent TREE read fails the whole commit when it fails: building without `base_tree` would
15
15
  * silently delete every file on the branch this export does not write.
16
- * - `.tovu/managed-files.json` records every path THIS adapter wrote plus its blob sha. A later
16
+ * - `.jini/managed-files.json` records every path THIS adapter wrote plus its blob sha. A later
17
17
  * export deletes a path it no longer writes only when the live blob still has that exact sha; a
18
18
  * hand-edited, unverifiable or v1 (no sha) path is kept and reported in `divergedPaths`. A
19
19
  * manifest that cannot be read fails the commit, rather than forgetting what it owned.
@@ -32,7 +32,7 @@ const GITHUB_API = "https://api.github.com";
32
32
  const GITHUB_API_VERSION = "2026-03-10";
33
33
  /** Where this adapter records exactly which paths IT wrote. A dotfile directory, so it never collides
34
34
  * with real export output. */
35
- const MANAGED_MANIFEST_PATH = ".tovu/managed-files.json";
35
+ const MANAGED_MANIFEST_PATH = ".jini/managed-files.json";
36
36
  const GITHUB_FETCH_TIMEOUT_MS = 30_000;
37
37
  const GIT_SHA_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
38
38
 
@@ -77,7 +77,7 @@ function isGitHubTimeout({ err }, _options = {}) {
77
77
  *
78
78
  * @param {Kit} kit
79
79
  */
80
- export function createSiteCommitter(kit) {
80
+ export function createSiteCommitter(kit, _optional = {}) {
81
81
  /**
82
82
  * One request, classified before any status interpretation.
83
83
  * @param {string} url @param {RequestInit} init
@@ -181,10 +181,18 @@ export function createSiteCommitter(kit) {
181
181
  return { ok: true, treeSha: sha };
182
182
  }
183
183
 
184
+ async function fetchManagedManifestResponse({ token, owner, repo, branch, scope }) {
185
+ const result = await githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.manifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
186
+ if (result.kind === "response" && result.response.status === 404 && scope.previousManagedManifestPath) {
187
+ return githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.previousManagedManifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
188
+ }
189
+ return result;
190
+ }
191
+
184
192
  /** @param {string} token @param {string} owner @param {string} repo @param {string} branch
185
193
  * @returns {Promise<{ ok: true, files: readonly PreviouslyManagedFile[] } | StepFailure>} */
186
194
  async function fetchManagedManifest(token, owner, repo, branch, scope) {
187
- const result = await githubFetch(`${GITHUB_API}/repos/${enc(owner)}/${enc(repo)}/contents/${encPath(scope.manifestPath)}?ref=${enc(branch)}`, { headers: githubHeaders(token) });
195
+ const result = await fetchManagedManifestResponse({ token, owner, repo, branch, scope });
188
196
  if (result.kind !== "response") return nonResponseFailure(result);
189
197
  const { response } = result;
190
198
  if (response.status === 404) return { ok: true, files: [] }; // verified: no manifest yet — safe, not "unreadable"
@@ -287,7 +295,7 @@ export function createSiteCommitter(kit) {
287
295
  const fileTree = await buildFileTreeEntries(token, owner, repo, files);
288
296
  if (!fileTree.ok) return fileTree;
289
297
 
290
- const candidates = (previousManagedFiles ?? []).filter((f) => !fileTree.currentPaths.has(f.path) && f.path !== scope.manifestPath);
298
+ const candidates = (previousManagedFiles ?? []).filter((f) => !fileTree.currentPaths.has(f.path) && f.path !== scope.manifestPath && f.path !== scope.previousManagedManifestPath);
291
299
  const { deletions, deletedPaths, divergedPaths } = await resolveDeletionCandidates(token, owner, repo, branch, candidates);
292
300
 
293
301
  const sortedFiles = fileTree.currentFileShas.slice().sort((a, b) => {
@@ -336,26 +344,28 @@ export function createSiteCommitter(kit) {
336
344
  /** A new branch has no parent, no base tree and no manifest. @param {string} token @param {string} owner
337
345
  * @param {string} repo @param {string} branch @param {string | undefined} parentSha */
338
346
  async function resolveCommitPrerequisites(token, owner, repo, branch, parentSha, scope) {
339
- if (parentSha === undefined) return /** @type {const} */ ({ ok: true, baseTreeSha: undefined, previousManagedFiles: undefined, parents: [] });
347
+ if (parentSha === undefined) return /** @type {const} */ ({ ok: true, baseTreeSha: undefined, previousManagedFiles: undefined, parents: [], readRef: branch });
340
348
 
341
349
  const parentTreeResult = await fetchParentTree(token, owner, repo, parentSha);
342
350
  if (!parentTreeResult.ok) return parentTreeResult;
343
- const manifestResult = await fetchManagedManifest(token, owner, repo, branch, scope);
351
+ const readRef = scope.previousManagedManifestPath ? parentSha : branch;
352
+ const manifestResult = await fetchManagedManifest(token, owner, repo, readRef, scope);
344
353
  if (!manifestResult.ok) return manifestResult;
345
- return /** @type {const} */ ({ ok: true, baseTreeSha: parentTreeResult.treeSha, previousManagedFiles: manifestResult.files, parents: [parentSha] });
354
+ return /** @type {const} */ ({ ok: true, baseTreeSha: parentTreeResult.treeSha, previousManagedFiles: manifestResult.files, parents: [parentSha], readRef });
346
355
  }
347
356
 
348
357
  /** Prefix payloads once and reserve the local ownership manifest before any provider I/O.
349
- * @param {{ input: { folder?: string, files: readonly CommitFile[] } }} required
358
+ * @param {{ input: { folder?: string, previousManagedManifestPath?: string, files: readonly CommitFile[] } }} required
350
359
  * @complexity O(file count + path bytes), no effects.
351
360
  */
352
361
  function prepareCommitScope({ input }, _options = {}) {
353
362
  try {
354
363
  const folder = kit.repositoryPaths.normalizeFolder({ folder: input.folder });
355
364
  const manifestPath = kit.repositoryPaths.prefixPath({ folder, path: MANAGED_MANIFEST_PATH });
365
+ const previousManagedManifestPath = input.previousManagedManifestPath ? kit.repositoryPaths.prefixPath({ folder, path: input.previousManagedManifestPath }) : undefined;
356
366
  const files = input.files.map(file => ({ ...file, path: kit.repositoryPaths.prefixPath({ folder, path: file.path }) }));
357
- if (files.some(file => file.path === manifestPath)) return { ok: false, code: PROVIDER_ERROR, message: "Export cannot overwrite the managed manifest." };
358
- return { ok: true, folder, manifestPath, files };
367
+ if (files.some(file => file.path === manifestPath || file.path === previousManagedManifestPath)) return { ok: false, code: PROVIDER_ERROR, message: "Export cannot overwrite the managed manifest." };
368
+ return { ok: true, folder, manifestPath, previousManagedManifestPath, files };
359
369
  } catch {
360
370
  return { ok: false, code: PROVIDER_ERROR, message: "Invalid target folder or repository file path." };
361
371
  }
@@ -372,7 +382,7 @@ export function createSiteCommitter(kit) {
372
382
  }
373
383
 
374
384
  /**
375
- * @param {{ token: string, owner: string, repo: string, branch?: string, commitMessage: string, folder?: string, files: readonly CommitFile[] }} input
385
+ * @param {{ token: string, owner: string, repo: string, branch?: string, commitMessage: string, folder?: string, previousManagedManifestPath?: string, files: readonly CommitFile[] }} input
376
386
  * @complexity O(f) requests in the file count, plus one per path a previous export owned and dropped.
377
387
  */
378
388
  return async function commitSite(input) {
@@ -393,7 +403,7 @@ export function createSiteCommitter(kit) {
393
403
  const prereqs = await resolveCommitPrerequisites(token, owner, repo, branch, parentSha, scope);
394
404
  if (!prereqs.ok) return prereqs;
395
405
 
396
- const treeResult = await buildTree(token, owner, repo, branch, files, prereqs.baseTreeSha, prereqs.previousManagedFiles, scope);
406
+ const treeResult = await buildTree(token, owner, repo, prereqs.readRef, files, prereqs.baseTreeSha, prereqs.previousManagedFiles, scope);
397
407
  if (!treeResult.ok) return treeResult;
398
408
 
399
409
  if (unchangedSiteTree({ baseTreeSha: prereqs.baseTreeSha, treeSha: treeResult.sha })) {
@@ -23,7 +23,7 @@ import { createFileWriter, createGitDataClient } from "./write-files.mjs";
23
23
  * assertNotRedirected(response: Response, hostName: string): void,
24
24
  * isRedirectRefusal(error: unknown): boolean,
25
25
  * httpClient: { send(request: { method: string, url: string, headers: Record<string, string>, body?: string,
26
- * timeoutMs: number }): Promise<{ status: number, bodyText: string, headers?: Record<string, string> }> },
26
+ * timeoutMs: number }, options?: { redirect?: "follow" | "error" | "manual" }): Promise<{ status: number, bodyText: string, headers?: Record<string, string> }> },
27
27
  * describeTransportError(error: unknown): { refusal: string | undefined, logDetail: string },
28
28
  * sleep?(ms: number): Promise<void>,
29
29
  * }} Kit
@@ -65,16 +65,22 @@ export default {
65
65
  /**
66
66
  * `GET /user` -> `login`, the public name GitHub prints in every profile URL (never email, plan
67
67
  * or org membership). Best effort: any failure is `null`, never a throw.
68
+ *
69
+ * Sent through the guarded `kit.httpClient` with `redirect: "error"`, never `kit.fetch`: this call
70
+ * carries the bearer token, so it gets the host's egress checks like every other credentialed call,
71
+ * and a redirect is a refusal (the credential is never replayed to wherever an answer points).
68
72
  * @param {string} token
69
73
  */
70
74
  async readAccountLabel(token) {
71
75
  try {
72
- const resp = await kit.fetch(`${GITHUB_API}/user`, {
76
+ const resp = await kit.httpClient.send({
77
+ method: "GET",
78
+ url: `${GITHUB_API}/user`,
73
79
  headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json" },
74
- signal: AbortSignal.timeout(ACCOUNT_LABEL_PROBE_TIMEOUT_MS),
75
- });
76
- if (!resp.ok) return null;
77
- const body = await resp.json();
80
+ timeoutMs: ACCOUNT_LABEL_PROBE_TIMEOUT_MS,
81
+ }, { redirect: "error" });
82
+ if (resp.status < 200 || resp.status > 299) return null;
83
+ const body = JSON.parse(resp.bodyText);
78
84
  const login = typeof body === "object" && body !== null ? body.login : undefined;
79
85
  return typeof login === "string" && login !== "" ? login : null;
80
86
  } catch {
@@ -38,31 +38,31 @@ export function enc(value) {
38
38
  return encodeURIComponent(value);
39
39
  }
40
40
 
41
- /** @param {string} path */
42
- export function encPath(path) {
41
+ /** @param {{ path: string }} required */
42
+ export function encPath({ path }, _optional = {}) {
43
43
  return path.split("/").map(enc).join("/");
44
44
  }
45
45
 
46
46
  /** `<baseUrl>/repos/<owner>/<repo>`. @param {Target} target */
47
- export function repoPathOf(target) {
47
+ export function repoPathOf(target, _optional = {}) {
48
48
  const base = target.baseUrl.endsWith("/") ? target.baseUrl.slice(0, -1) : target.baseUrl;
49
49
  return `${base}/repos/${enc(target.owner)}/${enc(target.repo)}`;
50
50
  }
51
51
 
52
52
  /** @param {HttpResponse} response */
53
- export function isOk(response) {
53
+ export function isOk(response, _optional = {}) {
54
54
  return response.status >= 200 && response.status < 300;
55
55
  }
56
56
 
57
57
  /** @param {unknown} value @param {string} field */
58
- export function extractStringField(value, field) {
58
+ export function extractStringField({ value, field }, _optional = {}) {
59
59
  if (typeof value !== "object" || value === null) return "";
60
60
  const candidate = /** @type {Record<string, unknown>} */ (value)[field];
61
61
  return typeof candidate === "string" ? candidate : "";
62
62
  }
63
63
 
64
64
  /** @param {HttpResponse} response @returns {{ ok: true, json: any } | { ok: false, message: string }} */
65
- export function parseJsonBody(response) {
65
+ export function parseJsonBody(response, _optional = {}) {
66
66
  try {
67
67
  return { ok: true, json: JSON.parse(response.bodyText) };
68
68
  } catch {
@@ -70,8 +70,8 @@ export function parseJsonBody(response) {
70
70
  }
71
71
  }
72
72
 
73
- /** @param {HttpResponse} response @param {string} fallback */
74
- export function providerErrorMessage(response, fallback) {
73
+ /** @param {{ response: HttpResponse, fallback: string }} required */
74
+ export function providerErrorMessage({ response, fallback }, _optional = {}) {
75
75
  const body = parseJsonBody(response);
76
76
  const providerMessage = body.ok && typeof body.json?.message === "string" ? body.json.message : undefined;
77
77
  return providerMessage ? `${fallback}: ${providerMessage}` : `${fallback} (status ${response.status})`;
@@ -90,7 +90,7 @@ function splitRepoPath(path) {
90
90
 
91
91
  /** A regular file, not a symlink or submodule (both report `download_url: null`). @param {unknown} entry */
92
92
  function isRegularFileEntry(entry) {
93
- if (extractStringField(entry, "type") !== "file") return false;
93
+ if (extractStringField({ value: entry, field: "type" }) !== "file") return false;
94
94
  return !(entry !== null && typeof entry === "object" && /** @type {Record<string, unknown>} */ (entry).download_url === null);
95
95
  }
96
96
 
@@ -125,13 +125,12 @@ function gitHubRateLimitDelay({ response, retryAfter, policy }, _options = {}) {
125
125
  * GitHub's documented order: `retry-after` (seconds) first, then `x-ratelimit-reset` when
126
126
  * `x-ratelimit-remaining` is 0, then at least a minute for a secondary limit without either.
127
127
  *
128
- * @param {{ kind: "response", response: HttpResponse } | { kind: "network-unreachable", refused: boolean }} result
129
- * @param {number} attempt - 1 for the first retry.
130
- * @param {RetryPolicy} policy
128
+ * @param {{ result: { kind: "response", response: HttpResponse } | { kind: "network-unreachable", refused: boolean }, attempt: number, policy: RetryPolicy }} required
129
+ * @param {number} required.attempt - 1 for the first retry.
131
130
  * @returns {number | undefined}
132
131
  * @complexity O(headers).
133
132
  */
134
- export function retryDelayMs(result, attempt, policy) {
133
+ export function retryDelayMs({ result, attempt, policy }, _optional = {}) {
135
134
  const backoff = Math.min(policy.maxBackoffMs, policy.baseBackoffMs * 2 ** (attempt - 1));
136
135
  if (result.kind !== "response") return result.refused ? undefined : backoff;
137
136
  const { status } = result.response;
@@ -168,7 +167,7 @@ export function createGitDataClient(kit, options = {}) {
168
167
  let result = await sendOnce(target, request);
169
168
  const policy = options.retry;
170
169
  for (let attempt = 1; policy !== undefined && attempt < policy.maxAttempts; attempt++) {
171
- const waitMs = retryDelayMs(result, attempt, policy);
170
+ const waitMs = retryDelayMs({ result, attempt, policy });
172
171
  if (waitMs === undefined || waitMs > policy.maxWaitMs) break;
173
172
  await sleep(waitMs);
174
173
  result = await sendOnce(target, request);
@@ -215,7 +214,7 @@ export function createGitDataClient(kit, options = {}) {
215
214
  const result = await send(target, { method: "GET", url });
216
215
  if (result.kind !== "response") return nonResponseFailure(result);
217
216
  if (result.response.status === 404) return { ok: true, found: false };
218
- if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage(result.response, failureFallback) };
217
+ if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage({ response: result.response, fallback: failureFallback }) };
219
218
  const body = parseJsonBody(result.response);
220
219
  if (!body.ok) return { ok: false, code: PROVIDER_ERROR, message: body.message };
221
220
  return { ok: true, found: true, json: body.json };
@@ -226,7 +225,7 @@ export function createGitDataClient(kit, options = {}) {
226
225
  async function postJson(target, url, body, failureFallback) {
227
226
  const result = await send(target, { method: "POST", url, body: JSON.stringify(body) });
228
227
  if (result.kind !== "response") return nonResponseFailure(result);
229
- if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage(result.response, failureFallback) };
228
+ if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage({ response: result.response, fallback: failureFallback }) };
230
229
  const parsed = parseJsonBody(result.response);
231
230
  if (!parsed.ok) return { ok: false, code: PROVIDER_ERROR, message: parsed.message };
232
231
  return { ok: true, json: parsed.json };
@@ -237,7 +236,7 @@ export function createGitDataClient(kit, options = {}) {
237
236
  const bytes = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content.buffer, content.byteOffset, content.byteLength);
238
237
  const result = await postJson(target, `${repoPathOf(target)}/git/blobs`, { content: bytes.toString("base64"), encoding: "base64" }, "GitHub blob creation failed");
239
238
  if (!result.ok) return result;
240
- const sha = extractStringField(result.json, "sha");
239
+ const sha = extractStringField({ value: result.json, field: "sha" });
241
240
  if (!sha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub blob creation response did not include a sha" };
242
241
  return { ok: true, sha };
243
242
  }
@@ -245,12 +244,12 @@ export function createGitDataClient(kit, options = {}) {
245
244
  /** Unforced: a 422 means the branch moved. @param {Target} target @param {string} branch @param {string} sha
246
245
  * @returns {Promise<{ ok: true } | { ok: false, code: "diverged", message: string } | Failure>} */
247
246
  async function updateRef(target, branch, sha) {
248
- const result = await send(target, { method: "PATCH", url: `${repoPathOf(target)}/git/refs/heads/${encPath(branch)}`, body: JSON.stringify({ sha }) });
247
+ const result = await send(target, { method: "PATCH", url: `${repoPathOf(target)}/git/refs/heads/${encPath({ path: branch })}`, body: JSON.stringify({ sha }) });
249
248
  if (result.kind !== "response") return nonResponseFailure(result);
250
249
  if (result.response.status === 422) {
251
250
  return { ok: false, code: "diverged", message: "the branch has moved since this write was confirmed — refusing to overwrite it" };
252
251
  }
253
- if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage(result.response, "GitHub branch update failed") };
252
+ if (!isOk(result.response)) return { ok: false, code: PROVIDER_ERROR, message: providerErrorMessage({ response: result.response, fallback: "GitHub branch update failed" }) };
254
253
  return { ok: true };
255
254
  }
256
255
 
@@ -260,10 +259,10 @@ export function createGitDataClient(kit, options = {}) {
260
259
  /** @typedef {ReturnType<typeof createGitDataClient>} GitDataClient */
261
260
 
262
261
  /** The two write-files operations. @param {GitDataClient} git */
263
- export function createFileWriter(git) {
262
+ export function createFileWriter(git, _optional = {}) {
264
263
  /** @param {Target} target @param {string} branch @param {string} path */
265
264
  async function checkOneFileExistence(target, branch, path) {
266
- const result = await git.getJson(target, `${repoPathOf(target)}/contents/${encPath(path)}?ref=${enc(branch)}`, `GitHub lookup of '${path}' failed`);
265
+ const result = await git.getJson(target, `${repoPathOf(target)}/contents/${encPath({ path })}?ref=${enc(branch)}`, `GitHub lookup of '${path}' failed`);
267
266
  if (!result.ok) return result;
268
267
  if (!result.found) return { ok: true, state: { path, exists: false } };
269
268
  if (Array.isArray(result.json) || result.json.type !== "file") return notRegularFileFailure(path);
@@ -293,7 +292,7 @@ export function createFileWriter(git) {
293
292
 
294
293
  /** @param {{ target: Target, branch: string, dirFiles: WriteFile[], entries: any[], stateByPath: Map<string, { path: string, exists: boolean }> }} required */
295
294
  async function resolveDirectoryFileStates({ target, branch, dirFiles, entries, stateByPath }, _options = {}) {
296
- const entryByName = new Map(entries.map((entry) => [extractStringField(entry, "name"), entry]));
295
+ const entryByName = new Map(entries.map((entry) => [extractStringField({ value: entry, field: "name" }), entry]));
297
296
  const listingMayBeIncomplete = entries.length >= CONTENTS_API_DIRECTORY_LISTING_CAP;
298
297
  for (const file of dirFiles) {
299
298
  const entry = entryByName.get(splitRepoPath(file.path).name);
@@ -306,7 +305,7 @@ export function createFileWriter(git) {
306
305
 
307
306
  /** @param {{ target: Target, branch: string, dir: string, dirFiles: WriteFile[], stateByPath: Map<string, { path: string, exists: boolean }> }} required */
308
307
  async function checkDirectoryFileExistence({ target, branch, dir, dirFiles, stateByPath }, _options = {}) {
309
- const directoryPath = dir ? `/${encPath(dir)}` : "";
308
+ const directoryPath = dir ? `/${encPath({ path: dir })}` : "";
310
309
  const listUrl = `${repoPathOf(target)}/contents${directoryPath}?ref=${enc(branch)}`;
311
310
  const listResult = await git.getJson(target, listUrl, `GitHub directory lookup of '${dir}' failed`);
312
311
  if (!listResult.ok) return listResult;
@@ -338,16 +337,16 @@ export function createFileWriter(git) {
338
337
  /** @param {Target & { branch: string, files: readonly WriteFile[] }} input */
339
338
  async function planFileWrite(input) {
340
339
  const repoPath = repoPathOf(input);
341
- const refJson = await git.getJson(input, `${repoPath}/git/ref/heads/${encPath(input.branch)}`, "GitHub branch lookup failed");
340
+ const refJson = await git.getJson(input, `${repoPath}/git/ref/heads/${encPath({ path: input.branch })}`, "GitHub branch lookup failed");
342
341
  if (!refJson.ok) return refJson;
343
342
  if (!refJson.found) return { ok: false, code: "branch-not-found", message: `branch '${input.branch}' does not exist in ${input.owner}/${input.repo}` };
344
- const parentCommitSha = extractStringField(refJson.json.object, "sha");
343
+ const parentCommitSha = extractStringField({ value: refJson.json.object, field: "sha" });
345
344
  if (!parentCommitSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub branch lookup response did not include a sha" };
346
345
 
347
346
  const commitJson = await git.getJson(input, `${repoPath}/git/commits/${enc(parentCommitSha)}`, "GitHub parent-commit lookup failed");
348
347
  if (!commitJson.ok) return commitJson;
349
348
  if (!commitJson.found) return { ok: false, code: PROVIDER_ERROR, message: "GitHub parent-commit lookup returned 404 for a sha this call just resolved" };
350
- const baseTreeSha = extractStringField(commitJson.json.tree, "sha");
349
+ const baseTreeSha = extractStringField({ value: commitJson.json.tree, field: "sha" });
351
350
  if (!baseTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub parent-commit response did not include a tree sha" };
352
351
 
353
352
  const existence = await checkFileExistence(input, input.branch, input.files);
@@ -446,7 +445,7 @@ export function createFileWriter(git) {
446
445
 
447
446
  const treeResult = await git.postJson(input, `${repoPath}/git/trees`, { tree: blobs.entries, base_tree: plan.baseTreeSha }, "GitHub tree creation failed");
448
447
  if (!treeResult.ok) return treeResult;
449
- const newTreeSha = extractStringField(treeResult.json, "sha");
448
+ const newTreeSha = extractStringField({ value: treeResult.json, field: "sha" });
450
449
  if (!newTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub tree creation response did not include a sha" };
451
450
 
452
451
  const commitResult = await git.postJson(
@@ -456,7 +455,7 @@ export function createFileWriter(git) {
456
455
  "GitHub commit creation failed"
457
456
  );
458
457
  if (!commitResult.ok) return commitResult;
459
- const commitSha = extractStringField(commitResult.json, "sha");
458
+ const commitSha = extractStringField({ value: commitResult.json, field: "sha" });
460
459
  if (!commitSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub commit creation response did not include a sha" };
461
460
 
462
461
  const refResult = await git.updateRef(input, input.branch, commitSha);