@kodycodes/cli 1.26.2 → 1.26.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/dist/auth-4FW6GCLG.js +26 -0
- package/dist/auth-4FW6GCLG.js.map +6 -0
- package/dist/bin.js +27 -3
- package/dist/bin.js.map +6 -1
- package/dist/chunk-46IJPEID.js +30 -0
- package/dist/chunk-46IJPEID.js.map +6 -0
- package/dist/chunk-4D6ORNXY.js +24404 -0
- package/dist/chunk-4D6ORNXY.js.map +6 -0
- package/dist/chunk-64IM6G4Z.js +341 -0
- package/dist/chunk-64IM6G4Z.js.map +6 -0
- package/dist/{package-local-runtime-source.js → chunk-64XN367G.js} +373 -52
- package/dist/chunk-64XN367G.js.map +6 -0
- package/dist/chunk-6XQP5SWX.js +26 -0
- package/dist/chunk-6XQP5SWX.js.map +6 -0
- package/dist/chunk-75RZUXQL.js +62 -0
- package/dist/chunk-75RZUXQL.js.map +6 -0
- package/dist/chunk-BISUL7CE.js +106 -0
- package/dist/chunk-BISUL7CE.js.map +6 -0
- package/dist/chunk-BPGY4IE7.js +57 -0
- package/dist/chunk-BPGY4IE7.js.map +6 -0
- package/dist/chunk-CASGRYOF.js +21 -0
- package/dist/chunk-CASGRYOF.js.map +6 -0
- package/dist/chunk-CWWHR4FH.js +19 -0
- package/dist/chunk-CWWHR4FH.js.map +6 -0
- package/dist/chunk-D55XPY3T.js +1382 -0
- package/dist/chunk-D55XPY3T.js.map +6 -0
- package/dist/chunk-EOCV74B2.js +948 -0
- package/dist/chunk-EOCV74B2.js.map +6 -0
- package/dist/chunk-FBVNFWR6.js +437 -0
- package/dist/chunk-FBVNFWR6.js.map +6 -0
- package/dist/chunk-G4YN6XP5.js +14 -0
- package/dist/chunk-G4YN6XP5.js.map +6 -0
- package/dist/chunk-G6LJWROP.js +18 -0
- package/dist/chunk-G6LJWROP.js.map +6 -0
- package/dist/chunk-IHP6PV6X.js +49 -0
- package/dist/chunk-IHP6PV6X.js.map +6 -0
- package/dist/chunk-JWEFKKAD.js +24 -0
- package/dist/chunk-JWEFKKAD.js.map +6 -0
- package/dist/chunk-LWNB26KO.js +147 -0
- package/dist/chunk-LWNB26KO.js.map +6 -0
- package/dist/chunk-OVGXPRSY.js +20 -0
- package/dist/chunk-OVGXPRSY.js.map +6 -0
- package/dist/chunk-PDWCKWQF.js +453 -0
- package/dist/chunk-PDWCKWQF.js.map +6 -0
- package/dist/chunk-QHBCP4OB.js +44 -0
- package/dist/chunk-QHBCP4OB.js.map +6 -0
- package/dist/chunk-R4IUV5P5.js +664 -0
- package/dist/chunk-R4IUV5P5.js.map +6 -0
- package/dist/chunk-RM34N3KI.js +525 -0
- package/dist/chunk-RM34N3KI.js.map +6 -0
- package/dist/chunk-RTWUNV76.js +309 -0
- package/dist/chunk-RTWUNV76.js.map +6 -0
- package/dist/chunk-SMURF26I.js +23 -0
- package/dist/chunk-SMURF26I.js.map +6 -0
- package/dist/chunk-SXHULGL4.js +426 -0
- package/dist/chunk-SXHULGL4.js.map +6 -0
- package/dist/chunk-TIL35OWA.js +1959 -0
- package/dist/chunk-TIL35OWA.js.map +6 -0
- package/dist/chunk-VQS5YSCI.js +54 -0
- package/dist/chunk-VQS5YSCI.js.map +6 -0
- package/dist/chunk-XDCOWU5R.js +696 -0
- package/dist/chunk-XDCOWU5R.js.map +6 -0
- package/dist/chunk-XOPPGRUP.js +605 -0
- package/dist/chunk-XOPPGRUP.js.map +6 -0
- package/dist/cli.js +74 -1500
- package/dist/cli.js.map +6 -1
- package/dist/dev-command-3LX234N6.js +4900 -0
- package/dist/dev-command-3LX234N6.js.map +6 -0
- package/dist/git-credential-FUE3JE3T.js +163 -0
- package/dist/git-credential-FUE3JE3T.js.map +6 -0
- package/dist/install-ZML2TCDG.js +10694 -0
- package/dist/install-ZML2TCDG.js.map +6 -0
- package/dist/local-execute-SZV6XN4T.js +368 -0
- package/dist/local-execute-SZV6XN4T.js.map +6 -0
- package/dist/local-package-run-2TMCAZZ2.js +23 -0
- package/dist/local-package-run-2TMCAZZ2.js.map +6 -0
- package/dist/mcp-G2AWTIXR.js +21 -0
- package/dist/mcp-G2AWTIXR.js.map +6 -0
- package/dist/mock-dep-resolve-TVABDNR7.js +52 -0
- package/dist/mock-dep-resolve-TVABDNR7.js.map +6 -0
- package/dist/mock-fetch-gateway-B5TFGGQS.js +34 -0
- package/dist/mock-fetch-gateway-B5TFGGQS.js.map +6 -0
- package/dist/mock-local-deps-5SZT3PWT.js +197 -0
- package/dist/mock-local-deps-5SZT3PWT.js.map +6 -0
- package/dist/mock-server-SV2IKC4I.js +21 -0
- package/dist/mock-server-SV2IKC4I.js.map +6 -0
- package/dist/open-api-client-DVVMLY7P.js +42 -0
- package/dist/open-api-client-DVVMLY7P.js.map +6 -0
- package/dist/org-X7B5BI4R.js +132 -0
- package/dist/org-X7B5BI4R.js.map +6 -0
- package/dist/package-manifest-QH2RU64C.js +14 -0
- package/dist/package-manifest-QH2RU64C.js.map +6 -0
- package/dist/remote-execute-QMQDVHOY.js +110 -0
- package/dist/remote-execute-QMQDVHOY.js.map +6 -0
- package/dist/setup-git-5KCUBYPB.js +88 -0
- package/dist/setup-git-5KCUBYPB.js.map +6 -0
- package/dist/skill-ENPATRIW.js +43 -0
- package/dist/skill-ENPATRIW.js.map +6 -0
- package/dist/store-WTMRH527.js +48 -0
- package/dist/store-WTMRH527.js.map +6 -0
- package/dist/structured-error-C65GQ53Z.js +13 -0
- package/dist/structured-error-C65GQ53Z.js.map +6 -0
- package/dist/target-3QHY7JT4.js +45 -0
- package/dist/target-3QHY7JT4.js.map +6 -0
- package/dist/webapi-NTVP4BO3.js +2482 -0
- package/dist/webapi-NTVP4BO3.js.map +6 -0
- package/package.json +8 -8
- package/dist/add-mcp-install.js +0 -59
- package/dist/add-mcp-install.js.map +0 -1
- package/dist/api-token-store.js +0 -120
- package/dist/api-token-store.js.map +0 -1
- package/dist/api-token.js +0 -238
- package/dist/api-token.js.map +0 -1
- package/dist/auth-bootstrap.js +0 -373
- package/dist/auth-bootstrap.js.map +0 -1
- package/dist/auth.js +0 -386
- package/dist/auth.js.map +0 -1
- package/dist/capability-proxy.js +0 -527
- package/dist/capability-proxy.js.map +0 -1
- package/dist/credential-call-map.js +0 -155
- package/dist/credential-call-map.js.map +0 -1
- package/dist/credential-client-runtime-source.js +0 -9
- package/dist/credential-client-runtime-source.js.map +0 -1
- package/dist/credentialed-fetch-scan.js +0 -98
- package/dist/credentialed-fetch-scan.js.map +0 -1
- package/dist/defaults.js +0 -34
- package/dist/defaults.js.map +0 -1
- package/dist/detect-running-hosts.js +0 -13
- package/dist/detect-running-hosts.js.map +0 -1
- package/dist/dev/dev-assets.js +0 -202
- package/dist/dev/dev-assets.js.map +0 -1
- package/dist/dev/dev-bundler.js +0 -65
- package/dist/dev/dev-bundler.js.map +0 -1
- package/dist/dev/dev-events.js +0 -94
- package/dist/dev/dev-events.js.map +0 -1
- package/dist/dev/dev-port.js +0 -80
- package/dist/dev/dev-port.js.map +0 -1
- package/dist/dev/dev-protocol.js +0 -14
- package/dist/dev/dev-protocol.js.map +0 -1
- package/dist/dev/dev-registry.js +0 -95
- package/dist/dev/dev-registry.js.map +0 -1
- package/dist/dev/dev-watcher.js +0 -162
- package/dist/dev/dev-watcher.js.map +0 -1
- package/dist/dev/error-page.js +0 -64
- package/dist/dev/error-page.js.map +0 -1
- package/dist/dev/live-reload.js +0 -151
- package/dist/dev/live-reload.js.map +0 -1
- package/dist/dev/prebuild.js +0 -102
- package/dist/dev/prebuild.js.map +0 -1
- package/dist/dev/process-reaper.js +0 -151
- package/dist/dev/process-reaper.js.map +0 -1
- package/dist/dev/stack-trace.js +0 -56
- package/dist/dev/stack-trace.js.map +0 -1
- package/dist/dev/workerd-process.js +0 -118
- package/dist/dev/workerd-process.js.map +0 -1
- package/dist/dev-command.js +0 -676
- package/dist/dev-command.js.map +0 -1
- package/dist/discover-login-identity.js +0 -77
- package/dist/discover-login-identity.js.map +0 -1
- package/dist/discover-org.js +0 -62
- package/dist/discover-org.js.map +0 -1
- package/dist/git-credential.js +0 -147
- package/dist/git-credential.js.map +0 -1
- package/dist/help.js +0 -333
- package/dist/help.js.map +0 -1
- package/dist/host-catalog.js +0 -427
- package/dist/host-catalog.js.map +0 -1
- package/dist/host-config.js +0 -80
- package/dist/host-config.js.map +0 -1
- package/dist/http-error-body.js +0 -35
- package/dist/http-error-body.js.map +0 -1
- package/dist/install-hosts.js +0 -328
- package/dist/install-hosts.js.map +0 -1
- package/dist/install.js +0 -120
- package/dist/install.js.map +0 -1
- package/dist/invoke-passthrough.js +0 -60
- package/dist/invoke-passthrough.js.map +0 -1
- package/dist/local-bundle.js +0 -200
- package/dist/local-bundle.js.map +0 -1
- package/dist/local-execute-auth.js +0 -53
- package/dist/local-execute-auth.js.map +0 -1
- package/dist/local-execute.js +0 -338
- package/dist/local-execute.js.map +0 -1
- package/dist/local-gateway-fetch-forward.js +0 -135
- package/dist/local-gateway-fetch-forward.js.map +0 -1
- package/dist/local-host-runtime-surface.js +0 -75
- package/dist/local-host-runtime-surface.js.map +0 -1
- package/dist/local-package-graph.js +0 -405
- package/dist/local-package-graph.js.map +0 -1
- package/dist/local-package-run.js +0 -307
- package/dist/local-package-run.js.map +0 -1
- package/dist/local-runtime-bridge.js +0 -132
- package/dist/local-runtime-bridge.js.map +0 -1
- package/dist/local-runtime-source.js +0 -541
- package/dist/local-runtime-source.js.map +0 -1
- package/dist/login-callback-assets.js +0 -10
- package/dist/login-callback-assets.js.map +0 -1
- package/dist/login-callback-page.js +0 -362
- package/dist/login-callback-page.js.map +0 -1
- package/dist/mcp.js +0 -134
- package/dist/mcp.js.map +0 -1
- package/dist/mock/ensure-msw.js +0 -215
- package/dist/mock/ensure-msw.js.map +0 -1
- package/dist/mock/install-mock-fetch-shim.js +0 -36
- package/dist/mock/install-mock-fetch-shim.js.map +0 -1
- package/dist/mock/load-package-mocks.js +0 -136
- package/dist/mock/load-package-mocks.js.map +0 -1
- package/dist/mock/mock-fetch-gateway.js +0 -343
- package/dist/mock/mock-fetch-gateway.js.map +0 -1
- package/dist/mock/mock-gateway-fetch-shim.js +0 -104
- package/dist/mock/mock-gateway-fetch-shim.js.map +0 -1
- package/dist/mock/mock-server.js +0 -499
- package/dist/mock/mock-server.js.map +0 -1
- package/dist/mock/mock-storage.js +0 -186
- package/dist/mock/mock-storage.js.map +0 -1
- package/dist/mock/mock-supported.js +0 -63
- package/dist/mock/mock-supported.js.map +0 -1
- package/dist/mock-dep-resolve.js +0 -47
- package/dist/mock-dep-resolve.js.map +0 -1
- package/dist/mock-local-deps.js +0 -207
- package/dist/mock-local-deps.js.map +0 -1
- package/dist/network-error.js +0 -11
- package/dist/network-error.js.map +0 -1
- package/dist/node-engine.js +0 -21
- package/dist/node-engine.js.map +0 -1
- package/dist/oauth-provider.js +0 -107
- package/dist/oauth-provider.js.map +0 -1
- package/dist/onboarding-prompt.js +0 -15
- package/dist/onboarding-prompt.js.map +0 -1
- package/dist/open-api-client.js +0 -432
- package/dist/open-api-client.js.map +0 -1
- package/dist/open-url.js +0 -21
- package/dist/open-url.js.map +0 -1
- package/dist/org-resolve.js +0 -16
- package/dist/org-resolve.js.map +0 -1
- package/dist/org-slug.js +0 -11
- package/dist/org-slug.js.map +0 -1
- package/dist/org.js +0 -100
- package/dist/org.js.map +0 -1
- package/dist/package-app-dev.js +0 -922
- package/dist/package-app-dev.js.map +0 -1
- package/dist/package-collaborators.js +0 -179
- package/dist/package-collaborators.js.map +0 -1
- package/dist/package-info.js +0 -19
- package/dist/package-info.js.map +0 -1
- package/dist/package-local-runtime-source.js.map +0 -1
- package/dist/package-manifest.js +0 -364
- package/dist/package-manifest.js.map +0 -1
- package/dist/process-info.js +0 -14
- package/dist/process-info.js.map +0 -1
- package/dist/redact.js +0 -16
- package/dist/redact.js.map +0 -1
- package/dist/remote-execute.js +0 -108
- package/dist/remote-execute.js.map +0 -1
- package/dist/setup-git.js +0 -676
- package/dist/setup-git.js.map +0 -1
- package/dist/skill.js +0 -35
- package/dist/skill.js.map +0 -1
- package/dist/store.js +0 -597
- package/dist/store.js.map +0 -1
- package/dist/structured-error.js +0 -57
- package/dist/structured-error.js.map +0 -1
- package/dist/target.js +0 -52
- package/dist/target.js.map +0 -1
- package/dist/tool-result.js +0 -19
- package/dist/tool-result.js.map +0 -1
- package/dist/which.js +0 -22
- package/dist/which.js.map +0 -1
- package/dist/workerd-binary.js +0 -98
- package/dist/workerd-binary.js.map +0 -1
package/dist/dev-command.js
DELETED
|
@@ -1,676 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `kody dev` and its agent-facing subcommands: serve, fetch, job, webhook,
|
|
3
|
-
* emit, check. Covers the four package surfaces: exports (via execute/invoke
|
|
4
|
-
* against the local package), webhooks, schedules (job once), and subscriptions.
|
|
5
|
-
*/
|
|
6
|
-
import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
7
|
-
import { dirname, join, resolve } from 'node:path';
|
|
8
|
-
import { detectCredentialedFetchInSource, mocksSuggestionDetail, } from './credentialed-fetch-scan.js';
|
|
9
|
-
import { buildLocalPackageContext, runLocalPackageModule } from './local-package-run.js';
|
|
10
|
-
import { ensureMockTarget } from './mock/mock-server.js';
|
|
11
|
-
import { packageMocksRelativePath } from './mock/load-package-mocks.js';
|
|
12
|
-
import { startPackageAppDev } from './package-app-dev.js';
|
|
13
|
-
import { loadPackageManifest, resolveExportModulePath, resolvePackagePath, } from './package-manifest.js';
|
|
14
|
-
import { StructuredCliError } from './structured-error.js';
|
|
15
|
-
import { formatToolResult } from './tool-result.js';
|
|
16
|
-
import { bundleLocalUserModule } from './local-bundle.js';
|
|
17
|
-
import { formatDevEvent } from './dev/dev-events.js';
|
|
18
|
-
import { defaultDevPort } from './dev/dev-port.js';
|
|
19
|
-
import { devStatusPath, findRunningDevServer, removeDevRegistration, writeDevRegistration, } from './dev/dev-registry.js';
|
|
20
|
-
export { parseDevPort } from './dev/dev-port.js';
|
|
21
|
-
export async function resolveDevAuth(input) {
|
|
22
|
-
if (input.target !== 'mock') {
|
|
23
|
-
return {
|
|
24
|
-
token: input.token,
|
|
25
|
-
apiUrl: input.apiUrl,
|
|
26
|
-
...(input.org ? { org: input.org } : {}),
|
|
27
|
-
...(input.passthroughHosts?.length
|
|
28
|
-
? { passthroughHosts: input.passthroughHosts }
|
|
29
|
-
: {}),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const ensured = await ensureMockTarget({
|
|
33
|
-
sessionId: input.sessionId,
|
|
34
|
-
resetStorage: input.resetStorage,
|
|
35
|
-
packageId: input.packageId,
|
|
36
|
-
orgSlug: input.orgSlug ?? input.org,
|
|
37
|
-
});
|
|
38
|
-
let mockClosed = false;
|
|
39
|
-
return {
|
|
40
|
-
token: ensured.token,
|
|
41
|
-
apiUrl: ensured.apiUrl,
|
|
42
|
-
...(input.org ? { org: input.org } : {}),
|
|
43
|
-
...(input.depResolve ? { depResolve: input.depResolve } : {}),
|
|
44
|
-
...(input.passthroughHosts?.length
|
|
45
|
-
? { passthroughHosts: input.passthroughHosts }
|
|
46
|
-
: {}),
|
|
47
|
-
mockServer: ensured.server,
|
|
48
|
-
closeMock: ensured.started
|
|
49
|
-
? async () => {
|
|
50
|
-
if (mockClosed)
|
|
51
|
-
return;
|
|
52
|
-
mockClosed = true;
|
|
53
|
-
await ensured.server.close();
|
|
54
|
-
}
|
|
55
|
-
: undefined,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export async function runDevServe(input) {
|
|
59
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
60
|
-
if (input.port === undefined) {
|
|
61
|
-
const running = await findRunningDevServer({ root: manifest.root, target: input.target });
|
|
62
|
-
if (running) {
|
|
63
|
-
const { registration } = running;
|
|
64
|
-
throw new StructuredCliError({
|
|
65
|
-
code: 'dev_already_running',
|
|
66
|
-
target: input.target,
|
|
67
|
-
message: `kody dev is already running for ${manifest.name} at ${registration.origin}${registration.basePath || '/'} (pid ${registration.pid}).`,
|
|
68
|
-
fix: `Reuse it (\`kody dev fetch <path>\` attaches automatically), stop it with \`kill ${registration.pid}\`, or pass --port to start a second server.`,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const onEvent = input.json
|
|
73
|
-
? (event) => writeJsonEvent(input.io, event)
|
|
74
|
-
: (event) => writeDevEvent(input.io, event);
|
|
75
|
-
let registered = false;
|
|
76
|
-
let server;
|
|
77
|
-
try {
|
|
78
|
-
server = await startPackageAppDev({
|
|
79
|
-
manifest,
|
|
80
|
-
token: input.auth.token,
|
|
81
|
-
apiUrl: input.auth.apiUrl,
|
|
82
|
-
target: input.target,
|
|
83
|
-
port: input.port,
|
|
84
|
-
defaultPort: defaultDevPort(manifest.kodyId),
|
|
85
|
-
appBasePath: input.appBasePath,
|
|
86
|
-
...(input.auth.org ? { org: input.auth.org } : {}),
|
|
87
|
-
...(input.auth.depResolve ? { depResolve: input.auth.depResolve } : {}),
|
|
88
|
-
...(input.passthroughHosts?.length
|
|
89
|
-
? { passthroughHosts: input.passthroughHosts }
|
|
90
|
-
: input.auth.passthroughHosts?.length
|
|
91
|
-
? { passthroughHosts: input.auth.passthroughHosts }
|
|
92
|
-
: {}),
|
|
93
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
94
|
-
liveReload: input.liveReload ?? true,
|
|
95
|
-
onStatus: (message) => input.io.stderr(`${message}\n`),
|
|
96
|
-
onError: (message) => input.io.stderr(`${message}\n`),
|
|
97
|
-
onEvent,
|
|
98
|
-
// Register as soon as the port is bound so a second `kody dev`
|
|
99
|
-
// during the first build hits `dev_already_running` instead of
|
|
100
|
-
// stealing the next free port and overwriting the registry.
|
|
101
|
-
// Explicit `--port` starts a second server on purpose — leave the
|
|
102
|
-
// primary attach registry alone so fetch keeps talking to it.
|
|
103
|
-
onListening: async ({ port, hostedUrl, appBasePath }) => {
|
|
104
|
-
if (input.port !== undefined)
|
|
105
|
-
return;
|
|
106
|
-
await writeDevRegistration({
|
|
107
|
-
pid: process.pid,
|
|
108
|
-
origin: hostedUrl,
|
|
109
|
-
port,
|
|
110
|
-
basePath: appBasePath,
|
|
111
|
-
target: input.target,
|
|
112
|
-
root: manifest.root,
|
|
113
|
-
});
|
|
114
|
-
registered = true;
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
if (registered) {
|
|
120
|
-
await removeDevRegistration(manifest.root, process.pid, input.target).catch(() => { });
|
|
121
|
-
}
|
|
122
|
-
await input.auth.closeMock?.();
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
const shutdown = async () => {
|
|
126
|
-
await server.close();
|
|
127
|
-
await removeDevRegistration(manifest.root, process.pid, input.target).catch(() => { });
|
|
128
|
-
if (input.readyFile)
|
|
129
|
-
await removeOwnedReadyFile(input.readyFile, process.pid);
|
|
130
|
-
await input.auth.closeMock?.();
|
|
131
|
-
};
|
|
132
|
-
try {
|
|
133
|
-
const status = server.status();
|
|
134
|
-
const statusUrl = `${server.hostedUrl}${devStatusPath}`;
|
|
135
|
-
const ready = {
|
|
136
|
-
url: status.url,
|
|
137
|
-
port: server.port,
|
|
138
|
-
basePath: server.appBasePath,
|
|
139
|
-
pid: process.pid,
|
|
140
|
-
statusUrl,
|
|
141
|
-
};
|
|
142
|
-
if (input.readyFile) {
|
|
143
|
-
await mkdir(dirname(input.readyFile), { recursive: true });
|
|
144
|
-
await writeFile(input.readyFile, `${JSON.stringify(ready, null, 2)}\n`);
|
|
145
|
-
}
|
|
146
|
-
if (input.json) {
|
|
147
|
-
input.io.stdout(`${JSON.stringify({
|
|
148
|
-
type: 'ready',
|
|
149
|
-
ts: new Date().toISOString(),
|
|
150
|
-
...ready,
|
|
151
|
-
target: input.target,
|
|
152
|
-
package: status.package,
|
|
153
|
-
buildId: status.buildId,
|
|
154
|
-
state: status.state,
|
|
155
|
-
})}\n`);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
input.io.stdout(`kody dev listening on ${status.url}\n` +
|
|
159
|
-
`target: ${input.target}\n` +
|
|
160
|
-
`package: ${manifest.name} (${manifest.kodyId})\n` +
|
|
161
|
-
`status: ${statusUrl}\n` +
|
|
162
|
-
`Agents: kody dev fetch /path | job <name> | webhook <name> --body file.json | emit <event> --body file.json | check\n`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
// Ready-file failures must not leave the listen handles up.
|
|
167
|
-
await shutdown().catch(() => { });
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
if (input.serveOnce) {
|
|
171
|
-
await shutdown();
|
|
172
|
-
return 0;
|
|
173
|
-
}
|
|
174
|
-
await new Promise((resolveWait) => {
|
|
175
|
-
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
176
|
-
const stop = async () => {
|
|
177
|
-
for (const signal of signals)
|
|
178
|
-
process.off(signal, onSig);
|
|
179
|
-
await shutdown();
|
|
180
|
-
resolveWait();
|
|
181
|
-
};
|
|
182
|
-
const onSig = () => {
|
|
183
|
-
void stop();
|
|
184
|
-
};
|
|
185
|
-
for (const signal of signals)
|
|
186
|
-
process.on(signal, onSig);
|
|
187
|
-
});
|
|
188
|
-
return 0;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* `kody dev fetch` against an already running `kody dev` for this package and
|
|
192
|
-
* target, if there is one. Returns null when nothing is running so the caller
|
|
193
|
-
* can boot a one-shot server.
|
|
194
|
-
*/
|
|
195
|
-
export async function tryAttachedDevFetch(input) {
|
|
196
|
-
let root;
|
|
197
|
-
try {
|
|
198
|
-
root = (await loadPackageManifest(input.cwd)).root;
|
|
199
|
-
}
|
|
200
|
-
catch {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
const running = await findRunningDevServer({ root, target: input.target });
|
|
204
|
-
if (!running)
|
|
205
|
-
return null;
|
|
206
|
-
const { registration } = running;
|
|
207
|
-
const rest = input.path.startsWith('/') ? input.path : `/${input.path}`;
|
|
208
|
-
const url = new URL(`${registration.basePath}${rest === '/' && registration.basePath ? '' : rest}` || '/', registration.origin);
|
|
209
|
-
input.io.stderr(`Attached to running kody dev (pid ${registration.pid}) at ${registration.origin}\n`);
|
|
210
|
-
const response = await fetch(url, {
|
|
211
|
-
method: input.method ?? 'GET',
|
|
212
|
-
headers: input.body ? { 'content-type': 'application/json' } : undefined,
|
|
213
|
-
body: input.body,
|
|
214
|
-
});
|
|
215
|
-
const body = await response.text();
|
|
216
|
-
const headers = {};
|
|
217
|
-
response.headers.forEach((value, key) => {
|
|
218
|
-
headers[key] = value;
|
|
219
|
-
});
|
|
220
|
-
const result = { status: response.status, headers, body };
|
|
221
|
-
if (input.json) {
|
|
222
|
-
input.io.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
input.io.stdout(`HTTP ${result.status}\n${result.body}\n`);
|
|
226
|
-
}
|
|
227
|
-
return result.status >= 400 ? 1 : 0;
|
|
228
|
-
}
|
|
229
|
-
export async function runDevFetch(input) {
|
|
230
|
-
let server;
|
|
231
|
-
try {
|
|
232
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
233
|
-
server = await startPackageAppDev({
|
|
234
|
-
manifest,
|
|
235
|
-
token: input.auth.token,
|
|
236
|
-
apiUrl: input.auth.apiUrl,
|
|
237
|
-
target: input.target,
|
|
238
|
-
port: input.port,
|
|
239
|
-
appBasePath: input.appBasePath,
|
|
240
|
-
...(input.auth.org ? { org: input.auth.org } : {}),
|
|
241
|
-
...(input.auth.depResolve ? { depResolve: input.auth.depResolve } : {}),
|
|
242
|
-
...(input.auth.passthroughHosts?.length
|
|
243
|
-
? { passthroughHosts: input.auth.passthroughHosts }
|
|
244
|
-
: {}),
|
|
245
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
246
|
-
watch: false,
|
|
247
|
-
onStatus: (message) => input.io.stderr(`${message}\n`),
|
|
248
|
-
onError: (message) => input.io.stderr(`${message}\n`),
|
|
249
|
-
onEvent: (event) => {
|
|
250
|
-
// stdout is reserved for the fetch result; logs and errors go to stderr.
|
|
251
|
-
// Without a watcher a build error rejects startup, and the CLI prints that.
|
|
252
|
-
if (event.type === 'log' || event.type === 'runtime_error') {
|
|
253
|
-
input.io.stderr(`${formatDevEvent(event).text}\n`);
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
catch (error) {
|
|
259
|
-
await input.auth.closeMock?.();
|
|
260
|
-
if (input.json) {
|
|
261
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
262
|
-
input.io.stdout(`${JSON.stringify({ type: 'build_error', message, ts: new Date().toISOString() }, null, 2)}\n`);
|
|
263
|
-
}
|
|
264
|
-
throw error;
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
const result = await server.fetchPath(input.path, {
|
|
268
|
-
method: input.method,
|
|
269
|
-
body: input.body,
|
|
270
|
-
headers: input.body
|
|
271
|
-
? { 'content-type': 'application/json' }
|
|
272
|
-
: undefined,
|
|
273
|
-
});
|
|
274
|
-
if (input.json) {
|
|
275
|
-
input.io.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
input.io.stdout(`HTTP ${result.status}\n${result.body}\n`);
|
|
279
|
-
}
|
|
280
|
-
return result.status >= 400 ? 1 : 0;
|
|
281
|
-
}
|
|
282
|
-
finally {
|
|
283
|
-
await server.close();
|
|
284
|
-
await input.auth.closeMock?.();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
export async function runDevJob(input) {
|
|
288
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
289
|
-
const job = manifest.jobs[input.jobName];
|
|
290
|
-
if (!job) {
|
|
291
|
-
throw new StructuredCliError({
|
|
292
|
-
code: 'dev_surface_missing',
|
|
293
|
-
message: `No job named ${JSON.stringify(input.jobName)}.`,
|
|
294
|
-
where: manifest.packageJsonPath,
|
|
295
|
-
fix: `Known jobs: ${Object.keys(manifest.jobs).join(', ') || '(none)'}.`,
|
|
296
|
-
target: input.target,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
const modulePath = resolvePackagePath(manifest, job.entry);
|
|
300
|
-
if (input.dryRun) {
|
|
301
|
-
return printDevDryRun({
|
|
302
|
-
target: input.target,
|
|
303
|
-
surface: `job:${input.jobName}`,
|
|
304
|
-
modulePath,
|
|
305
|
-
params: undefined,
|
|
306
|
-
extra: {
|
|
307
|
-
schedule: job.schedule,
|
|
308
|
-
scheduleRaw: job.scheduleRaw,
|
|
309
|
-
timezone: job.timezone ?? null,
|
|
310
|
-
enabled: job.enabled ?? null,
|
|
311
|
-
},
|
|
312
|
-
json: input.json,
|
|
313
|
-
io: input.io,
|
|
314
|
-
closeMock: input.auth.closeMock,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
// Scheduler contract: no params. Never schedules locally — runs once.
|
|
318
|
-
return await runPackageModuleOnce({
|
|
319
|
-
manifest,
|
|
320
|
-
modulePath,
|
|
321
|
-
params: undefined,
|
|
322
|
-
target: input.target,
|
|
323
|
-
auth: input.auth,
|
|
324
|
-
json: input.json,
|
|
325
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
326
|
-
io: input.io,
|
|
327
|
-
surface: `job:${input.jobName}`,
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
export async function runDevWebhook(input) {
|
|
331
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
332
|
-
const webhook = manifest.webhooks[input.webhookName];
|
|
333
|
-
if (!webhook) {
|
|
334
|
-
throw new StructuredCliError({
|
|
335
|
-
code: 'dev_surface_missing',
|
|
336
|
-
message: `No webhook named ${JSON.stringify(input.webhookName)}.`,
|
|
337
|
-
where: manifest.packageJsonPath,
|
|
338
|
-
fix: `Known webhooks: ${Object.keys(manifest.webhooks).join(', ') || '(none)'}.`,
|
|
339
|
-
target: input.target,
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
const rawBody = await readFile(resolve(input.cwd ?? process.cwd(), input.bodyPath), 'utf8');
|
|
343
|
-
let jsonBody = null;
|
|
344
|
-
try {
|
|
345
|
-
jsonBody = JSON.parse(rawBody);
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
348
|
-
jsonBody = null;
|
|
349
|
-
}
|
|
350
|
-
const params = webhook.inputMode === 'params'
|
|
351
|
-
? (jsonBody ?? {})
|
|
352
|
-
: {
|
|
353
|
-
webhook: {
|
|
354
|
-
packageKodyId: manifest.kodyId,
|
|
355
|
-
name: input.webhookName,
|
|
356
|
-
receivedAt: new Date().toISOString(),
|
|
357
|
-
},
|
|
358
|
-
request: {
|
|
359
|
-
method: 'POST',
|
|
360
|
-
contentType: 'application/json',
|
|
361
|
-
headers: { 'content-type': 'application/json' },
|
|
362
|
-
body: rawBody,
|
|
363
|
-
json: jsonBody,
|
|
364
|
-
},
|
|
365
|
-
synthetic: true,
|
|
366
|
-
};
|
|
367
|
-
const modulePath = resolveExportModulePath(manifest, webhook.export);
|
|
368
|
-
if (input.dryRun) {
|
|
369
|
-
return printDevDryRun({
|
|
370
|
-
target: input.target,
|
|
371
|
-
surface: `webhook:${input.webhookName}`,
|
|
372
|
-
modulePath,
|
|
373
|
-
params,
|
|
374
|
-
extra: { export: webhook.export, bodyPath: input.bodyPath },
|
|
375
|
-
json: input.json,
|
|
376
|
-
io: input.io,
|
|
377
|
-
closeMock: input.auth.closeMock,
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
return await runPackageModuleOnce({
|
|
381
|
-
manifest,
|
|
382
|
-
modulePath,
|
|
383
|
-
params,
|
|
384
|
-
target: input.target,
|
|
385
|
-
auth: input.auth,
|
|
386
|
-
json: input.json,
|
|
387
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
388
|
-
io: input.io,
|
|
389
|
-
surface: `webhook:${input.webhookName}`,
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Deliver an event to the local subscription handler in the platform's delivery
|
|
394
|
-
* shape. On mock, any event type is allowed (handler may still validate).
|
|
395
|
-
*/
|
|
396
|
-
export async function runDevEmit(input) {
|
|
397
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
398
|
-
const subscription = manifest.subscriptions[input.event];
|
|
399
|
-
if (!subscription) {
|
|
400
|
-
if (input.target !== 'mock') {
|
|
401
|
-
throw new StructuredCliError({
|
|
402
|
-
code: 'dev_surface_missing',
|
|
403
|
-
message: `No subscription for event ${JSON.stringify(input.event)}.`,
|
|
404
|
-
where: manifest.packageJsonPath,
|
|
405
|
-
fix: `Known subscriptions: ${Object.keys(manifest.subscriptions).join(', ') || '(none)'}. On --target mock you can still declare the handler first.`,
|
|
406
|
-
target: input.target,
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
throw new StructuredCliError({
|
|
410
|
-
code: 'dev_surface_missing',
|
|
411
|
-
message: `No subscription for event ${JSON.stringify(input.event)} in package.json#kody.subscriptions.`,
|
|
412
|
-
where: manifest.packageJsonPath,
|
|
413
|
-
fix: `Add a handler under kody.subscriptions[${JSON.stringify(input.event)}], then retry. Mock allows any event type once declared.`,
|
|
414
|
-
target: input.target,
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
const rawBody = await readFile(resolve(input.cwd ?? process.cwd(), input.bodyPath), 'utf8');
|
|
418
|
-
let envelope;
|
|
419
|
-
try {
|
|
420
|
-
const parsed = JSON.parse(rawBody);
|
|
421
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
422
|
-
throw new Error('body must be a JSON object');
|
|
423
|
-
}
|
|
424
|
-
envelope = { ...parsed };
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
throw new StructuredCliError({
|
|
428
|
-
code: 'package_manifest_invalid',
|
|
429
|
-
message: `Could not parse event body ${input.bodyPath} as a JSON object.`,
|
|
430
|
-
fix: 'Pass --body event.json with the platform delivery envelope fields.',
|
|
431
|
-
details: { cause: error instanceof Error ? error.message : String(error) },
|
|
432
|
-
target: input.target,
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
// Platform delivery shape: caller body is the handler params; mark synthetic.
|
|
436
|
-
if (typeof envelope.event !== 'string') {
|
|
437
|
-
envelope.event = input.event;
|
|
438
|
-
}
|
|
439
|
-
envelope.synthetic = true;
|
|
440
|
-
if (envelope.idempotency_key === undefined) {
|
|
441
|
-
envelope.idempotency_key = `synthetic:local:${Date.now()}`;
|
|
442
|
-
}
|
|
443
|
-
const modulePath = resolvePackagePath(manifest, subscription.handler);
|
|
444
|
-
if (input.dryRun) {
|
|
445
|
-
return printDevDryRun({
|
|
446
|
-
target: input.target,
|
|
447
|
-
surface: `subscription:${input.event}`,
|
|
448
|
-
modulePath,
|
|
449
|
-
params: envelope,
|
|
450
|
-
extra: { handler: subscription.handler, bodyPath: input.bodyPath },
|
|
451
|
-
json: input.json,
|
|
452
|
-
io: input.io,
|
|
453
|
-
closeMock: input.auth.closeMock,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
return await runPackageModuleOnce({
|
|
457
|
-
manifest,
|
|
458
|
-
modulePath,
|
|
459
|
-
params: envelope,
|
|
460
|
-
target: input.target,
|
|
461
|
-
auth: input.auth,
|
|
462
|
-
json: input.json,
|
|
463
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
464
|
-
io: input.io,
|
|
465
|
-
surface: `subscription:${input.event}`,
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Bundle the package surfaces + light publish validations without running them.
|
|
470
|
-
* Soft-suggests `.kody/mocks.ts` when credentialed fetch is detected.
|
|
471
|
-
*/
|
|
472
|
-
export async function runDevCheck(input) {
|
|
473
|
-
const manifest = await loadPackageManifest(input.cwd);
|
|
474
|
-
const checks = [];
|
|
475
|
-
const credentialSignals = [];
|
|
476
|
-
const push = (name, ok, detail) => {
|
|
477
|
-
checks.push({ name, ok, detail });
|
|
478
|
-
};
|
|
479
|
-
const bundleAndScan = async (label, modulePath) => {
|
|
480
|
-
try {
|
|
481
|
-
const bundled = await bundleLocalUserModule(modulePath);
|
|
482
|
-
push(label, true, label.startsWith('app.entry') ? modulePath : undefined);
|
|
483
|
-
credentialSignals.push(...(await detectCredentialedFetchInSource(bundled, label)));
|
|
484
|
-
}
|
|
485
|
-
catch (error) {
|
|
486
|
-
push(label, false, error instanceof Error ? error.message : String(error));
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
push('package.json', true, manifest.name);
|
|
490
|
-
push('kody.id', Boolean(manifest.kodyId), manifest.kodyId);
|
|
491
|
-
try {
|
|
492
|
-
await readFile(resolve(manifest.root, 'README.md'));
|
|
493
|
-
push('README.md', true);
|
|
494
|
-
}
|
|
495
|
-
catch {
|
|
496
|
-
push('README.md', false, 'Publish requires README.md');
|
|
497
|
-
}
|
|
498
|
-
try {
|
|
499
|
-
await readFile(resolve(manifest.root, 'AGENTS.md'));
|
|
500
|
-
push('AGENTS.md', true);
|
|
501
|
-
}
|
|
502
|
-
catch {
|
|
503
|
-
push('AGENTS.md', false, 'Publish requires AGENTS.md');
|
|
504
|
-
}
|
|
505
|
-
if (manifest.app?.entry) {
|
|
506
|
-
await bundleAndScan('app.entry bundle', resolvePackagePath(manifest, manifest.app.entry));
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
push('app.entry', true, 'none (ok)');
|
|
510
|
-
}
|
|
511
|
-
for (const [name, job] of Object.entries(manifest.jobs)) {
|
|
512
|
-
await bundleAndScan(`job:${name}`, resolvePackagePath(manifest, job.entry));
|
|
513
|
-
}
|
|
514
|
-
for (const [name, webhook] of Object.entries(manifest.webhooks)) {
|
|
515
|
-
await bundleAndScan(`webhook:${name}`, resolveExportModulePath(manifest, webhook.export));
|
|
516
|
-
}
|
|
517
|
-
for (const [topic, sub] of Object.entries(manifest.subscriptions)) {
|
|
518
|
-
await bundleAndScan(`subscription:${topic}`, resolvePackagePath(manifest, sub.handler));
|
|
519
|
-
}
|
|
520
|
-
for (const [key, rel] of Object.entries(manifest.exports)) {
|
|
521
|
-
await bundleAndScan(`export:${key}`, resolvePackagePath(manifest, rel));
|
|
522
|
-
}
|
|
523
|
-
let hasMocksFile = false;
|
|
524
|
-
try {
|
|
525
|
-
await access(join(manifest.root, packageMocksRelativePath));
|
|
526
|
-
hasMocksFile = true;
|
|
527
|
-
}
|
|
528
|
-
catch {
|
|
529
|
-
hasMocksFile = false;
|
|
530
|
-
}
|
|
531
|
-
const mocksDetail = mocksSuggestionDetail({
|
|
532
|
-
signals: credentialSignals,
|
|
533
|
-
hasMocksFile,
|
|
534
|
-
});
|
|
535
|
-
if (mocksDetail) {
|
|
536
|
-
// Soft tip — never fails the check; agents learn before unmocked_request.
|
|
537
|
-
push(packageMocksRelativePath, true, mocksDetail);
|
|
538
|
-
}
|
|
539
|
-
const failed = checks.filter((check) => !check.ok);
|
|
540
|
-
if (input.json) {
|
|
541
|
-
input.io.stdout(`${JSON.stringify({
|
|
542
|
-
target: input.target,
|
|
543
|
-
checks,
|
|
544
|
-
ok: failed.length === 0,
|
|
545
|
-
...(credentialSignals.length > 0
|
|
546
|
-
? {
|
|
547
|
-
credentialedFetch: {
|
|
548
|
-
detected: true,
|
|
549
|
-
hasMocksFile,
|
|
550
|
-
signals: credentialSignals,
|
|
551
|
-
},
|
|
552
|
-
}
|
|
553
|
-
: {}),
|
|
554
|
-
}, null, 2)}\n`);
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
for (const check of checks) {
|
|
558
|
-
const mark = check.ok ? 'ok' : 'FAIL';
|
|
559
|
-
input.io.stdout(`${mark.padEnd(4)} ${check.name}${check.detail ? ` — ${check.detail}` : ''}\n`);
|
|
560
|
-
}
|
|
561
|
-
input.io.stdout(failed.length === 0
|
|
562
|
-
? `kody dev check passed (${checks.length} checks, target ${input.target})\n`
|
|
563
|
-
: `kody dev check failed: ${failed.length}/${checks.length}\n`);
|
|
564
|
-
}
|
|
565
|
-
return failed.length === 0 ? 0 : 1;
|
|
566
|
-
}
|
|
567
|
-
async function runPackageModuleOnce(input) {
|
|
568
|
-
const packageContext = buildLocalPackageContext({
|
|
569
|
-
kodyId: input.manifest.kodyId,
|
|
570
|
-
hostedUrl: input.auth.apiUrl.startsWith('http')
|
|
571
|
-
? 'http://127.0.0.1:0'
|
|
572
|
-
: 'http://127.0.0.1:0',
|
|
573
|
-
appBasePath: '',
|
|
574
|
-
});
|
|
575
|
-
try {
|
|
576
|
-
const result = await runLocalPackageModule({
|
|
577
|
-
modulePath: input.modulePath,
|
|
578
|
-
params: input.params,
|
|
579
|
-
token: input.auth.token,
|
|
580
|
-
apiUrl: input.auth.apiUrl,
|
|
581
|
-
target: input.target,
|
|
582
|
-
packageContext,
|
|
583
|
-
packageRoot: input.manifest.root,
|
|
584
|
-
...(input.auth.org ? { org: input.auth.org } : {}),
|
|
585
|
-
...(input.auth.depResolve ? { depResolve: input.auth.depResolve } : {}),
|
|
586
|
-
...(input.auth.passthroughHosts?.length
|
|
587
|
-
? { passthroughHosts: input.auth.passthroughHosts }
|
|
588
|
-
: {}),
|
|
589
|
-
allowPrivateNetwork: input.allowPrivateNetwork,
|
|
590
|
-
onStatus: (message) => input.io.stderr(`${message}\n`),
|
|
591
|
-
});
|
|
592
|
-
input.io.stdout(formatToolResult(result, input.json === true));
|
|
593
|
-
return result.isError ? 1 : 0;
|
|
594
|
-
}
|
|
595
|
-
finally {
|
|
596
|
-
await input.auth.closeMock?.();
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Show what `kody dev job|webhook|emit` would run without invoking the module
|
|
601
|
-
* (safe against prod side effects).
|
|
602
|
-
*/
|
|
603
|
-
async function printDevDryRun(input) {
|
|
604
|
-
try {
|
|
605
|
-
const plan = {
|
|
606
|
-
dryRun: true,
|
|
607
|
-
wouldInvoke: true,
|
|
608
|
-
target: input.target,
|
|
609
|
-
surface: input.surface,
|
|
610
|
-
modulePath: input.modulePath,
|
|
611
|
-
params: input.params ?? null,
|
|
612
|
-
...(input.extra ?? {}),
|
|
613
|
-
note: input.target === 'prod'
|
|
614
|
-
? 'No module run and no prod side effects. Drop --dry-run to invoke once against prod CapabilityProxy.'
|
|
615
|
-
: 'No module run. Drop --dry-run to invoke against the selected target.',
|
|
616
|
-
};
|
|
617
|
-
if (input.json) {
|
|
618
|
-
input.io.stdout(`${JSON.stringify(plan, null, 2)}\n`);
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
input.io.stdout(`dry-run: would invoke ${input.surface} on --target ${input.target}\n` +
|
|
622
|
-
`module: ${input.modulePath}\n` +
|
|
623
|
-
`params: ${JSON.stringify(input.params ?? null, null, 2)}\n` +
|
|
624
|
-
(input.extra
|
|
625
|
-
? `detail: ${JSON.stringify(input.extra, null, 2)}\n`
|
|
626
|
-
: '') +
|
|
627
|
-
`${plan.note}\n`);
|
|
628
|
-
}
|
|
629
|
-
return 0;
|
|
630
|
-
}
|
|
631
|
-
finally {
|
|
632
|
-
await input.closeMock?.();
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
function writeJsonEvent(io, event) {
|
|
636
|
-
io.stdout(`${JSON.stringify({ ...event, ts: new Date().toISOString() })}\n`);
|
|
637
|
-
}
|
|
638
|
-
function writeDevEvent(io, event) {
|
|
639
|
-
const { stream, text } = formatDevEvent(event);
|
|
640
|
-
io[stream](`${text}\n`);
|
|
641
|
-
}
|
|
642
|
-
/** Parse `kody dev` argv after the `dev` token. */
|
|
643
|
-
export function parseDevSubcommand(positionals) {
|
|
644
|
-
const raw = positionals[0];
|
|
645
|
-
if (!raw || raw.startsWith('-')) {
|
|
646
|
-
return { subcommand: 'serve', rest: positionals };
|
|
647
|
-
}
|
|
648
|
-
switch (raw) {
|
|
649
|
-
case 'serve':
|
|
650
|
-
case 'fetch':
|
|
651
|
-
case 'job':
|
|
652
|
-
case 'webhook':
|
|
653
|
-
case 'emit':
|
|
654
|
-
case 'check':
|
|
655
|
-
return { subcommand: raw, rest: positionals.slice(1) };
|
|
656
|
-
default:
|
|
657
|
-
throw new Error(`Unknown kody dev subcommand ${JSON.stringify(raw)}. Use serve | fetch | job | webhook | emit | check.`);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* Remove `--ready-file` only when it still names this process. A successor
|
|
662
|
-
* `kody dev` may have rewritten the same path before our shutdown finishes.
|
|
663
|
-
*/
|
|
664
|
-
export async function removeOwnedReadyFile(path, ownerPid) {
|
|
665
|
-
try {
|
|
666
|
-
const parsed = JSON.parse(await readFile(path, 'utf8'));
|
|
667
|
-
if (parsed.pid !== ownerPid)
|
|
668
|
-
return;
|
|
669
|
-
await rm(path, { force: true });
|
|
670
|
-
}
|
|
671
|
-
catch {
|
|
672
|
-
// Missing or unreadable — nothing to clean up.
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
void null;
|
|
676
|
-
//# sourceMappingURL=dev-command.js.map
|