@jini-ai/agent-plugins 0.7.2 → 0.7.3-next.1
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.
- package/CHANGELOG.md +4 -6
- package/NOTICE +2 -0
- package/README.md +11 -15
- package/calendly/plugin.json +3 -3
- package/cloudflare/lib/forms.mjs +9 -10
- package/cloudflare/lib/target.mjs +1 -1
- package/cloudflare/plugin.json +3 -3
- package/cloudflare/worker/forms-receiver.mjs +9 -9
- package/composio/plugin.json +3 -3
- package/core/persistent-state.js +227 -163
- package/dist/admin-surfaces/connections/connections.d.ts +11 -6
- package/dist/admin-surfaces/connections/connections.js +102 -85
- package/dist/admin-surfaces/node.d.ts +27 -0
- package/dist/admin-surfaces/node.js +32 -0
- package/dist/admin-surfaces/plugin-state.js +21 -18
- package/dist/admin-surfaces/surface-client.d.ts +4 -0
- package/dist/admin-surfaces/surface-client.js +124 -117
- package/dist/admin-surfaces/surface-handlers.js +21 -17
- package/dist/admin-surfaces/theme.d.ts +5 -1
- package/dist/admin-surfaces/theme.js +3 -3
- package/dist/connect/access-token-tool.d.ts +3 -1
- package/dist/connect/access-token-tool.js +3 -2
- package/dist/connect/apply-connect-defaults.js +2 -2
- package/dist/connect/apply-tool-renames.js +9 -8
- package/dist/connect/connect-tool.d.ts +2 -0
- package/dist/connect/connect-tool.js +3 -2
- package/dist/connect/credential-cards.js +3 -2
- package/dist/connect/credential-save-tool.d.ts +14 -11
- package/dist/connect/credential-save-tool.js +128 -121
- package/dist/connect/enable-access.d.ts +2 -2
- package/dist/connect/enable-access.js +6 -6
- package/dist/connect/executable/register.js +40 -34
- package/dist/connect/federate-mcp.d.ts +21 -11
- package/dist/connect/federate-mcp.js +28 -21
- package/dist/connect/grant-signed-in-defaults.js +3 -3
- package/dist/connect/import-access-token.js +2 -1
- package/dist/connect/index.d.ts +1 -0
- package/dist/connect/index.js +1 -0
- package/dist/connect/plugin-credential-card.js +2 -1
- package/dist/connect/plugin-host/index.d.ts +9 -5
- package/dist/connect/plugin-host/index.js +113 -100
- package/dist/connect/ports.d.ts +1 -1
- package/dist/connect/row-update.d.ts +22 -0
- package/dist/connect/row-update.js +18 -0
- package/dist/connect/switch-on-saved-token.d.ts +4 -2
- package/dist/connect/switch-on-saved-token.js +1 -1
- package/dist/connect/token-map.d.ts +44 -0
- package/dist/connect/token-map.js +49 -0
- package/dist/core/identity-namespace.js +5 -0
- package/dist/folder-zip.d.ts +3 -1
- package/dist/folder-zip.js +2 -2
- package/dist/lifecycle/activation.d.ts +4 -4
- package/dist/lifecycle/activation.js +4 -5
- package/dist/lifecycle/automatic-use.js +236 -210
- package/dist/lifecycle/bundled-digests.d.ts +75 -12
- package/dist/lifecycle/bundled-digests.js +213 -212
- package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
- package/dist/lifecycle/bundled-source-archive.js +263 -264
- package/dist/lifecycle/capability-projection.d.ts +1 -1
- package/dist/lifecycle/capability-projection.js +1 -1
- package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
- package/dist/lifecycle/credential-card-metadata.js +27 -3
- package/dist/lifecycle/exports.js +9 -4
- package/dist/lifecycle/fetch-archive.d.ts +1 -1
- package/dist/lifecycle/fetch-archive.js +1 -1
- package/dist/lifecycle/host-tools/identity.js +3 -2
- package/dist/lifecycle/host-tools/ports.d.ts +2 -0
- package/dist/lifecycle/host-tools/search-tool.js +8 -8
- package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
- package/dist/lifecycle/host-tools/skill-tool.js +16 -8
- package/dist/lifecycle/index.d.ts +118 -110
- package/dist/lifecycle/index.js +45 -12
- package/dist/lifecycle/install-errors.d.ts +1 -1
- package/dist/lifecycle/install-from-url.d.ts +1 -1
- package/dist/lifecycle/install-from-url.js +1 -1
- package/dist/lifecycle/install.d.ts +7 -2
- package/dist/lifecycle/install.js +414 -396
- package/dist/lifecycle/installed-package-index.js +45 -42
- package/dist/lifecycle/layout.d.ts +1 -1
- package/dist/lifecycle/layout.js +1 -1
- package/dist/lifecycle/mail/catalog.d.ts +8 -32
- package/dist/lifecycle/mail/catalog.js +25 -20
- package/dist/lifecycle/mail/contribution.d.ts +2 -2
- package/dist/lifecycle/mail/contribution.js +34 -34
- package/dist/lifecycle/mail/selection.js +6 -2
- package/dist/lifecycle/manifest.d.ts +3 -3
- package/dist/lifecycle/manifest.js +4 -4
- package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
- package/dist/lifecycle/mcp-provisioning.js +3 -3
- package/dist/lifecycle/package-paths.d.ts +1 -1
- package/dist/lifecycle/package-paths.js +1 -1
- package/dist/lifecycle/persistent-state.js +1 -2
- package/dist/lifecycle/ports.d.ts +5 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
- package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
- package/dist/lifecycle/retire-bundled.d.ts +1 -52
- package/dist/lifecycle/retire-bundled.js +134 -84
- package/dist/lifecycle/search.d.ts +2 -1
- package/dist/lifecycle/search.js +1 -1
- package/dist/lifecycle/seed-bundled.d.ts +1 -1
- package/dist/lifecycle/seed-bundled.js +154 -155
- package/dist/lifecycle/set-enabled.d.ts +1 -1
- package/dist/lifecycle/set-enabled.js +1 -1
- package/dist/lifecycle/skill-file-reader.js +53 -50
- package/dist/lifecycle/tools/projection.d.ts +4 -7
- package/dist/lifecycle/tools/projection.js +109 -108
- package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
- package/dist/lifecycle/trusted-plugin-files.js +1 -1
- package/dist/lifecycle/uninstall.d.ts +1 -1
- package/dist/lifecycle/uninstall.js +237 -241
- package/dist/lifecycle/update-store.js +20 -17
- package/dist/lifecycle/update.js +287 -281
- package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
- package/dist/lifecycle/yauzl-archive-reader.js +8 -2
- package/dist/manifest.d.ts +11 -3
- package/dist/manifest.js +9 -9
- package/fly/jini-credential-schemes.json +11 -0
- package/fly/plugin.json +3 -4
- package/github/plugin.json +3 -3
- package/github/source-control/backup-push.mjs +11 -11
- package/github/source-control/commit-site.mjs +3 -3
- package/github/source-control/github.mjs +12 -6
- package/github/source-control/write-files.mjs +27 -28
- package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
- package/github-pages/plugin.json +3 -3
- package/github-pages/targets/github-pages.mjs +3 -3
- package/google-login/plugin.json +3 -3
- package/google-workspace/README.md +14 -14
- package/google-workspace/form-destinations/README.md +3 -3
- package/google-workspace/form-destinations/dedupe.mjs +1 -1
- package/google-workspace/form-destinations/mapping.mjs +8 -9
- package/google-workspace/form-destinations/sheets.mjs +1 -1
- package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
- package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
- package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
- package/google-workspace/lib/auth.mjs +2 -2
- package/google-workspace/lib/form-destination-settings.mjs +1 -1
- package/google-workspace/lib/picker-flow.mjs +2 -2
- package/google-workspace/lib/request-policy.mjs +1 -1
- package/google-workspace/lib/surface-actions.mjs +1 -1
- package/google-workspace/plugin.json +3 -3
- package/google-workspace/tools/sheets/README.md +3 -3
- package/google-workspace/tools/sheets-admin/README.md +3 -3
- package/google-workspace/ui/README.md +4 -4
- package/google-workspace/ui/connection-panel.mjs +51 -51
- package/google-workspace/ui/destination-panel.mjs +34 -34
- package/google-workspace/ui/dom.mjs +15 -16
- package/google-workspace/ui/picker-flow.mjs +2 -2
- package/google-workspace/ui/picker.mjs +19 -19
- package/google-workspace/ui/surface-client.mjs +96 -69
- package/higgsfield-media/plugin.json +3 -3
- package/jev/plugin.json +3 -3
- package/kuinetic/CHANGELOG.md +12 -0
- package/kuinetic/mcp.json +4 -0
- package/kuinetic/plugin.json +27 -0
- package/kuinetic/skills/kuinetic/SKILL.md +120 -0
- package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
- package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
- package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
- package/meilisearch/plugin.json +5 -5
- package/netlify/plugin.json +3 -3
- package/netlify/targets/netlify.mjs +14 -4
- package/opentelemetry/plugin.json +3 -3
- package/package.json +25 -20
- package/posthog/plugin.json +3 -3
- package/railway/plugin.json +3 -3
- package/render/plugin.json +3 -3
- package/resend/NOTES.md +2 -2
- package/resend/adapters/resend.mjs +1 -1
- package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
- package/resend/lib/domains.mjs +8 -8
- package/resend/plugin.json +3 -3
- package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
- package/s3-compatible/jini-object-stores.json +29 -0
- package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
- package/s3-compatible/plugin.json +3 -3
- package/s3-compatible/targets/s3-compatible.mjs +25 -25
- package/sentry/plugin.json +3 -3
- package/shadcn-ui/CHANGELOG.md +7 -0
- package/shadcn-ui/LICENSE +201 -0
- package/shadcn-ui/NOTICE +10 -0
- package/shadcn-ui/mcp.json +4 -0
- package/shadcn-ui/plugin.json +26 -0
- package/shopify/plugin.json +3 -3
- package/site-compliance/plugin.json +3 -3
- package/site-import/plugin.json +3 -3
- package/supabase/mcp.json +1 -4
- package/supabase/plugin.json +3 -3
- package/ui-ux-design/CHANGELOG.md +13 -0
- package/ui-ux-design/NOTICE +2 -0
- package/ui-ux-design/README.md +17 -7
- package/ui-ux-design/plugin.json +6 -3
- package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
- package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
- package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
- package/vercel/NOTES.md +1 -1
- package/vercel/object-stores/vercel-blob.mjs +12 -2
- package/vercel/plugin.json +3 -3
- package/vercel/targets/vercel.mjs +3 -3
- package/wordpress/plugin.json +3 -3
- package/dist/lifecycle/node.d.ts +0 -11
- package/dist/lifecycle/node.js +0 -38
- package/fly/tovu-credential-schemes.json +0 -11
- package/github/deployments/github.mjs +0 -415
- package/s3-compatible/tovu-object-stores.json +0 -29
- package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
- /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
- /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
- /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
- /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
- /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
- /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
- /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
- /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
- /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
- /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /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
|
-
*
|
|
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
|
-
|
|
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 };
|
package/dist/manifest.d.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
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.
|
|
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": "
|
|
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
|
-
"
|
|
23
|
-
"id": "tovu/fly",
|
|
22
|
+
"id": "jini/fly",
|
|
24
23
|
"provides": [
|
|
25
24
|
"deploy-ops:fly",
|
|
26
25
|
"deploy-config:fly",
|
package/github/plugin.json
CHANGED
|
@@ -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.
|
|
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": "
|
|
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": "
|
|
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
|
-
* - `.
|
|
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 = ".
|
|
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
|
|
@@ -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.
|
|
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
|
-
|
|
75
|
-
});
|
|
76
|
-
if (
|
|
77
|
-
const body =
|
|
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}
|
|
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 {
|
|
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 }}
|
|
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);
|