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,268 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { detectRemovals, computeApplicable, mergeAllow, isBootstrap, resolveAgentDefaults, unique, } from '../defaults-merge.js';
|
|
3
|
-
describe('detectRemovals', () => {
|
|
4
|
-
it('returns lastInjected items missing from onDisk', () => {
|
|
5
|
-
expect(detectRemovals(['a', 'b', 'c'], ['a', 'c'])).toEqual(['b']);
|
|
6
|
-
});
|
|
7
|
-
it('returns empty when nothing was removed', () => {
|
|
8
|
-
expect(detectRemovals(['a', 'b'], ['a', 'b', 'c'])).toEqual([]);
|
|
9
|
-
});
|
|
10
|
-
it('returns all when onDisk is empty', () => {
|
|
11
|
-
expect(detectRemovals(['a', 'b'], [])).toEqual(['a', 'b']);
|
|
12
|
-
});
|
|
13
|
-
it('returns empty when lastInjected is empty', () => {
|
|
14
|
-
expect(detectRemovals([], ['a', 'b'])).toEqual([]);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('computeApplicable', () => {
|
|
18
|
-
it('filters out opted-out items', () => {
|
|
19
|
-
expect(computeApplicable(['a', 'b', 'c'], ['b'])).toEqual(['a', 'c']);
|
|
20
|
-
});
|
|
21
|
-
it('returns full set when no opt-outs', () => {
|
|
22
|
-
expect(computeApplicable(['a', 'b'], [])).toEqual(['a', 'b']);
|
|
23
|
-
});
|
|
24
|
-
it('returns empty when everything is opted out', () => {
|
|
25
|
-
expect(computeApplicable(['a', 'b'], ['a', 'b'])).toEqual([]);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('mergeAllow', () => {
|
|
29
|
-
it('places defaults before team rules', () => {
|
|
30
|
-
expect(mergeAllow(['default1', 'default2'], ['team1'])).toEqual([
|
|
31
|
-
'default1',
|
|
32
|
-
'default2',
|
|
33
|
-
'team1',
|
|
34
|
-
]);
|
|
35
|
-
});
|
|
36
|
-
it('dedupes silently when team rule equals default', () => {
|
|
37
|
-
expect(mergeAllow(['Bash(runwork *)', 'Bash(git status)'], ['Bash(runwork *)'])).toEqual([
|
|
38
|
-
'Bash(git status)',
|
|
39
|
-
'Bash(runwork *)',
|
|
40
|
-
]);
|
|
41
|
-
});
|
|
42
|
-
it('preserves order within each segment', () => {
|
|
43
|
-
expect(mergeAllow(['a', 'b', 'c'], ['x', 'y'])).toEqual(['a', 'b', 'c', 'x', 'y']);
|
|
44
|
-
});
|
|
45
|
-
it('handles empty team rules', () => {
|
|
46
|
-
expect(mergeAllow(['a', 'b'], [])).toEqual(['a', 'b']);
|
|
47
|
-
});
|
|
48
|
-
it('handles empty defaults', () => {
|
|
49
|
-
expect(mergeAllow([], ['x', 'y'])).toEqual(['x', 'y']);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('unique', () => {
|
|
53
|
-
it('removes duplicates preserving first-seen order', () => {
|
|
54
|
-
expect(unique(['a', 'b', 'a', 'c', 'b'])).toEqual(['a', 'b', 'c']);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('isBootstrap', () => {
|
|
58
|
-
it('true when state is undefined', () => {
|
|
59
|
-
expect(isBootstrap(undefined)).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it('false when state is defined (even if empty)', () => {
|
|
62
|
-
const state = {
|
|
63
|
-
lastInjected: {},
|
|
64
|
-
userOptOuts: {},
|
|
65
|
-
};
|
|
66
|
-
expect(isBootstrap(state)).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('resolveAgentDefaults', () => {
|
|
70
|
-
const baked = {
|
|
71
|
-
allow: ['Bash(runwork *)', 'Bash(git status)', 'Bash(ls:*)'],
|
|
72
|
-
deny: ['Bash(rm -rf *)'],
|
|
73
|
-
};
|
|
74
|
-
it('case 1: no baked defaults emits team rules unchanged', () => {
|
|
75
|
-
const result = resolveAgentDefaults({
|
|
76
|
-
baked: undefined,
|
|
77
|
-
state: undefined,
|
|
78
|
-
onDisk: undefined,
|
|
79
|
-
team: { allow: ['custom'], deny: [] },
|
|
80
|
-
});
|
|
81
|
-
expect(result.managedAllow).toEqual(['custom']);
|
|
82
|
-
expect(result.managedDeny).toEqual([]);
|
|
83
|
-
expect(result.applicableAllow).toEqual([]);
|
|
84
|
-
expect(result.bootstrapped).toBe(false);
|
|
85
|
-
});
|
|
86
|
-
it('case 2: bootstrap does NOT inject defaults but applies team rules', () => {
|
|
87
|
-
const result = resolveAgentDefaults({
|
|
88
|
-
baked,
|
|
89
|
-
state: undefined,
|
|
90
|
-
onDisk: { allow: ['userPersonalRule'] },
|
|
91
|
-
team: { allow: ['teamRule'] },
|
|
92
|
-
});
|
|
93
|
-
expect(result.managedAllow).toEqual(['teamRule']);
|
|
94
|
-
expect(result.applicableAllow).toEqual([]);
|
|
95
|
-
expect(result.bootstrapped).toBe(true);
|
|
96
|
-
expect(result.newOptOutsAllow).toEqual([]);
|
|
97
|
-
});
|
|
98
|
-
it('case 3 normal: injects baked defaults when state has empty injection', () => {
|
|
99
|
-
const state = {
|
|
100
|
-
lastInjected: { allow: [], deny: [] },
|
|
101
|
-
userOptOuts: { allow: [], deny: [] },
|
|
102
|
-
};
|
|
103
|
-
const result = resolveAgentDefaults({
|
|
104
|
-
baked,
|
|
105
|
-
state,
|
|
106
|
-
onDisk: { allow: [], deny: [] },
|
|
107
|
-
team: undefined,
|
|
108
|
-
});
|
|
109
|
-
expect(result.managedAllow).toEqual(baked.allow);
|
|
110
|
-
expect(result.managedDeny).toEqual(baked.deny);
|
|
111
|
-
expect(result.applicableAllow).toEqual(baked.allow);
|
|
112
|
-
expect(result.bootstrapped).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
it('case 3 normal: sticky opt-out — removed entry stays out next sync', () => {
|
|
115
|
-
// Previous sync injected the 3 defaults. User removed 'Bash(ls:*)' from
|
|
116
|
-
// settings.json. On the next sync we should detect that and never
|
|
117
|
-
// re-inject it.
|
|
118
|
-
const state = {
|
|
119
|
-
lastInjected: { allow: baked.allow, deny: baked.deny },
|
|
120
|
-
userOptOuts: { allow: [], deny: [] },
|
|
121
|
-
};
|
|
122
|
-
const result = resolveAgentDefaults({
|
|
123
|
-
baked,
|
|
124
|
-
state,
|
|
125
|
-
onDisk: { allow: ['Bash(runwork *)', 'Bash(git status)'], deny: baked.deny },
|
|
126
|
-
team: undefined,
|
|
127
|
-
});
|
|
128
|
-
expect(result.newOptOutsAllow).toEqual(['Bash(ls:*)']);
|
|
129
|
-
expect(result.applicableAllow).toEqual(['Bash(runwork *)', 'Bash(git status)']);
|
|
130
|
-
expect(result.managedAllow).toEqual(['Bash(runwork *)', 'Bash(git status)']);
|
|
131
|
-
expect(result.removalsThisSync.allow).toBe(1);
|
|
132
|
-
});
|
|
133
|
-
it('case 3 normal: opt-out persists even when on-disk equals lastInjected', () => {
|
|
134
|
-
// User opted out 'Bash(ls:*)' two syncs ago. Sync after that ran with
|
|
135
|
-
// applicable = [runwork *, git status]. Now another sync: on-disk has
|
|
136
|
-
// exactly that. We should NOT re-inject 'Bash(ls:*)'.
|
|
137
|
-
const state = {
|
|
138
|
-
lastInjected: { allow: ['Bash(runwork *)', 'Bash(git status)'] },
|
|
139
|
-
userOptOuts: { allow: ['Bash(ls:*)'] },
|
|
140
|
-
};
|
|
141
|
-
const result = resolveAgentDefaults({
|
|
142
|
-
baked,
|
|
143
|
-
state,
|
|
144
|
-
onDisk: { allow: ['Bash(runwork *)', 'Bash(git status)'] },
|
|
145
|
-
team: undefined,
|
|
146
|
-
});
|
|
147
|
-
expect(result.applicableAllow).toEqual(['Bash(runwork *)', 'Bash(git status)']);
|
|
148
|
-
expect(result.newOptOutsAllow).toEqual(['Bash(ls:*)']);
|
|
149
|
-
expect(result.removalsThisSync.allow).toBe(0);
|
|
150
|
-
});
|
|
151
|
-
it('case 3 normal: baked-default shrink auto-removes from managed block', () => {
|
|
152
|
-
// CLI used to inject ['a','b','c']. New CLI version only has ['a','b'].
|
|
153
|
-
// Previous sync recorded ['a','b','c'] as lastInjected. User did not
|
|
154
|
-
// touch settings.json — onDisk still has ['a','b','c']. Next sync:
|
|
155
|
-
// 'c' is no longer in baked → applicable = ['a','b'] → managed = ['a','b'].
|
|
156
|
-
// No opt-out should be created for 'c' (it was a baked-default removal,
|
|
157
|
-
// not a user removal).
|
|
158
|
-
const oldBaked = {
|
|
159
|
-
allow: ['a', 'b', 'c'],
|
|
160
|
-
deny: [],
|
|
161
|
-
};
|
|
162
|
-
const newBaked = {
|
|
163
|
-
allow: ['a', 'b'],
|
|
164
|
-
deny: [],
|
|
165
|
-
};
|
|
166
|
-
const state = {
|
|
167
|
-
lastInjected: { allow: oldBaked.allow },
|
|
168
|
-
userOptOuts: { allow: [] },
|
|
169
|
-
};
|
|
170
|
-
const result = resolveAgentDefaults({
|
|
171
|
-
baked: newBaked,
|
|
172
|
-
state,
|
|
173
|
-
onDisk: { allow: ['a', 'b', 'c'] },
|
|
174
|
-
team: undefined,
|
|
175
|
-
});
|
|
176
|
-
expect(result.applicableAllow).toEqual(['a', 'b']);
|
|
177
|
-
expect(result.managedAllow).toEqual(['a', 'b']);
|
|
178
|
-
// 'c' was on-disk so detectRemovals doesn't flag it; opt-outs stay empty.
|
|
179
|
-
expect(result.newOptOutsAllow).toEqual([]);
|
|
180
|
-
});
|
|
181
|
-
it('case 3 normal: team rules dedupe silently with defaults', () => {
|
|
182
|
-
const state = {
|
|
183
|
-
lastInjected: { allow: [] },
|
|
184
|
-
userOptOuts: { allow: [] },
|
|
185
|
-
};
|
|
186
|
-
const result = resolveAgentDefaults({
|
|
187
|
-
baked: { allow: ['Bash(runwork *)', 'Bash(ls:*)'], deny: [] },
|
|
188
|
-
state,
|
|
189
|
-
onDisk: { allow: [] },
|
|
190
|
-
team: { allow: ['Bash(runwork *)', 'Bash(npm test)'] },
|
|
191
|
-
});
|
|
192
|
-
// Default 'Bash(runwork *)' overlaps with team; team copy wins on position.
|
|
193
|
-
expect(result.managedAllow).toEqual([
|
|
194
|
-
'Bash(ls:*)',
|
|
195
|
-
'Bash(runwork *)',
|
|
196
|
-
'Bash(npm test)',
|
|
197
|
-
]);
|
|
198
|
-
});
|
|
199
|
-
it('case 3 normal: simultaneous removal + new baked addition', () => {
|
|
200
|
-
// Previous sync injected ['a','b']. User removed 'a'. CLI added 'c'.
|
|
201
|
-
// Result: applicable = ['b','c'] (a opted out, c is new).
|
|
202
|
-
const state = {
|
|
203
|
-
lastInjected: { allow: ['a', 'b'] },
|
|
204
|
-
userOptOuts: { allow: [] },
|
|
205
|
-
};
|
|
206
|
-
const result = resolveAgentDefaults({
|
|
207
|
-
baked: { allow: ['a', 'b', 'c'], deny: [] },
|
|
208
|
-
state,
|
|
209
|
-
onDisk: { allow: ['b'] },
|
|
210
|
-
team: undefined,
|
|
211
|
-
});
|
|
212
|
-
expect(result.newOptOutsAllow).toEqual(['a']);
|
|
213
|
-
expect(result.applicableAllow).toEqual(['b', 'c']);
|
|
214
|
-
});
|
|
215
|
-
it('case 3 markerless: undefined onDisk does NOT fabricate opt-outs (Cursor)', () => {
|
|
216
|
-
// Cursor's readManagedBlock returns undefined because there's no marker
|
|
217
|
-
// on disk to identify our entries. The resolver must NOT treat that as
|
|
218
|
-
// "everything was removed" — otherwise every default becomes a sticky
|
|
219
|
-
// opt-out after the first injection, corrupting setup.json forever.
|
|
220
|
-
const state = {
|
|
221
|
-
lastInjected: { allow: ['runwork', 'git status', 'ls'] },
|
|
222
|
-
userOptOuts: { allow: [] },
|
|
223
|
-
};
|
|
224
|
-
const result = resolveAgentDefaults({
|
|
225
|
-
baked,
|
|
226
|
-
state,
|
|
227
|
-
onDisk: undefined,
|
|
228
|
-
team: undefined,
|
|
229
|
-
});
|
|
230
|
-
// No new opt-outs created from the missing read.
|
|
231
|
-
expect(result.newOptOutsAllow).toEqual([]);
|
|
232
|
-
expect(result.removalsThisSync.allow).toBe(0);
|
|
233
|
-
// Defaults are still applied (filtered by any existing opt-outs).
|
|
234
|
-
expect(result.applicableAllow).toEqual(baked.allow);
|
|
235
|
-
});
|
|
236
|
-
it('case 3 markerless: existing opt-outs are preserved when onDisk is undefined', () => {
|
|
237
|
-
// User had previously opted out of 'Bash(ls:*)' (recorded in state).
|
|
238
|
-
// This sync's onDisk read came back undefined. We must keep the existing
|
|
239
|
-
// opt-out, not silently re-inject the default.
|
|
240
|
-
const state = {
|
|
241
|
-
lastInjected: { allow: ['Bash(runwork *)', 'Bash(git status)'] },
|
|
242
|
-
userOptOuts: { allow: ['Bash(ls:*)'] },
|
|
243
|
-
};
|
|
244
|
-
const result = resolveAgentDefaults({
|
|
245
|
-
baked,
|
|
246
|
-
state,
|
|
247
|
-
onDisk: undefined,
|
|
248
|
-
team: undefined,
|
|
249
|
-
});
|
|
250
|
-
expect(result.newOptOutsAllow).toEqual(['Bash(ls:*)']);
|
|
251
|
-
expect(result.applicableAllow).not.toContain('Bash(ls:*)');
|
|
252
|
-
});
|
|
253
|
-
it('case 3 normal: deny side mirrors allow side', () => {
|
|
254
|
-
const state = {
|
|
255
|
-
lastInjected: { deny: ['Bash(rm -rf *)', 'Bash(sudo rm *)'] },
|
|
256
|
-
userOptOuts: { deny: [] },
|
|
257
|
-
};
|
|
258
|
-
const result = resolveAgentDefaults({
|
|
259
|
-
baked: { allow: [], deny: ['Bash(rm -rf *)', 'Bash(sudo rm *)'] },
|
|
260
|
-
state,
|
|
261
|
-
onDisk: { deny: ['Bash(rm -rf *)'] },
|
|
262
|
-
team: undefined,
|
|
263
|
-
});
|
|
264
|
-
expect(result.newOptOutsDeny).toEqual(['Bash(sudo rm *)']);
|
|
265
|
-
expect(result.applicableDeny).toEqual(['Bash(rm -rf *)']);
|
|
266
|
-
expect(result.managedDeny).toEqual(['Bash(rm -rf *)']);
|
|
267
|
-
});
|
|
268
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
// Force a Windows environment for Windows-only detection methods. The
|
|
3
|
-
// `runAgentDetection` function bails out off Windows for `windows-appx` and
|
|
4
|
-
// `windows-start-app`, so we have to pretend.
|
|
5
|
-
vi.mock('os', async () => {
|
|
6
|
-
const actual = await vi.importActual('os');
|
|
7
|
-
return { ...actual, platform: vi.fn(() => 'win32') };
|
|
8
|
-
});
|
|
9
|
-
const execBehaviors = [];
|
|
10
|
-
let defaultBehavior = { kind: 'success' };
|
|
11
|
-
vi.mock('child_process', () => ({
|
|
12
|
-
// promisify(execFile) drives this: the last argument is always the
|
|
13
|
-
// (err, stdout, stderr) callback regardless of whether options are passed.
|
|
14
|
-
execFile: (...args) => {
|
|
15
|
-
const cb = args[args.length - 1];
|
|
16
|
-
const behavior = execBehaviors.shift() ?? defaultBehavior;
|
|
17
|
-
const finish = (b) => {
|
|
18
|
-
if (b.kind === 'success')
|
|
19
|
-
cb(null, '', '');
|
|
20
|
-
else if (b.kind === 'fail')
|
|
21
|
-
cb(new Error('exit 1'), '', '');
|
|
22
|
-
};
|
|
23
|
-
if (behavior.kind === 'delay') {
|
|
24
|
-
setTimeout(() => finish({ kind: behavior.result }), behavior.ms);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
finish(behavior);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
31
|
-
vi.mock('../../utils/which.js', () => ({
|
|
32
|
-
whichBinary: vi.fn((name) => (name === 'present-binary' ? `/usr/bin/${name}` : null)),
|
|
33
|
-
}));
|
|
34
|
-
import { runAgentDetection } from '../detection.js';
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
vi.clearAllMocks();
|
|
37
|
-
execBehaviors.length = 0;
|
|
38
|
-
defaultBehavior = { kind: 'success' };
|
|
39
|
-
});
|
|
40
|
-
describe('runAgentDetection', () => {
|
|
41
|
-
it('reports binary detection via whichBinary', async () => {
|
|
42
|
-
expect(await runAgentDetection({ method: 'binary', target: 'present-binary' })).toBe(true);
|
|
43
|
-
expect(await runAgentDetection({ method: 'binary', target: 'missing-binary' })).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
it('reports false when a windows-appx probe exits non-zero', async () => {
|
|
46
|
-
defaultBehavior = { kind: 'fail' };
|
|
47
|
-
expect(await runAgentDetection({ method: 'windows-appx', target: 'Some.Package' })).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
it('reports true when any windows-appx probe succeeds', async () => {
|
|
50
|
-
// First two probes fail, third succeeds — the function should still
|
|
51
|
-
// return true because we union with Promise.all + .some(Boolean).
|
|
52
|
-
execBehaviors.push({ kind: 'fail' }, { kind: 'fail' }, { kind: 'success' });
|
|
53
|
-
expect(await runAgentDetection({ method: 'windows-appx', target: ['A', 'B', 'C'] })).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
it('runs windows-appx probes in parallel (wall time ≈ slowest probe, not sum)', async () => {
|
|
56
|
-
// Each probe takes 80ms. Six probes serialized = ~480ms; parallel = ~80ms.
|
|
57
|
-
// Allow slack for CI noise but enough to catch a regression to sync execution.
|
|
58
|
-
defaultBehavior = { kind: 'delay', ms: 80, result: 'fail' };
|
|
59
|
-
const start = Date.now();
|
|
60
|
-
const result = await runAgentDetection({
|
|
61
|
-
method: 'windows-appx',
|
|
62
|
-
target: ['A', 'B', 'C', 'D', 'E', 'F'],
|
|
63
|
-
});
|
|
64
|
-
const elapsed = Date.now() - start;
|
|
65
|
-
expect(result).toBe(false);
|
|
66
|
-
expect(elapsed).toBeLessThan(300);
|
|
67
|
-
});
|
|
68
|
-
it('any combinator returns true on first hit', async () => {
|
|
69
|
-
expect(await runAgentDetection({
|
|
70
|
-
method: 'any',
|
|
71
|
-
target: [
|
|
72
|
-
{ method: 'binary', target: 'missing-binary' },
|
|
73
|
-
{ method: 'binary', target: 'present-binary' },
|
|
74
|
-
],
|
|
75
|
-
})).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
it('any combinator returns false when every probe misses', async () => {
|
|
78
|
-
expect(await runAgentDetection({
|
|
79
|
-
method: 'any',
|
|
80
|
-
target: [
|
|
81
|
-
{ method: 'binary', target: 'missing-binary' },
|
|
82
|
-
{ method: 'binary', target: 'also-missing' },
|
|
83
|
-
],
|
|
84
|
-
})).toBe(false);
|
|
85
|
-
});
|
|
86
|
-
it('always method reports true without any local probe (web-only agents)', async () => {
|
|
87
|
-
expect(await runAgentDetection({ method: 'always' })).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
vi.mock('fs', () => ({
|
|
3
|
-
existsSync: vi.fn(() => false),
|
|
4
|
-
readFileSync: vi.fn(() => { throw new Error('ENOENT'); }),
|
|
5
|
-
readdirSync: vi.fn(() => []),
|
|
6
|
-
statSync: vi.fn(() => { throw new Error('ENOENT'); }),
|
|
7
|
-
mkdirSync: vi.fn(),
|
|
8
|
-
writeFileSync: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
vi.mock('os', () => ({
|
|
11
|
-
homedir: vi.fn(() => '/nonexistent/home'),
|
|
12
|
-
platform: vi.fn(() => 'darwin'),
|
|
13
|
-
}));
|
|
14
|
-
vi.mock('child_process', () => ({
|
|
15
|
-
execFileSync: vi.fn(() => { throw new Error('ENOENT'); }),
|
|
16
|
-
// detection.ts wraps execFile via util.promisify; provide the callback
|
|
17
|
-
// shape so the import doesn't blow up even though no test here exercises it.
|
|
18
|
-
execFile: vi.fn((..._args) => {
|
|
19
|
-
const cb = _args[_args.length - 1];
|
|
20
|
-
cb(new Error('ENOENT'));
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
vi.mock('../../utils/sqlite.js', () => ({
|
|
24
|
-
querySqlite: vi.fn(() => ''),
|
|
25
|
-
openWritableSqlite: vi.fn(() => null),
|
|
26
|
-
sqliteAvailable: vi.fn(() => false),
|
|
27
|
-
sqliteFlavor: vi.fn(() => null),
|
|
28
|
-
}));
|
|
29
|
-
vi.mock('smol-toml', () => ({
|
|
30
|
-
parse: vi.fn(() => ({})),
|
|
31
|
-
stringify: vi.fn(() => ''),
|
|
32
|
-
}));
|
|
33
|
-
import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
34
|
-
import { homedir } from 'os';
|
|
35
|
-
import { execFileSync } from 'child_process';
|
|
36
|
-
import { ClaudeCodeAdapter } from '../claude-code.js';
|
|
37
|
-
import { ClaudeDesktopAdapter } from '../claude-desktop.js';
|
|
38
|
-
import { CursorAdapter } from '../cursor.js';
|
|
39
|
-
import { CodexAdapter } from '../codex.js';
|
|
40
|
-
const adapters = [
|
|
41
|
-
{ name: 'claude-code', adapter: new ClaudeCodeAdapter() },
|
|
42
|
-
{ name: 'claude-desktop', adapter: new ClaudeDesktopAdapter() },
|
|
43
|
-
{ name: 'cursor', adapter: new CursorAdapter() },
|
|
44
|
-
{ name: 'codex', adapter: new CodexAdapter() },
|
|
45
|
-
];
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
vi.clearAllMocks();
|
|
48
|
-
// Default: everything fails
|
|
49
|
-
vi.mocked(homedir).mockReturnValue('/nonexistent/home');
|
|
50
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
51
|
-
vi.mocked(readFileSync).mockImplementation(() => { throw new Error('ENOENT'); });
|
|
52
|
-
vi.mocked(readdirSync).mockReturnValue([]);
|
|
53
|
-
vi.mocked(statSync).mockImplementation(() => { throw new Error('ENOENT'); });
|
|
54
|
-
vi.mocked(execFileSync).mockImplementation(() => { throw new Error('ENOENT'); });
|
|
55
|
-
});
|
|
56
|
-
describe('Graceful degradation: all adapters return null on errors', () => {
|
|
57
|
-
for (const { name, adapter } of adapters) {
|
|
58
|
-
describe(`${name} adapter`, () => {
|
|
59
|
-
it('readUsageStats returns null when homedir points to nonexistent path', async () => {
|
|
60
|
-
vi.mocked(homedir).mockReturnValue('/totally/nonexistent/path');
|
|
61
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
62
|
-
const result = await adapter.readUsageStats(null);
|
|
63
|
-
expect(result).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
it('readUsageStats returns null when existsSync throws', async () => {
|
|
66
|
-
vi.mocked(existsSync).mockImplementation(() => {
|
|
67
|
-
throw new Error('Unexpected filesystem error');
|
|
68
|
-
});
|
|
69
|
-
const result = await adapter.readUsageStats(null);
|
|
70
|
-
expect(result).toBeNull();
|
|
71
|
-
});
|
|
72
|
-
it('readUsageStats returns null when readFileSync throws EACCES', async () => {
|
|
73
|
-
vi.mocked(existsSync).mockReturnValue(true);
|
|
74
|
-
vi.mocked(readFileSync).mockImplementation(() => {
|
|
75
|
-
const err = new Error('EACCES: permission denied');
|
|
76
|
-
err.code = 'EACCES';
|
|
77
|
-
throw err;
|
|
78
|
-
});
|
|
79
|
-
vi.mocked(readdirSync).mockImplementation(() => {
|
|
80
|
-
const err = new Error('EACCES: permission denied');
|
|
81
|
-
err.code = 'EACCES';
|
|
82
|
-
throw err;
|
|
83
|
-
});
|
|
84
|
-
const result = await adapter.readUsageStats(null);
|
|
85
|
-
expect(result).toBeNull();
|
|
86
|
-
});
|
|
87
|
-
it('readUsageStats never throws even on unexpected errors', async () => {
|
|
88
|
-
vi.mocked(existsSync).mockImplementation(() => {
|
|
89
|
-
throw new TypeError('Cannot read properties of undefined');
|
|
90
|
-
});
|
|
91
|
-
// Must not throw, must return null
|
|
92
|
-
await expect(adapter.readUsageStats(null)).resolves.toBeNull();
|
|
93
|
-
});
|
|
94
|
-
if (adapter.readVersion) {
|
|
95
|
-
it('readVersion returns null when command/file not found', async () => {
|
|
96
|
-
vi.mocked(execFileSync).mockImplementation(() => {
|
|
97
|
-
throw new Error('ENOENT: command not found');
|
|
98
|
-
});
|
|
99
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
100
|
-
const result = await adapter.readVersion();
|
|
101
|
-
expect(result).toBeNull();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
// Claude Code is the only adapter with readSkillUsage
|
|
107
|
-
describe('claude-code readSkillUsage', () => {
|
|
108
|
-
const ccAdapter = new ClaudeCodeAdapter();
|
|
109
|
-
it('readSkillUsage returns null when skills dir does not exist', async () => {
|
|
110
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
111
|
-
const result = await ccAdapter.readSkillUsage(null);
|
|
112
|
-
expect(result).toBeNull();
|
|
113
|
-
});
|
|
114
|
-
it('readSkillUsage returns null when readdirSync throws', async () => {
|
|
115
|
-
vi.mocked(existsSync).mockReturnValue(true);
|
|
116
|
-
vi.mocked(readdirSync).mockImplementation(() => {
|
|
117
|
-
throw new Error('EACCES: permission denied');
|
|
118
|
-
});
|
|
119
|
-
const result = await ccAdapter.readSkillUsage(null);
|
|
120
|
-
expect(result).toBeNull();
|
|
121
|
-
});
|
|
122
|
-
it('readSkillUsage never throws even on unexpected errors', async () => {
|
|
123
|
-
vi.mocked(existsSync).mockImplementation(() => {
|
|
124
|
-
throw new TypeError('Unexpected error');
|
|
125
|
-
});
|
|
126
|
-
await expect(ccAdapter.readSkillUsage(null)).resolves.toBeNull();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { writeHintToFile } from '../utils/instruction-hint.js';
|
|
3
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { tmpdir } from 'os';
|
|
6
|
-
let testDir;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
testDir = join(tmpdir(), `runwork-hint-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
9
|
-
mkdirSync(testDir, { recursive: true });
|
|
10
|
-
});
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
// Clean up
|
|
13
|
-
try {
|
|
14
|
-
const { rmSync } = require('fs');
|
|
15
|
-
rmSync(testDir, { recursive: true, force: true });
|
|
16
|
-
}
|
|
17
|
-
catch { /* ignore */ }
|
|
18
|
-
});
|
|
19
|
-
describe('writeHintToFile', () => {
|
|
20
|
-
it('creates new file with hint', () => {
|
|
21
|
-
const filePath = join(testDir, 'CLAUDE.md');
|
|
22
|
-
writeHintToFile(filePath, '<!-- runwork:start -->\n## Runwork\nHello\n<!-- runwork:end -->');
|
|
23
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
24
|
-
expect(content).toContain('## Runwork');
|
|
25
|
-
expect(content).toContain('Hello');
|
|
26
|
-
});
|
|
27
|
-
it('appends to existing file', () => {
|
|
28
|
-
const filePath = join(testDir, 'CLAUDE.md');
|
|
29
|
-
writeFileSync(filePath, '# My Instructions\n\nDo stuff.\n');
|
|
30
|
-
writeHintToFile(filePath, '<!-- runwork:start -->\n## Runwork\nHello\n<!-- runwork:end -->');
|
|
31
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
32
|
-
expect(content).toContain('# My Instructions');
|
|
33
|
-
expect(content).toContain('Do stuff.');
|
|
34
|
-
expect(content).toContain('## Runwork');
|
|
35
|
-
expect(content).toContain('Hello');
|
|
36
|
-
});
|
|
37
|
-
it('replaces existing runwork section', () => {
|
|
38
|
-
const filePath = join(testDir, 'CLAUDE.md');
|
|
39
|
-
writeFileSync(filePath, [
|
|
40
|
-
'# My Instructions',
|
|
41
|
-
'',
|
|
42
|
-
'<!-- runwork:start -->',
|
|
43
|
-
'## Runwork',
|
|
44
|
-
'Old content',
|
|
45
|
-
'<!-- runwork:end -->',
|
|
46
|
-
'',
|
|
47
|
-
'# Other stuff',
|
|
48
|
-
].join('\n'));
|
|
49
|
-
writeHintToFile(filePath, '<!-- runwork:start -->\n## Runwork\nNew content\n<!-- runwork:end -->');
|
|
50
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
51
|
-
expect(content).toContain('New content');
|
|
52
|
-
expect(content).not.toContain('Old content');
|
|
53
|
-
expect(content).toContain('# My Instructions');
|
|
54
|
-
expect(content).toContain('# Other stuff');
|
|
55
|
-
});
|
|
56
|
-
it('creates parent directories', () => {
|
|
57
|
-
const filePath = join(testDir, 'nested', 'dir', 'CLAUDE.md');
|
|
58
|
-
writeHintToFile(filePath, '<!-- runwork:start -->\nTest\n<!-- runwork:end -->');
|
|
59
|
-
expect(existsSync(filePath)).toBe(true);
|
|
60
|
-
expect(readFileSync(filePath, 'utf-8')).toContain('Test');
|
|
61
|
-
});
|
|
62
|
-
it('preserves content before and after markers', () => {
|
|
63
|
-
const filePath = join(testDir, 'CLAUDE.md');
|
|
64
|
-
writeFileSync(filePath, 'BEFORE\n<!-- runwork:start -->\nold\n<!-- runwork:end -->\nAFTER');
|
|
65
|
-
writeHintToFile(filePath, '<!-- runwork:start -->\nnew\n<!-- runwork:end -->');
|
|
66
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
67
|
-
expect(content).toBe('BEFORE\n<!-- runwork:start -->\nnew\n<!-- runwork:end -->\nAFTER');
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|