memory-journal-mcp 6.1.2 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -28
- package/dist/{chunk-X4SWFATC.js → chunk-BI4ZNSKA.js} +38 -24
- package/dist/{chunk-HCEWINSB.js → chunk-N6EBIDN7.js} +99 -102
- package/dist/cli.js +2 -2
- package/dist/index.js +2 -2
- package/dist/tools-WPRY5MJ6.js +2 -0
- package/package.json +10 -1
- package/skills/github-commander/SKILL.md +151 -0
- package/skills/github-commander/config/project-config.example.md +125 -0
- package/skills/github-commander/workflows/code-quality-audit.md +80 -0
- package/skills/github-commander/workflows/full-audit.md +134 -0
- package/skills/github-commander/workflows/issue-triage.md +239 -0
- package/skills/github-commander/workflows/milestone-sprint.md +81 -0
- package/skills/github-commander/workflows/perf-audit.md +142 -0
- package/skills/github-commander/workflows/pr-review.md +123 -0
- package/skills/github-commander/workflows/security-audit.md +170 -0
- package/skills/github-commander/workflows/update-deps.md +109 -0
- package/.dockerignore +0 -139
- package/.gitattributes +0 -20
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -95
- package/.github/ISSUE_TEMPLATE/config.yml +0 -11
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -110
- package/.github/ISSUE_TEMPLATE/question.md +0 -78
- package/.github/aw/actions-lock.json +0 -14
- package/.github/copilot-instructions.md +0 -122
- package/.github/dependabot.yml +0 -93
- package/.github/pull_request_template.md +0 -135
- package/.github/workflows/README.md +0 -133
- package/.github/workflows/agentics-maintenance.yml +0 -141
- package/.github/workflows/auto-release.yml +0 -68
- package/.github/workflows/ci-health-monitor.lock.yml +0 -1121
- package/.github/workflows/ci-health-monitor.md +0 -87
- package/.github/workflows/codeql.yml +0 -41
- package/.github/workflows/dependabot-auto-merge.yml +0 -42
- package/.github/workflows/dependency-maintenance.lock.yml +0 -1182
- package/.github/workflows/dependency-maintenance.md +0 -147
- package/.github/workflows/docker-publish.yml +0 -254
- package/.github/workflows/docs-drift-detector.lock.yml +0 -1142
- package/.github/workflows/docs-drift-detector.md +0 -115
- package/.github/workflows/lint-and-test.yml +0 -60
- package/.github/workflows/publish-npm.yml +0 -85
- package/.github/workflows/secrets-scanning.yml +0 -32
- package/.github/workflows/security-update.yml +0 -127
- package/.gitleaks.toml +0 -9
- package/.prettierignore +0 -21
- package/.prettierrc +0 -33
- package/.scout-ignore +0 -12
- package/.trivyignore +0 -21
- package/CHANGELOG.md +0 -1814
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -263
- package/DOCKER_README.md +0 -331
- package/Dockerfile +0 -128
- package/SECURITY.md +0 -227
- package/UNRELEASED.md +0 -1
- package/dist/tools-T4U5A3X4.js +0 -2
- package/docker-compose.yml +0 -71
- package/docs/README.md +0 -18
- package/docs/agentic-journal-synergy.md +0 -175
- package/docs/copilot-setup.md +0 -72
- package/eslint.config.js +0 -110
- package/mcp-config-example.json +0 -21
- package/playwright.config.ts +0 -35
- package/releases/v2.1.0.md +0 -220
- package/releases/v2.2.0.md +0 -168
- package/releases/v3.0.0.md +0 -237
- package/releases/v3.1.0.md +0 -104
- package/releases/v3.1.1.md +0 -42
- package/releases/v3.1.2.md +0 -40
- package/releases/v3.1.3.md +0 -64
- package/releases/v3.1.4.md +0 -32
- package/releases/v3.1.5.md +0 -44
- package/releases/v4.0.0.md +0 -71
- package/releases/v4.1.0.md +0 -88
- package/releases/v4.2.0.md +0 -90
- package/releases/v4.3.0.md +0 -92
- package/releases/v4.3.1.md +0 -69
- package/releases/v4.4.0.md +0 -120
- package/releases/v4.4.1.md +0 -33
- package/releases/v4.4.2.md +0 -31
- package/releases/v4.5.0.md +0 -116
- package/releases/v5.0.0.md +0 -105
- package/releases/v5.0.1.md +0 -25
- package/releases/v5.1.0.md +0 -83
- package/releases/v5.1.1.md +0 -10
- package/releases/v6.0.0.md +0 -48
- package/releases/v6.0.1.md +0 -36
- package/releases/v6.1.0.md +0 -68
- package/releases/v6.1.1.md +0 -30
- package/releases/v6.1.2.md +0 -23
- package/scripts/generate-server-instructions.ts +0 -306
- package/scripts/server-instructions-function-body.ts +0 -107
- package/scripts/server-instructions-gotchas.ts +0 -45
- package/server.json +0 -42
- package/social-preview.png +0 -0
- package/src/auth/auth-context.ts +0 -78
- package/src/auth/authorization-server-discovery.ts +0 -263
- package/src/auth/errors.ts +0 -215
- package/src/auth/index.ts +0 -58
- package/src/auth/middleware.ts +0 -392
- package/src/auth/oauth-resource-server.ts +0 -170
- package/src/auth/scope-map.ts +0 -46
- package/src/auth/scopes.ts +0 -256
- package/src/auth/token-validator.ts +0 -293
- package/src/auth/transport-agnostic.ts +0 -164
- package/src/auth/types.ts +0 -372
- package/src/cli.ts +0 -279
- package/src/codemode/api-constants.ts +0 -263
- package/src/codemode/api.ts +0 -302
- package/src/codemode/auto-return.ts +0 -65
- package/src/codemode/index.ts +0 -47
- package/src/codemode/sandbox-factory.ts +0 -144
- package/src/codemode/sandbox.ts +0 -220
- package/src/codemode/security.ts +0 -155
- package/src/codemode/types.ts +0 -228
- package/src/codemode/worker-sandbox.ts +0 -277
- package/src/codemode/worker-script.ts +0 -239
- package/src/constants/icons.ts +0 -183
- package/src/constants/server-instructions.md +0 -166
- package/src/constants/server-instructions.ts +0 -514
- package/src/database/adapter-factory.ts +0 -16
- package/src/database/core/entry-columns.ts +0 -10
- package/src/database/core/interfaces.ts +0 -188
- package/src/database/core/schema.ts +0 -152
- package/src/database/sqlite-adapter/backup.ts +0 -167
- package/src/database/sqlite-adapter/entries/crud.ts +0 -233
- package/src/database/sqlite-adapter/entries/importance.ts +0 -76
- package/src/database/sqlite-adapter/entries/index.ts +0 -142
- package/src/database/sqlite-adapter/entries/search.ts +0 -294
- package/src/database/sqlite-adapter/entries/shared.ts +0 -102
- package/src/database/sqlite-adapter/entries/statistics.ts +0 -162
- package/src/database/sqlite-adapter/index.ts +0 -265
- package/src/database/sqlite-adapter/native-connection.ts +0 -301
- package/src/database/sqlite-adapter/relationships.ts +0 -70
- package/src/database/sqlite-adapter/tags.ts +0 -182
- package/src/filtering/tool-filter.ts +0 -312
- package/src/github/github-integration/client.ts +0 -114
- package/src/github/github-integration/index.ts +0 -297
- package/src/github/github-integration/insights.ts +0 -155
- package/src/github/github-integration/issues.ts +0 -213
- package/src/github/github-integration/milestones.ts +0 -262
- package/src/github/github-integration/projects.ts +0 -414
- package/src/github/github-integration/pull-requests.ts +0 -235
- package/src/github/github-integration/repository.ts +0 -110
- package/src/github/github-integration/types.ts +0 -43
- package/src/handlers/prompts/github.ts +0 -210
- package/src/handlers/prompts/index.ts +0 -97
- package/src/handlers/prompts/workflow.ts +0 -361
- package/src/handlers/resources/core/briefing/context-section.ts +0 -182
- package/src/handlers/resources/core/briefing/github-section.ts +0 -354
- package/src/handlers/resources/core/briefing/index.ts +0 -106
- package/src/handlers/resources/core/briefing/user-message.ts +0 -114
- package/src/handlers/resources/core/health.ts +0 -75
- package/src/handlers/resources/core/index.ts +0 -31
- package/src/handlers/resources/core/instructions.ts +0 -45
- package/src/handlers/resources/core/utilities.ts +0 -310
- package/src/handlers/resources/github.ts +0 -340
- package/src/handlers/resources/graph.ts +0 -218
- package/src/handlers/resources/help.ts +0 -410
- package/src/handlers/resources/index.ts +0 -143
- package/src/handlers/resources/shared.ts +0 -219
- package/src/handlers/resources/team.ts +0 -134
- package/src/handlers/resources/templates.ts +0 -334
- package/src/handlers/tools/admin.ts +0 -351
- package/src/handlers/tools/analytics.ts +0 -346
- package/src/handlers/tools/backup.ts +0 -272
- package/src/handlers/tools/codemode.ts +0 -188
- package/src/handlers/tools/core.ts +0 -359
- package/src/handlers/tools/error-fields-mixin.ts +0 -10
- package/src/handlers/tools/export.ts +0 -150
- package/src/handlers/tools/github/copilot-tools.ts +0 -72
- package/src/handlers/tools/github/helpers.ts +0 -125
- package/src/handlers/tools/github/insights-tools.ts +0 -112
- package/src/handlers/tools/github/issue-tools.ts +0 -442
- package/src/handlers/tools/github/kanban-tools.ts +0 -153
- package/src/handlers/tools/github/milestone-tools.ts +0 -371
- package/src/handlers/tools/github/mutation-tools.ts +0 -17
- package/src/handlers/tools/github/read-tools.ts +0 -302
- package/src/handlers/tools/github/schemas.ts +0 -435
- package/src/handlers/tools/github.ts +0 -39
- package/src/handlers/tools/index.ts +0 -255
- package/src/handlers/tools/relationships.ts +0 -390
- package/src/handlers/tools/schemas.ts +0 -165
- package/src/handlers/tools/search.ts +0 -448
- package/src/handlers/tools/team/admin-tools.ts +0 -164
- package/src/handlers/tools/team/analytics-tools.ts +0 -233
- package/src/handlers/tools/team/backup-tools.ts +0 -83
- package/src/handlers/tools/team/core-tools.ts +0 -197
- package/src/handlers/tools/team/export-tools.ts +0 -130
- package/src/handlers/tools/team/helpers.ts +0 -66
- package/src/handlers/tools/team/index.ts +0 -45
- package/src/handlers/tools/team/relationship-tools.ts +0 -219
- package/src/handlers/tools/team/schemas.ts +0 -558
- package/src/handlers/tools/team/search-tools.ts +0 -145
- package/src/handlers/tools/team/vector-tools.ts +0 -261
- package/src/index.ts +0 -57
- package/src/server/mcp-server.ts +0 -446
- package/src/server/registration.ts +0 -141
- package/src/server/scheduler.ts +0 -283
- package/src/transports/http/handlers.ts +0 -78
- package/src/transports/http/index.ts +0 -8
- package/src/transports/http/security.ts +0 -147
- package/src/transports/http/server/index.ts +0 -397
- package/src/transports/http/server/legacy-sse.ts +0 -87
- package/src/transports/http/server/stateful.ts +0 -222
- package/src/transports/http/server/stateless.ts +0 -42
- package/src/transports/http/types.ts +0 -132
- package/src/types/entities.ts +0 -145
- package/src/types/error-types.ts +0 -92
- package/src/types/errors.ts +0 -200
- package/src/types/filtering.ts +0 -55
- package/src/types/github.ts +0 -216
- package/src/types/index.ts +0 -348
- package/src/utils/error-helpers.ts +0 -78
- package/src/utils/errors/error-response-fields.ts +0 -29
- package/src/utils/errors/suggestions.ts +0 -94
- package/src/utils/github-helpers.ts +0 -33
- package/src/utils/logger.ts +0 -107
- package/src/utils/mcp-logger.ts +0 -155
- package/src/utils/progress-utils.ts +0 -100
- package/src/utils/query-helpers.ts +0 -78
- package/src/utils/resource-annotations.ts +0 -75
- package/src/utils/security-utils.ts +0 -198
- package/src/utils/vector-index-helpers.ts +0 -24
- package/src/vector/vector-search-manager.ts +0 -409
- package/src/version.ts +0 -15
- package/test-server/README.md +0 -193
- package/test-server/code-map.md +0 -399
- package/test-server/test-agent-experience.md +0 -213
- package/test-server/test-filter-instructions.mjs +0 -295
- package/test-server/test-instruction-levels.mjs +0 -102
- package/test-server/test-preflight.md +0 -55
- package/test-server/test-prompts.mjs +0 -185
- package/test-server/test-scheduler.mjs +0 -174
- package/test-server/test-tool-annotations.mjs +0 -115
- package/test-server/test-tools-codemode.md +0 -632
- package/test-server/test-tools-codemode2.md +0 -1218
- package/test-server/test-tools-team.md +0 -215
- package/test-server/test-tools.md +0 -429
- package/test-server/test-tools2.md +0 -361
- package/test-server/test-tools3.md +0 -396
- package/test-server/tool-reference.md +0 -231
- package/tests/README.md +0 -54
- package/tests/auth/auth-context.test.ts +0 -162
- package/tests/auth/authorization-server-discovery.test.ts +0 -265
- package/tests/auth/errors.test.ts +0 -170
- package/tests/auth/middleware.test.ts +0 -585
- package/tests/auth/oauth-resource-server.test.ts +0 -173
- package/tests/auth/scope-map.test.ts +0 -66
- package/tests/auth/scopes.test.ts +0 -347
- package/tests/auth/token-validator.test.ts +0 -271
- package/tests/codemode/api.test.ts +0 -396
- package/tests/codemode/auto-return.test.ts +0 -167
- package/tests/codemode/codemode-tool-handlers.test.ts +0 -197
- package/tests/codemode/sandbox-factory.test.ts +0 -152
- package/tests/codemode/sandbox.test.ts +0 -190
- package/tests/codemode/security.test.ts +0 -242
- package/tests/codemode/worker-sandbox.test.ts +0 -106
- package/tests/constants/icons.test.ts +0 -101
- package/tests/constants/server-instructions.test.ts +0 -514
- package/tests/database/crud-workflow-branches.test.ts +0 -418
- package/tests/database/database-branches.test.ts +0 -132
- package/tests/database/entries-auth-branches.test.ts +0 -390
- package/tests/database/native-connection.test.ts +0 -249
- package/tests/database/shared-helpers.test.ts +0 -103
- package/tests/database/sqlite-adapter.bench.ts +0 -63
- package/tests/database/sqlite-adapter.test.ts +0 -690
- package/tests/database/tags.test.ts +0 -134
- package/tests/e2e/README.md +0 -39
- package/tests/e2e/auth.spec.ts +0 -106
- package/tests/e2e/codemode-abuse.spec.ts +0 -75
- package/tests/e2e/health.spec.ts +0 -63
- package/tests/e2e/helpers.ts +0 -139
- package/tests/e2e/oauth-discovery.spec.ts +0 -102
- package/tests/e2e/oauth-scopes.spec.ts +0 -222
- package/tests/e2e/payloads-admin.spec.ts +0 -76
- package/tests/e2e/payloads-analytics.spec.ts +0 -37
- package/tests/e2e/payloads-backup-restore.spec.ts +0 -102
- package/tests/e2e/payloads-backup.spec.ts +0 -44
- package/tests/e2e/payloads-codemode-api.spec.ts +0 -131
- package/tests/e2e/payloads-codemode-readonly.spec.ts +0 -116
- package/tests/e2e/payloads-codemode.spec.ts +0 -116
- package/tests/e2e/payloads-core.spec.ts +0 -82
- package/tests/e2e/payloads-error-contracts.spec.ts +0 -159
- package/tests/e2e/payloads-export.spec.ts +0 -46
- package/tests/e2e/payloads-github-degradation.spec.ts +0 -73
- package/tests/e2e/payloads-github.spec.ts +0 -176
- package/tests/e2e/payloads-relationships.spec.ts +0 -56
- package/tests/e2e/payloads-search.spec.ts +0 -64
- package/tests/e2e/payloads-team-happy.spec.ts +0 -231
- package/tests/e2e/payloads-team.spec.ts +0 -174
- package/tests/e2e/prompts-expanded.spec.ts +0 -137
- package/tests/e2e/prompts.spec.ts +0 -62
- package/tests/e2e/protocols.spec.ts +0 -134
- package/tests/e2e/rate-limiting.spec.ts +0 -291
- package/tests/e2e/resources-briefing-env.spec.ts +0 -106
- package/tests/e2e/resources-complete.spec.ts +0 -180
- package/tests/e2e/resources-expanded.spec.ts +0 -83
- package/tests/e2e/resources-instructions-levels.spec.ts +0 -145
- package/tests/e2e/resources-templates.spec.ts +0 -123
- package/tests/e2e/resources.spec.ts +0 -103
- package/tests/e2e/scheduler.spec.ts +0 -79
- package/tests/e2e/security.spec.ts +0 -112
- package/tests/e2e/session-advanced.spec.ts +0 -152
- package/tests/e2e/sessions.spec.ts +0 -95
- package/tests/e2e/stateless.spec.ts +0 -79
- package/tests/e2e/streaming.spec.ts +0 -176
- package/tests/e2e/tool-filtering-presets.spec.ts +0 -192
- package/tests/e2e/tool-filtering.spec.ts +0 -77
- package/tests/e2e/tools.spec.ts +0 -111
- package/tests/filtering/tool-filter.test.ts +0 -314
- package/tests/github/client-issues-errors.test.ts +0 -433
- package/tests/github/github-integration-branches.test.ts +0 -490
- package/tests/github/github-integration.test.ts +0 -1015
- package/tests/github/github-managers-branches.test.ts +0 -907
- package/tests/github/pull-requests.test.ts +0 -334
- package/tests/handlers/analytics-branches.test.ts +0 -222
- package/tests/handlers/backup-branches.test.ts +0 -270
- package/tests/handlers/briefing-context-section.test.ts +0 -388
- package/tests/handlers/briefing-github-section.test.ts +0 -392
- package/tests/handlers/briefing-user-message.test.ts +0 -405
- package/tests/handlers/codemode-tools.test.ts +0 -85
- package/tests/handlers/copilot-tools.test.ts +0 -126
- package/tests/handlers/error-path-coverage.test.ts +0 -324
- package/tests/handlers/export-tools.test.ts +0 -203
- package/tests/handlers/github-resource-handlers.test.ts +0 -929
- package/tests/handlers/github-tool-handlers.test.ts +0 -1452
- package/tests/handlers/handler-error-branches.test.ts +0 -346
- package/tests/handlers/help-resource.test.ts +0 -92
- package/tests/handlers/prompt-handler-coverage.test.ts +0 -108
- package/tests/handlers/prompt-handlers.test.ts +0 -131
- package/tests/handlers/resource-handler-coverage.test.ts +0 -281
- package/tests/handlers/resource-handlers.test.ts +0 -357
- package/tests/handlers/resource-prompt-branches.test.ts +0 -495
- package/tests/handlers/search-tool-handlers.test.ts +0 -379
- package/tests/handlers/targeted-gap-closure.test.ts +0 -387
- package/tests/handlers/team-admin.test.ts +0 -291
- package/tests/handlers/team-analytics.test.ts +0 -220
- package/tests/handlers/team-core.test.ts +0 -148
- package/tests/handlers/team-data.test.ts +0 -198
- package/tests/handlers/team-relationships.test.ts +0 -271
- package/tests/handlers/team-resource-handlers.test.ts +0 -161
- package/tests/handlers/team-search.test.ts +0 -134
- package/tests/handlers/team-tool-handlers.test.ts +0 -301
- package/tests/handlers/team-vector.test.ts +0 -213
- package/tests/handlers/template-github-branches.test.ts +0 -676
- package/tests/handlers/tool-annotations.test.ts +0 -90
- package/tests/handlers/tool-handler-coverage.test.ts +0 -514
- package/tests/handlers/tool-handlers.test.ts +0 -510
- package/tests/handlers/tool-output-schemas.test.ts +0 -116
- package/tests/handlers/vector-tool-handlers.test.ts +0 -238
- package/tests/security/sql-injection.test.ts +0 -284
- package/tests/server/mcp-server.bench.ts +0 -55
- package/tests/server/mcp-server.test.ts +0 -1326
- package/tests/server/scheduler.test.ts +0 -400
- package/tests/transports/http-legacy-sse.test.ts +0 -275
- package/tests/transports/http-security.test.ts +0 -322
- package/tests/transports/http-stateful.test.ts +0 -487
- package/tests/transports/http-transport-server.test.ts +0 -301
- package/tests/transports/http-transport.test.ts +0 -771
- package/tests/utils/github-helpers.test.ts +0 -58
- package/tests/utils/logger.test.ts +0 -180
- package/tests/utils/mcp-logger.test.ts +0 -211
- package/tests/utils/progress-utils.test.ts +0 -156
- package/tests/utils/query-helpers.test.ts +0 -80
- package/tests/utils/security-utils.test.ts +0 -82
- package/tests/vector/vector-search-branches.test.ts +0 -111
- package/tests/vector/vector-search-manager.test.ts +0 -375
- package/tests/vector/vector-search.bench.ts +0 -48
- package/tsconfig.json +0 -42
- package/tsup.config.ts +0 -19
- package/vitest.config.ts +0 -25
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* memory-journal-mcp — Briefing User Message Formatter Unit Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for the formatUserMessage function that builds the
|
|
5
|
-
* markdown summary table displayed to the user.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect } from 'vitest'
|
|
9
|
-
import { formatUserMessage } from '../../src/handlers/resources/core/briefing/user-message.js'
|
|
10
|
-
|
|
11
|
-
// ============================================================================
|
|
12
|
-
// Helpers
|
|
13
|
-
// ============================================================================
|
|
14
|
-
|
|
15
|
-
function baseOpts() {
|
|
16
|
-
return {
|
|
17
|
-
repoName: 'neverinfamous/memory-journal-mcp',
|
|
18
|
-
branchName: 'main',
|
|
19
|
-
ciStatus: 'passing',
|
|
20
|
-
totalEntries: 42,
|
|
21
|
-
latestPreview: '#1: Recent entry preview',
|
|
22
|
-
github: null,
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Tests
|
|
28
|
-
// ============================================================================
|
|
29
|
-
|
|
30
|
-
describe('formatUserMessage', () => {
|
|
31
|
-
it('should produce basic markdown table without GitHub', () => {
|
|
32
|
-
const result = formatUserMessage(baseOpts())
|
|
33
|
-
|
|
34
|
-
expect(result).toContain('📋 **Session Context Loaded**')
|
|
35
|
-
expect(result).toContain('memory-journal-mcp')
|
|
36
|
-
expect(result).toContain('main')
|
|
37
|
-
expect(result).toContain('passing')
|
|
38
|
-
expect(result).toContain('42 entries')
|
|
39
|
-
expect(result).toContain('#1: Recent entry preview')
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('should include team DB row when teamTotalEntries is set', () => {
|
|
43
|
-
const result = formatUserMessage({
|
|
44
|
-
...baseOpts(),
|
|
45
|
-
teamTotalEntries: 15,
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
expect(result).toContain('**Team DB**')
|
|
49
|
-
expect(result).toContain('15 entries')
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('should NOT include team DB row when teamTotalEntries is undefined', () => {
|
|
53
|
-
const result = formatUserMessage(baseOpts())
|
|
54
|
-
expect(result).not.toContain('**Team DB**')
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
// ========================================================================
|
|
58
|
-
// CI with workflow runs
|
|
59
|
-
// ========================================================================
|
|
60
|
-
|
|
61
|
-
it('should display workflow runs with icons when runs are provided', () => {
|
|
62
|
-
const result = formatUserMessage({
|
|
63
|
-
...baseOpts(),
|
|
64
|
-
github: {
|
|
65
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
66
|
-
branch: 'main',
|
|
67
|
-
ci: 'passing',
|
|
68
|
-
openIssues: 3,
|
|
69
|
-
openPRs: 1,
|
|
70
|
-
milestones: [],
|
|
71
|
-
workflowSummary: {
|
|
72
|
-
passing: 2,
|
|
73
|
-
failing: 1,
|
|
74
|
-
pending: 0,
|
|
75
|
-
cancelled: 0,
|
|
76
|
-
runs: [
|
|
77
|
-
{ name: 'CI', conclusion: 'success' },
|
|
78
|
-
{ name: 'CodeQL', conclusion: 'failure' },
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
expect(result).toContain('✅ CI')
|
|
85
|
-
expect(result).toContain('❌ CodeQL')
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('should display CI counts when no individual runs', () => {
|
|
89
|
-
const result = formatUserMessage({
|
|
90
|
-
...baseOpts(),
|
|
91
|
-
github: {
|
|
92
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
93
|
-
branch: 'main',
|
|
94
|
-
ci: 'passing',
|
|
95
|
-
openIssues: 0,
|
|
96
|
-
openPRs: 0,
|
|
97
|
-
milestones: [],
|
|
98
|
-
workflowSummary: {
|
|
99
|
-
passing: 3,
|
|
100
|
-
failing: 1,
|
|
101
|
-
pending: 2,
|
|
102
|
-
cancelled: 0,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
expect(result).toContain('3 passing')
|
|
108
|
-
expect(result).toContain('1 failing')
|
|
109
|
-
expect(result).toContain('2 pending')
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
// ========================================================================
|
|
113
|
-
// Issues
|
|
114
|
-
// ========================================================================
|
|
115
|
-
|
|
116
|
-
it('should include issue titles when openIssueList is provided', () => {
|
|
117
|
-
const result = formatUserMessage({
|
|
118
|
-
...baseOpts(),
|
|
119
|
-
github: {
|
|
120
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
121
|
-
branch: 'main',
|
|
122
|
-
ci: 'passing',
|
|
123
|
-
openIssues: 2,
|
|
124
|
-
openPRs: 0,
|
|
125
|
-
milestones: [],
|
|
126
|
-
openIssueList: [
|
|
127
|
-
{ number: 42, title: 'Fix bug' },
|
|
128
|
-
{ number: 43, title: 'Add feature' },
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
expect(result).toContain('**Issues**')
|
|
134
|
-
expect(result).toContain('#42 Fix bug')
|
|
135
|
-
expect(result).toContain('#43 Add feature')
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('should show issue count only when no issue list', () => {
|
|
139
|
-
const result = formatUserMessage({
|
|
140
|
-
...baseOpts(),
|
|
141
|
-
github: {
|
|
142
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
143
|
-
branch: 'main',
|
|
144
|
-
ci: 'passing',
|
|
145
|
-
openIssues: 5,
|
|
146
|
-
openPRs: 0,
|
|
147
|
-
milestones: [],
|
|
148
|
-
},
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
expect(result).toContain('**Issues**')
|
|
152
|
-
expect(result).toContain('5 open')
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
// ========================================================================
|
|
156
|
-
// PRs
|
|
157
|
-
// ========================================================================
|
|
158
|
-
|
|
159
|
-
it('should include PR status summary when prStatusSummary is provided', () => {
|
|
160
|
-
const result = formatUserMessage({
|
|
161
|
-
...baseOpts(),
|
|
162
|
-
github: {
|
|
163
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
164
|
-
branch: 'main',
|
|
165
|
-
ci: 'passing',
|
|
166
|
-
openIssues: 0,
|
|
167
|
-
openPRs: 3,
|
|
168
|
-
milestones: [],
|
|
169
|
-
prStatusSummary: { open: 2, merged: 5, closed: 1 },
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
expect(result).toContain('**PRs**')
|
|
174
|
-
expect(result).toContain('2 open')
|
|
175
|
-
expect(result).toContain('5 merged')
|
|
176
|
-
expect(result).toContain('1 closed')
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
it('should include PR titles when openPrList is provided (no status summary)', () => {
|
|
180
|
-
const result = formatUserMessage({
|
|
181
|
-
...baseOpts(),
|
|
182
|
-
github: {
|
|
183
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
184
|
-
branch: 'main',
|
|
185
|
-
ci: 'passing',
|
|
186
|
-
openIssues: 0,
|
|
187
|
-
openPRs: 1,
|
|
188
|
-
milestones: [],
|
|
189
|
-
openPrList: [{ number: 10, title: 'Add OAuth', state: 'OPEN' }],
|
|
190
|
-
},
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
expect(result).toContain('**PRs**')
|
|
194
|
-
expect(result).toContain('#10 Add OAuth')
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
it('should show PR count only when no list or summary', () => {
|
|
198
|
-
const result = formatUserMessage({
|
|
199
|
-
...baseOpts(),
|
|
200
|
-
github: {
|
|
201
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
202
|
-
branch: 'main',
|
|
203
|
-
ci: 'passing',
|
|
204
|
-
openIssues: 0,
|
|
205
|
-
openPRs: 7,
|
|
206
|
-
milestones: [],
|
|
207
|
-
},
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
expect(result).toContain('**PRs**')
|
|
211
|
-
expect(result).toContain('7 open')
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
// ========================================================================
|
|
215
|
-
// Milestones
|
|
216
|
-
// ========================================================================
|
|
217
|
-
|
|
218
|
-
it('should include milestones with progress and due dates', () => {
|
|
219
|
-
const result = formatUserMessage({
|
|
220
|
-
...baseOpts(),
|
|
221
|
-
github: {
|
|
222
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
223
|
-
branch: 'main',
|
|
224
|
-
ci: 'passing',
|
|
225
|
-
openIssues: 0,
|
|
226
|
-
openPRs: 0,
|
|
227
|
-
milestones: [
|
|
228
|
-
{ title: 'v1.0', progress: '75%', dueOn: '2025-03-15T00:00:00Z' },
|
|
229
|
-
{ title: 'v2.0', progress: '25%', dueOn: null },
|
|
230
|
-
],
|
|
231
|
-
},
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
expect(result).toContain('**Milestones**')
|
|
235
|
-
expect(result).toContain('v1.0 (75%, due 2025-03-15)')
|
|
236
|
-
expect(result).toContain('v2.0 (25%)')
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
it('should omit milestones row when empty', () => {
|
|
240
|
-
const result = formatUserMessage({
|
|
241
|
-
...baseOpts(),
|
|
242
|
-
github: {
|
|
243
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
244
|
-
branch: 'main',
|
|
245
|
-
ci: 'passing',
|
|
246
|
-
openIssues: 0,
|
|
247
|
-
openPRs: 0,
|
|
248
|
-
milestones: [],
|
|
249
|
-
},
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
expect(result).not.toContain('**Milestones**')
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
// ========================================================================
|
|
256
|
-
// Insights
|
|
257
|
-
// ========================================================================
|
|
258
|
-
|
|
259
|
-
it('should include insights row with stars, forks, clones, and views', () => {
|
|
260
|
-
const result = formatUserMessage({
|
|
261
|
-
...baseOpts(),
|
|
262
|
-
github: {
|
|
263
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
264
|
-
branch: 'main',
|
|
265
|
-
ci: 'passing',
|
|
266
|
-
openIssues: 0,
|
|
267
|
-
openPRs: 0,
|
|
268
|
-
milestones: [],
|
|
269
|
-
insights: {
|
|
270
|
-
stars: 120,
|
|
271
|
-
forks: 30,
|
|
272
|
-
clones14d: 500,
|
|
273
|
-
views14d: 2000,
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
expect(result).toContain('**Insights**')
|
|
279
|
-
expect(result).toContain('⭐ 120 stars')
|
|
280
|
-
expect(result).toContain('🍴 30 forks')
|
|
281
|
-
expect(result).toContain('📦 500 clones')
|
|
282
|
-
expect(result).toContain('👁️ 2000 views')
|
|
283
|
-
expect(result).toContain('(14d)')
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
it('should omit insights row when stars and forks are null', () => {
|
|
287
|
-
const result = formatUserMessage({
|
|
288
|
-
...baseOpts(),
|
|
289
|
-
github: {
|
|
290
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
291
|
-
branch: 'main',
|
|
292
|
-
ci: 'passing',
|
|
293
|
-
openIssues: 0,
|
|
294
|
-
openPRs: 0,
|
|
295
|
-
milestones: [],
|
|
296
|
-
insights: { stars: null, forks: null },
|
|
297
|
-
},
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
expect(result).not.toContain('**Insights**')
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
// ========================================================================
|
|
304
|
-
// Copilot Reviews
|
|
305
|
-
// ========================================================================
|
|
306
|
-
|
|
307
|
-
it('should include Copilot row with review stats', () => {
|
|
308
|
-
const result = formatUserMessage({
|
|
309
|
-
...baseOpts(),
|
|
310
|
-
github: {
|
|
311
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
312
|
-
branch: 'main',
|
|
313
|
-
ci: 'passing',
|
|
314
|
-
openIssues: 0,
|
|
315
|
-
openPRs: 0,
|
|
316
|
-
milestones: [],
|
|
317
|
-
copilotReviews: {
|
|
318
|
-
reviewed: 5,
|
|
319
|
-
approved: 3,
|
|
320
|
-
changesRequested: 1,
|
|
321
|
-
totalComments: 12,
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
expect(result).toContain('**Copilot**')
|
|
327
|
-
expect(result).toContain('5 reviewed')
|
|
328
|
-
expect(result).toContain('3 approved')
|
|
329
|
-
expect(result).toContain('1 changes requested')
|
|
330
|
-
expect(result).toContain('(12 comments)')
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
it('should omit changes requested when zero', () => {
|
|
334
|
-
const result = formatUserMessage({
|
|
335
|
-
...baseOpts(),
|
|
336
|
-
github: {
|
|
337
|
-
repo: 'neverinfamous/memory-journal-mcp',
|
|
338
|
-
branch: 'main',
|
|
339
|
-
ci: 'passing',
|
|
340
|
-
openIssues: 0,
|
|
341
|
-
openPRs: 0,
|
|
342
|
-
milestones: [],
|
|
343
|
-
copilotReviews: {
|
|
344
|
-
reviewed: 2,
|
|
345
|
-
approved: 2,
|
|
346
|
-
changesRequested: 0,
|
|
347
|
-
totalComments: 0,
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
expect(result).toContain('**Copilot**')
|
|
353
|
-
expect(result).not.toContain('changes requested')
|
|
354
|
-
expect(result).not.toContain('comments')
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
// ========================================================================
|
|
358
|
-
// Rules & Skills
|
|
359
|
-
// ========================================================================
|
|
360
|
-
|
|
361
|
-
it('should include rules file info', () => {
|
|
362
|
-
const result = formatUserMessage({
|
|
363
|
-
...baseOpts(),
|
|
364
|
-
rulesFile: {
|
|
365
|
-
path: '/path/to/.rules',
|
|
366
|
-
name: '.rules',
|
|
367
|
-
sizeKB: 4,
|
|
368
|
-
lastModified: '2h ago',
|
|
369
|
-
},
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
expect(result).toContain('**Rules**')
|
|
373
|
-
expect(result).toContain('.rules')
|
|
374
|
-
expect(result).toContain('4 KB')
|
|
375
|
-
expect(result).toContain('2h ago')
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
it('should include skills directory info', () => {
|
|
379
|
-
const result = formatUserMessage({
|
|
380
|
-
...baseOpts(),
|
|
381
|
-
skillsDir: {
|
|
382
|
-
path: '/path/to/skills',
|
|
383
|
-
count: 3,
|
|
384
|
-
names: ['cloudflare', 'mcp-builder', 'next'],
|
|
385
|
-
},
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
expect(result).toContain('**Skills**')
|
|
389
|
-
expect(result).toContain('3 skills available')
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
it('should use singular "skill" for count of 1', () => {
|
|
393
|
-
const result = formatUserMessage({
|
|
394
|
-
...baseOpts(),
|
|
395
|
-
skillsDir: {
|
|
396
|
-
path: '/path/to/skills',
|
|
397
|
-
count: 1,
|
|
398
|
-
names: ['cloudflare'],
|
|
399
|
-
},
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
expect(result).toContain('1 skill available')
|
|
403
|
-
expect(result).not.toContain('1 skills')
|
|
404
|
-
})
|
|
405
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
|
2
|
-
import { DatabaseAdapter } from '../../src/database/sqlite-adapter/index.js'
|
|
3
|
-
import { callTool } from '../../src/handlers/tools/index.js'
|
|
4
|
-
import * as fs from 'fs'
|
|
5
|
-
|
|
6
|
-
vi.mock('../../src/codemode/sandbox-factory.js', async (importOriginal) => {
|
|
7
|
-
const actual = await importOriginal<any>()
|
|
8
|
-
return {
|
|
9
|
-
...actual,
|
|
10
|
-
createSandboxPool: () => ({
|
|
11
|
-
execute: async (code: string) => {
|
|
12
|
-
if (code.includes('throw')) {
|
|
13
|
-
return { success: false, error: 'test error' }
|
|
14
|
-
}
|
|
15
|
-
if (code.includes('mj.core.create_entry')) {
|
|
16
|
-
return { success: true, result: 'undefined' }
|
|
17
|
-
}
|
|
18
|
-
return { success: true, result: 2 }
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
setDefaultSandboxMode: vi.fn(),
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
describe('Code Mode Tool Handlers', () => {
|
|
26
|
-
let personalDb: DatabaseAdapter
|
|
27
|
-
|
|
28
|
-
const personalDbPath = './test-codemode-handlers.db'
|
|
29
|
-
|
|
30
|
-
beforeAll(async () => {
|
|
31
|
-
try {
|
|
32
|
-
if (fs.existsSync(personalDbPath)) fs.unlinkSync(personalDbPath)
|
|
33
|
-
} catch {}
|
|
34
|
-
personalDb = new DatabaseAdapter(personalDbPath)
|
|
35
|
-
await personalDb.initialize()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
afterAll(() => {
|
|
39
|
-
personalDb.close()
|
|
40
|
-
try {
|
|
41
|
-
if (fs.existsSync(personalDbPath)) fs.unlinkSync(personalDbPath)
|
|
42
|
-
} catch {}
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should execute basic code', async () => {
|
|
46
|
-
const result = (await callTool(
|
|
47
|
-
'mj_execute_code',
|
|
48
|
-
{ code: 'return 1 + 1;' },
|
|
49
|
-
personalDb
|
|
50
|
-
)) as any
|
|
51
|
-
expect(result.success).toBe(true)
|
|
52
|
-
expect(result.result).toBe(2)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should block malicious code', async () => {
|
|
56
|
-
const result = (await callTool(
|
|
57
|
-
'mj_execute_code',
|
|
58
|
-
{ code: 'process.exit(1)' },
|
|
59
|
-
personalDb
|
|
60
|
-
)) as any
|
|
61
|
-
expect(result.success).toBe(false)
|
|
62
|
-
expect(result.error).toContain('Security validation failed')
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should respect readonly mode', async () => {
|
|
66
|
-
const result = (await callTool(
|
|
67
|
-
'mj_execute_code',
|
|
68
|
-
{ code: 'return typeof mj.core.create_entry', readonly: true },
|
|
69
|
-
personalDb
|
|
70
|
-
)) as any
|
|
71
|
-
expect(result.success).toBe(true)
|
|
72
|
-
// create_entry does not have readOnlyHint: true, so it is filtered out
|
|
73
|
-
expect(result.result).toBe('undefined')
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('should capture runtime errors', async () => {
|
|
77
|
-
const result = (await callTool(
|
|
78
|
-
'mj_execute_code',
|
|
79
|
-
{ code: 'throw new Error("test error")' },
|
|
80
|
-
personalDb
|
|
81
|
-
)) as any
|
|
82
|
-
expect(result.success).toBe(false)
|
|
83
|
-
expect(result.error).toContain('test error')
|
|
84
|
-
})
|
|
85
|
-
})
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* memory-journal-mcp — Copilot Tools Unit Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for getCopilotReviewTools handler.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// Hoisted mocks
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
const { mockResolveOwnerRepo } = vi.hoisted(() => ({
|
|
14
|
-
mockResolveOwnerRepo: vi.fn(),
|
|
15
|
-
}))
|
|
16
|
-
|
|
17
|
-
vi.mock('../../src/utils/logger.js', () => ({
|
|
18
|
-
logger: { info: vi.fn(), warning: vi.fn(), error: vi.fn(), debug: vi.fn() },
|
|
19
|
-
}))
|
|
20
|
-
|
|
21
|
-
vi.mock('../../src/utils/error-helpers.js', () => ({
|
|
22
|
-
formatHandlerError: vi.fn().mockImplementation((err: Error) => ({
|
|
23
|
-
success: false,
|
|
24
|
-
error: err.message,
|
|
25
|
-
})),
|
|
26
|
-
}))
|
|
27
|
-
|
|
28
|
-
vi.mock('../../src/handlers/tools/github/helpers.js', () => ({
|
|
29
|
-
resolveOwnerRepo: mockResolveOwnerRepo,
|
|
30
|
-
}))
|
|
31
|
-
|
|
32
|
-
import { getCopilotReviewTools } from '../../src/handlers/tools/github/copilot-tools.js'
|
|
33
|
-
|
|
34
|
-
// ============================================================================
|
|
35
|
-
// Helpers
|
|
36
|
-
// ============================================================================
|
|
37
|
-
|
|
38
|
-
function createMockContext() {
|
|
39
|
-
return {
|
|
40
|
-
db: {},
|
|
41
|
-
progress: null,
|
|
42
|
-
github: {
|
|
43
|
-
getCopilotReviewSummary: vi.fn().mockResolvedValue({
|
|
44
|
-
prNumber: 42,
|
|
45
|
-
state: 'approved',
|
|
46
|
-
commentCount: 3,
|
|
47
|
-
comments: [
|
|
48
|
-
{ body: 'Use const here', path: 'src/index.ts', line: 10, isCopilot: true },
|
|
49
|
-
{ body: 'Missing null check', path: 'src/utils.ts', line: 25, isCopilot: true },
|
|
50
|
-
{ body: 'Good pattern', path: 'src/core.ts', line: 50, isCopilot: true },
|
|
51
|
-
],
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ============================================================================
|
|
58
|
-
// Tests
|
|
59
|
-
// ============================================================================
|
|
60
|
-
|
|
61
|
-
describe('getCopilotReviewTools', () => {
|
|
62
|
-
beforeEach(() => {
|
|
63
|
-
vi.clearAllMocks()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should define get_copilot_reviews tool', () => {
|
|
67
|
-
const context = createMockContext()
|
|
68
|
-
const tools = getCopilotReviewTools(context as never)
|
|
69
|
-
|
|
70
|
-
expect(tools).toHaveLength(1)
|
|
71
|
-
expect(tools[0]!.name).toBe('get_copilot_reviews')
|
|
72
|
-
expect(tools[0]!.group).toBe('github')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should return Copilot review summary on success', async () => {
|
|
76
|
-
const context = createMockContext()
|
|
77
|
-
mockResolveOwnerRepo.mockResolvedValue({
|
|
78
|
-
owner: 'neverinfamous',
|
|
79
|
-
repo: 'memory-journal-mcp',
|
|
80
|
-
detectedOwner: 'neverinfamous',
|
|
81
|
-
detectedRepo: 'memory-journal-mcp',
|
|
82
|
-
github: context.github,
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const tools = getCopilotReviewTools(context as never)
|
|
86
|
-
const handler = tools[0]!.handler
|
|
87
|
-
|
|
88
|
-
const result = (await handler({ pr_number: 42 })) as Record<string, unknown>
|
|
89
|
-
|
|
90
|
-
expect(result['prNumber']).toBe(42)
|
|
91
|
-
expect(result['state']).toBe('approved')
|
|
92
|
-
expect(result['commentCount']).toBe(3)
|
|
93
|
-
expect(result['comments']).toHaveLength(3)
|
|
94
|
-
expect((result['comments'] as Record<string, unknown>[])[0]!['body']).toBe('Use const here')
|
|
95
|
-
expect(result['owner']).toBe('neverinfamous')
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('should return error response when GitHub not available', async () => {
|
|
99
|
-
const context = createMockContext()
|
|
100
|
-
mockResolveOwnerRepo.mockResolvedValue({
|
|
101
|
-
error: true,
|
|
102
|
-
response: { success: false, error: 'GitHub integration not available' },
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const tools = getCopilotReviewTools(context as never)
|
|
106
|
-
const handler = tools[0]!.handler
|
|
107
|
-
|
|
108
|
-
const result = (await handler({ pr_number: 42 })) as Record<string, unknown>
|
|
109
|
-
|
|
110
|
-
expect(result['success']).toBe(false)
|
|
111
|
-
expect(result['error']).toContain('GitHub')
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('should handle handler errors via formatHandlerError', async () => {
|
|
115
|
-
const context = createMockContext()
|
|
116
|
-
mockResolveOwnerRepo.mockRejectedValue(new Error('Network failure'))
|
|
117
|
-
|
|
118
|
-
const tools = getCopilotReviewTools(context as never)
|
|
119
|
-
const handler = tools[0]!.handler
|
|
120
|
-
|
|
121
|
-
const result = (await handler({ pr_number: 42 })) as Record<string, unknown>
|
|
122
|
-
|
|
123
|
-
expect(result['success']).toBe(false)
|
|
124
|
-
expect(result['error']).toContain('Network failure')
|
|
125
|
-
})
|
|
126
|
-
})
|