runwork 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19272 -116
- package/package.json +4 -4
- package/dist/__tests__/curl-parser.test.d.ts +0 -1
- package/dist/__tests__/curl-parser.test.js +0 -250
- package/dist/__tests__/install-scripts.test.d.ts +0 -1
- package/dist/__tests__/install-scripts.test.js +0 -280
- package/dist/__tests__/types-manager.test.d.ts +0 -1
- package/dist/__tests__/types-manager.test.js +0 -89
- package/dist/agents/__tests__/chatgpt-registry.test.d.ts +0 -1
- package/dist/agents/__tests__/chatgpt-registry.test.js +0 -61
- package/dist/agents/__tests__/claude-code-managed-block.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-managed-block.test.js +0 -97
- package/dist/agents/__tests__/claude-code-plugin.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-plugin.test.js +0 -47
- package/dist/agents/__tests__/claude-code-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-code-stats.test.js +0 -390
- package/dist/agents/__tests__/claude-desktop-memory.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-memory.test.js +0 -154
- package/dist/agents/__tests__/claude-desktop-plugin-tree.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-plugin-tree.test.js +0 -161
- package/dist/agents/__tests__/claude-desktop-plugin.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-plugin.test.js +0 -117
- package/dist/agents/__tests__/claude-desktop-rpm.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-rpm.test.js +0 -126
- package/dist/agents/__tests__/claude-desktop-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/claude-desktop-stats.test.js +0 -280
- package/dist/agents/__tests__/codex-instructions.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-instructions.test.js +0 -57
- package/dist/agents/__tests__/codex-minimum-permissions.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-minimum-permissions.test.js +0 -82
- package/dist/agents/__tests__/codex-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/codex-stats.test.js +0 -370
- package/dist/agents/__tests__/cursor-merge.test.d.ts +0 -1
- package/dist/agents/__tests__/cursor-merge.test.js +0 -66
- package/dist/agents/__tests__/cursor-stats.test.d.ts +0 -1
- package/dist/agents/__tests__/cursor-stats.test.js +0 -183
- package/dist/agents/__tests__/defaults-merge.test.d.ts +0 -1
- package/dist/agents/__tests__/defaults-merge.test.js +0 -268
- package/dist/agents/__tests__/detection.test.d.ts +0 -1
- package/dist/agents/__tests__/detection.test.js +0 -89
- package/dist/agents/__tests__/graceful-degradation.test.d.ts +0 -1
- package/dist/agents/__tests__/graceful-degradation.test.js +0 -129
- package/dist/agents/__tests__/instruction-hint.test.d.ts +0 -1
- package/dist/agents/__tests__/instruction-hint.test.js +0 -69
- package/dist/agents/__tests__/intro-skill.test.d.ts +0 -1
- package/dist/agents/__tests__/intro-skill.test.js +0 -193
- package/dist/agents/__tests__/schema-validation.test.d.ts +0 -1
- package/dist/agents/__tests__/schema-validation.test.js +0 -212
- package/dist/agents/__tests__/skill-slug.test.d.ts +0 -1
- package/dist/agents/__tests__/skill-slug.test.js +0 -77
- package/dist/agents/claude-code.d.ts +0 -53
- package/dist/agents/claude-code.js +0 -754
- package/dist/agents/claude-desktop-plugin-tree.d.ts +0 -59
- package/dist/agents/claude-desktop-plugin-tree.js +0 -143
- package/dist/agents/claude-desktop.d.ts +0 -47
- package/dist/agents/claude-desktop.js +0 -684
- package/dist/agents/cline.d.ts +0 -15
- package/dist/agents/cline.js +0 -130
- package/dist/agents/codex.d.ts +0 -44
- package/dist/agents/codex.js +0 -453
- package/dist/agents/conversation-skills.d.ts +0 -18
- package/dist/agents/conversation-skills.js +0 -229
- package/dist/agents/cursor.d.ts +0 -48
- package/dist/agents/cursor.js +0 -324
- package/dist/agents/default-config.d.ts +0 -30
- package/dist/agents/default-config.js +0 -67
- package/dist/agents/defaults-merge.d.ts +0 -72
- package/dist/agents/defaults-merge.js +0 -131
- package/dist/agents/detect.d.ts +0 -4
- package/dist/agents/detect.js +0 -67
- package/dist/agents/detection.d.ts +0 -18
- package/dist/agents/detection.js +0 -94
- package/dist/agents/gemini.d.ts +0 -15
- package/dist/agents/gemini.js +0 -122
- package/dist/agents/generic-adapter.d.ts +0 -25
- package/dist/agents/generic-adapter.js +0 -151
- package/dist/agents/intro-skill.d.ts +0 -45
- package/dist/agents/intro-skill.js +0 -447
- package/dist/agents/registry-data.d.ts +0 -192
- package/dist/agents/registry-data.js +0 -669
- package/dist/agents/registry.d.ts +0 -13
- package/dist/agents/registry.js +0 -36
- package/dist/agents/runtime-detection.d.ts +0 -82
- package/dist/agents/runtime-detection.js +0 -271
- package/dist/agents/session-start-hook.d.ts +0 -37
- package/dist/agents/session-start-hook.js +0 -159
- package/dist/agents/types.d.ts +0 -171
- package/dist/agents/types.js +0 -75
- package/dist/agents/utils/instruction-hint.d.ts +0 -21
- package/dist/agents/utils/instruction-hint.js +0 -108
- package/dist/agents/utils/json-config.d.ts +0 -19
- package/dist/agents/utils/json-config.js +0 -69
- package/dist/agents/utils/toml-config.d.ts +0 -8
- package/dist/agents/utils/toml-config.js +0 -27
- package/dist/agents/windsurf.d.ts +0 -14
- package/dist/agents/windsurf.js +0 -102
- package/dist/api/__tests__/client.test.d.ts +0 -1
- package/dist/api/__tests__/client.test.js +0 -272
- package/dist/api/client.d.ts +0 -326
- package/dist/api/client.js +0 -427
- package/dist/auth/__tests__/login-flow.test.d.ts +0 -1
- package/dist/auth/__tests__/login-flow.test.js +0 -101
- package/dist/auth/__tests__/store.test.d.ts +0 -1
- package/dist/auth/__tests__/store.test.js +0 -132
- package/dist/auth/login-flow.d.ts +0 -26
- package/dist/auth/login-flow.js +0 -137
- package/dist/auth/store.d.ts +0 -5
- package/dist/auth/store.js +0 -62
- package/dist/commands/__tests__/clone-args.test.d.ts +0 -1
- package/dist/commands/__tests__/clone-args.test.js +0 -51
- package/dist/commands/__tests__/clone-source-result.test.d.ts +0 -1
- package/dist/commands/__tests__/clone-source-result.test.js +0 -45
- package/dist/commands/__tests__/info-merge.test.d.ts +0 -1
- package/dist/commands/__tests__/info-merge.test.js +0 -55
- package/dist/commands/__tests__/mcp-entries.test.d.ts +0 -1
- package/dist/commands/__tests__/mcp-entries.test.js +0 -48
- package/dist/commands/__tests__/setup-persona.test.d.ts +0 -1
- package/dist/commands/__tests__/setup-persona.test.js +0 -31
- package/dist/commands/__tests__/setup.test.d.ts +0 -1
- package/dist/commands/__tests__/setup.test.js +0 -81
- package/dist/commands/__tests__/sync-redetect.test.d.ts +0 -1
- package/dist/commands/__tests__/sync-redetect.test.js +0 -96
- package/dist/commands/__tests__/sync-telemetry.test.d.ts +0 -1
- package/dist/commands/__tests__/sync-telemetry.test.js +0 -281
- package/dist/commands/__tests__/upgrade.test.d.ts +0 -1
- package/dist/commands/__tests__/upgrade.test.js +0 -157
- package/dist/commands/agents.d.ts +0 -2
- package/dist/commands/agents.js +0 -160
- package/dist/commands/api-keys.d.ts +0 -2
- package/dist/commands/api-keys.js +0 -95
- package/dist/commands/apps.d.ts +0 -2
- package/dist/commands/apps.js +0 -82
- package/dist/commands/build-plugin.d.ts +0 -2
- package/dist/commands/build-plugin.js +0 -135
- package/dist/commands/clone.d.ts +0 -60
- package/dist/commands/clone.js +0 -271
- package/dist/commands/components.d.ts +0 -2
- package/dist/commands/components.js +0 -43
- package/dist/commands/deploy.d.ts +0 -2
- package/dist/commands/deploy.js +0 -279
- package/dist/commands/dev.d.ts +0 -11
- package/dist/commands/dev.js +0 -1011
- package/dist/commands/doctor.d.ts +0 -2
- package/dist/commands/doctor.js +0 -230
- package/dist/commands/endpoints.d.ts +0 -2
- package/dist/commands/endpoints.js +0 -189
- package/dist/commands/entities.d.ts +0 -2
- package/dist/commands/entities.js +0 -198
- package/dist/commands/files.d.ts +0 -2
- package/dist/commands/files.js +0 -193
- package/dist/commands/inbox.d.ts +0 -11
- package/dist/commands/inbox.js +0 -60
- package/dist/commands/info.d.ts +0 -178
- package/dist/commands/info.js +0 -455
- package/dist/commands/init.d.ts +0 -21
- package/dist/commands/init.js +0 -185
- package/dist/commands/integrations.d.ts +0 -2
- package/dist/commands/integrations.js +0 -233
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -44
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.js +0 -13
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -232
- package/dist/commands/mcp-entries.d.ts +0 -13
- package/dist/commands/mcp-entries.js +0 -26
- package/dist/commands/mcp.d.ts +0 -2
- package/dist/commands/mcp.js +0 -245
- package/dist/commands/open.d.ts +0 -2
- package/dist/commands/open.js +0 -53
- package/dist/commands/resume.d.ts +0 -2
- package/dist/commands/resume.js +0 -289
- package/dist/commands/save-convo.d.ts +0 -8
- package/dist/commands/save-convo.js +0 -20
- package/dist/commands/schedules.d.ts +0 -2
- package/dist/commands/schedules.js +0 -221
- package/dist/commands/setup.d.ts +0 -27
- package/dist/commands/setup.js +0 -177
- package/dist/commands/share-convo.d.ts +0 -24
- package/dist/commands/share-convo.js +0 -167
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -352
- package/dist/commands/sync-telemetry.d.ts +0 -33
- package/dist/commands/sync-telemetry.js +0 -186
- package/dist/commands/sync.d.ts +0 -37
- package/dist/commands/sync.js +0 -702
- package/dist/commands/uninstall.d.ts +0 -2
- package/dist/commands/uninstall.js +0 -145
- package/dist/commands/upgrade.d.ts +0 -14
- package/dist/commands/upgrade.js +0 -217
- package/dist/commands/validate.d.ts +0 -2
- package/dist/commands/validate.js +0 -89
- package/dist/commands/welcome.d.ts +0 -1
- package/dist/commands/welcome.js +0 -86
- package/dist/commands/workflows.d.ts +0 -2
- package/dist/commands/workflows.js +0 -187
- package/dist/deploy/__tests__/deploy-state.test.d.ts +0 -1
- package/dist/deploy/__tests__/deploy-state.test.js +0 -80
- package/dist/deploy/__tests__/deploy-status.test.d.ts +0 -1
- package/dist/deploy/__tests__/deploy-status.test.js +0 -41
- package/dist/deploy/__tests__/detach-args.test.d.ts +0 -1
- package/dist/deploy/__tests__/detach-args.test.js +0 -30
- package/dist/deploy/deploy-state.d.ts +0 -36
- package/dist/deploy/deploy-state.js +0 -63
- package/dist/deploy/deploy-status.d.ts +0 -21
- package/dist/deploy/deploy-status.js +0 -36
- package/dist/deploy/detach.d.ts +0 -32
- package/dist/deploy/detach.js +0 -71
- package/dist/dev/__tests__/attach.test.d.ts +0 -1
- package/dist/dev/__tests__/attach.test.js +0 -296
- package/dist/dev/__tests__/detach.test.d.ts +0 -1
- package/dist/dev/__tests__/detach.test.js +0 -404
- package/dist/dev/__tests__/preview-url-poller.test.d.ts +0 -1
- package/dist/dev/__tests__/preview-url-poller.test.js +0 -149
- package/dist/dev/__tests__/session.test.d.ts +0 -1
- package/dist/dev/__tests__/session.test.js +0 -446
- package/dist/dev/__tests__/startup-sync.test.d.ts +0 -1
- package/dist/dev/__tests__/startup-sync.test.js +0 -32
- package/dist/dev/__tests__/stop.test.d.ts +0 -1
- package/dist/dev/__tests__/stop.test.js +0 -172
- package/dist/dev/attach.d.ts +0 -120
- package/dist/dev/attach.js +0 -269
- package/dist/dev/detach.d.ts +0 -187
- package/dist/dev/detach.js +0 -292
- package/dist/dev/preview-url-poller.d.ts +0 -35
- package/dist/dev/preview-url-poller.js +0 -50
- package/dist/dev/session.d.ts +0 -175
- package/dist/dev/session.js +0 -258
- package/dist/dev/startup-sync.d.ts +0 -23
- package/dist/dev/startup-sync.js +0 -14
- package/dist/dev/stop.d.ts +0 -52
- package/dist/dev/stop.js +0 -101
- package/dist/devtools/registry-data.d.ts +0 -46
- package/dist/devtools/registry-data.js +0 -40
- package/dist/generated/bundled-types.d.ts +0 -1
- package/dist/generated/bundled-types.js +0 -46
- package/dist/generated/version.d.ts +0 -1
- package/dist/generated/version.js +0 -2
- package/dist/git/__tests__/auto-commit.test.d.ts +0 -1
- package/dist/git/__tests__/auto-commit.test.js +0 -431
- package/dist/git/__tests__/classify-sync-error.test.d.ts +0 -1
- package/dist/git/__tests__/classify-sync-error.test.js +0 -57
- package/dist/git/__tests__/credential-helper-e2e.test.d.ts +0 -21
- package/dist/git/__tests__/credential-helper-e2e.test.js +0 -195
- package/dist/git/__tests__/credentials.test.d.ts +0 -1
- package/dist/git/__tests__/credentials.test.js +0 -141
- package/dist/git/__tests__/deploy-guard.test.d.ts +0 -1
- package/dist/git/__tests__/deploy-guard.test.js +0 -61
- package/dist/git/__tests__/ensure-git-credential-helper.test.d.ts +0 -1
- package/dist/git/__tests__/ensure-git-credential-helper.test.js +0 -133
- package/dist/git/__tests__/ensure-runwork-remote.test.d.ts +0 -1
- package/dist/git/__tests__/ensure-runwork-remote.test.js +0 -109
- package/dist/git/__tests__/identity.test.d.ts +0 -1
- package/dist/git/__tests__/identity.test.js +0 -146
- package/dist/git/__tests__/manifest.test.d.ts +0 -1
- package/dist/git/__tests__/manifest.test.js +0 -446
- package/dist/git/__tests__/preflight-resolution.test.d.ts +0 -1
- package/dist/git/__tests__/preflight-resolution.test.js +0 -366
- package/dist/git/__tests__/preflight.test.d.ts +0 -1
- package/dist/git/__tests__/preflight.test.js +0 -36
- package/dist/git/__tests__/repo-config.test.d.ts +0 -1
- package/dist/git/__tests__/repo-config.test.js +0 -26
- package/dist/git/__tests__/sync.test.d.ts +0 -1
- package/dist/git/__tests__/sync.test.js +0 -405
- package/dist/git/auto-commit.d.ts +0 -35
- package/dist/git/auto-commit.js +0 -293
- package/dist/git/classify-sync-error.d.ts +0 -21
- package/dist/git/classify-sync-error.js +0 -111
- package/dist/git/credentials.d.ts +0 -75
- package/dist/git/credentials.js +0 -164
- package/dist/git/critical-files.d.ts +0 -20
- package/dist/git/critical-files.js +0 -68
- package/dist/git/deploy-guard.d.ts +0 -53
- package/dist/git/deploy-guard.js +0 -78
- package/dist/git/identity.d.ts +0 -44
- package/dist/git/identity.js +0 -133
- package/dist/git/preflight.d.ts +0 -57
- package/dist/git/preflight.js +0 -276
- package/dist/git/remote.d.ts +0 -37
- package/dist/git/remote.js +0 -75
- package/dist/git/repo-config.d.ts +0 -8
- package/dist/git/repo-config.js +0 -29
- package/dist/git/sync.d.ts +0 -15
- package/dist/git/sync.js +0 -159
- package/dist/health/__tests__/checks.test.d.ts +0 -1
- package/dist/health/__tests__/checks.test.js +0 -357
- package/dist/health/__tests__/cli-distribution-checks.test.d.ts +0 -1
- package/dist/health/__tests__/cli-distribution-checks.test.js +0 -196
- package/dist/health/__tests__/fix.test.d.ts +0 -1
- package/dist/health/__tests__/fix.test.js +0 -72
- package/dist/health/__tests__/runner-filter.test.d.ts +0 -1
- package/dist/health/__tests__/runner-filter.test.js +0 -61
- package/dist/health/checks.d.ts +0 -42
- package/dist/health/checks.js +0 -636
- package/dist/health/fix.d.ts +0 -22
- package/dist/health/fix.js +0 -62
- package/dist/health/runner.d.ts +0 -8
- package/dist/health/runner.js +0 -47
- package/dist/health/types.d.ts +0 -12
- package/dist/health/types.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/logs/__tests__/tailer-format.test.d.ts +0 -1
- package/dist/logs/__tests__/tailer-format.test.js +0 -43
- package/dist/logs/tailer.d.ts +0 -17
- package/dist/logs/tailer.js +0 -217
- package/dist/sync/__tests__/change-detect.test.d.ts +0 -1
- package/dist/sync/__tests__/change-detect.test.js +0 -123
- package/dist/sync/__tests__/hash.test.d.ts +0 -1
- package/dist/sync/__tests__/hash.test.js +0 -18
- package/dist/sync/change-detect.d.ts +0 -19
- package/dist/sync/change-detect.js +0 -136
- package/dist/sync/conflict-ui.d.ts +0 -5
- package/dist/sync/conflict-ui.js +0 -78
- package/dist/sync/executor.d.ts +0 -23
- package/dist/sync/executor.js +0 -102
- package/dist/sync/hash.d.ts +0 -1
- package/dist/sync/hash.js +0 -4
- package/dist/sync/types.d.ts +0 -24
- package/dist/sync/types.js +0 -1
- package/dist/template/manifest.d.ts +0 -17
- package/dist/template/manifest.js +0 -145
- package/dist/tools/types.d.ts +0 -52
- package/dist/tools/types.js +0 -8
- package/dist/types-manager.d.ts +0 -1
- package/dist/types-manager.js +0 -35
- package/dist/types.d.ts +0 -349
- package/dist/types.js +0 -1
- package/dist/ui/__tests__/banner.test.d.ts +0 -1
- package/dist/ui/__tests__/banner.test.js +0 -98
- package/dist/ui/__tests__/colors.test.d.ts +0 -1
- package/dist/ui/__tests__/colors.test.js +0 -22
- package/dist/ui/__tests__/keyboard.test.d.ts +0 -1
- package/dist/ui/__tests__/keyboard.test.js +0 -34
- package/dist/ui/__tests__/status-line.test.d.ts +0 -1
- package/dist/ui/__tests__/status-line.test.js +0 -54
- package/dist/ui/banner.d.ts +0 -29
- package/dist/ui/banner.js +0 -153
- package/dist/ui/colors.d.ts +0 -4
- package/dist/ui/colors.js +0 -7
- package/dist/ui/keyboard.d.ts +0 -12
- package/dist/ui/keyboard.js +0 -61
- package/dist/ui/status-line.d.ts +0 -6
- package/dist/ui/status-line.js +0 -53
- package/dist/utils/__tests__/format-error.test.d.ts +0 -1
- package/dist/utils/__tests__/format-error.test.js +0 -43
- package/dist/utils/__tests__/help-json.test.d.ts +0 -1
- package/dist/utils/__tests__/help-json.test.js +0 -39
- package/dist/utils/__tests__/http.test.d.ts +0 -1
- package/dist/utils/__tests__/http.test.js +0 -381
- package/dist/utils/__tests__/ignore-matcher.test.d.ts +0 -1
- package/dist/utils/__tests__/ignore-matcher.test.js +0 -205
- package/dist/utils/__tests__/output.test.d.ts +0 -1
- package/dist/utils/__tests__/output.test.js +0 -38
- package/dist/utils/__tests__/prompt.test.d.ts +0 -1
- package/dist/utils/__tests__/prompt.test.js +0 -27
- package/dist/utils/__tests__/resolve.test.d.ts +0 -1
- package/dist/utils/__tests__/resolve.test.js +0 -95
- package/dist/utils/__tests__/sqlite.test.d.ts +0 -1
- package/dist/utils/__tests__/sqlite.test.js +0 -89
- package/dist/utils/agent-guidance.d.ts +0 -47
- package/dist/utils/agent-guidance.js +0 -128
- package/dist/utils/app-info.d.ts +0 -70
- package/dist/utils/app-info.js +0 -167
- package/dist/utils/curl-parser.d.ts +0 -12
- package/dist/utils/curl-parser.js +0 -162
- package/dist/utils/data-input.d.ts +0 -1
- package/dist/utils/data-input.js +0 -38
- package/dist/utils/format-error.d.ts +0 -10
- package/dist/utils/format-error.js +0 -38
- package/dist/utils/fs.d.ts +0 -5
- package/dist/utils/fs.js +0 -23
- package/dist/utils/help-json.d.ts +0 -70
- package/dist/utils/help-json.js +0 -88
- package/dist/utils/http.d.ts +0 -46
- package/dist/utils/http.js +0 -421
- package/dist/utils/ignore-matcher.d.ts +0 -47
- package/dist/utils/ignore-matcher.js +0 -132
- package/dist/utils/output.d.ts +0 -17
- package/dist/utils/output.js +0 -27
- package/dist/utils/prompt.d.ts +0 -5
- package/dist/utils/prompt.js +0 -42
- package/dist/utils/resolve.d.ts +0 -12
- package/dist/utils/resolve.js +0 -52
- package/dist/utils/setup-state.d.ts +0 -3
- package/dist/utils/setup-state.js +0 -19
- package/dist/utils/sqlite-adapter.d.ts +0 -48
- package/dist/utils/sqlite-adapter.js +0 -147
- package/dist/utils/sqlite.d.ts +0 -14
- package/dist/utils/sqlite.js +0 -14
- package/dist/utils/subprocess.d.ts +0 -19
- package/dist/utils/subprocess.js +0 -27
- package/dist/utils/which.d.ts +0 -14
- package/dist/utils/which.js +0 -47
- package/dist/utils/zip.d.ts +0 -7
- package/dist/utils/zip.js +0 -42
- package/dist/validate/__tests__/validate.test.d.ts +0 -1
- package/dist/validate/__tests__/validate.test.js +0 -42
- package/dist/validate/freshness.d.ts +0 -28
- package/dist/validate/freshness.js +0 -48
- package/dist/validate/preview.d.ts +0 -21
- package/dist/validate/preview.js +0 -39
- package/dist/workspace/resolve.d.ts +0 -19
- package/dist/workspace/resolve.js +0 -100
package/dist/utils/http.js
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal `fetch`-like HTTP client built on `node:http` / `node:https`.
|
|
3
|
-
*
|
|
4
|
-
* Why this exists rather than calling `fetch` directly:
|
|
5
|
-
* 1) Single seam for diagnostics, retries, transport swaps, etc., without
|
|
6
|
-
* touching every call site.
|
|
7
|
-
* 2) Opt-in `curl` transport (set `RUNWORK_HTTP_TRANSPORT=curl`) as a
|
|
8
|
-
* break-glass: it shells out to the system `curl` binary so HTTP runs
|
|
9
|
-
* in a subprocess, immune to any runtime regression in the Bun-compiled
|
|
10
|
-
* binary. We've kept it after needing it once on an older Bun version.
|
|
11
|
-
*
|
|
12
|
-
* Default transport is `node:https` on every platform. Surface mirrors
|
|
13
|
-
* enough of the standard `Response` API for call sites to swap from
|
|
14
|
-
* `fetch(...)` to `httpFetch(...)` with no other change. Out of scope:
|
|
15
|
-
* streaming bodies, AbortController, ReadableStream request bodies, the
|
|
16
|
-
* `cache` option. This is a workaround layer, not a fetch polyfill.
|
|
17
|
-
*/
|
|
18
|
-
import { request as httpRequest } from 'node:http';
|
|
19
|
-
import { request as httpsRequest } from 'node:https';
|
|
20
|
-
import { URL } from 'node:url';
|
|
21
|
-
import { spawn } from 'node:child_process';
|
|
22
|
-
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
23
|
-
import { tmpdir } from 'node:os';
|
|
24
|
-
import { join } from 'node:path';
|
|
25
|
-
import { createBrotliDecompress, createGunzip, createInflate, createInflateRaw, } from 'node:zlib';
|
|
26
|
-
const MAX_REDIRECTS = 10;
|
|
27
|
-
let transportOverride = 'auto';
|
|
28
|
-
export function __setTransportForTests(t) { transportOverride = t; }
|
|
29
|
-
function pickTransport() {
|
|
30
|
-
if (transportOverride === 'curl')
|
|
31
|
-
return 'curl';
|
|
32
|
-
if (transportOverride === 'node')
|
|
33
|
-
return 'node';
|
|
34
|
-
const env = (process.env.RUNWORK_HTTP_TRANSPORT || '').toLowerCase().trim();
|
|
35
|
-
if (env === 'curl')
|
|
36
|
-
return 'curl';
|
|
37
|
-
return 'node';
|
|
38
|
-
}
|
|
39
|
-
export async function httpFetch(url, init = {}) {
|
|
40
|
-
const transport = pickTransport();
|
|
41
|
-
if (transport === 'curl')
|
|
42
|
-
return curlFetch(url, init);
|
|
43
|
-
return doRequest(url, init, 0);
|
|
44
|
-
}
|
|
45
|
-
async function doRequest(url, init, redirectCount) {
|
|
46
|
-
const parsed = new URL(url);
|
|
47
|
-
const isHttps = parsed.protocol === 'https:';
|
|
48
|
-
const isHttp = parsed.protocol === 'http:';
|
|
49
|
-
if (!isHttps && !isHttp) {
|
|
50
|
-
throw new Error(`Unsupported protocol "${parsed.protocol}" -- only http: and https: are supported.`);
|
|
51
|
-
}
|
|
52
|
-
const requestFn = isHttps ? httpsRequest : httpRequest;
|
|
53
|
-
const headers = normalizeHeaders(init.headers);
|
|
54
|
-
const method = (init.method || 'GET').toUpperCase();
|
|
55
|
-
const isBodylessMethod = method === 'GET' || method === 'HEAD';
|
|
56
|
-
const bodyBuffer = isBodylessMethod ? null : bodyToBuffer(init.body);
|
|
57
|
-
if (bodyBuffer && headers['content-length'] === undefined) {
|
|
58
|
-
headers['content-length'] = String(bodyBuffer.byteLength);
|
|
59
|
-
}
|
|
60
|
-
// Match `fetch`'s default of advertising compression support. We
|
|
61
|
-
// transparently decompress gzip/deflate/br responses below.
|
|
62
|
-
if (headers['accept-encoding'] === undefined) {
|
|
63
|
-
headers['accept-encoding'] = 'gzip, deflate, br';
|
|
64
|
-
}
|
|
65
|
-
const requestOptions = {
|
|
66
|
-
method,
|
|
67
|
-
headers,
|
|
68
|
-
};
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
const req = requestFn(url, requestOptions, (res) => {
|
|
71
|
-
const status = res.statusCode ?? 0;
|
|
72
|
-
// Follow redirects manually so behavior matches `fetch`. We wait for
|
|
73
|
-
// the previous response to fully drain before starting the recursive
|
|
74
|
-
// request: guarantees socket cleanup ordering and avoids leaking
|
|
75
|
-
// the previous request when the new one fails.
|
|
76
|
-
const location = res.headers.location;
|
|
77
|
-
if (status >= 300 && status < 400 && location && redirectCount < MAX_REDIRECTS) {
|
|
78
|
-
res.resume();
|
|
79
|
-
res.once('end', () => {
|
|
80
|
-
let nextUrl;
|
|
81
|
-
try {
|
|
82
|
-
nextUrl = new URL(location, url).toString();
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
reject(err);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const shouldDowngradeToGet = status === 303 ||
|
|
89
|
-
((status === 301 || status === 302) && method !== 'GET' && method !== 'HEAD');
|
|
90
|
-
const nextInit = shouldDowngradeToGet
|
|
91
|
-
? { ...init, method: 'GET', body: undefined }
|
|
92
|
-
: init;
|
|
93
|
-
doRequest(nextUrl, nextInit, redirectCount + 1).then(resolve, reject);
|
|
94
|
-
});
|
|
95
|
-
res.once('error', reject);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// Decompress gzip / deflate / br transparently to match fetch.
|
|
99
|
-
const decoded = decompressedStream(res);
|
|
100
|
-
const chunks = [];
|
|
101
|
-
decoded.on('data', (chunk) => {
|
|
102
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
103
|
-
});
|
|
104
|
-
decoded.on('end', () => {
|
|
105
|
-
const buffer = Buffer.concat(chunks);
|
|
106
|
-
// For HEAD responses there is no body; preserve the empty buffer.
|
|
107
|
-
resolve(buildResponse(url, res, status, buffer));
|
|
108
|
-
});
|
|
109
|
-
decoded.on('error', reject);
|
|
110
|
-
// Surface upstream socket errors too when we are reading through a
|
|
111
|
-
// decompressor (the transformed stream wouldn't otherwise see them).
|
|
112
|
-
if (decoded !== res) {
|
|
113
|
-
res.on('error', reject);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
req.on('error', reject);
|
|
117
|
-
if (bodyBuffer)
|
|
118
|
-
req.write(bodyBuffer);
|
|
119
|
-
req.end();
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function normalizeHeaders(input) {
|
|
123
|
-
const out = {};
|
|
124
|
-
if (!input)
|
|
125
|
-
return out;
|
|
126
|
-
if (input instanceof Headers) {
|
|
127
|
-
input.forEach((value, key) => {
|
|
128
|
-
out[key.toLowerCase()] = value;
|
|
129
|
-
});
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
|
-
for (const [key, value] of Object.entries(input)) {
|
|
133
|
-
if (value === undefined || value === null)
|
|
134
|
-
continue;
|
|
135
|
-
out[key.toLowerCase()] = String(value);
|
|
136
|
-
}
|
|
137
|
-
return out;
|
|
138
|
-
}
|
|
139
|
-
function bodyToBuffer(body) {
|
|
140
|
-
if (body === undefined || body === null)
|
|
141
|
-
return null;
|
|
142
|
-
if (typeof body === 'string')
|
|
143
|
-
return Buffer.from(body, 'utf-8');
|
|
144
|
-
if (Buffer.isBuffer(body))
|
|
145
|
-
return body;
|
|
146
|
-
if (body instanceof Uint8Array)
|
|
147
|
-
return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
148
|
-
if (body instanceof ArrayBuffer)
|
|
149
|
-
return Buffer.from(new Uint8Array(body));
|
|
150
|
-
throw new TypeError('Unsupported request body type');
|
|
151
|
-
}
|
|
152
|
-
function decompressedStream(res) {
|
|
153
|
-
// Per RFC 7230, Content-Encoding may be a comma-separated list of
|
|
154
|
-
// transformations applied in order. Unwrap them in reverse, but in
|
|
155
|
-
// practice servers send a single encoding so the simple cases dominate.
|
|
156
|
-
const raw = (res.headers['content-encoding'] || '').toString().toLowerCase().trim();
|
|
157
|
-
if (!raw || raw === 'identity')
|
|
158
|
-
return res;
|
|
159
|
-
const encodings = raw.split(',').map((s) => s.trim()).filter(Boolean).reverse();
|
|
160
|
-
let stream = res;
|
|
161
|
-
for (const enc of encodings) {
|
|
162
|
-
let decoder = null;
|
|
163
|
-
if (enc === 'gzip' || enc === 'x-gzip')
|
|
164
|
-
decoder = createGunzip();
|
|
165
|
-
else if (enc === 'br')
|
|
166
|
-
decoder = createBrotliDecompress();
|
|
167
|
-
else if (enc === 'deflate')
|
|
168
|
-
decoder = createInflate();
|
|
169
|
-
else if (enc === 'deflate-raw')
|
|
170
|
-
decoder = createInflateRaw();
|
|
171
|
-
else
|
|
172
|
-
continue; // unknown encoding -- pass bytes through
|
|
173
|
-
stream.pipe(decoder);
|
|
174
|
-
stream = decoder;
|
|
175
|
-
}
|
|
176
|
-
return stream;
|
|
177
|
-
}
|
|
178
|
-
function buildResponse(url, res, status, buffer) {
|
|
179
|
-
const headers = new Headers();
|
|
180
|
-
for (const [name, value] of Object.entries(res.headers)) {
|
|
181
|
-
if (value === undefined)
|
|
182
|
-
continue;
|
|
183
|
-
if (Array.isArray(value)) {
|
|
184
|
-
for (const v of value)
|
|
185
|
-
headers.append(name, v);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
headers.set(name, value);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
ok: status >= 200 && status < 300,
|
|
193
|
-
status,
|
|
194
|
-
statusText: res.statusMessage ?? '',
|
|
195
|
-
headers,
|
|
196
|
-
url,
|
|
197
|
-
async text() {
|
|
198
|
-
return buffer.toString('utf-8');
|
|
199
|
-
},
|
|
200
|
-
async json() {
|
|
201
|
-
const text = buffer.toString('utf-8');
|
|
202
|
-
return JSON.parse(text);
|
|
203
|
-
},
|
|
204
|
-
async arrayBuffer() {
|
|
205
|
-
// Slice the underlying buffer so the returned ArrayBuffer matches the
|
|
206
|
-
// exact byte range and is independent of Node's internal pool.
|
|
207
|
-
const copy = new Uint8Array(buffer.byteLength);
|
|
208
|
-
copy.set(buffer);
|
|
209
|
-
return copy.buffer;
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
214
|
-
// curl-based transport (Windows workaround)
|
|
215
|
-
//
|
|
216
|
-
// On Windows we spawn `curl.exe` for every HTTP call so we never touch
|
|
217
|
-
// Bun's broken HTTP runtime in the standalone binary. The subprocess
|
|
218
|
-
// approach trades a few tens of milliseconds of process-spawn overhead per
|
|
219
|
-
// request for rock-solid reliability. Curl ships at
|
|
220
|
-
// C:\Windows\System32\curl.exe on Windows 10+ since 2018.
|
|
221
|
-
//
|
|
222
|
-
// Layout:
|
|
223
|
-
// - body → written by curl to a temp file (--output)
|
|
224
|
-
// - response hdrs → written by curl to a temp file (--dump-header)
|
|
225
|
-
// - status/url → printed by curl to stdout via --write-out
|
|
226
|
-
//
|
|
227
|
-
// We never let body bytes share a stream with metadata, so binary
|
|
228
|
-
// downloads (zip skeletons, presigned URL fetches) round-trip cleanly.
|
|
229
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
230
|
-
async function curlFetch(url, init) {
|
|
231
|
-
return curlFetchOnce(url, init, 0);
|
|
232
|
-
}
|
|
233
|
-
async function curlFetchOnce(url, init, redirectCount) {
|
|
234
|
-
// Quick URL sanity check so we throw the same way the node:https path
|
|
235
|
-
// does for unsupported protocols, before paying the spawn cost.
|
|
236
|
-
const parsed = new URL(url);
|
|
237
|
-
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
238
|
-
throw new Error(`Unsupported protocol "${parsed.protocol}" -- only http: and https: are supported.`);
|
|
239
|
-
}
|
|
240
|
-
const headers = normalizeHeaders(init.headers);
|
|
241
|
-
const method = (init.method || 'GET').toUpperCase();
|
|
242
|
-
const isBodyless = method === 'GET' || method === 'HEAD';
|
|
243
|
-
const bodyBuffer = isBodyless ? null : bodyToBuffer(init.body);
|
|
244
|
-
if (headers['accept-encoding'] === undefined) {
|
|
245
|
-
headers['accept-encoding'] = 'identity';
|
|
246
|
-
}
|
|
247
|
-
// Per-call temp directory keeps cleanup simple and concurrent calls from
|
|
248
|
-
// racing on shared filenames.
|
|
249
|
-
const tmp = mkdtempSync(join(tmpdir(), 'runwork-curl-'));
|
|
250
|
-
const bodyOutPath = join(tmp, 'body.bin');
|
|
251
|
-
const headerOutPath = join(tmp, 'headers.txt');
|
|
252
|
-
const args = [
|
|
253
|
-
'--silent',
|
|
254
|
-
'--show-error',
|
|
255
|
-
// We deliberately do NOT pass --location. curl's redirect-method
|
|
256
|
-
// semantics differ subtly from fetch's (notably curl can preserve
|
|
257
|
-
// POST across 303 in some versions despite the spec). We follow
|
|
258
|
-
// redirects ourselves below so behavior matches the node:https
|
|
259
|
-
// transport exactly.
|
|
260
|
-
'--output', bodyOutPath, // body to file (binary safe)
|
|
261
|
-
'--dump-header', headerOutPath, // response headers to file
|
|
262
|
-
'--write-out', '%{http_code}\n%{url_effective}\n',
|
|
263
|
-
];
|
|
264
|
-
if (method === 'HEAD') {
|
|
265
|
-
// --head sends HEAD AND tells curl not to expect a body, otherwise
|
|
266
|
-
// curl hangs waiting for body bytes. The downside is that --head also
|
|
267
|
-
// writes the response headers into the --output body file -- we work
|
|
268
|
-
// around that below by ignoring the body buffer when method is HEAD.
|
|
269
|
-
args.push('--head');
|
|
270
|
-
}
|
|
271
|
-
else if (method !== 'GET') {
|
|
272
|
-
args.push('--request', method);
|
|
273
|
-
}
|
|
274
|
-
// Curl's default already follows fetch semantics on 301/302/303 (downgrade
|
|
275
|
-
// POST to GET). We do NOT pass --post30x because those flags violate that
|
|
276
|
-
// default and force POST to be preserved across redirects.
|
|
277
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
278
|
-
args.push('--header', `${name}: ${value}`);
|
|
279
|
-
}
|
|
280
|
-
if (bodyBuffer) {
|
|
281
|
-
// Read request body from stdin so we don't have to write it to disk.
|
|
282
|
-
args.push('--data-binary', '@-');
|
|
283
|
-
}
|
|
284
|
-
args.push(url);
|
|
285
|
-
// Async spawn: spawnSync would block the event loop, which deadlocks
|
|
286
|
-
// unit tests (the test server lives in the same Node worker, can't
|
|
287
|
-
// service curl's connection while we're blocked). The async path is
|
|
288
|
-
// also strictly nicer for any future caller that wants to overlap
|
|
289
|
-
// requests.
|
|
290
|
-
const result = await new Promise((resolve) => {
|
|
291
|
-
const child = spawn('curl', args, { windowsHide: true });
|
|
292
|
-
const stdoutChunks = [];
|
|
293
|
-
const stderrChunks = [];
|
|
294
|
-
child.stdout.on('data', (c) => stdoutChunks.push(c));
|
|
295
|
-
child.stderr.on('data', (c) => stderrChunks.push(c));
|
|
296
|
-
child.on('error', (err) => resolve({
|
|
297
|
-
status: -1,
|
|
298
|
-
stdout: Buffer.concat(stdoutChunks).toString('utf-8'),
|
|
299
|
-
stderr: Buffer.concat(stderrChunks).toString('utf-8'),
|
|
300
|
-
error: err,
|
|
301
|
-
}));
|
|
302
|
-
child.on('close', (code) => resolve({
|
|
303
|
-
status: code ?? -1,
|
|
304
|
-
stdout: Buffer.concat(stdoutChunks).toString('utf-8'),
|
|
305
|
-
stderr: Buffer.concat(stderrChunks).toString('utf-8'),
|
|
306
|
-
}));
|
|
307
|
-
if (bodyBuffer) {
|
|
308
|
-
child.stdin.write(bodyBuffer);
|
|
309
|
-
}
|
|
310
|
-
child.stdin.end();
|
|
311
|
-
});
|
|
312
|
-
if (result.error) {
|
|
313
|
-
safeRm(tmp);
|
|
314
|
-
throw result.error;
|
|
315
|
-
}
|
|
316
|
-
const stdoutLines = result.stdout.trim().split(/\r?\n/);
|
|
317
|
-
const statusLine = stdoutLines[0] || '0';
|
|
318
|
-
const finalUrl = stdoutLines[1] || url;
|
|
319
|
-
const status = Number.parseInt(statusLine, 10) || 0;
|
|
320
|
-
if (status === 0) {
|
|
321
|
-
// curl never received a response, or exited before writing the status.
|
|
322
|
-
const stderr = result.stderr.trim();
|
|
323
|
-
safeRm(tmp);
|
|
324
|
-
throw new Error(`curl failed (exit ${result.status}): ${stderr || 'no error output'}`);
|
|
325
|
-
}
|
|
326
|
-
let bodyBuf;
|
|
327
|
-
try {
|
|
328
|
-
bodyBuf = readFileSync(bodyOutPath);
|
|
329
|
-
}
|
|
330
|
-
catch {
|
|
331
|
-
bodyBuf = Buffer.alloc(0);
|
|
332
|
-
}
|
|
333
|
-
// For HEAD, --head causes curl to write the response status line + headers
|
|
334
|
-
// into the body output file (since there is no real body to write). Strip
|
|
335
|
-
// it so callers see an empty body, matching fetch's HEAD behavior.
|
|
336
|
-
if (method === 'HEAD') {
|
|
337
|
-
bodyBuf = Buffer.alloc(0);
|
|
338
|
-
}
|
|
339
|
-
let headerText = '';
|
|
340
|
-
try {
|
|
341
|
-
headerText = readFileSync(headerOutPath, 'utf-8');
|
|
342
|
-
}
|
|
343
|
-
catch {
|
|
344
|
-
// best-effort
|
|
345
|
-
}
|
|
346
|
-
safeRm(tmp);
|
|
347
|
-
// After redirects curl writes one header block per hop; the LAST block is
|
|
348
|
-
// the response we actually want to expose to the caller.
|
|
349
|
-
const blocks = headerText.split(/\r?\n\r?\n/).map((b) => b.trim()).filter(Boolean);
|
|
350
|
-
const finalBlock = blocks[blocks.length - 1] || '';
|
|
351
|
-
const finalLines = finalBlock.split(/\r?\n/);
|
|
352
|
-
// Pull statusText off the HTTP/x.y NNN <reason> status line if present.
|
|
353
|
-
let statusText = '';
|
|
354
|
-
if (finalLines.length > 0 && finalLines[0].startsWith('HTTP/')) {
|
|
355
|
-
const match = finalLines[0].match(/^HTTP\/\S+\s+\d+\s*(.*)$/);
|
|
356
|
-
if (match)
|
|
357
|
-
statusText = match[1].trim();
|
|
358
|
-
}
|
|
359
|
-
const responseHeaders = new Headers();
|
|
360
|
-
for (const line of finalLines) {
|
|
361
|
-
if (line.startsWith('HTTP/'))
|
|
362
|
-
continue;
|
|
363
|
-
const colon = line.indexOf(':');
|
|
364
|
-
if (colon < 0)
|
|
365
|
-
continue;
|
|
366
|
-
const name = line.slice(0, colon).trim();
|
|
367
|
-
const value = line.slice(colon + 1).trim();
|
|
368
|
-
if (!name)
|
|
369
|
-
continue;
|
|
370
|
-
responseHeaders.append(name, value);
|
|
371
|
-
}
|
|
372
|
-
// Manual redirect handling so curl and node:https behave identically.
|
|
373
|
-
// 303 always downgrades to GET; 301/302 downgrade non-GET/HEAD to GET;
|
|
374
|
-
// 307/308 preserve method and body.
|
|
375
|
-
const location = responseHeaders.get('location');
|
|
376
|
-
if (status >= 300 && status < 400 && location && redirectCount < MAX_REDIRECTS) {
|
|
377
|
-
let nextUrl;
|
|
378
|
-
try {
|
|
379
|
-
nextUrl = new URL(location, url).toString();
|
|
380
|
-
}
|
|
381
|
-
catch (err) {
|
|
382
|
-
throw err;
|
|
383
|
-
}
|
|
384
|
-
const shouldDowngradeToGet = status === 303 ||
|
|
385
|
-
((status === 301 || status === 302) && method !== 'GET' && method !== 'HEAD');
|
|
386
|
-
const nextInit = shouldDowngradeToGet
|
|
387
|
-
? { ...init, method: 'GET', body: undefined }
|
|
388
|
-
: init;
|
|
389
|
-
return curlFetchOnce(nextUrl, nextInit, redirectCount + 1);
|
|
390
|
-
}
|
|
391
|
-
// Mirror the node-path warning on unexpected encoding so the diagnostics
|
|
392
|
-
// are consistent across platforms.
|
|
393
|
-
const enc = (responseHeaders.get('content-encoding') || '').toLowerCase().trim();
|
|
394
|
-
if (enc && enc !== 'identity') {
|
|
395
|
-
try {
|
|
396
|
-
process.stderr.write(`[http] warning: server returned Content-Encoding: ${enc} despite Accept-Encoding: identity; ` +
|
|
397
|
-
`body returned as raw bytes (${url}).\n`);
|
|
398
|
-
}
|
|
399
|
-
catch { /* ignore */ }
|
|
400
|
-
}
|
|
401
|
-
return {
|
|
402
|
-
ok: status >= 200 && status < 300,
|
|
403
|
-
status,
|
|
404
|
-
statusText,
|
|
405
|
-
headers: responseHeaders,
|
|
406
|
-
url: finalUrl,
|
|
407
|
-
async text() { return bodyBuf.toString('utf-8'); },
|
|
408
|
-
async json() { return JSON.parse(bodyBuf.toString('utf-8')); },
|
|
409
|
-
async arrayBuffer() {
|
|
410
|
-
const copy = new Uint8Array(bodyBuf.byteLength);
|
|
411
|
-
copy.set(bodyBuf);
|
|
412
|
-
return copy.buffer;
|
|
413
|
-
},
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
function safeRm(path) {
|
|
417
|
-
try {
|
|
418
|
-
rmSync(path, { recursive: true, force: true });
|
|
419
|
-
}
|
|
420
|
-
catch { /* best-effort */ }
|
|
421
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export interface IgnoreSets {
|
|
2
|
-
dirs: Set<string>;
|
|
3
|
-
files: Set<string>;
|
|
4
|
-
extensions: Set<string>;
|
|
5
|
-
}
|
|
6
|
-
export declare function defaultIgnoreSets(): IgnoreSets;
|
|
7
|
-
interface ParsedGitignore {
|
|
8
|
-
dirs: Set<string>;
|
|
9
|
-
files: Set<string>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Parse a `.gitignore` file's contents into basename-level dir and file sets.
|
|
13
|
-
*
|
|
14
|
-
* Only the simple, basename-style patterns are extracted: `name`, `name/`,
|
|
15
|
-
* `/name`, `/name/`. Patterns containing glob characters (`*`, `?`, `[`),
|
|
16
|
-
* negations (`!`), comments (`#`) or path separators are skipped — handling
|
|
17
|
-
* those correctly requires a full gitignore matcher, which the agent's
|
|
18
|
-
* walkers do not need: the goal is to avoid descending into well-known huge
|
|
19
|
-
* gitignored directories like `.bun-cache`, `.next`, `dist`, `coverage`.
|
|
20
|
-
*
|
|
21
|
-
* Patterns without a trailing slash are added to both `dirs` and `files`
|
|
22
|
-
* because gitignore semantics apply to either, and basename-only matching
|
|
23
|
-
* cannot tell them apart safely.
|
|
24
|
-
*/
|
|
25
|
-
export declare function parseGitignoreContent(content: string): ParsedGitignore;
|
|
26
|
-
/**
|
|
27
|
-
* Build a combined IgnoreSets for `dir` by merging the static defaults with
|
|
28
|
-
* simple patterns parsed from `dir`/.gitignore (if present).
|
|
29
|
-
*/
|
|
30
|
-
export declare function buildIgnoreSets(dir: string): IgnoreSets;
|
|
31
|
-
/**
|
|
32
|
-
* Returns true if `filePath`'s basename matches any directory, file, or
|
|
33
|
-
* extension in `sets`. Matching is intentionally basename-only so it can
|
|
34
|
-
* be used as the predicate for chokidar's `ignored` option and for
|
|
35
|
-
* recursive directory walkers without needing absolute-path bookkeeping.
|
|
36
|
-
*/
|
|
37
|
-
export declare function isPathIgnored(filePath: string, sets: IgnoreSets): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Like isPathIgnored, but for a full repo-relative path (e.g. the output of
|
|
40
|
-
* `git ls-files`) rather than a single traversal step. It also treats a path
|
|
41
|
-
* as ignored when ANY parent directory segment is an ignored dir (e.g.
|
|
42
|
-
* `worker/.bun-cache/x.js`). The chokidar watcher gets this for free because
|
|
43
|
-
* it never descends into an ignored directory; a flat path list does not, so
|
|
44
|
-
* callers staging untracked files must use this variant to match the watcher.
|
|
45
|
-
*/
|
|
46
|
-
export declare function isRelPathIgnored(relPath: string, sets: IgnoreSets): boolean;
|
|
47
|
-
export {};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'fs';
|
|
2
|
-
import { basename, join } from 'path';
|
|
3
|
-
const DEFAULT_DIR_NAMES = [
|
|
4
|
-
'.git',
|
|
5
|
-
'node_modules',
|
|
6
|
-
'.runwork',
|
|
7
|
-
// .bun-cache is bun's per-project package cache. It commonly grows into
|
|
8
|
-
// hundreds of MB / tens of thousands of files and is universally
|
|
9
|
-
// gitignored. Walking it on every dev startup made the CLI lock-contend
|
|
10
|
-
// on file descriptors and never spawn the dev server.
|
|
11
|
-
'.bun-cache',
|
|
12
|
-
];
|
|
13
|
-
const DEFAULT_FILE_NAMES = [
|
|
14
|
-
'.dev.vars',
|
|
15
|
-
'.env',
|
|
16
|
-
];
|
|
17
|
-
const DEFAULT_EXTENSIONS = [
|
|
18
|
-
'.log',
|
|
19
|
-
];
|
|
20
|
-
export function defaultIgnoreSets() {
|
|
21
|
-
return {
|
|
22
|
-
dirs: new Set(DEFAULT_DIR_NAMES),
|
|
23
|
-
files: new Set(DEFAULT_FILE_NAMES),
|
|
24
|
-
extensions: new Set(DEFAULT_EXTENSIONS),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const GLOB_CHARS = /[*?\[\]]/;
|
|
28
|
-
/**
|
|
29
|
-
* Parse a `.gitignore` file's contents into basename-level dir and file sets.
|
|
30
|
-
*
|
|
31
|
-
* Only the simple, basename-style patterns are extracted: `name`, `name/`,
|
|
32
|
-
* `/name`, `/name/`. Patterns containing glob characters (`*`, `?`, `[`),
|
|
33
|
-
* negations (`!`), comments (`#`) or path separators are skipped — handling
|
|
34
|
-
* those correctly requires a full gitignore matcher, which the agent's
|
|
35
|
-
* walkers do not need: the goal is to avoid descending into well-known huge
|
|
36
|
-
* gitignored directories like `.bun-cache`, `.next`, `dist`, `coverage`.
|
|
37
|
-
*
|
|
38
|
-
* Patterns without a trailing slash are added to both `dirs` and `files`
|
|
39
|
-
* because gitignore semantics apply to either, and basename-only matching
|
|
40
|
-
* cannot tell them apart safely.
|
|
41
|
-
*/
|
|
42
|
-
export function parseGitignoreContent(content) {
|
|
43
|
-
const dirs = new Set();
|
|
44
|
-
const files = new Set();
|
|
45
|
-
for (const rawLine of content.split('\n')) {
|
|
46
|
-
const line = rawLine.trim();
|
|
47
|
-
if (!line || line.startsWith('#'))
|
|
48
|
-
continue;
|
|
49
|
-
if (line.startsWith('!'))
|
|
50
|
-
continue;
|
|
51
|
-
if (GLOB_CHARS.test(line))
|
|
52
|
-
continue;
|
|
53
|
-
let pattern = line;
|
|
54
|
-
const isDirOnly = pattern.endsWith('/');
|
|
55
|
-
if (isDirOnly)
|
|
56
|
-
pattern = pattern.slice(0, -1);
|
|
57
|
-
if (pattern.startsWith('/'))
|
|
58
|
-
pattern = pattern.slice(1);
|
|
59
|
-
if (!pattern)
|
|
60
|
-
continue;
|
|
61
|
-
if (pattern.includes('/'))
|
|
62
|
-
continue;
|
|
63
|
-
if (isDirOnly) {
|
|
64
|
-
dirs.add(pattern);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
dirs.add(pattern);
|
|
68
|
-
files.add(pattern);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return { dirs, files };
|
|
72
|
-
}
|
|
73
|
-
function loadGitignoreFromDir(dir) {
|
|
74
|
-
const path = join(dir, '.gitignore');
|
|
75
|
-
if (!existsSync(path))
|
|
76
|
-
return { dirs: new Set(), files: new Set() };
|
|
77
|
-
try {
|
|
78
|
-
return parseGitignoreContent(readFileSync(path, 'utf-8'));
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return { dirs: new Set(), files: new Set() };
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Build a combined IgnoreSets for `dir` by merging the static defaults with
|
|
86
|
-
* simple patterns parsed from `dir`/.gitignore (if present).
|
|
87
|
-
*/
|
|
88
|
-
export function buildIgnoreSets(dir) {
|
|
89
|
-
const sets = defaultIgnoreSets();
|
|
90
|
-
const parsed = loadGitignoreFromDir(dir);
|
|
91
|
-
for (const name of parsed.dirs)
|
|
92
|
-
sets.dirs.add(name);
|
|
93
|
-
for (const name of parsed.files)
|
|
94
|
-
sets.files.add(name);
|
|
95
|
-
return sets;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns true if `filePath`'s basename matches any directory, file, or
|
|
99
|
-
* extension in `sets`. Matching is intentionally basename-only so it can
|
|
100
|
-
* be used as the predicate for chokidar's `ignored` option and for
|
|
101
|
-
* recursive directory walkers without needing absolute-path bookkeeping.
|
|
102
|
-
*/
|
|
103
|
-
export function isPathIgnored(filePath, sets) {
|
|
104
|
-
const name = basename(filePath);
|
|
105
|
-
if (sets.dirs.has(name))
|
|
106
|
-
return true;
|
|
107
|
-
if (sets.files.has(name))
|
|
108
|
-
return true;
|
|
109
|
-
const dotIndex = name.lastIndexOf('.');
|
|
110
|
-
if (dotIndex >= 0) {
|
|
111
|
-
const ext = name.slice(dotIndex);
|
|
112
|
-
if (sets.extensions.has(ext))
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Like isPathIgnored, but for a full repo-relative path (e.g. the output of
|
|
119
|
-
* `git ls-files`) rather than a single traversal step. It also treats a path
|
|
120
|
-
* as ignored when ANY parent directory segment is an ignored dir (e.g.
|
|
121
|
-
* `worker/.bun-cache/x.js`). The chokidar watcher gets this for free because
|
|
122
|
-
* it never descends into an ignored directory; a flat path list does not, so
|
|
123
|
-
* callers staging untracked files must use this variant to match the watcher.
|
|
124
|
-
*/
|
|
125
|
-
export function isRelPathIgnored(relPath, sets) {
|
|
126
|
-
const segments = relPath.split('/');
|
|
127
|
-
for (let i = 0; i < segments.length - 1; i++) {
|
|
128
|
-
if (sets.dirs.has(segments[i]))
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
return isPathIgnored(relPath, sets);
|
|
132
|
-
}
|
package/dist/utils/output.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON output utilities for agent-friendly CLI.
|
|
3
|
-
*
|
|
4
|
-
* When stdout is not a TTY (piped/captured by an agent), output switches
|
|
5
|
-
* to machine-readable JSON automatically. The --json flag forces it.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Determine whether to output JSON based on:
|
|
9
|
-
* 1. Explicit --json flag (true)
|
|
10
|
-
* 2. Explicit --no-json flag (false)
|
|
11
|
-
* 3. Auto-detect: non-TTY stdout means agent/pipe, output JSON
|
|
12
|
-
*/
|
|
13
|
-
export declare function shouldOutputJson(jsonFlag: boolean | undefined): boolean;
|
|
14
|
-
/** Write a single JSON object to stdout (for one-shot commands). */
|
|
15
|
-
export declare function jsonOut(data: unknown): void;
|
|
16
|
-
/** Write one NDJSON line to stdout (for streaming commands). */
|
|
17
|
-
export declare function jsonLine(data: unknown): void;
|
package/dist/utils/output.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON output utilities for agent-friendly CLI.
|
|
3
|
-
*
|
|
4
|
-
* When stdout is not a TTY (piped/captured by an agent), output switches
|
|
5
|
-
* to machine-readable JSON automatically. The --json flag forces it.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Determine whether to output JSON based on:
|
|
9
|
-
* 1. Explicit --json flag (true)
|
|
10
|
-
* 2. Explicit --no-json flag (false)
|
|
11
|
-
* 3. Auto-detect: non-TTY stdout means agent/pipe, output JSON
|
|
12
|
-
*/
|
|
13
|
-
export function shouldOutputJson(jsonFlag) {
|
|
14
|
-
if (jsonFlag === true)
|
|
15
|
-
return true;
|
|
16
|
-
if (jsonFlag === false)
|
|
17
|
-
return false;
|
|
18
|
-
return !process.stdout.isTTY;
|
|
19
|
-
}
|
|
20
|
-
/** Write a single JSON object to stdout (for one-shot commands). */
|
|
21
|
-
export function jsonOut(data) {
|
|
22
|
-
process.stdout.write(JSON.stringify(data) + '\n');
|
|
23
|
-
}
|
|
24
|
-
/** Write one NDJSON line to stdout (for streaming commands). */
|
|
25
|
-
export function jsonLine(data) {
|
|
26
|
-
process.stdout.write(JSON.stringify(data) + '\n');
|
|
27
|
-
}
|
package/dist/utils/prompt.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function promptSelect<T extends {
|
|
2
|
-
label: string;
|
|
3
|
-
}>(message: string, choices: T[]): Promise<T>;
|
|
4
|
-
export declare function promptInput(message: string, defaultValue?: string): Promise<string>;
|
|
5
|
-
export declare function promptConfirm(message: string): Promise<boolean>;
|