@kodycodes/cli 3.0.1 → 3.0.3
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/README.md +21 -21
- package/dist/{auth-5Z3XBOGI.js → auth-FV2O77LC.js} +6 -6
- package/dist/bin.js +8 -8
- package/dist/{mock-local-deps-HGYWVRFD.js → chunk-2OVTW5ME.js} +10 -14
- package/dist/chunk-2OVTW5ME.js.map +6 -0
- package/dist/{chunk-XHKHDK76.js → chunk-5X563FYY.js} +3 -3
- package/dist/{chunk-2XKHD5AY.js → chunk-7OE3VVWV.js} +278 -13
- package/dist/{chunk-2XKHD5AY.js.map → chunk-7OE3VVWV.js.map} +1 -1
- package/dist/{chunk-ENB4AFHF.js → chunk-AXU5TTPK.js} +42 -41
- package/dist/chunk-AXU5TTPK.js.map +6 -0
- package/dist/{chunk-PWWN6JI2.js → chunk-BML3W5CO.js} +2 -2
- package/dist/{chunk-FQDXZCNC.js → chunk-BYNTHMDS.js} +3 -3
- package/dist/{chunk-5BJUKHNZ.js → chunk-CCRCEU7S.js} +2 -2
- package/dist/{chunk-7YWXBKSA.js → chunk-D7OPYEJ5.js} +136 -11
- package/dist/chunk-D7OPYEJ5.js.map +6 -0
- package/dist/{chunk-V7TJUMHF.js → chunk-DCQ57UXY.js} +2 -2
- package/dist/{chunk-LSFY5BNX.js → chunk-NHRYNRXG.js} +2 -2
- package/dist/{chunk-LSFY5BNX.js.map → chunk-NHRYNRXG.js.map} +1 -1
- package/dist/{chunk-5YWQO43I.js → chunk-PIPQ2TTK.js} +4 -4
- package/dist/{chunk-QXRBLEAK.js → chunk-PUQGDXIY.js} +4 -4
- package/dist/{chunk-KK3NWPOZ.js → chunk-PZKBPKJ2.js} +3 -3
- package/dist/{chunk-WB7BWPKK.js → chunk-SSBZQMVX.js} +3 -3
- package/dist/cli.js +8 -8
- package/dist/{dev-command-RS24SIQM.js → dev-command-MQKDDGZ2.js} +39 -11
- package/dist/dev-command-MQKDDGZ2.js.map +6 -0
- package/dist/{git-credential-GFQJHBTK.js → git-credential-6CJWVNED.js} +7 -7
- package/dist/{local-execute-JMLNPN5F.js → local-execute-MCLHJIY7.js} +7 -7
- package/dist/{local-package-graph-IEU5VLS4.js → local-package-graph-NMYUOCAL.js} +26 -4
- package/dist/local-package-graph.d.ts +60 -0
- package/dist/{local-package-run-HBZJO3HO.js → local-package-run-7LL744ZB.js} +15 -8
- package/dist/local-package-run.d.ts +40 -0
- package/dist/{mock-dep-resolve-HJLRVWYS.js → mock-dep-resolve-TTCQQEN2.js} +7 -7
- package/dist/{mock-fetch-gateway-DIHCENGI.js → mock-fetch-gateway-TNK74HEP.js} +4 -4
- package/dist/mock-local-deps-VR37B2DQ.js +30 -0
- package/dist/{mock-server-NO5RFVAF.js → mock-server-CJQI6B3A.js} +5 -5
- package/dist/{open-api-client-5BQMPAQY.js → open-api-client-42L6TM2U.js} +5 -5
- package/dist/package-local-runtime-source.d.ts +9 -0
- package/dist/publish-exit.d.ts +1 -1
- package/dist/{remote-execute-DNOU4AMT.js → remote-execute-J35MQTUC.js} +5 -5
- package/dist/{setup-git-CZFPTTTQ.js → setup-git-IGLLNSLA.js} +6 -6
- package/dist/setup-git-IGLLNSLA.js.map +6 -0
- package/package.json +1 -1
- package/dist/chunk-7YWXBKSA.js.map +0 -6
- package/dist/chunk-ENB4AFHF.js.map +0 -6
- package/dist/dev-command-RS24SIQM.js.map +0 -6
- package/dist/mock-local-deps-HGYWVRFD.js.map +0 -6
- /package/dist/{auth-5Z3XBOGI.js.map → auth-FV2O77LC.js.map} +0 -0
- /package/dist/{chunk-XHKHDK76.js.map → chunk-5X563FYY.js.map} +0 -0
- /package/dist/{chunk-PWWN6JI2.js.map → chunk-BML3W5CO.js.map} +0 -0
- /package/dist/{chunk-FQDXZCNC.js.map → chunk-BYNTHMDS.js.map} +0 -0
- /package/dist/{chunk-5BJUKHNZ.js.map → chunk-CCRCEU7S.js.map} +0 -0
- /package/dist/{chunk-V7TJUMHF.js.map → chunk-DCQ57UXY.js.map} +0 -0
- /package/dist/{chunk-5YWQO43I.js.map → chunk-PIPQ2TTK.js.map} +0 -0
- /package/dist/{chunk-QXRBLEAK.js.map → chunk-PUQGDXIY.js.map} +0 -0
- /package/dist/{chunk-KK3NWPOZ.js.map → chunk-PZKBPKJ2.js.map} +0 -0
- /package/dist/{chunk-WB7BWPKK.js.map → chunk-SSBZQMVX.js.map} +0 -0
- /package/dist/{git-credential-GFQJHBTK.js.map → git-credential-6CJWVNED.js.map} +0 -0
- /package/dist/{local-execute-JMLNPN5F.js.map → local-execute-MCLHJIY7.js.map} +0 -0
- /package/dist/{local-package-graph-IEU5VLS4.js.map → local-package-graph-NMYUOCAL.js.map} +0 -0
- /package/dist/{local-package-run-HBZJO3HO.js.map → local-package-run-7LL744ZB.js.map} +0 -0
- /package/dist/{mock-dep-resolve-HJLRVWYS.js.map → mock-dep-resolve-TTCQQEN2.js.map} +0 -0
- /package/dist/{mock-fetch-gateway-DIHCENGI.js.map → mock-fetch-gateway-TNK74HEP.js.map} +0 -0
- /package/dist/{mock-server-NO5RFVAF.js.map → mock-local-deps-VR37B2DQ.js.map} +0 -0
- /package/dist/{open-api-client-5BQMPAQY.js.map → mock-server-CJQI6B3A.js.map} +0 -0
- /package/dist/{setup-git-CZFPTTTQ.js.map → open-api-client-42L6TM2U.js.map} +0 -0
- /package/dist/{remote-execute-DNOU4AMT.js.map → remote-execute-J35MQTUC.js.map} +0 -0
package/README.md
CHANGED
|
@@ -69,27 +69,27 @@ multi-org store as the active org (no re-login).
|
|
|
69
69
|
|
|
70
70
|
## Commands
|
|
71
71
|
|
|
72
|
-
| Command | Purpose
|
|
73
|
-
| ------------------------------------------------- |
|
|
74
|
-
| `kody install` | Detect running local MCP clients, write their config, and start host OAuth. **Recommended long-term path.**
|
|
75
|
-
| `kody skill install` | Copies the getting-started skill into Claude Code / Cursor / Agents.
|
|
76
|
-
| `kody login` | Browser OAuth (CIMD + PKCE) for the CLI itself. Adds/replaces one org login (browser picker, or `kody login --org acme`) and keeps other org logins.
|
|
77
|
-
| `kody org list` | Lists logged-in orgs and marks the active one. `--json` for agents.
|
|
78
|
-
| `kody org use [<slug>]` | Switches the active org. With a slug (agents) switches directly; with no slug on a TTY opens a chooser; without a TTY pass a slug.
|
|
79
|
-
| `kody logout` | Removes the active org login (or `--org <slug>` for one org) and clears a stored bootstrap/API token when appropriate.
|
|
80
|
-
| `kody status` | Shows CLI login / stored API token state without printing secrets.
|
|
81
|
-
| `kody auth bootstrap --code` | Redeems a one-shot `kody_bc_…` from MCP `cliCredentialBootstrap` and stores the resulting `kody_at_…` for `execute --local` (never prints the token).
|
|
82
|
-
| `kody auth bootstrap --scopes` | Opt-in extra scopes: mints the code itself by passing `scopes` to `cliCredentialBootstrap` (with `--token`, else the `kody login` session, else a stored token), then redeems and stores it. See [Opt-in scopes](#opt-in-scopes).
|
|
83
|
-
| `kody auth setup-git` | Installs a Git credential helper for `https://kody.codes/@owner/name.git` (persistent `kody_at_…`, user-owned token with `package:read`/`package:write`). See [Git HTTPS](#git-https-setup-git).
|
|
84
|
-
| `kody auth remove-git` | Inverse of `setup-git`: clears Kody HTTPS git helpers, revokes the stored API token, deletes it from the keychain. Leaves `kody login` alone.
|
|
85
|
-
| `kody git-credential` | Credential helper invoked by Git after `setup-git` (`get` / `store` / `erase`).
|
|
86
|
-
| `kody whoami` | Confirms the CLI MCP connection and lists tools. With a scoped API token (and no login), shows token identity via the Open API.
|
|
87
|
-
| `kody search [query]` | Calls Kody `search` from the CLI (prefer the host MCP tool). Token-only auth uses Open API `GET /v1/search`.
|
|
88
|
-
| `kody api <operationId>` | Thin Open API wrapper matching the MCP `api` tool: `operationId` + flat `--params` JSON. Auth: `--token` / `KODY_API_TOKEN` / stored `auth bootstrap` token. The parsed `/openapi.json` route map is cached under the Kody cache dir keyed by the document's `ETag` and revalidated with `If-None-Match` on each run.
|
|
89
|
-
| `kody package publish` | Thin wrapper for `packagePublishExternalPush`. Optional positional `@owner/leaf`, bare leaf name, or package UUID (names are resolved to the package UUID via `packageList`); extra fields via `--params`. Same auth as `kody api`. Prints the API JSON. Exit **0** for `published`, `already_published` (including `artifacts_rebuilt: true`), and `dispatched` (poll `workflowRunList`). Exit **1** for refusal/rejection statuses (`checks_failed`, `locked`, `approval_required`, `not_fast_forward`) with the API `message` (or a checks summary) on stderr, like npm. Auth / permission / network failures also exit 1; `--json` adds `{ error, message, sent }` on stdout for network errors (`sent: false` = not sent; `sent: "unknown"` = maybe sent — prefer `kody api workflowRunList` before retry). Re-publishing the same commit is safe (durable dedupe / `already_published`). |
|
|
90
|
-
| `kody package collaborators` / `grant` / `revoke` | Who can use one package, and add or remove teams and members of the org (`--org`). `<package>` is `@owner/leaf`, the kody id, or the package id. `grant <package> --team <slug>\|--user <username> [--preset use\|contribute\|manage]` (default `use`) adds or changes a collaborator via `packageCollaboratorSet`; people outside the org are refused. `revoke <package> --team\|--user\|--grant <grant_id>` removes one via `packageCollaboratorRemove`. Needs Manage on the package and a token with `package:manage_access` (`auth bootstrap --scopes …,package:manage_access`). Prints a summary, or JSON with `--json`.
|
|
91
|
-
| `kody execute` | Calls Kody `execute` from the CLI (`--invoke`, `--code`, `--file`, or stdin via `--file -`). With a scoped API token and no login (or with `--token`), cloud execute goes through CapabilityProxy → `kody.execute` — no `kody login`. Add `--local` to run the module (and static `kody:@…` package modules) on this machine instead. `--credential key=name` (repeatable; `org:name` / `personal:name` / empty `=` for none) picks ADR 0068 credentials for `--local` or a `kody login` MCP session. `--allow-private-network` opts local execution into private and local network access. `--target prod\|mock` (default `prod`) sends CapabilityProxy / search hops to prod or the built-in CLI mock; `--target mock` implies local workerd.
|
|
92
|
-
| `kody dev` | Local testing for unpublished packages. Serves `kody.app.entry` on localhost via workerd with hot reload. Subcommands: `fetch`, `job`, `webhook`, `emit`, `check`. Default `--target mock` (scratch storage, fake credentials). Covers exports, webhooks, schedules (run-once), and subscriptions. See [Local package testing](#local-package-testing-kody-dev).
|
|
72
|
+
| Command | Purpose |
|
|
73
|
+
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `kody install` | Detect running local MCP clients, write their config, and start host OAuth. **Recommended long-term path.** |
|
|
75
|
+
| `kody skill install` | Copies the getting-started skill into Claude Code / Cursor / Agents. |
|
|
76
|
+
| `kody login` | Browser OAuth (CIMD + PKCE) for the CLI itself. Adds/replaces one org login (browser picker, or `kody login --org acme`) and keeps other org logins. |
|
|
77
|
+
| `kody org list` | Lists logged-in orgs and marks the active one. `--json` for agents. |
|
|
78
|
+
| `kody org use [<slug>]` | Switches the active org. With a slug (agents) switches directly; with no slug on a TTY opens a chooser; without a TTY pass a slug. |
|
|
79
|
+
| `kody logout` | Removes the active org login (or `--org <slug>` for one org) and clears a stored bootstrap/API token when appropriate. |
|
|
80
|
+
| `kody status` | Shows CLI login / stored API token state without printing secrets. |
|
|
81
|
+
| `kody auth bootstrap --code` | Redeems a one-shot `kody_bc_…` from MCP `cliCredentialBootstrap` and stores the resulting `kody_at_…` for `execute --local` (never prints the token). |
|
|
82
|
+
| `kody auth bootstrap --scopes` | Opt-in extra scopes: mints the code itself by passing `scopes` to `cliCredentialBootstrap` (with `--token`, else the `kody login` session, else a stored token), then redeems and stores it. See [Opt-in scopes](#opt-in-scopes). |
|
|
83
|
+
| `kody auth setup-git` | Installs a Git credential helper for `https://kody.codes/@owner/name.git` (persistent `kody_at_…`, user-owned token with `package:read`/`package:write`). See [Git HTTPS](#git-https-setup-git). |
|
|
84
|
+
| `kody auth remove-git` | Inverse of `setup-git`: clears Kody HTTPS git helpers, revokes the stored API token, deletes it from the keychain. Leaves `kody login` alone. |
|
|
85
|
+
| `kody git-credential` | Credential helper invoked by Git after `setup-git` (`get` / `store` / `erase`). |
|
|
86
|
+
| `kody whoami` | Confirms the CLI MCP connection and lists tools. With a scoped API token (and no login), shows token identity via the Open API. |
|
|
87
|
+
| `kody search [query]` | Calls Kody `search` from the CLI (prefer the host MCP tool). Token-only auth uses Open API `GET /v1/search`. |
|
|
88
|
+
| `kody api <operationId>` | Thin Open API wrapper matching the MCP `api` tool: `operationId` + flat `--params` JSON. Auth: `--token` / `KODY_API_TOKEN` / stored `auth bootstrap` token. The parsed `/openapi.json` route map is cached under the Kody cache dir keyed by the document's `ETag` and revalidated with `If-None-Match` on each run. |
|
|
89
|
+
| `kody package publish` | Thin wrapper for `packagePublishExternalPush`. Optional positional `@owner/leaf`, bare leaf name, or package UUID (names are resolved to the package UUID via `packageList`); extra fields via `--params`. Same auth as `kody api`. Prints the API JSON. Exit **0** for `published`, `already_published` (including `artifacts_rebuilt: true`), and `dispatched` (poll `workflowRunList({ workflow_id })`). Exit **1** for refusal/rejection statuses (`checks_failed`, `locked`, `approval_required`, `not_fast_forward`) with the API `message` (or a checks summary) on stderr, like npm. Auth / permission / network failures also exit 1; `--json` adds `{ error, message, sent }` on stdout for network errors (`sent: false` = not sent; `sent: "unknown"` = maybe sent — prefer `kody api workflowRunList` with `workflow_id` when known, otherwise a recent list, before retry). Re-publishing the same commit is safe (durable dedupe / `already_published`). |
|
|
90
|
+
| `kody package collaborators` / `grant` / `revoke` | Who can use one package, and add or remove teams and members of the org (`--org`). `<package>` is `@owner/leaf`, the kody id, or the package id. `grant <package> --team <slug>\|--user <username> [--preset use\|contribute\|manage]` (default `use`) adds or changes a collaborator via `packageCollaboratorSet`; people outside the org are refused. `revoke <package> --team\|--user\|--grant <grant_id>` removes one via `packageCollaboratorRemove`. Needs Manage on the package and a token with `package:manage_access` (`auth bootstrap --scopes …,package:manage_access`). Prints a summary, or JSON with `--json`. |
|
|
91
|
+
| `kody execute` | Calls Kody `execute` from the CLI (`--invoke`, `--code`, `--file`, or stdin via `--file -`). With a scoped API token and no login (or with `--token`), cloud execute goes through CapabilityProxy → `kody.execute` — no `kody login`. Add `--local` to run the module (and static `kody:@…` package modules) on this machine instead. `--credential key=name` (repeatable; `org:name` / `personal:name` / empty `=` for none) picks ADR 0068 credentials for `--local` or a `kody login` MCP session. `--allow-private-network` opts local execution into private and local network access. `--target prod\|mock` (default `prod`) sends CapabilityProxy / search hops to prod or the built-in CLI mock; `--target mock` implies local workerd. |
|
|
92
|
+
| `kody dev` | Local testing for unpublished packages. Serves `kody.app.entry` on localhost via workerd with hot reload. Subcommands: `fetch`, `job`, `webhook`, `emit`, `check`. Default `--target mock` (scratch storage, fake credentials). Covers exports, webhooks, schedules (run-once), and subscriptions. See [Local package testing](#local-package-testing-kody-dev). |
|
|
93
93
|
|
|
94
94
|
`--json` prints structured MCP results. On command failures it also prints a
|
|
95
95
|
JSON error object on stdout (`error`, `message`, and when a network hop failed
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
login,
|
|
8
8
|
refreshStoredCredentials,
|
|
9
9
|
resolvePendingOrgSlug
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SSBZQMVX.js";
|
|
11
11
|
import "./chunk-CASGRYOF.js";
|
|
12
12
|
import "./chunk-GVSGNTG6.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-PIPQ2TTK.js";
|
|
14
14
|
import "./chunk-46IJPEID.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-BML3W5CO.js";
|
|
16
|
+
import "./chunk-CCRCEU7S.js";
|
|
17
|
+
import "./chunk-NHRYNRXG.js";
|
|
18
18
|
import "./chunk-CWWHR4FH.js";
|
|
19
19
|
import "./chunk-3H72XY5R.js";
|
|
20
20
|
import "./chunk-BTL3PJ2H.js";
|
|
@@ -28,4 +28,4 @@ export {
|
|
|
28
28
|
refreshStoredCredentials,
|
|
29
29
|
resolvePendingOrgSlug
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=auth-
|
|
31
|
+
//# sourceMappingURL=auth-FV2O77LC.js.map
|
package/dist/bin.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
runCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AXU5TTPK.js";
|
|
6
6
|
import "./chunk-2XPH7L2P.js";
|
|
7
7
|
import "./chunk-SLNAWWQK.js";
|
|
8
8
|
import "./chunk-YDWTXEKQ.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-PZKBPKJ2.js";
|
|
10
|
+
import "./chunk-PUQGDXIY.js";
|
|
11
11
|
import "./chunk-6ZYUGXVW.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-SSBZQMVX.js";
|
|
13
13
|
import "./chunk-CASGRYOF.js";
|
|
14
14
|
import "./chunk-GVSGNTG6.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-PIPQ2TTK.js";
|
|
16
16
|
import "./chunk-46IJPEID.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-BML3W5CO.js";
|
|
18
|
+
import "./chunk-CCRCEU7S.js";
|
|
19
|
+
import "./chunk-NHRYNRXG.js";
|
|
20
20
|
import "./chunk-7PRJ36I5.js";
|
|
21
21
|
import "./chunk-CWWHR4FH.js";
|
|
22
22
|
import "./chunk-3H72XY5R.js";
|
|
@@ -6,20 +6,13 @@ import {
|
|
|
6
6
|
loadPackageManifest,
|
|
7
7
|
resolveExportModulePath
|
|
8
8
|
} from "./chunk-TUUFQYWP.js";
|
|
9
|
-
import "./chunk-XV6D6HSG.js";
|
|
10
9
|
import {
|
|
11
10
|
LocalPackageGraphError,
|
|
12
11
|
absolutizeWorkerdPackageImports,
|
|
13
12
|
hasLiteralDynamicSavedPackageImports,
|
|
14
13
|
listSavedPackageImports,
|
|
15
14
|
rewriteBareKodyBuiltinImports
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-5BJUKHNZ.js";
|
|
18
|
-
import "./chunk-LSFY5BNX.js";
|
|
19
|
-
import "./chunk-EJXEVGWF.js";
|
|
20
|
-
import "./chunk-3H72XY5R.js";
|
|
21
|
-
import "./chunk-BTL3PJ2H.js";
|
|
22
|
-
import "./chunk-UW6AWLXX.js";
|
|
15
|
+
} from "./chunk-7OE3VVWV.js";
|
|
23
16
|
|
|
24
17
|
// src/mock-local-deps.ts
|
|
25
18
|
import { access, readFile } from "node:fs/promises";
|
|
@@ -181,7 +174,9 @@ function mergePackageGraphs(local, published) {
|
|
|
181
174
|
modules: [...byName.values()],
|
|
182
175
|
imports: [
|
|
183
176
|
.../* @__PURE__ */ new Set([...published.imports, ...local.map((module) => module.name)])
|
|
184
|
-
]
|
|
177
|
+
],
|
|
178
|
+
packageBindings: { ...published.packageBindings },
|
|
179
|
+
packageIdsByImport: { ...published.packageIdsByImport }
|
|
185
180
|
};
|
|
186
181
|
}
|
|
187
182
|
async function tryLoadSelfManifest(cwd) {
|
|
@@ -194,13 +189,14 @@ async function tryLoadSelfManifest(cwd) {
|
|
|
194
189
|
function packageRootOf(manifestPath) {
|
|
195
190
|
return dirname(manifestPath);
|
|
196
191
|
}
|
|
192
|
+
|
|
197
193
|
export {
|
|
198
|
-
loadLocalDepMap,
|
|
199
194
|
localDepsRelativePath,
|
|
200
|
-
mergePackageGraphs,
|
|
201
|
-
packageRootOf,
|
|
202
195
|
parseKodyPackageSpecifier,
|
|
196
|
+
loadLocalDepMap,
|
|
203
197
|
resolveLocalPackageModules,
|
|
204
|
-
|
|
198
|
+
mergePackageGraphs,
|
|
199
|
+
tryLoadSelfManifest,
|
|
200
|
+
packageRootOf
|
|
205
201
|
};
|
|
206
|
-
//# sourceMappingURL=
|
|
202
|
+
//# s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GAAG,UAAU,mBAAmB;AAAA,EACvD;AACD;AAGA,eAAsB,oBACrB,KAC2C;AAC3C,MAAI;AACH,WAAO,MAAM,oBAAoB,GAAG;AAAA,EACrC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAGO,SAAS,cAAc,cAA8B;AAC3D,SAAO,QAAQ,YAAY;AAC5B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
unmockedRequestError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DCQ57UXY.js";
|
|
5
5
|
import {
|
|
6
6
|
StructuredCliError,
|
|
7
7
|
notImplementedInMock
|
|
8
8
|
} from "./chunk-XV6D6HSG.js";
|
|
9
9
|
import {
|
|
10
10
|
userCacheDir
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BML3W5CO.js";
|
|
12
12
|
|
|
13
13
|
// src/mock/mock-server.ts
|
|
14
14
|
import {
|
|
@@ -768,4 +768,4 @@ export {
|
|
|
768
768
|
ensureMockTarget,
|
|
769
769
|
withMockServer
|
|
770
770
|
};
|
|
771
|
-
//# sourceMappingURL=chunk-
|
|
771
|
+
//# sourceMappingURL=chunk-5X563FYY.js.map
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
readPackageVersion,
|
|
12
12
|
rejectedApiTokenMessage,
|
|
13
13
|
rejectedOauthBearerMessage
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CCRCEU7S.js";
|
|
15
15
|
import {
|
|
16
16
|
formatUnreachableApiMessage,
|
|
17
17
|
requestSentStatus
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NHRYNRXG.js";
|
|
19
19
|
import {
|
|
20
20
|
cliName
|
|
21
21
|
} from "./chunk-BTL3PJ2H.js";
|
|
@@ -876,6 +876,108 @@ function synthesizePackageGraphEntry(imports) {
|
|
|
876
876
|
export default async function main() {}
|
|
877
877
|
`;
|
|
878
878
|
}
|
|
879
|
+
var packageRuntimeModulePrefix = ".__kody_virtual__/package-runtime";
|
|
880
|
+
function decodePathKey(value) {
|
|
881
|
+
const bytes = value.match(/[0-9a-f]{2}/gi);
|
|
882
|
+
if (!bytes || bytes.join("") !== value) return null;
|
|
883
|
+
try {
|
|
884
|
+
return new TextDecoder().decode(
|
|
885
|
+
new Uint8Array(bytes.map((byte) => Number.parseInt(byte, 16)))
|
|
886
|
+
);
|
|
887
|
+
} catch {
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
function encodePathKey(value) {
|
|
892
|
+
return Array.from(
|
|
893
|
+
new TextEncoder().encode(value),
|
|
894
|
+
(byte) => byte.toString(16).padStart(2, "0")
|
|
895
|
+
).join("");
|
|
896
|
+
}
|
|
897
|
+
function parsePackageRuntimeModulePathPackageId(modulePath) {
|
|
898
|
+
const normalized = modulePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
899
|
+
const prefix = `${packageRuntimeModulePrefix}/`;
|
|
900
|
+
const isPackageRuntimePath = normalized.startsWith(prefix) || normalized.includes(`/${prefix}`);
|
|
901
|
+
if (!isPackageRuntimePath) return null;
|
|
902
|
+
const fileName = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
903
|
+
if (!fileName.endsWith(".js")) return null;
|
|
904
|
+
return decodePathKey(fileName.slice(0, -".js".length));
|
|
905
|
+
}
|
|
906
|
+
function packageRuntimeFacadeImportSpecifier(packageId) {
|
|
907
|
+
return `/${packageRuntimeModulePrefix}/${encodePathKey(packageId)}.js`;
|
|
908
|
+
}
|
|
909
|
+
function resolvePackageRuntimeFacadeImportSpecifier(graph, packageId) {
|
|
910
|
+
let best = null;
|
|
911
|
+
for (const module of graph.modules) {
|
|
912
|
+
if (parsePackageRuntimeModulePathPackageId(module.name) !== packageId) {
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
const specifier = module.name.startsWith("/") ? module.name : `/${module.name}`;
|
|
916
|
+
if (best === null || specifier.length < best.length) {
|
|
917
|
+
best = specifier;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return best;
|
|
921
|
+
}
|
|
922
|
+
async function rewriteLocalModulesToPackageFacades(graph) {
|
|
923
|
+
const packageIdsByImport = graph.packageIdsByImport ?? {};
|
|
924
|
+
if (Object.keys(packageIdsByImport).length === 0) {
|
|
925
|
+
return graph;
|
|
926
|
+
}
|
|
927
|
+
const flatAlias = localWorkerModuleNames.runtimeFlatAlias;
|
|
928
|
+
const flatAliasAbsolute = `/${flatAlias}`;
|
|
929
|
+
const modules = [];
|
|
930
|
+
for (const module of graph.modules) {
|
|
931
|
+
if (!module.name.startsWith("kody:@")) {
|
|
932
|
+
modules.push(module);
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
const packageId = packageIdsByImport[module.name];
|
|
936
|
+
if (!packageId) {
|
|
937
|
+
modules.push(module);
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
940
|
+
const facadeSpecifier = resolvePackageRuntimeFacadeImportSpecifier(
|
|
941
|
+
graph,
|
|
942
|
+
packageId
|
|
943
|
+
);
|
|
944
|
+
if (!facadeSpecifier) {
|
|
945
|
+
modules.push(module);
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
const rewritten = await rewriteRuntimeAliasImports(
|
|
949
|
+
module.esModule,
|
|
950
|
+
flatAlias,
|
|
951
|
+
flatAliasAbsolute,
|
|
952
|
+
facadeSpecifier
|
|
953
|
+
);
|
|
954
|
+
modules.push(
|
|
955
|
+
rewritten === module.esModule ? module : { name: module.name, esModule: rewritten }
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
return { ...graph, modules };
|
|
959
|
+
}
|
|
960
|
+
async function rewriteRuntimeAliasImports(esModule, flatAlias, flatAliasAbsolute, facadeSpecifier) {
|
|
961
|
+
await esModuleLexerReady;
|
|
962
|
+
const edits = parseModuleImports(esModule).filter((im) => typeof im.specifier === "string").map((im) => {
|
|
963
|
+
const specifier = im.specifier;
|
|
964
|
+
if (specifier !== flatAlias && specifier !== flatAliasAbsolute) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
return { start: im.start, end: im.end, facadeSpecifier };
|
|
968
|
+
}).filter(
|
|
969
|
+
(edit) => edit !== null
|
|
970
|
+
).sort((a, b) => b.start - a.start);
|
|
971
|
+
if (edits.length === 0) return esModule;
|
|
972
|
+
let out = esModule;
|
|
973
|
+
for (const edit of edits) {
|
|
974
|
+
const raw = esModule.slice(edit.start, edit.end);
|
|
975
|
+
const quote = raw.startsWith("'") || raw.startsWith('"') ? raw[0] : null;
|
|
976
|
+
const replacement = quote ? `${quote}${edit.facadeSpecifier}${quote}` : edit.facadeSpecifier;
|
|
977
|
+
out = `${out.slice(0, edit.start)}${replacement}${out.slice(edit.end)}`;
|
|
978
|
+
}
|
|
979
|
+
return out;
|
|
980
|
+
}
|
|
879
981
|
function isTypeOnlyImport(im) {
|
|
880
982
|
if (im.type === "dynamic") return im.probablyTypeOnly === true;
|
|
881
983
|
return im.typeOnly === true;
|
|
@@ -1011,7 +1113,12 @@ async function writePackageModuleFiles(workDir, graph, writeFile, joinPath) {
|
|
|
1011
1113
|
async function resolveLocalPackageGraph(input) {
|
|
1012
1114
|
const imports = await listSavedPackageImports(input.code);
|
|
1013
1115
|
if (input.depResolve && imports.length === 0 && !await hasLiteralDynamicSavedPackageImports(input.code)) {
|
|
1014
|
-
return {
|
|
1116
|
+
return {
|
|
1117
|
+
modules: [],
|
|
1118
|
+
imports: [],
|
|
1119
|
+
packageBindings: {},
|
|
1120
|
+
packageIdsByImport: {}
|
|
1121
|
+
};
|
|
1015
1122
|
}
|
|
1016
1123
|
let localModules = [];
|
|
1017
1124
|
let unresolved = imports;
|
|
@@ -1019,7 +1126,7 @@ async function resolveLocalPackageGraph(input) {
|
|
|
1019
1126
|
mergePackageGraphs,
|
|
1020
1127
|
resolveLocalPackageModules,
|
|
1021
1128
|
tryLoadSelfManifest
|
|
1022
|
-
} = await import("./mock-local-deps-
|
|
1129
|
+
} = await import("./mock-local-deps-VR37B2DQ.js");
|
|
1023
1130
|
if (imports.length > 0 && input.packageRoot) {
|
|
1024
1131
|
const selfManifest = await tryLoadSelfManifest(input.packageRoot);
|
|
1025
1132
|
const local = await resolveLocalPackageModules({
|
|
@@ -1030,8 +1137,13 @@ async function resolveLocalPackageGraph(input) {
|
|
|
1030
1137
|
});
|
|
1031
1138
|
localModules = local.modules;
|
|
1032
1139
|
unresolved = local.unresolved;
|
|
1033
|
-
if (unresolved.length === 0 &&
|
|
1034
|
-
return {
|
|
1140
|
+
if (unresolved.length === 0 && input.depResolve === void 0 && isLikelyMockBearer(input.token)) {
|
|
1141
|
+
return {
|
|
1142
|
+
modules: localModules,
|
|
1143
|
+
imports,
|
|
1144
|
+
packageBindings: {},
|
|
1145
|
+
packageIdsByImport: {}
|
|
1146
|
+
};
|
|
1035
1147
|
}
|
|
1036
1148
|
}
|
|
1037
1149
|
if (unresolved.length > 0 && !input.depResolve && isLikelyMockBearer(input.token)) {
|
|
@@ -1056,14 +1168,140 @@ async function resolveLocalPackageGraph(input) {
|
|
|
1056
1168
|
`Resolving ${unresolved.length} kody:@ dependenc${unresolved.length === 1 ? "y" : "ies"} from published package-graph (mock keeps storage/credentials local)\u2026`
|
|
1057
1169
|
);
|
|
1058
1170
|
}
|
|
1059
|
-
const
|
|
1171
|
+
const localOnlyFallback = localModules.length > 0 && unresolved.length === 0 && input.depResolve !== void 0 ? {
|
|
1172
|
+
modules: localModules,
|
|
1173
|
+
imports,
|
|
1174
|
+
packageBindings: {},
|
|
1175
|
+
packageIdsByImport: {}
|
|
1176
|
+
} : null;
|
|
1177
|
+
let published;
|
|
1178
|
+
try {
|
|
1179
|
+
published = await fetchLocalPackageGraph({
|
|
1180
|
+
...client,
|
|
1181
|
+
code: input.code,
|
|
1182
|
+
conversationId: input.conversationId,
|
|
1183
|
+
...localModules.length > 0 ? { requiredImports: unresolved } : {}
|
|
1184
|
+
});
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
if (localOnlyFallback) {
|
|
1187
|
+
input.onStatus?.(
|
|
1188
|
+
"Package bindings unavailable; continuing with local modules unbound."
|
|
1189
|
+
);
|
|
1190
|
+
return localOnlyFallback;
|
|
1191
|
+
}
|
|
1192
|
+
throw error;
|
|
1193
|
+
}
|
|
1194
|
+
if (localModules.length === 0) return published;
|
|
1195
|
+
const withLocalBindings = await probeLocalPackageBindings({
|
|
1060
1196
|
...client,
|
|
1061
|
-
code: input.code,
|
|
1062
1197
|
conversationId: input.conversationId,
|
|
1063
|
-
|
|
1198
|
+
localModules,
|
|
1199
|
+
published
|
|
1064
1200
|
});
|
|
1065
|
-
|
|
1066
|
-
|
|
1201
|
+
return rewriteLocalModulesToPackageFacades(
|
|
1202
|
+
mergePackageGraphs(localModules, withLocalBindings)
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
async function probeLocalPackageBindings(input) {
|
|
1206
|
+
const knownIds = input.published.packageIdsByImport ?? {};
|
|
1207
|
+
const probeImports = [
|
|
1208
|
+
...new Set(
|
|
1209
|
+
input.localModules.map((module) => module.name).filter(
|
|
1210
|
+
(name) => name.startsWith("kody:@") && knownIds[name] === void 0
|
|
1211
|
+
)
|
|
1212
|
+
)
|
|
1213
|
+
];
|
|
1214
|
+
if (probeImports.length === 0) return input.published;
|
|
1215
|
+
let merged = input.published;
|
|
1216
|
+
for (const specifier of probeImports) {
|
|
1217
|
+
try {
|
|
1218
|
+
const probed = await fetchLocalPackageGraph({
|
|
1219
|
+
apiUrl: input.apiUrl,
|
|
1220
|
+
token: input.token,
|
|
1221
|
+
code: synthesizePackageGraphEntry([specifier]),
|
|
1222
|
+
requiredImports: [specifier],
|
|
1223
|
+
...input.org ? { org: input.org } : {},
|
|
1224
|
+
...input.fetchFn ? { fetchFn: input.fetchFn } : {},
|
|
1225
|
+
...input.conversationId !== void 0 ? { conversationId: input.conversationId } : {},
|
|
1226
|
+
...input.signal ? { signal: input.signal } : {}
|
|
1227
|
+
});
|
|
1228
|
+
merged = mergePackageGraphBindings(merged, probed);
|
|
1229
|
+
} catch (error) {
|
|
1230
|
+
if (!isPackageGraphResolutionError(error)) throw error;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return embedMergedBindingsInPrimaryShim(merged);
|
|
1234
|
+
}
|
|
1235
|
+
function mergePackageGraphBindings(base, probed) {
|
|
1236
|
+
const byName = /* @__PURE__ */ new Map();
|
|
1237
|
+
for (const module of base.modules) byName.set(module.name, module);
|
|
1238
|
+
for (const module of probed.modules) {
|
|
1239
|
+
if (module.name.startsWith("kody:@")) continue;
|
|
1240
|
+
if (isLocalExecuteGatewayFetchShimModuleName(module.name)) continue;
|
|
1241
|
+
if (isRootPackageRuntimeFacadeModuleName(module.name)) {
|
|
1242
|
+
byName.set(module.name, module);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return {
|
|
1246
|
+
modules: [...byName.values()],
|
|
1247
|
+
imports: base.imports,
|
|
1248
|
+
packageBindings: {
|
|
1249
|
+
...base.packageBindings,
|
|
1250
|
+
...probed.packageBindings
|
|
1251
|
+
},
|
|
1252
|
+
packageIdsByImport: {
|
|
1253
|
+
...base.packageIdsByImport,
|
|
1254
|
+
...probed.packageIdsByImport
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
function isLocalExecuteGatewayFetchShimModuleName(moduleName) {
|
|
1259
|
+
if (moduleName === localExecuteGatewayFetchShimModuleName) return true;
|
|
1260
|
+
return moduleName.endsWith(`/${localExecuteGatewayFetchShimModuleName}`) || moduleName.includes(`/${localExecuteGatewayFetchShimModuleName}/`);
|
|
1261
|
+
}
|
|
1262
|
+
function isRootPackageRuntimeFacadeModuleName(moduleName) {
|
|
1263
|
+
const normalized = moduleName.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
1264
|
+
const prefix = `${packageRuntimeModulePrefix}/`;
|
|
1265
|
+
if (!normalized.startsWith(prefix) || !normalized.endsWith(".js")) {
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
const rest = normalized.slice(prefix.length, -".js".length);
|
|
1269
|
+
return rest.length > 0 && !rest.includes("/");
|
|
1270
|
+
}
|
|
1271
|
+
function embedMergedBindingsInPrimaryShim(graph) {
|
|
1272
|
+
const packageBindings = graph.packageBindings ?? {};
|
|
1273
|
+
if (Object.keys(packageBindings).length === 0) return graph;
|
|
1274
|
+
const modules = graph.modules.map((module) => {
|
|
1275
|
+
if (!isLocalExecuteGatewayFetchShimModuleName(module.name)) return module;
|
|
1276
|
+
const rewritten = rewritePackageBindingsLiteral(
|
|
1277
|
+
module.esModule,
|
|
1278
|
+
packageBindings
|
|
1279
|
+
);
|
|
1280
|
+
return rewritten === module.esModule ? module : { name: module.name, esModule: rewritten };
|
|
1281
|
+
});
|
|
1282
|
+
return { ...graph, modules };
|
|
1283
|
+
}
|
|
1284
|
+
var packageBindingsLiteralPattern = /const __kodyPackageBindings = \{[\s\S]*?\n\};/;
|
|
1285
|
+
function createPackageBindingsLiteral(bindings) {
|
|
1286
|
+
const entries = Object.entries(bindings).filter(
|
|
1287
|
+
([packageId, binding]) => packageId && packageId !== "__proto__" && typeof binding === "string" && binding
|
|
1288
|
+
).sort(([left], [right]) => left.localeCompare(right)).map(
|
|
1289
|
+
([packageId, binding]) => ` ${JSON.stringify(packageId)}: ${JSON.stringify(binding)},`
|
|
1290
|
+
);
|
|
1291
|
+
return `{
|
|
1292
|
+
__proto__: null,
|
|
1293
|
+
${entries.join("\n")}${entries.length ? "\n" : ""}}`;
|
|
1294
|
+
}
|
|
1295
|
+
function rewritePackageBindingsLiteral(esModule, bindings) {
|
|
1296
|
+
if (!packageBindingsLiteralPattern.test(esModule)) return esModule;
|
|
1297
|
+
return esModule.replace(
|
|
1298
|
+
packageBindingsLiteralPattern,
|
|
1299
|
+
`const __kodyPackageBindings = ${createPackageBindingsLiteral(bindings)};`
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
function isPackageGraphResolutionError(error) {
|
|
1303
|
+
if (!(error instanceof LocalPackageGraphError)) return false;
|
|
1304
|
+
return error.code === "package_import_unresolved" || error.code === "package_import_unpublished" || error.code === "incomplete_package_graph" || error.code === "not_found" || error.status === 400 || error.status === 404 || error.status === 422;
|
|
1067
1305
|
}
|
|
1068
1306
|
function isLikelyMockBearer(token) {
|
|
1069
1307
|
return token === "mock" || token.startsWith("kody_mock_");
|
|
@@ -1152,7 +1390,23 @@ function parsePackageGraphBody(body, imports) {
|
|
|
1152
1390
|
modules.push({ name: entry.name, esModule });
|
|
1153
1391
|
}
|
|
1154
1392
|
const reportedImports = Array.isArray(body.imports) ? body.imports.filter((value) => typeof value === "string") : imports;
|
|
1155
|
-
|
|
1393
|
+
const packageBindings = parseStringRecord(body.packageBindings);
|
|
1394
|
+
const packageIdsByImport = parseStringRecord(body.packageIdsByImport);
|
|
1395
|
+
return {
|
|
1396
|
+
modules,
|
|
1397
|
+
imports: reportedImports,
|
|
1398
|
+
packageBindings,
|
|
1399
|
+
packageIdsByImport
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
function parseStringRecord(value) {
|
|
1403
|
+
if (!isRecord(value)) return {};
|
|
1404
|
+
const out = {};
|
|
1405
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1406
|
+
if (!key || key === "__proto__") continue;
|
|
1407
|
+
if (typeof entry === "string" && entry) out[key] = entry;
|
|
1408
|
+
}
|
|
1409
|
+
return out;
|
|
1156
1410
|
}
|
|
1157
1411
|
function describePackageGraphFailure(status, body, url, imports, token) {
|
|
1158
1412
|
const failure = readErrorBody(body);
|
|
@@ -1262,6 +1516,13 @@ export {
|
|
|
1262
1516
|
localPackageGraphPlatformIssueUrl,
|
|
1263
1517
|
packageGraphInlineCodePreferImportsChars,
|
|
1264
1518
|
synthesizePackageGraphEntry,
|
|
1519
|
+
packageRuntimeModulePrefix,
|
|
1520
|
+
decodePathKey,
|
|
1521
|
+
encodePathKey,
|
|
1522
|
+
parsePackageRuntimeModulePathPackageId,
|
|
1523
|
+
packageRuntimeFacadeImportSpecifier,
|
|
1524
|
+
resolvePackageRuntimeFacadeImportSpecifier,
|
|
1525
|
+
rewriteLocalModulesToPackageFacades,
|
|
1265
1526
|
listSavedPackageImports,
|
|
1266
1527
|
hasSavedPackageImports,
|
|
1267
1528
|
hasLiteralDynamicSavedPackageImports,
|
|
@@ -1275,6 +1536,10 @@ export {
|
|
|
1275
1536
|
localExecuteGatewayFetchShimModuleName,
|
|
1276
1537
|
writePackageModuleFiles,
|
|
1277
1538
|
resolveLocalPackageGraph,
|
|
1539
|
+
mergePackageGraphBindings,
|
|
1540
|
+
isRootPackageRuntimeFacadeModuleName,
|
|
1541
|
+
embedMergedBindingsInPrimaryShim,
|
|
1542
|
+
createPackageBindingsLiteral,
|
|
1278
1543
|
fetchLocalPackageGraph
|
|
1279
1544
|
};
|
|
1280
|
-
//# sourceMappingURL=chunk-
|
|
1545
|
+
//# sourceMappingURL=chunk-7OE3VVWV.js.map
|