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
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
vi.mock('../../agents/detect.js', () => ({
|
|
3
|
-
detectAgents: vi.fn(),
|
|
4
|
-
// getAdapterBySlug is imported by sync.ts at module load; stub it so the
|
|
5
|
-
// import graph resolves without dragging in real adapter side-effects.
|
|
6
|
-
getAdapterBySlug: vi.fn(() => undefined),
|
|
7
|
-
}));
|
|
8
|
-
import { detectAgents } from '../../agents/detect.js';
|
|
9
|
-
import { shouldRedetect, refreshConfiguredAgents, REDETECT_TTL_MS, } from '../sync.js';
|
|
10
|
-
const baseOpts = {
|
|
11
|
-
dryRun: false,
|
|
12
|
-
pullOnly: false,
|
|
13
|
-
yes: true,
|
|
14
|
-
};
|
|
15
|
-
function makeState(overrides = {}) {
|
|
16
|
-
return {
|
|
17
|
-
workspaceId: 'ws-1',
|
|
18
|
-
workspaceName: 'Test',
|
|
19
|
-
configuredAgents: ['claude-code'],
|
|
20
|
-
scope: 'user',
|
|
21
|
-
lastSyncAt: '',
|
|
22
|
-
mcpServers: [],
|
|
23
|
-
skills: [],
|
|
24
|
-
skillHashes: {},
|
|
25
|
-
lastDetectedAt: new Date().toISOString(),
|
|
26
|
-
...overrides,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function fakeAdapter(slug) {
|
|
30
|
-
return {
|
|
31
|
-
name: slug,
|
|
32
|
-
slug,
|
|
33
|
-
detect: async () => true,
|
|
34
|
-
writeMcpServers: async () => { },
|
|
35
|
-
writeSkills: async () => { },
|
|
36
|
-
writeInstructionHint: async () => { },
|
|
37
|
-
supportsSkills: () => false,
|
|
38
|
-
supportsMcpScope: () => false,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
vi.clearAllMocks();
|
|
43
|
-
});
|
|
44
|
-
describe('shouldRedetect', () => {
|
|
45
|
-
it('returns true when --redetect is passed even on fresh state', () => {
|
|
46
|
-
expect(shouldRedetect(makeState(), { ...baseOpts, redetect: true })).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it('returns true when configuredAgents is empty (recovery)', () => {
|
|
49
|
-
expect(shouldRedetect(makeState({ configuredAgents: [] }), baseOpts)).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it('returns true when lastDetectedAt is missing (first sync)', () => {
|
|
52
|
-
expect(shouldRedetect(makeState({ lastDetectedAt: undefined }), baseOpts)).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
it('returns true when lastDetectedAt is unparseable (corrupt state)', () => {
|
|
55
|
-
expect(shouldRedetect(makeState({ lastDetectedAt: 'not-a-date' }), baseOpts)).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
it('returns true when lastDetectedAt is older than the TTL', () => {
|
|
58
|
-
const stale = new Date(Date.now() - REDETECT_TTL_MS - 1000).toISOString();
|
|
59
|
-
expect(shouldRedetect(makeState({ lastDetectedAt: stale }), baseOpts)).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it('returns false when lastDetectedAt is fresh (within TTL)', () => {
|
|
62
|
-
const fresh = new Date(Date.now() - 60_000).toISOString();
|
|
63
|
-
expect(shouldRedetect(makeState({ lastDetectedAt: fresh }), baseOpts)).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
describe('refreshConfiguredAgents', () => {
|
|
67
|
-
it('appends newly-detected agents and returns the diff', async () => {
|
|
68
|
-
vi.mocked(detectAgents).mockResolvedValue([
|
|
69
|
-
fakeAdapter('claude-code'),
|
|
70
|
-
fakeAdapter('codex'),
|
|
71
|
-
fakeAdapter('cursor'),
|
|
72
|
-
]);
|
|
73
|
-
const state = makeState({ configuredAgents: ['claude-code'], lastDetectedAt: undefined });
|
|
74
|
-
const added = await refreshConfiguredAgents(state);
|
|
75
|
-
expect(added.sort()).toEqual(['codex', 'cursor']);
|
|
76
|
-
expect(state.configuredAgents.sort()).toEqual(['claude-code', 'codex', 'cursor']);
|
|
77
|
-
expect(state.lastDetectedAt).toBeTruthy();
|
|
78
|
-
});
|
|
79
|
-
it('returns empty diff and stamps lastDetectedAt when nothing new is found', async () => {
|
|
80
|
-
vi.mocked(detectAgents).mockResolvedValue([fakeAdapter('claude-code')]);
|
|
81
|
-
const state = makeState({ configuredAgents: ['claude-code'], lastDetectedAt: undefined });
|
|
82
|
-
const added = await refreshConfiguredAgents(state);
|
|
83
|
-
expect(added).toEqual([]);
|
|
84
|
-
expect(state.configuredAgents).toEqual(['claude-code']);
|
|
85
|
-
expect(state.lastDetectedAt).toBeTruthy();
|
|
86
|
-
});
|
|
87
|
-
it('never removes agents that are no longer detected', async () => {
|
|
88
|
-
// A transient PATH glitch or temporarily-unmounted disk shouldn't wipe
|
|
89
|
-
// an agent the user explicitly configured. Removal is opt-in via setup.
|
|
90
|
-
vi.mocked(detectAgents).mockResolvedValue([fakeAdapter('claude-code')]);
|
|
91
|
-
const state = makeState({ configuredAgents: ['claude-code', 'codex', 'cursor'] });
|
|
92
|
-
const added = await refreshConfiguredAgents(state);
|
|
93
|
-
expect(added).toEqual([]);
|
|
94
|
-
expect(state.configuredAgents.sort()).toEqual(['claude-code', 'codex', 'cursor']);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { collectTelemetryEvents, summarizeTelemetryForDryRun } from '../sync-telemetry.js';
|
|
3
|
-
function mockAdapter(slug, opts = {}) {
|
|
4
|
-
return {
|
|
5
|
-
slug,
|
|
6
|
-
name: slug,
|
|
7
|
-
detect: async () => true,
|
|
8
|
-
supportsSkills: () => false,
|
|
9
|
-
supportsMcpScope: () => false,
|
|
10
|
-
writeSkills: async () => { },
|
|
11
|
-
writeMcpServers: async () => { },
|
|
12
|
-
writeInstructionHint: async () => { },
|
|
13
|
-
...opts,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function baseState(overrides = {}) {
|
|
17
|
-
return {
|
|
18
|
-
workspaceId: 'ws-1',
|
|
19
|
-
workspaceName: 'Test',
|
|
20
|
-
configuredAgents: [],
|
|
21
|
-
scope: 'user',
|
|
22
|
-
lastSyncAt: '2026-04-13T00:00:00.000Z',
|
|
23
|
-
mcpServers: [],
|
|
24
|
-
skills: [],
|
|
25
|
-
...overrides,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const NOW = '2026-04-14T00:00:00.000Z';
|
|
29
|
-
describe('collectTelemetryEvents', () => {
|
|
30
|
-
it('always emits a sync_completed event with aggregate counts', async () => {
|
|
31
|
-
const result = await collectTelemetryEvents({
|
|
32
|
-
adapters: [],
|
|
33
|
-
state: baseState(),
|
|
34
|
-
syncedSkillsCount: 5,
|
|
35
|
-
syncedMcpServersCount: 2,
|
|
36
|
-
teamInstructionsApplied: true,
|
|
37
|
-
agentConfigsApplied: 1,
|
|
38
|
-
now: NOW,
|
|
39
|
-
});
|
|
40
|
-
const syncCompleted = result.events.find(e => e.eventType === 'local_agent.sync_completed');
|
|
41
|
-
expect(syncCompleted).toBeDefined();
|
|
42
|
-
expect(syncCompleted?.metadata).toMatchObject({
|
|
43
|
-
syncedSkills: 5,
|
|
44
|
-
syncedMcpServers: 2,
|
|
45
|
-
teamInstructionsApplied: true,
|
|
46
|
-
agentConfigsApplied: 1,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
it('emits local_agent.detected only for newly seen agents', async () => {
|
|
50
|
-
const result = await collectTelemetryEvents({
|
|
51
|
-
adapters: [],
|
|
52
|
-
state: baseState({
|
|
53
|
-
configuredAgents: ['claude-code', 'cursor', 'codex'],
|
|
54
|
-
reportedAgentSlugs: ['claude-code'],
|
|
55
|
-
}),
|
|
56
|
-
syncedSkillsCount: 0,
|
|
57
|
-
syncedMcpServersCount: 0,
|
|
58
|
-
teamInstructionsApplied: false,
|
|
59
|
-
agentConfigsApplied: 0,
|
|
60
|
-
now: NOW,
|
|
61
|
-
});
|
|
62
|
-
const detectedSlugs = result.events
|
|
63
|
-
.filter(e => e.eventType === 'local_agent.detected')
|
|
64
|
-
.map(e => e.agentSlug);
|
|
65
|
-
expect(detectedSlugs).toEqual(['cursor', 'codex']);
|
|
66
|
-
expect(result.newlyReportedAgents).toEqual(['cursor', 'codex']);
|
|
67
|
-
});
|
|
68
|
-
it('emits local_agent.usage when adapter reports hasNewActivity', async () => {
|
|
69
|
-
const stats = {
|
|
70
|
-
hasNewActivity: true,
|
|
71
|
-
sessionCount: 3,
|
|
72
|
-
messageCount: 42,
|
|
73
|
-
toolCallCount: 10,
|
|
74
|
-
tokensUsed: 1000,
|
|
75
|
-
aiLinesAdded: 50,
|
|
76
|
-
aiLinesRemoved: 10,
|
|
77
|
-
lastActiveAt: '2026-04-13T23:00:00.000Z',
|
|
78
|
-
modelsUsed: ['sonnet'],
|
|
79
|
-
mcpToolCount: 5,
|
|
80
|
-
extra: { customField: 'value' },
|
|
81
|
-
};
|
|
82
|
-
const adapter = mockAdapter('claude-code', {
|
|
83
|
-
readUsageStats: async () => stats,
|
|
84
|
-
});
|
|
85
|
-
const result = await collectTelemetryEvents({
|
|
86
|
-
adapters: [adapter],
|
|
87
|
-
state: baseState({ configuredAgents: ['claude-code'], reportedAgentSlugs: ['claude-code'] }),
|
|
88
|
-
syncedSkillsCount: 0,
|
|
89
|
-
syncedMcpServersCount: 0,
|
|
90
|
-
teamInstructionsApplied: false,
|
|
91
|
-
agentConfigsApplied: 0,
|
|
92
|
-
now: NOW,
|
|
93
|
-
});
|
|
94
|
-
const usage = result.events.find(e => e.eventType === 'local_agent.usage');
|
|
95
|
-
expect(usage).toBeDefined();
|
|
96
|
-
expect(usage?.agentSlug).toBe('claude-code');
|
|
97
|
-
expect(usage?.metadata).toMatchObject({
|
|
98
|
-
sessionCount: 3,
|
|
99
|
-
messageCount: 42,
|
|
100
|
-
tokensUsed: 1000,
|
|
101
|
-
mcpToolCount: 5,
|
|
102
|
-
customField: 'value',
|
|
103
|
-
});
|
|
104
|
-
expect(result.adapterResults[0].stats).toEqual(stats);
|
|
105
|
-
});
|
|
106
|
-
it('does not emit usage event when hasNewActivity is false', async () => {
|
|
107
|
-
const adapter = mockAdapter('cursor', {
|
|
108
|
-
readUsageStats: async () => ({
|
|
109
|
-
hasNewActivity: false,
|
|
110
|
-
sessionCount: 0,
|
|
111
|
-
messageCount: 0,
|
|
112
|
-
toolCallCount: 0,
|
|
113
|
-
tokensUsed: 0,
|
|
114
|
-
aiLinesAdded: 0,
|
|
115
|
-
aiLinesRemoved: 0,
|
|
116
|
-
lastActiveAt: null,
|
|
117
|
-
}),
|
|
118
|
-
});
|
|
119
|
-
const result = await collectTelemetryEvents({
|
|
120
|
-
adapters: [adapter],
|
|
121
|
-
state: baseState({ configuredAgents: ['cursor'], reportedAgentSlugs: ['cursor'] }),
|
|
122
|
-
syncedSkillsCount: 0,
|
|
123
|
-
syncedMcpServersCount: 0,
|
|
124
|
-
teamInstructionsApplied: false,
|
|
125
|
-
agentConfigsApplied: 0,
|
|
126
|
-
now: NOW,
|
|
127
|
-
});
|
|
128
|
-
expect(result.events.find(e => e.eventType === 'local_agent.usage')).toBeUndefined();
|
|
129
|
-
expect(result.adapterResults[0].stats).toBeTruthy();
|
|
130
|
-
});
|
|
131
|
-
it('marks stats and skills as unsupported when adapter lacks readers', async () => {
|
|
132
|
-
const adapter = mockAdapter('cline');
|
|
133
|
-
const result = await collectTelemetryEvents({
|
|
134
|
-
adapters: [adapter],
|
|
135
|
-
state: baseState({ configuredAgents: ['cline'], reportedAgentSlugs: ['cline'] }),
|
|
136
|
-
syncedSkillsCount: 0,
|
|
137
|
-
syncedMcpServersCount: 0,
|
|
138
|
-
teamInstructionsApplied: false,
|
|
139
|
-
agentConfigsApplied: 0,
|
|
140
|
-
now: NOW,
|
|
141
|
-
});
|
|
142
|
-
expect(result.adapterResults[0].stats).toBe('unsupported');
|
|
143
|
-
expect(result.adapterResults[0].skills).toBe('unsupported');
|
|
144
|
-
});
|
|
145
|
-
it('captures errors thrown by readUsageStats without failing overall collection', async () => {
|
|
146
|
-
const good = mockAdapter('codex', {
|
|
147
|
-
readUsageStats: async () => ({
|
|
148
|
-
hasNewActivity: true,
|
|
149
|
-
sessionCount: 1,
|
|
150
|
-
messageCount: 0,
|
|
151
|
-
toolCallCount: 0,
|
|
152
|
-
tokensUsed: 100,
|
|
153
|
-
aiLinesAdded: 0,
|
|
154
|
-
aiLinesRemoved: 0,
|
|
155
|
-
lastActiveAt: NOW,
|
|
156
|
-
}),
|
|
157
|
-
});
|
|
158
|
-
const broken = mockAdapter('cursor', {
|
|
159
|
-
readUsageStats: async () => {
|
|
160
|
-
throw new Error('db locked');
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
const result = await collectTelemetryEvents({
|
|
164
|
-
adapters: [broken, good],
|
|
165
|
-
state: baseState({
|
|
166
|
-
configuredAgents: ['cursor', 'codex'],
|
|
167
|
-
reportedAgentSlugs: ['cursor', 'codex'],
|
|
168
|
-
}),
|
|
169
|
-
syncedSkillsCount: 0,
|
|
170
|
-
syncedMcpServersCount: 0,
|
|
171
|
-
teamInstructionsApplied: false,
|
|
172
|
-
agentConfigsApplied: 0,
|
|
173
|
-
now: NOW,
|
|
174
|
-
});
|
|
175
|
-
const brokenResult = result.adapterResults.find(r => r.slug === 'cursor');
|
|
176
|
-
expect(brokenResult?.error).toContain('db locked');
|
|
177
|
-
expect(brokenResult?.stats).toBeNull();
|
|
178
|
-
const goodResult = result.adapterResults.find(r => r.slug === 'codex');
|
|
179
|
-
expect(goodResult?.error).toBeUndefined();
|
|
180
|
-
expect(result.events
|
|
181
|
-
.filter(e => e.eventType === 'local_agent.usage')
|
|
182
|
-
.map(e => e.agentSlug)).toEqual(['codex']);
|
|
183
|
-
});
|
|
184
|
-
it('emits one skill_used event per skill entry', async () => {
|
|
185
|
-
const entries = [
|
|
186
|
-
{ skillName: 'runwork', count: 1, lastUsedAt: '2026-04-13T12:00:00.000Z' },
|
|
187
|
-
{ skillName: 'seo-content-strategist', count: 2, lastUsedAt: '2026-04-13T13:00:00.000Z' },
|
|
188
|
-
];
|
|
189
|
-
const adapter = mockAdapter('claude-code', {
|
|
190
|
-
readSkillUsage: async () => entries,
|
|
191
|
-
});
|
|
192
|
-
const result = await collectTelemetryEvents({
|
|
193
|
-
adapters: [adapter],
|
|
194
|
-
state: baseState({ configuredAgents: ['claude-code'], reportedAgentSlugs: ['claude-code'] }),
|
|
195
|
-
syncedSkillsCount: 0,
|
|
196
|
-
syncedMcpServersCount: 0,
|
|
197
|
-
teamInstructionsApplied: false,
|
|
198
|
-
agentConfigsApplied: 0,
|
|
199
|
-
now: NOW,
|
|
200
|
-
});
|
|
201
|
-
const skillEvents = result.events.filter(e => e.eventType === 'local_agent.skill_used');
|
|
202
|
-
expect(skillEvents).toHaveLength(2);
|
|
203
|
-
expect(skillEvents[0].metadata?.skillName).toBe('runwork');
|
|
204
|
-
expect(skillEvents[1].metadata?.skillName).toBe('seo-content-strategist');
|
|
205
|
-
});
|
|
206
|
-
it('reports health when lastHealthReportAt is missing', async () => {
|
|
207
|
-
const adapter = mockAdapter('codex', {
|
|
208
|
-
readVersion: async () => '0.5.0',
|
|
209
|
-
});
|
|
210
|
-
const result = await collectTelemetryEvents({
|
|
211
|
-
adapters: [adapter],
|
|
212
|
-
state: baseState({ configuredAgents: ['codex'], reportedAgentSlugs: ['codex'] }),
|
|
213
|
-
syncedSkillsCount: 0,
|
|
214
|
-
syncedMcpServersCount: 0,
|
|
215
|
-
teamInstructionsApplied: false,
|
|
216
|
-
agentConfigsApplied: 0,
|
|
217
|
-
now: NOW,
|
|
218
|
-
});
|
|
219
|
-
expect(result.healthReported).toBe(true);
|
|
220
|
-
const health = result.events.find(e => e.eventType === 'local_agent.health');
|
|
221
|
-
expect(health?.metadata?.version).toBe('0.5.0');
|
|
222
|
-
expect(health?.metadata?.installed).toBe(true);
|
|
223
|
-
});
|
|
224
|
-
it('skips health when last reported less than 24h ago', async () => {
|
|
225
|
-
const recent = new Date(Date.now() - 60 * 60 * 1000).toISOString();
|
|
226
|
-
const adapter = mockAdapter('codex', {
|
|
227
|
-
readVersion: async () => '0.5.0',
|
|
228
|
-
});
|
|
229
|
-
const result = await collectTelemetryEvents({
|
|
230
|
-
adapters: [adapter],
|
|
231
|
-
state: baseState({
|
|
232
|
-
configuredAgents: ['codex'],
|
|
233
|
-
reportedAgentSlugs: ['codex'],
|
|
234
|
-
lastHealthReportAt: recent,
|
|
235
|
-
}),
|
|
236
|
-
syncedSkillsCount: 0,
|
|
237
|
-
syncedMcpServersCount: 0,
|
|
238
|
-
teamInstructionsApplied: false,
|
|
239
|
-
agentConfigsApplied: 0,
|
|
240
|
-
now: NOW,
|
|
241
|
-
});
|
|
242
|
-
expect(result.healthReported).toBe(false);
|
|
243
|
-
expect(result.events.find(e => e.eventType === 'local_agent.health')).toBeUndefined();
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
describe('summarizeTelemetryForDryRun', () => {
|
|
247
|
-
it('counts adapters with active stats', async () => {
|
|
248
|
-
const result = await collectTelemetryEvents({
|
|
249
|
-
adapters: [
|
|
250
|
-
mockAdapter('codex', {
|
|
251
|
-
readUsageStats: async () => ({
|
|
252
|
-
hasNewActivity: true,
|
|
253
|
-
sessionCount: 1,
|
|
254
|
-
messageCount: 0,
|
|
255
|
-
toolCallCount: 0,
|
|
256
|
-
tokensUsed: 0,
|
|
257
|
-
aiLinesAdded: 0,
|
|
258
|
-
aiLinesRemoved: 0,
|
|
259
|
-
lastActiveAt: NOW,
|
|
260
|
-
}),
|
|
261
|
-
}),
|
|
262
|
-
mockAdapter('cursor', {
|
|
263
|
-
readUsageStats: async () => null,
|
|
264
|
-
}),
|
|
265
|
-
mockAdapter('cline'),
|
|
266
|
-
],
|
|
267
|
-
state: baseState({
|
|
268
|
-
configuredAgents: ['codex', 'cursor', 'cline'],
|
|
269
|
-
reportedAgentSlugs: ['codex', 'cursor', 'cline'],
|
|
270
|
-
}),
|
|
271
|
-
syncedSkillsCount: 0,
|
|
272
|
-
syncedMcpServersCount: 0,
|
|
273
|
-
teamInstructionsApplied: false,
|
|
274
|
-
agentConfigsApplied: 0,
|
|
275
|
-
now: NOW,
|
|
276
|
-
});
|
|
277
|
-
const summary = summarizeTelemetryForDryRun(result);
|
|
278
|
-
expect(summary).toContain('1 adapter with activity');
|
|
279
|
-
expect(summary).toContain('events would be sent');
|
|
280
|
-
});
|
|
281
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for `runwork upgrade`.
|
|
3
|
-
*
|
|
4
|
-
* The module under test has top-level side effects (it builds a Commander
|
|
5
|
-
* command and captures `httpFetch` references), so we exercise the exported
|
|
6
|
-
* __internal helpers against a local HTTP server that serves a fake
|
|
7
|
-
* /cli/latest.json. We intercept `httpFetch` and rewrite the LATEST_JSON_URL
|
|
8
|
-
* to point at the test server so the actual node:https-backed wrapper is
|
|
9
|
-
* exercised end to end.
|
|
10
|
-
*/
|
|
11
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
12
|
-
import { createServer } from 'node:http';
|
|
13
|
-
let currentServerUrl = null;
|
|
14
|
-
vi.mock('../../utils/http.js', async () => {
|
|
15
|
-
const actual = await vi.importActual('../../utils/http.js');
|
|
16
|
-
return {
|
|
17
|
-
...actual,
|
|
18
|
-
httpFetch: (url, init) => {
|
|
19
|
-
if (currentServerUrl && url.endsWith('/cli/latest.json')) {
|
|
20
|
-
return actual.httpFetch(`${currentServerUrl}/cli/latest.json`, init);
|
|
21
|
-
}
|
|
22
|
-
return actual.httpFetch(url, init);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
import { __internal } from '../upgrade.js';
|
|
27
|
-
function startJsonServer(body, status = 200) {
|
|
28
|
-
return new Promise((resolvePromise) => {
|
|
29
|
-
const server = createServer((req, res) => {
|
|
30
|
-
if (req.url === '/cli/latest.json') {
|
|
31
|
-
if (body === null) {
|
|
32
|
-
res.writeHead(status, { 'Content-Type': 'application/json' });
|
|
33
|
-
res.end('{"error": "not found"}');
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
res.writeHead(status, {
|
|
37
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
38
|
-
});
|
|
39
|
-
res.end(JSON.stringify(body));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
res.writeHead(404);
|
|
43
|
-
res.end('not found');
|
|
44
|
-
});
|
|
45
|
-
server.listen(0, '127.0.0.1', () => {
|
|
46
|
-
const addr = server.address();
|
|
47
|
-
if (addr && typeof addr === 'object') {
|
|
48
|
-
const url = `http://127.0.0.1:${addr.port}`;
|
|
49
|
-
const stop = () => new Promise((resolveStop) => {
|
|
50
|
-
server.close(() => resolveStop());
|
|
51
|
-
});
|
|
52
|
-
resolvePromise({ url, stop });
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
describe('__internal.fetchLatestVersion', () => {
|
|
58
|
-
let originalBase;
|
|
59
|
-
let serverStop = null;
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
originalBase = process.env.RUNWORK_DOWNLOAD_BASE_URL;
|
|
62
|
-
});
|
|
63
|
-
afterEach(async () => {
|
|
64
|
-
if (serverStop)
|
|
65
|
-
await serverStop();
|
|
66
|
-
serverStop = null;
|
|
67
|
-
currentServerUrl = null;
|
|
68
|
-
if (originalBase === undefined)
|
|
69
|
-
delete process.env.RUNWORK_DOWNLOAD_BASE_URL;
|
|
70
|
-
else
|
|
71
|
-
process.env.RUNWORK_DOWNLOAD_BASE_URL = originalBase;
|
|
72
|
-
});
|
|
73
|
-
it('parses the version field from a valid manifest', async () => {
|
|
74
|
-
const server = await startJsonServer({
|
|
75
|
-
name: 'runwork',
|
|
76
|
-
version: '1.2.3',
|
|
77
|
-
publishedAt: '2026-04-14T00:00:00Z',
|
|
78
|
-
artifacts: {},
|
|
79
|
-
});
|
|
80
|
-
serverStop = server.stop;
|
|
81
|
-
currentServerUrl = server.url;
|
|
82
|
-
const version = await __internal.fetchLatestVersion();
|
|
83
|
-
expect(version).toBe('1.2.3');
|
|
84
|
-
});
|
|
85
|
-
it('strips a leading v from the version', async () => {
|
|
86
|
-
const server = await startJsonServer({ version: 'v9.9.9' });
|
|
87
|
-
serverStop = server.stop;
|
|
88
|
-
currentServerUrl = server.url;
|
|
89
|
-
const version = await __internal.fetchLatestVersion();
|
|
90
|
-
expect(version).toBe('9.9.9');
|
|
91
|
-
});
|
|
92
|
-
it('returns null on HTTP error', async () => {
|
|
93
|
-
const server = await startJsonServer(null, 500);
|
|
94
|
-
serverStop = server.stop;
|
|
95
|
-
currentServerUrl = server.url;
|
|
96
|
-
const version = await __internal.fetchLatestVersion();
|
|
97
|
-
expect(version).toBeNull();
|
|
98
|
-
});
|
|
99
|
-
it('returns null when fetch throws', async () => {
|
|
100
|
-
// Point at a port that is virtually guaranteed to refuse connections.
|
|
101
|
-
currentServerUrl = 'http://127.0.0.1:1';
|
|
102
|
-
const version = await __internal.fetchLatestVersion();
|
|
103
|
-
expect(version).toBeNull();
|
|
104
|
-
});
|
|
105
|
-
it('returns null when the manifest has no version field', async () => {
|
|
106
|
-
const server = await startJsonServer({ name: 'runwork' });
|
|
107
|
-
serverStop = server.stop;
|
|
108
|
-
currentServerUrl = server.url;
|
|
109
|
-
const version = await __internal.fetchLatestVersion();
|
|
110
|
-
expect(version).toBeNull();
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('__internal endpoint constants', () => {
|
|
114
|
-
it('all endpoints live on runwork.ai', () => {
|
|
115
|
-
expect(__internal.BASE_URL).toBe('https://runwork.ai');
|
|
116
|
-
expect(__internal.LATEST_JSON_URL).toBe('https://runwork.ai/cli/latest.json');
|
|
117
|
-
expect(__internal.INSTALL_SH_URL).toBe('https://runwork.ai/install.sh');
|
|
118
|
-
expect(__internal.INSTALL_PS1_URL).toBe('https://runwork.ai/install.ps1');
|
|
119
|
-
});
|
|
120
|
-
it('does not reference api.github.com or github.com/.../releases', () => {
|
|
121
|
-
const values = Object.values(__internal).filter((v) => typeof v === 'string');
|
|
122
|
-
for (const v of values) {
|
|
123
|
-
expect(v).not.toContain('api.github.com');
|
|
124
|
-
expect(v).not.toContain('/releases');
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
describe('__internal.detectInstallMethod', () => {
|
|
129
|
-
const originalArgv1 = process.argv[1];
|
|
130
|
-
afterEach(() => {
|
|
131
|
-
process.argv[1] = originalArgv1;
|
|
132
|
-
});
|
|
133
|
-
it('detects homebrew installs', () => {
|
|
134
|
-
process.argv[1] = '/opt/homebrew/Cellar/runwork/0.6.2/bin/runwork';
|
|
135
|
-
expect(__internal.detectInstallMethod()).toBe('brew');
|
|
136
|
-
});
|
|
137
|
-
it('detects bun global installs', () => {
|
|
138
|
-
process.argv[1] = '/Users/user/.bun/install/global/node_modules/runwork/bin/runwork.js';
|
|
139
|
-
expect(__internal.detectInstallMethod()).toBe('bun');
|
|
140
|
-
});
|
|
141
|
-
it('detects pnpm global installs', () => {
|
|
142
|
-
process.argv[1] = '/Users/user/.local/share/pnpm/global/5/node_modules/runwork/bin/runwork.js';
|
|
143
|
-
expect(__internal.detectInstallMethod()).toBe('pnpm');
|
|
144
|
-
});
|
|
145
|
-
it('detects yarn global installs', () => {
|
|
146
|
-
process.argv[1] = '/Users/user/.yarn/bin/runwork';
|
|
147
|
-
expect(__internal.detectInstallMethod()).toBe('yarn');
|
|
148
|
-
});
|
|
149
|
-
it('detects volta installs', () => {
|
|
150
|
-
process.argv[1] = '/Users/user/.volta/tools/image/packages/runwork/bin/runwork';
|
|
151
|
-
expect(__internal.detectInstallMethod()).toBe('volta');
|
|
152
|
-
});
|
|
153
|
-
it('falls back to binary for standalone paths', () => {
|
|
154
|
-
process.argv[1] = '/Users/user/.runwork/bin/runwork';
|
|
155
|
-
expect(__internal.detectInstallMethod()).toBe('binary');
|
|
156
|
-
});
|
|
157
|
-
});
|