@bevel-software/platform-core-backend 0.29.0 → 0.31.0
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/agent-guide/access-control.md +49 -4
- package/agent-guide/html-views.md +76 -2
- package/dist/__tests__/test-repositories.d.ts +3 -0
- package/dist/__tests__/test-repositories.d.ts.map +1 -0
- package/dist/__tests__/test-repositories.js +18 -0
- package/dist/__tests__/test-repositories.js.map +1 -0
- package/dist/core/catalog-revision.js +3 -3
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +3 -2
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +3 -0
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +35 -5
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +8 -0
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +4 -0
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +20 -0
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +32 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +135 -17
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +20 -6
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.d.ts +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.js +1 -1
- package/dist/modules/audit/agent-audit.service.d.ts.map +1 -1
- package/dist/modules/audit/agent-audit.service.js +66 -6
- package/dist/modules/audit/agent-audit.service.js.map +1 -1
- package/dist/modules/audit/audit.contract.d.ts +52 -8
- package/dist/modules/audit/audit.contract.d.ts.map +1 -1
- package/dist/modules/audit/audit.contract.js +37 -1
- package/dist/modules/audit/audit.contract.js.map +1 -1
- package/dist/modules/audit/audit.routes.d.ts +1 -1
- package/dist/modules/audit/audit.routes.d.ts.map +1 -1
- package/dist/modules/audit/audit.routes.js +15 -13
- package/dist/modules/audit/audit.routes.js.map +1 -1
- package/dist/modules/audit/request-audit.d.ts +21 -10
- package/dist/modules/audit/request-audit.d.ts.map +1 -1
- package/dist/modules/audit/request-audit.js +26 -10
- package/dist/modules/audit/request-audit.js.map +1 -1
- package/dist/modules/database/core-schema.d.ts +22 -3
- package/dist/modules/database/core-schema.d.ts.map +1 -1
- package/dist/modules/database/core-schema.js +15 -6
- package/dist/modules/database/core-schema.js.map +1 -1
- package/dist/modules/diff/diff.service.d.ts.map +1 -1
- package/dist/modules/diff/diff.service.js +7 -1
- package/dist/modules/diff/diff.service.js.map +1 -1
- package/dist/modules/kb-fs/git-dir.d.ts +21 -0
- package/dist/modules/kb-fs/git-dir.d.ts.map +1 -0
- package/dist/modules/kb-fs/git-dir.js +58 -0
- package/dist/modules/kb-fs/git-dir.js.map +1 -0
- package/dist/modules/kb-fs/index.d.ts +3 -0
- package/dist/modules/kb-fs/index.d.ts.map +1 -1
- package/dist/modules/kb-fs/index.js +3 -1
- package/dist/modules/kb-fs/index.js.map +1 -1
- package/dist/modules/kb-fs/locking-filesystem.d.ts.map +1 -1
- package/dist/modules/kb-fs/locking-filesystem.js +3 -12
- package/dist/modules/kb-fs/locking-filesystem.js.map +1 -1
- package/dist/modules/kb-fs/mutex.d.ts +11 -0
- package/dist/modules/kb-fs/mutex.d.ts.map +1 -1
- package/dist/modules/kb-fs/mutex.js +14 -0
- package/dist/modules/kb-fs/mutex.js.map +1 -1
- package/dist/modules/kb-fs/ref-files.d.ts +63 -0
- package/dist/modules/kb-fs/ref-files.d.ts.map +1 -0
- package/dist/modules/kb-fs/ref-files.js +249 -0
- package/dist/modules/kb-fs/ref-files.js.map +1 -0
- package/dist/modules/mcp/mcp-auth.middleware.d.ts +14 -0
- package/dist/modules/mcp/mcp-auth.middleware.d.ts.map +1 -1
- package/dist/modules/mcp/mcp-auth.middleware.js +4 -0
- package/dist/modules/mcp/mcp-auth.middleware.js.map +1 -1
- package/dist/modules/mcp/mcp.routes.d.ts +5 -0
- package/dist/modules/mcp/mcp.routes.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.routes.js +67 -0
- package/dist/modules/mcp/mcp.routes.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +107 -27
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +257 -50
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/request-context.d.ts +25 -0
- package/dist/modules/mcp/request-context.d.ts.map +1 -0
- package/dist/modules/mcp/request-context.js +11 -0
- package/dist/modules/mcp/request-context.js.map +1 -0
- package/dist/modules/mcp/shared-definitions.d.ts +56 -0
- package/dist/modules/mcp/shared-definitions.d.ts.map +1 -0
- package/dist/modules/mcp/shared-definitions.js +117 -0
- package/dist/modules/mcp/shared-definitions.js.map +1 -0
- package/dist/modules/mcp/surface-cache.d.ts +70 -0
- package/dist/modules/mcp/surface-cache.d.ts.map +1 -0
- package/dist/modules/mcp/surface-cache.js +104 -0
- package/dist/modules/mcp/surface-cache.js.map +1 -0
- package/dist/modules/plugins/teams.routes.d.ts +4 -0
- package/dist/modules/plugins/teams.routes.d.ts.map +1 -1
- package/dist/modules/plugins/teams.routes.js +9 -1
- package/dist/modules/plugins/teams.routes.js.map +1 -1
- package/dist/modules/tool-auth/internal-token.service.d.ts +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts +1 -2
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.js +1 -2
- package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -1
- package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-context.js +33 -12
- package/dist/modules/tool-helpers/tool-context.js.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts +2 -2
- package/dist/modules/tool-helpers/tool.contract.d.ts +10 -2
- package/dist/modules/tool-helpers/tool.contract.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool.contract.js.map +1 -1
- package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/change-request-read.tools.js +3 -14
- package/dist/modules/workflow/agent-tools/change-request-read.tools.js.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +18 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +453 -2
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +142 -4
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +645 -128
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/read-on-branch.d.ts +35 -0
- package/dist/modules/workflow/read-on-branch.d.ts.map +1 -0
- package/dist/modules/workflow/read-on-branch.js +58 -0
- package/dist/modules/workflow/read-on-branch.js.map +1 -0
- package/dist/modules/workflow/workflow-hooks.d.ts +1 -1
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +22 -41
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +48 -8
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +163 -16
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/agent-access.gate.d.ts +2 -2
- package/dist/modules/workspace/agent-access.gate.js +2 -2
- package/dist/modules/workspace/bounded-matcher.d.ts +79 -0
- package/dist/modules/workspace/bounded-matcher.d.ts.map +1 -0
- package/dist/modules/workspace/bounded-matcher.js +261 -0
- package/dist/modules/workspace/bounded-matcher.js.map +1 -0
- package/dist/modules/workspace/fetch-instant.d.ts +9 -0
- package/dist/modules/workspace/fetch-instant.d.ts.map +1 -0
- package/dist/modules/workspace/fetch-instant.js +13 -0
- package/dist/modules/workspace/fetch-instant.js.map +1 -0
- package/dist/modules/workspace/index.d.ts +9 -0
- package/dist/modules/workspace/index.d.ts.map +1 -1
- package/dist/modules/workspace/index.js +10 -0
- package/dist/modules/workspace/index.js.map +1 -1
- package/dist/modules/workspace/kb-repository.contract.d.ts +124 -0
- package/dist/modules/workspace/kb-repository.contract.d.ts.map +1 -0
- package/dist/modules/workspace/kb-repository.contract.js +19 -0
- package/dist/modules/workspace/kb-repository.contract.js.map +1 -0
- package/dist/modules/workspace/kb-repository.d.ts +236 -0
- package/dist/modules/workspace/kb-repository.d.ts.map +1 -0
- package/dist/modules/workspace/kb-repository.js +811 -0
- package/dist/modules/workspace/kb-repository.js.map +1 -0
- package/dist/modules/workspace/pattern-matcher.contract.d.ts +50 -0
- package/dist/modules/workspace/pattern-matcher.contract.d.ts.map +1 -0
- package/dist/modules/workspace/pattern-matcher.contract.js +27 -0
- package/dist/modules/workspace/pattern-matcher.contract.js.map +1 -0
- package/dist/modules/workspace/routine-write-policy.d.ts +0 -7
- package/dist/modules/workspace/routine-write-policy.d.ts.map +1 -1
- package/dist/modules/workspace/routine-write-policy.js +0 -5
- package/dist/modules/workspace/routine-write-policy.js.map +1 -1
- package/dist/modules/workspace/set-aside-clone.d.ts +40 -0
- package/dist/modules/workspace/set-aside-clone.d.ts.map +1 -1
- package/dist/modules/workspace/set-aside-clone.js +139 -0
- package/dist/modules/workspace/set-aside-clone.js.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +99 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +407 -29
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +68 -32
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +240 -161
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +13 -4
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +162 -336
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/shared/git.contract.d.ts +7 -0
- package/dist/shared/git.contract.d.ts.map +1 -1
- package/dist/shared/git.contract.js +9 -0
- package/dist/shared/git.contract.js.map +1 -1
- package/dist/shared/no-link-below.d.ts +10 -0
- package/dist/shared/no-link-below.d.ts.map +1 -0
- package/dist/shared/no-link-below.js +30 -0
- package/dist/shared/no-link-below.js.map +1 -0
- package/dist/test-setup.js +4 -0
- package/dist/test-setup.js.map +1 -1
- package/migrations/0018_agent_events_page.sql +11 -0
- package/migrations/meta/0018_snapshot.json +2429 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +3 -3
- package/src/__tests__/test-repositories.ts +22 -0
- package/src/__tests__/workspace-service.ts +69 -0
- package/src/core/__tests__/lifecycle.test.ts +16 -0
- package/src/core/catalog-revision.ts +3 -3
- package/src/core/create-core-server.ts +3 -2
- package/src/core/create-core-services.ts +39 -4
- package/src/core/lifecycle.ts +10 -0
- package/src/modules/access/__tests__/access-control.atref-cache.test.ts +144 -4
- package/src/modules/access/__tests__/access-control.group-read.test.ts +73 -0
- package/src/modules/access/__tests__/access.routes.group-grant.test.ts +66 -0
- package/src/modules/access/__tests__/access.routes.unknown-email.test.ts +2 -0
- package/src/modules/access/access-control.interface.ts +22 -0
- package/src/modules/access/access-control.service.ts +138 -15
- package/src/modules/access/access.routes.ts +22 -6
- package/src/modules/agent-guide/__tests__/agent-guide.test.ts +22 -1
- package/src/modules/agent-instructions/shared-file-rules.ts +1 -1
- package/src/modules/audit/__tests__/agent-audit.service.test.ts +78 -1
- package/src/modules/audit/__tests__/audit.routes.test.ts +43 -5
- package/src/modules/audit/agent-audit.service.ts +66 -6
- package/src/modules/audit/audit.contract.ts +62 -10
- package/src/modules/audit/audit.routes.ts +14 -12
- package/src/modules/audit/request-audit.ts +28 -13
- package/src/modules/database/core-schema.ts +15 -6
- package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.worktree.test.ts +76 -0
- package/src/modules/diff/diff.service.ts +6 -4
- package/src/modules/kb-fs/__tests__/git-dir.test.ts +77 -0
- package/src/modules/kb-fs/__tests__/mutex.canonical.test.ts +57 -0
- package/src/modules/kb-fs/__tests__/ref-files.test.ts +338 -0
- package/src/modules/kb-fs/git-dir.ts +53 -0
- package/src/modules/kb-fs/index.ts +3 -0
- package/src/modules/kb-fs/locking-filesystem.ts +3 -12
- package/src/modules/kb-fs/mutex.ts +16 -0
- package/src/modules/kb-fs/ref-files.ts +279 -0
- package/src/modules/mcp/__tests__/mcp-routes-harness.ts +7 -1
- package/src/modules/mcp/__tests__/mcp.routes.page.test.ts +115 -0
- package/src/modules/mcp/__tests__/mcp.surface-cache.test.ts +521 -0
- package/src/modules/mcp/__tests__/shared-definitions.test.ts +28 -0
- package/src/modules/mcp/__tests__/surface-cache.test.ts +127 -0
- package/src/modules/mcp/mcp-auth.middleware.ts +21 -0
- package/src/modules/mcp/mcp.routes.ts +68 -0
- package/src/modules/mcp/mcp.service.ts +315 -51
- package/src/modules/mcp/request-context.ts +34 -0
- package/src/modules/mcp/shared-definitions.ts +121 -0
- package/src/modules/mcp/surface-cache.ts +154 -0
- package/src/modules/plugins/__tests__/teams.routes.test.ts +55 -0
- package/src/modules/plugins/teams.routes.ts +14 -1
- package/src/modules/settings/__tests__/setup.routes.layout-phase.test.ts +2 -2
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +2 -2
- package/src/modules/tool-auth/internal-token.service.ts +1 -1
- package/src/modules/tool-auth/tool-auth.middleware.ts +1 -2
- package/src/modules/tool-helpers/__tests__/branch-declaration.test.ts +2 -2
- package/src/modules/tool-helpers/tool-context.ts +37 -18
- package/src/modules/tool-helpers/tool-handler.ts +2 -2
- package/src/modules/tool-helpers/tool.contract.ts +10 -2
- package/src/modules/tool-registry/__tests__/own-tool-schemas.test.ts +1 -1
- package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +7 -2
- package/src/modules/workflow/__tests__/workflow.routes.history-read-gate.test.ts +23 -12
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +250 -4
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +464 -4
- package/src/modules/workflow/agent-tools/change-request-read.tools.ts +4 -22
- package/src/modules/workflow/agent-tools/workflow.tools.ts +462 -1
- package/src/modules/workflow/git/__tests__/git.service.changedPathsMemo.test.ts +175 -0
- package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +76 -11
- package/src/modules/workflow/git/__tests__/git.service.mergeIntoBranch.test.ts +721 -0
- package/src/modules/workflow/git/__tests__/git.service.worktrees.test.ts +284 -0
- package/src/modules/workflow/git/git.service.ts +719 -126
- package/src/modules/workflow/read-on-branch.ts +79 -0
- package/src/modules/workflow/workflow-hooks.ts +1 -1
- package/src/modules/workflow/workflow.routes.ts +21 -39
- package/src/modules/workflow/workflow.service.ts +203 -16
- package/src/modules/workspace/__tests__/agent-downloads.test.ts +2 -2
- package/src/modules/workspace/__tests__/bounded-matcher.test.ts +213 -0
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +22 -7
- package/src/modules/workspace/__tests__/kb-repository.test.ts +481 -0
- package/src/modules/workspace/__tests__/rest-tool-arguments.test.ts +14 -0
- package/src/modules/workspace/__tests__/routine-write-policy.test.ts +0 -11
- package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.routes.folder-zip-access.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.routes.folders.test.ts +4 -3
- package/src/modules/workspace/__tests__/workspace.service.any-workspace-credentials.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.ensure-remotes-fetched.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.forget-clone-races.test.ts +12 -5
- package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +6 -6
- package/src/modules/workspace/__tests__/workspace.service.move-never-overwrites.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.test.ts +24 -23
- package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.worktrees.test.ts +620 -0
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +15 -1
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +71 -5
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +153 -298
- package/src/modules/workspace/agent-access.gate.ts +2 -2
- package/src/modules/workspace/bounded-matcher.ts +328 -0
- package/src/modules/workspace/fetch-instant.ts +13 -0
- package/src/modules/workspace/index.ts +23 -0
- package/src/modules/workspace/kb-repository.contract.ts +124 -0
- package/src/modules/workspace/kb-repository.ts +844 -0
- package/src/modules/workspace/pattern-matcher.contract.ts +69 -0
- package/src/modules/workspace/routine-write-policy.ts +0 -15
- package/src/modules/workspace/set-aside-clone.ts +140 -0
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.degraded.test.ts +3 -2
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +12 -10
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.worktrees.test.ts +613 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +422 -29
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +4 -3
- package/src/modules/workspace/workspace.service.ts +247 -169
- package/src/modules/workspace/workspace.tools.ts +179 -365
- package/src/shared/__tests__/no-link-below.test.ts +45 -0
- package/src/shared/git.contract.ts +10 -0
- package/src/shared/no-link-below.ts +29 -0
- package/src/test-setup.ts +5 -0
|
@@ -9,6 +9,8 @@ import type { WorkspaceService } from '../../../workspace/workspace.service.js';
|
|
|
9
9
|
import { WorkflowHooks } from '../../workflow-hooks.js';
|
|
10
10
|
import { GitService } from '../git.service.js';
|
|
11
11
|
import { WorkflowValidationError, BranchNameError } from '../../../../shared/domain-errors.js';
|
|
12
|
+
import { GitRunError, type IGitRunner } from '../../../../shared/git.contract.js';
|
|
13
|
+
import { NodeGitRunner } from '../node-git-runner.js';
|
|
12
14
|
|
|
13
15
|
const execFileAsync = promisify(execFile);
|
|
14
16
|
const PROCESS_MAP_DIR = 'knowledge-base';
|
|
@@ -107,7 +109,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
107
109
|
await runGit(repo, ['checkout', '-b', 'alice/edit-foo']);
|
|
108
110
|
await commitFile(repo, 'Knowledge/Foo.md', 'line one\nline two\n', 'add line two');
|
|
109
111
|
|
|
110
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
112
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
111
113
|
workspaceId,
|
|
112
114
|
'Knowledge/Foo.md',
|
|
113
115
|
'current-company-state',
|
|
@@ -117,6 +119,69 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
117
119
|
expect(diff).toContain('+line two');
|
|
118
120
|
});
|
|
119
121
|
|
|
122
|
+
it('asks the caller\'s verdict at the two commits served, before the path is described at either', async () => {
|
|
123
|
+
const { workspaceDir, repo } = await seedWorkspace(root, workspaceId);
|
|
124
|
+
const svc = new GitService(stubWorkspaceService(workspaceId, workspaceDir), new WorkflowHooks(), testKbContext());
|
|
125
|
+
await commitFile(repo, 'Knowledge/Foo.md', 'line one\n', 'base');
|
|
126
|
+
await commitFile(repo, 'Docs/a.md', 'a\n', 'a folder');
|
|
127
|
+
const base = (await execFileAsync('git', ['rev-parse', 'HEAD'], { cwd: repo })).stdout.trim();
|
|
128
|
+
await runGit(repo, ['checkout', '-b', 'alice/edit-foo']);
|
|
129
|
+
await commitFile(repo, 'Knowledge/Foo.md', 'line one\nline two\n', 'add line two');
|
|
130
|
+
const tip = (await execFileAsync('git', ['rev-parse', 'HEAD'], { cwd: repo })).stdout.trim();
|
|
131
|
+
|
|
132
|
+
const asked: unknown[] = [];
|
|
133
|
+
// Local branches only: each side resolves to the one commit it was served from.
|
|
134
|
+
const sides = { from: [base], to: [tip] };
|
|
135
|
+
const { diff } = await svc.diffFileBetweenBranches(workspaceId, 'Knowledge/Foo.md', 'current-company-state', 'alice/edit-foo', async (s) => {
|
|
136
|
+
asked.push(s);
|
|
137
|
+
});
|
|
138
|
+
expect(diff).toContain('+line two');
|
|
139
|
+
expect(asked).toEqual([sides]);
|
|
140
|
+
|
|
141
|
+
// A folder the caller may not read is refused as unreadable, never as a folder.
|
|
142
|
+
const refuse = async (s: unknown): Promise<void> => {
|
|
143
|
+
asked.push(s);
|
|
144
|
+
throw new WorkflowValidationError('not yours to read');
|
|
145
|
+
};
|
|
146
|
+
await expect(svc.diffFileBetweenBranches(workspaceId, 'Docs', 'current-company-state', 'alice/edit-foo', refuse)).rejects.toThrow(/not yours to read/);
|
|
147
|
+
expect(asked).toEqual([sides, sides]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('fails closed when a lookup of a side\'s other tip fails for any reason but absence: no diff, the verdict never asked', async () => {
|
|
151
|
+
const { workspaceDir, repo } = await seedWorkspace(root, workspaceId);
|
|
152
|
+
await commitFile(repo, 'Knowledge/Foo.md', 'line one\n', 'base');
|
|
153
|
+
await runGit(repo, ['checkout', '-b', 'alice/edit-foo']);
|
|
154
|
+
await commitFile(repo, 'Knowledge/Foo.md', 'line one\nline two\n', 'add line two');
|
|
155
|
+
const inner = new NodeGitRunner();
|
|
156
|
+
// The secondary lookup (`refs/remotes/origin/alice/edit-foo`, absent in
|
|
157
|
+
// this local-only repository) fails the way a corrupt repository or a
|
|
158
|
+
// deadline fails — not the way an absent ref answers.
|
|
159
|
+
let failure: GitRunError | null = null;
|
|
160
|
+
const gitRunner = {
|
|
161
|
+
defaultTimeoutMs: inner.defaultTimeoutMs,
|
|
162
|
+
credentials: inner.credentials,
|
|
163
|
+
run: async (cwd: string, args: string[], opts?: object) => {
|
|
164
|
+
if (failure && args[0] === 'rev-parse' && args.includes('refs/remotes/origin/alice/edit-foo')) throw failure;
|
|
165
|
+
return inner.run(cwd, args, opts as never);
|
|
166
|
+
},
|
|
167
|
+
} as unknown as IGitRunner;
|
|
168
|
+
const svc = new GitService(stubWorkspaceService(workspaceId, workspaceDir), new WorkflowHooks(), testKbContext(), undefined, null, gitRunner);
|
|
169
|
+
const asked: unknown[] = [];
|
|
170
|
+
const authorize = async (s: unknown): Promise<void> => { asked.push(s); };
|
|
171
|
+
for (const f of [
|
|
172
|
+
new GitRunError('git rev-parse failed', { exitCode: 128, stderr: 'fatal: bad object' }),
|
|
173
|
+
new GitRunError('git rev-parse timed out', { timedOut: true }),
|
|
174
|
+
]) {
|
|
175
|
+
failure = f;
|
|
176
|
+
await expect(svc.diffFileBetweenBranches(workspaceId, 'Knowledge/Foo.md', 'current-company-state', 'alice/edit-foo', authorize)).rejects.toBe(f);
|
|
177
|
+
}
|
|
178
|
+
expect(asked).toEqual([]);
|
|
179
|
+
// An absent ref is the one answer that is "no such commit": the diff goes on.
|
|
180
|
+
failure = null;
|
|
181
|
+
expect((await svc.diffFileBetweenBranches(workspaceId, 'Knowledge/Foo.md', 'current-company-state', 'alice/edit-foo', authorize)).diff).toContain('+line two');
|
|
182
|
+
expect(asked).toHaveLength(1);
|
|
183
|
+
});
|
|
184
|
+
|
|
120
185
|
it('returns the empty string when the file is identical on both branches', async () => {
|
|
121
186
|
const { workspaceDir, repo } = await seedWorkspace(root, workspaceId);
|
|
122
187
|
const svc = new GitService(
|
|
@@ -130,7 +195,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
130
195
|
// no edits to Same.md on the new branch
|
|
131
196
|
await commitFile(repo, 'Knowledge/Other.md', 'sidecar\n', 'unrelated edit');
|
|
132
197
|
|
|
133
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
198
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
134
199
|
workspaceId,
|
|
135
200
|
'Knowledge/Same.md',
|
|
136
201
|
'current-company-state',
|
|
@@ -151,7 +216,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
151
216
|
await runGit(repo, ['checkout', '-b', 'alice/cleanup']);
|
|
152
217
|
await deleteFileCommit(repo, 'Knowledge/Old.md', 'remove Old.md');
|
|
153
218
|
|
|
154
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
219
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
155
220
|
workspaceId,
|
|
156
221
|
'Knowledge/Old.md',
|
|
157
222
|
'current-company-state',
|
|
@@ -173,7 +238,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
173
238
|
await runGit(repo, ['checkout', '-b', 'alice/add-new']);
|
|
174
239
|
await commitFile(repo, 'Knowledge/New.md', 'brand new\n', 'add New.md');
|
|
175
240
|
|
|
176
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
241
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
177
242
|
workspaceId,
|
|
178
243
|
'Knowledge/New.md',
|
|
179
244
|
'current-company-state',
|
|
@@ -211,7 +276,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
211
276
|
testKbContext(),
|
|
212
277
|
);
|
|
213
278
|
|
|
214
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
279
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
215
280
|
workspaceId,
|
|
216
281
|
'Knowledge/Foo.md',
|
|
217
282
|
'current-company-state',
|
|
@@ -240,7 +305,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
240
305
|
await runGit(repo, ['checkout', '-b', 'alice/edit-foo']);
|
|
241
306
|
await commitFile(repo, 'Knowledge/Foo.md', 'baseline\nedit\n', 'edit');
|
|
242
307
|
|
|
243
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
308
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
244
309
|
workspaceId,
|
|
245
310
|
'knowledge-base/Knowledge/Foo.md',
|
|
246
311
|
'current-company-state',
|
|
@@ -267,7 +332,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
267
332
|
// and pressing save before sharing.
|
|
268
333
|
await writeFile(repo, 'Knowledge/Foo.md', 'baseline\nfresh edit\n');
|
|
269
334
|
|
|
270
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
335
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
271
336
|
workspaceId,
|
|
272
337
|
'Knowledge/Foo.md',
|
|
273
338
|
'current-company-state',
|
|
@@ -291,7 +356,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
291
356
|
// Brand-new file, never committed — only on disk.
|
|
292
357
|
await writeFile(repo, 'Knowledge/Brandnew.md', 'fresh content\n');
|
|
293
358
|
|
|
294
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
359
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
295
360
|
workspaceId,
|
|
296
361
|
'Knowledge/Brandnew.md',
|
|
297
362
|
'current-company-state',
|
|
@@ -313,7 +378,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
313
378
|
await runGit(repo, ['checkout', '-b', 'alice/draft']);
|
|
314
379
|
await writeFile(repo, 'Knowledge/Brandnew.md', 'fresh content\n');
|
|
315
380
|
|
|
316
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
381
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
317
382
|
workspaceId,
|
|
318
383
|
'Knowledge/Brandnew.md',
|
|
319
384
|
'alice/draft',
|
|
@@ -339,7 +404,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
339
404
|
// side. Lines added on current-company-state — i.e. the *removal* of
|
|
340
405
|
// "draft edit" — should appear as `+` on the to side, and "draft edit"
|
|
341
406
|
// should appear as `-`.
|
|
342
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
407
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
343
408
|
workspaceId,
|
|
344
409
|
'Knowledge/Foo.md',
|
|
345
410
|
'alice/edit-foo',
|
|
@@ -443,7 +508,7 @@ describe('GitService.diffFileBetweenBranches', () => {
|
|
|
443
508
|
await writeFile(repo, relPath, 'base content\nfeature edit\n');
|
|
444
509
|
await svc.commitFile(workspaceId, user, relPath, 'feature edit');
|
|
445
510
|
|
|
446
|
-
const diff = await svc.diffFileBetweenBranches(
|
|
511
|
+
const { diff } = await svc.diffFileBetweenBranches(
|
|
447
512
|
workspaceId,
|
|
448
513
|
relPath,
|
|
449
514
|
'current-company-state',
|