bkper 4.24.2 → 4.24.3

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.
Files changed (82) hide show
  1. package/lib/agent/extensions/builtins.d.ts.map +1 -1
  2. package/lib/agent/extensions/builtins.js +2 -2
  3. package/lib/agent/extensions/builtins.js.map +1 -1
  4. package/lib/agent/extensions/handoff.d.ts +2 -13
  5. package/lib/agent/extensions/handoff.d.ts.map +1 -1
  6. package/lib/agent/extensions/handoff.js +37 -17
  7. package/lib/agent/extensions/handoff.js.map +1 -1
  8. package/lib/agent/interactive/interactive-mode.d.ts.map +1 -1
  9. package/lib/agent/interactive/interactive-mode.js +1 -10
  10. package/lib/agent/interactive/interactive-mode.js.map +1 -1
  11. package/lib/commands/apps/deploy.d.ts +3 -1
  12. package/lib/commands/apps/deploy.d.ts.map +1 -1
  13. package/lib/commands/apps/deploy.js +29 -4
  14. package/lib/commands/apps/deploy.js.map +1 -1
  15. package/lib/commands/apps/git/clone.d.ts +23 -0
  16. package/lib/commands/apps/git/clone.d.ts.map +1 -0
  17. package/lib/commands/apps/git/clone.js +161 -0
  18. package/lib/commands/apps/git/clone.js.map +1 -0
  19. package/lib/commands/apps/git/credentials.d.ts +35 -0
  20. package/lib/commands/apps/git/credentials.d.ts.map +1 -0
  21. package/lib/commands/apps/git/credentials.js +196 -0
  22. package/lib/commands/apps/git/credentials.js.map +1 -0
  23. package/lib/commands/apps/git/index.d.ts +12 -0
  24. package/lib/commands/apps/git/index.d.ts.map +1 -0
  25. package/lib/commands/apps/git/index.js +12 -0
  26. package/lib/commands/apps/git/index.js.map +1 -0
  27. package/lib/commands/apps/git/inspect.d.ts +26 -0
  28. package/lib/commands/apps/git/inspect.d.ts.map +1 -0
  29. package/lib/commands/apps/git/inspect.js +207 -0
  30. package/lib/commands/apps/git/inspect.js.map +1 -0
  31. package/lib/commands/apps/git/markers.d.ts +16 -0
  32. package/lib/commands/apps/git/markers.d.ts.map +1 -0
  33. package/lib/commands/apps/git/markers.js +125 -0
  34. package/lib/commands/apps/git/markers.js.map +1 -0
  35. package/lib/commands/apps/git/mode.d.ts +25 -0
  36. package/lib/commands/apps/git/mode.d.ts.map +1 -0
  37. package/lib/commands/apps/git/mode.js +106 -0
  38. package/lib/commands/apps/git/mode.js.map +1 -0
  39. package/lib/commands/apps/git/platform-source.d.ts +18 -0
  40. package/lib/commands/apps/git/platform-source.d.ts.map +1 -0
  41. package/lib/commands/apps/git/platform-source.js +151 -0
  42. package/lib/commands/apps/git/platform-source.js.map +1 -0
  43. package/lib/commands/apps/git/preflight.d.ts +21 -0
  44. package/lib/commands/apps/git/preflight.d.ts.map +1 -0
  45. package/lib/commands/apps/git/preflight.js +130 -0
  46. package/lib/commands/apps/git/preflight.js.map +1 -0
  47. package/lib/commands/apps/git/push.d.ts +22 -0
  48. package/lib/commands/apps/git/push.d.ts.map +1 -0
  49. package/lib/commands/apps/git/push.js +107 -0
  50. package/lib/commands/apps/git/push.js.map +1 -0
  51. package/lib/commands/apps/git/remote.d.ts +7 -0
  52. package/lib/commands/apps/git/remote.d.ts.map +1 -0
  53. package/lib/commands/apps/git/remote.js +48 -0
  54. package/lib/commands/apps/git/remote.js.map +1 -0
  55. package/lib/commands/apps/git/run-git.d.ts +17 -0
  56. package/lib/commands/apps/git/run-git.d.ts.map +1 -0
  57. package/lib/commands/apps/git/run-git.js +61 -0
  58. package/lib/commands/apps/git/run-git.js.map +1 -0
  59. package/lib/commands/apps/git/types.d.ts +95 -0
  60. package/lib/commands/apps/git/types.d.ts.map +1 -0
  61. package/lib/commands/apps/git/types.js +17 -0
  62. package/lib/commands/apps/git/types.js.map +1 -0
  63. package/lib/commands/apps/index.d.ts +2 -0
  64. package/lib/commands/apps/index.d.ts.map +1 -1
  65. package/lib/commands/apps/index.js +3 -0
  66. package/lib/commands/apps/index.js.map +1 -1
  67. package/lib/commands/apps/init.d.ts.map +1 -1
  68. package/lib/commands/apps/init.js +19 -3
  69. package/lib/commands/apps/init.js.map +1 -1
  70. package/lib/commands/apps/register.d.ts.map +1 -1
  71. package/lib/commands/apps/register.js +23 -4
  72. package/lib/commands/apps/register.js.map +1 -1
  73. package/lib/commands/apps/source-workflow.d.ts +32 -0
  74. package/lib/commands/apps/source-workflow.d.ts.map +1 -0
  75. package/lib/commands/apps/source-workflow.js +170 -0
  76. package/lib/commands/apps/source-workflow.js.map +1 -0
  77. package/lib/commands/apps/sync.d.ts.map +1 -1
  78. package/lib/commands/apps/sync.js +13 -8
  79. package/lib/commands/apps/sync.js.map +1 -1
  80. package/lib/docs/cli/app-management.md +94 -6
  81. package/lib/docs/index.md +1 -1
  82. package/package.json +1 -1
@@ -0,0 +1,151 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { AUTHENTICATION_REQUIRED_MESSAGE } from '../../../auth/auth-errors.js';
11
+ import { getStoredOAuthToken } from '../../../auth/local-auth-service.js';
12
+ import { createPlatformClient } from '../../../platform/client.js';
13
+ import { ManagedGitError, } from './types.js';
14
+ const PLATFORM_API_URL = process.env.BKPER_PLATFORM_URL || 'https://platform.bkper.app';
15
+ function redactSecrets(value) {
16
+ return value
17
+ .replace(/(password=)[^\n\r]*/gi, '$1[redacted]')
18
+ .replace(/(Bearer\s+)[A-Za-z0-9._\-]+/gi, '$1[redacted]')
19
+ .replace(/([?&]token=)[^&\s]+/gi, '$1[redacted]');
20
+ }
21
+ function asErrorMessage(body, fallback) {
22
+ var _a, _b;
23
+ const message = (_b = (_a = body === null || body === void 0 ? void 0 : body.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : fallback;
24
+ return redactSecrets(message);
25
+ }
26
+ function authorizedFetch(path_1) {
27
+ return __awaiter(this, arguments, void 0, function* (path, init = {}, requireAuthentication = true) {
28
+ var _a;
29
+ const token = yield getStoredOAuthToken();
30
+ if (!token && requireAuthentication) {
31
+ throw new ManagedGitError('AUTHENTICATION_REQUIRED', AUTHENTICATION_REQUIRED_MESSAGE);
32
+ }
33
+ const response = yield fetch(`${PLATFORM_API_URL}${path}`, Object.assign(Object.assign({}, init), { headers: Object.assign(Object.assign(Object.assign(Object.assign({}, (token ? { Authorization: `Bearer ${token}` } : {})), { Accept: 'application/json' }), (init.body ? { 'Content-Type': 'application/json' } : {})), ((_a = init.headers) !== null && _a !== void 0 ? _a : {})) }));
34
+ let body = undefined;
35
+ const text = yield response.text();
36
+ if (text) {
37
+ try {
38
+ body = JSON.parse(text);
39
+ }
40
+ catch (_b) {
41
+ body = undefined;
42
+ }
43
+ }
44
+ return { response, body };
45
+ });
46
+ }
47
+ function throwPlatformError(response, body, fallback) {
48
+ var _a;
49
+ const code = (_a = body === null || body === void 0 ? void 0 : body.error) === null || _a === void 0 ? void 0 : _a.code;
50
+ const message = asErrorMessage(body, fallback);
51
+ if (response.status === 401 || code === 'MISSING_TOKEN' || code === 'INVALID_TOKEN') {
52
+ throw new ManagedGitError('AUTHENTICATION_REQUIRED', `${AUTHENTICATION_REQUIRED_MESSAGE}${message ? ` (${message})` : ''}`);
53
+ }
54
+ if (code === 'SOURCE_FEATURE_DISABLED' || response.status === 503) {
55
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Managed source control is not enabled in this Platform environment.');
56
+ }
57
+ if (code === 'SOURCE_RECORD_MISSING' || response.status === 409) {
58
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', message ||
59
+ 'Managed source record is missing or mismatched. Retry if this is a transient lookup, or request owner/developer access.');
60
+ }
61
+ if (response.status === 403 || code === 'ACCESS_DENIED') {
62
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', message ||
63
+ 'You do not have owner/developer access to this managed source. Request access from the App owner.');
64
+ }
65
+ if (response.status === 404 || code === 'APP_NOT_FOUND') {
66
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', message || 'App not found for managed source.');
67
+ }
68
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', message || fallback);
69
+ }
70
+ export function createPlatformSourceApi() {
71
+ return {
72
+ getStatus(appId) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ var _a, _b;
75
+ const { response, body } = yield authorizedFetch(`/api/apps/${encodeURIComponent(appId)}/source`, {}, false);
76
+ const errorBody = body;
77
+ if (response.status === 503 || ((_a = errorBody === null || errorBody === void 0 ? void 0 : errorBody.error) === null || _a === void 0 ? void 0 : _a.code) === 'SOURCE_FEATURE_DISABLED') {
78
+ return 'feature_disabled';
79
+ }
80
+ if (response.status === 404 || ((_b = errorBody === null || errorBody === void 0 ? void 0 : errorBody.error) === null || _b === void 0 ? void 0 : _b.code) === 'APP_NOT_FOUND') {
81
+ return 'app_not_found';
82
+ }
83
+ if (!response.ok) {
84
+ throwPlatformError(response, errorBody, 'Failed to load managed source status.');
85
+ }
86
+ const status = body;
87
+ if ((status === null || status === void 0 ? void 0 : status.mode) === 'managed' &&
88
+ (typeof status.remote !== 'string' || status.remote.length === 0)) {
89
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Managed source status did not include the registered remote.');
90
+ }
91
+ return status;
92
+ });
93
+ },
94
+ activate(appId, activationId) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ var _a;
97
+ const { response, body } = yield authorizedFetch(`/api/apps/${encodeURIComponent(appId)}/source/activate`, {
98
+ method: 'POST',
99
+ body: JSON.stringify({ activationId }),
100
+ });
101
+ const errorBody = body;
102
+ if (!response.ok) {
103
+ throwPlatformError(response, errorBody, 'Failed to activate managed source.');
104
+ }
105
+ const result = body;
106
+ if (!(result === null || result === void 0 ? void 0 : result.success) ||
107
+ ((_a = result.source) === null || _a === void 0 ? void 0 : _a.appId) !== appId ||
108
+ typeof result.source.remote !== 'string') {
109
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Managed source activation response was invalid.');
110
+ }
111
+ return result;
112
+ });
113
+ },
114
+ issueCredential(appId, scope) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const { response, body } = yield authorizedFetch(`/api/apps/${encodeURIComponent(appId)}/source/credentials`, {
117
+ method: 'POST',
118
+ body: JSON.stringify({ scope }),
119
+ });
120
+ const errorBody = body;
121
+ if (!response.ok) {
122
+ throwPlatformError(response, errorBody, 'Failed to issue managed source credentials.');
123
+ }
124
+ const credential = body;
125
+ if (!credential ||
126
+ typeof credential.token !== 'string' ||
127
+ typeof credential.remote !== 'string') {
128
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Managed source credential response was invalid.');
129
+ }
130
+ return credential;
131
+ });
132
+ },
133
+ };
134
+ }
135
+ /**
136
+ * Ensures the platform client module remains the auth base for non-source routes.
137
+ * Source operations keep a small fetch wrapper for explicit no-store and token-redaction handling.
138
+ */
139
+ export function getPlatformBaseUrl() {
140
+ createPlatformClient();
141
+ return PLATFORM_API_URL;
142
+ }
143
+ /**
144
+ * Strips provider query suffixes from repository tokens before handing them to Git.
145
+ * Never log the returned secret.
146
+ */
147
+ export function stripRepositoryTokenSecret(token) {
148
+ const queryIndex = token.indexOf('?');
149
+ return queryIndex === -1 ? token : token.slice(0, queryIndex);
150
+ }
151
+ //# sourceMappingURL=platform-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-source.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/platform-source.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,+BAA+B,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,qCA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AAM,EAAE,MAAM;oBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;iBAChC,CACJ,CAAC;gBACF,MAAM,SAAS,GAAG,IAAqC,CAAC;gBACxD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACf,kBAAkB,CACd,QAAQ,EACR,SAAS,EACT,6CAA6C,CAChD,CAAC;gBACN,CAAC;gBACD,MAAM,UAAU,GAAG,IAA+B,CAAC;gBACnD,IACI,CAAC,UAAU;oBACX,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ;oBACpC,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,EACvC,CAAC;oBACC,MAAM,IAAI,eAAe,CACrB,4BAA4B,EAC5B,iDAAiD,CACpD,CAAC;gBACN,CAAC;gBACD,OAAO,UAAU,CAAC;YACtB,CAAC;SAAA;KACJ,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAC9B,oBAAoB,EAAE,CAAC;IACvB,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACpD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type GitRunner } from './run-git.js';
2
+ import { type GitRepositoryInfo, type WorkingTreeStatus } from './types.js';
3
+ export interface ManagedGitPreflightOptions {
4
+ requireMainBranch?: boolean;
5
+ expectedOriginRemote?: string;
6
+ appDir?: string;
7
+ runner?: GitRunner;
8
+ }
9
+ export interface ManagedGitPreflightResult {
10
+ repo: GitRepositoryInfo;
11
+ branch: string;
12
+ head: string;
13
+ tree: WorkingTreeStatus;
14
+ }
15
+ /**
16
+ * Validates the local Git state required for managed source operations.
17
+ * Never mutates the repository.
18
+ */
19
+ export declare function requireManagedGitPreflight(options?: ManagedGitPreflightOptions): Promise<ManagedGitPreflightResult>;
20
+ export declare function requireManagedOrigin(repo: GitRepositoryInfo, expectedRemote: string): void;
21
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/preflight.ts"],"names":[],"mappings":"AAOA,OAAO,EAAS,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAGH,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACzB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,0BAA0B;IACvC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CAC3B;AAeD;;;GAGG;AACH,wBAAsB,0BAA0B,CAC5C,OAAO,GAAE,0BAA+B,GACzC,OAAO,CAAC,yBAAyB,CAAC,CAoGpC;AAED,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,iBAAiB,EACvB,cAAc,EAAE,MAAM,GACvB,IAAI,CAsCN"}
@@ -0,0 +1,130 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getOriginRemote, getWorkingTreeStatus, inspectGitRepository, remoteUrlsEqual, requireGitRepository, } from './inspect.js';
11
+ import { runGit } from './run-git.js';
12
+ import { DEFAULT_MANAGED_BRANCH, ManagedGitError, } from './types.js';
13
+ function formatFileList(files, limit = 10) {
14
+ if (files.length === 0) {
15
+ return '';
16
+ }
17
+ const shown = files.slice(0, limit);
18
+ const remaining = files.length - shown.length;
19
+ const lines = shown.map(file => ` - ${file}`);
20
+ if (remaining > 0) {
21
+ lines.push(` - ...and ${remaining} more`);
22
+ }
23
+ return lines.join('\n');
24
+ }
25
+ /**
26
+ * Validates the local Git state required for managed source operations.
27
+ * Never mutates the repository.
28
+ */
29
+ export function requireManagedGitPreflight() {
30
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
31
+ var _a, _b, _c;
32
+ const runner = (_a = options.runner) !== null && _a !== void 0 ? _a : runGit;
33
+ const appDir = (_b = options.appDir) !== null && _b !== void 0 ? _b : process.cwd();
34
+ const repo = yield inspectGitRepository(appDir, runner);
35
+ requireGitRepository(repo);
36
+ if (repo.isNestedApp) {
37
+ throw new ManagedGitError('BKPER_YAML_NOT_AT_GIT_ROOT', [
38
+ 'Managed source requires bkper.yaml at the Git repository root.',
39
+ `Git root: ${repo.root}`,
40
+ `App config: ${(_c = repo.bkperYamlPath) !== null && _c !== void 0 ? _c : appDir}`,
41
+ 'Nested monorepo Apps keep external source mode and are not migrated automatically.',
42
+ ].join('\n'));
43
+ }
44
+ if (!repo.hasCommits || !repo.head) {
45
+ throw new ManagedGitError('NO_COMMITS', [
46
+ 'Managed source requires a committed HEAD.',
47
+ 'Create an initial commit, then retry:',
48
+ ' git add .',
49
+ ' git commit -m "Initial app"',
50
+ ].join('\n'));
51
+ }
52
+ if (repo.detached || !repo.branch) {
53
+ throw new ManagedGitError('DETACHED_HEAD', [
54
+ 'Managed source requires an attached branch (detached HEAD is not allowed).',
55
+ 'Create or switch to a branch first, for example:',
56
+ ' git switch -c main',
57
+ 'or:',
58
+ ' git switch -c rollback/<name> <commit>',
59
+ ].join('\n'));
60
+ }
61
+ if (options.requireMainBranch && repo.branch !== DEFAULT_MANAGED_BRANCH) {
62
+ throw new ManagedGitError('FIRST_ACTIVATION_NOT_MAIN', [
63
+ `First managed-source activation requires branch '${DEFAULT_MANAGED_BRANCH}'.`,
64
+ `Current branch: ${repo.branch}`,
65
+ 'Switch to main without rewriting history, for example:',
66
+ ' git switch main',
67
+ ].join('\n'));
68
+ }
69
+ const tree = yield getWorkingTreeStatus(repo.root, runner);
70
+ if (tree.staged.length > 0) {
71
+ throw new ManagedGitError('STAGED_CHANGES', [
72
+ 'Managed source requires a clean working tree (no staged changes).',
73
+ 'Review and commit or unstage these files:',
74
+ formatFileList(tree.staged),
75
+ ].join('\n'), tree.staged);
76
+ }
77
+ if (tree.modified.length > 0) {
78
+ throw new ManagedGitError('MODIFIED_TRACKED_FILES', [
79
+ 'Managed source requires a clean working tree (no modified tracked files).',
80
+ 'Review and commit or restore these files:',
81
+ formatFileList(tree.modified),
82
+ ].join('\n'), tree.modified);
83
+ }
84
+ if (tree.untracked.length > 0) {
85
+ throw new ManagedGitError('UNTRACKED_FILES', [
86
+ 'Managed source requires a clean working tree (no non-ignored untracked files).',
87
+ 'Review, commit, or ignore these files:',
88
+ formatFileList(tree.untracked),
89
+ ].join('\n'), tree.untracked);
90
+ }
91
+ if (options.expectedOriginRemote) {
92
+ requireManagedOrigin(repo, options.expectedOriginRemote);
93
+ }
94
+ return {
95
+ repo,
96
+ branch: repo.branch,
97
+ head: repo.head,
98
+ tree,
99
+ };
100
+ });
101
+ }
102
+ export function requireManagedOrigin(repo, expectedRemote) {
103
+ const origin = getOriginRemote(repo.remotes);
104
+ if (!origin) {
105
+ throw new ManagedGitError('MISSING_MANAGED_ORIGIN', [
106
+ 'Managed source requires the Artifacts repository configured as `origin`.',
107
+ 'Repair local Git config with:',
108
+ ` git remote add origin ${expectedRemote}`,
109
+ 'Then install the Bkper credential helper and retry.',
110
+ ].join('\n'));
111
+ }
112
+ if (!origin.isArtifacts) {
113
+ throw new ManagedGitError('EXTERNAL_ORIGIN_PRESENT', [
114
+ 'Managed source keeps Artifacts as `origin` and never rewrites an external remote.',
115
+ `Current origin: ${origin.url}`,
116
+ 'Rename or remove the external origin yourself only if you intend to use managed source on this clone, for example:',
117
+ ' git remote rename origin upstream',
118
+ ` git remote add origin ${expectedRemote}`,
119
+ ].join('\n'));
120
+ }
121
+ if (!remoteUrlsEqual(origin.url, expectedRemote)) {
122
+ throw new ManagedGitError('INCORRECT_MANAGED_ORIGIN', [
123
+ 'The configured `origin` does not match the Platform-registered Artifacts remote.',
124
+ `Expected: ${expectedRemote}`,
125
+ `Actual: ${origin.url}`,
126
+ 'Repair the origin URL only when you are sure this clone belongs to that managed App.',
127
+ ].join('\n'));
128
+ }
129
+ }
130
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/preflight.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,MAAM,EAAiB,MAAM,cAAc,CAAC;AACpD,OAAO,EACH,sBAAsB,EACtB,eAAe,GAGlB,MAAM,YAAY,CAAC;AAgBpB,SAAS,cAAc,CAAC,KAAe,EAAE,KAAK,GAAG,EAAE;IAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,CAAC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,CAAC;AACL,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type GitRunner } from './run-git.js';
2
+ export interface SafePushOptions {
3
+ appDir?: string;
4
+ expectedOriginRemote?: string;
5
+ requireMainBranch?: boolean;
6
+ runner?: GitRunner;
7
+ }
8
+ export interface SafePushResult {
9
+ branch: string;
10
+ head: string;
11
+ action: 'pushed' | 'already_up_to_date' | 'created_remote_branch';
12
+ }
13
+ /**
14
+ * Fetches the remote branch and allows only missing, equal, or ancestor remote tips.
15
+ */
16
+ export declare function assertFastForwardPush(repoRoot: string, branch: string, head: string, runner?: GitRunner): Promise<'missing' | 'same' | 'ahead'>;
17
+ /**
18
+ * Safe current-branch push with upstream setup.
19
+ * Never commits, merges, rebases, force-pushes, or discards local changes.
20
+ */
21
+ export declare function pushCurrentBranchSafe(options?: SafePushOptions): Promise<SafePushResult>;
22
+ //# sourceMappingURL=push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/push.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAGpD,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;CACrE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,SAAkB,GAC3B,OAAO,CAAC,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC,CA2CvC;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACvC,OAAO,GAAE,eAAoB,GAC9B,OAAO,CAAC,cAAc,CAAC,CA+DzB"}
@@ -0,0 +1,107 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getOriginRemote, listRemotes, remoteUrlsEqual } from './inspect.js';
11
+ import { requireManagedGitPreflight } from './preflight.js';
12
+ import { runGit } from './run-git.js';
13
+ import { ManagedGitError } from './types.js';
14
+ /**
15
+ * Fetches the remote branch and allows only missing, equal, or ancestor remote tips.
16
+ */
17
+ export function assertFastForwardPush(repoRoot_1, branch_1, head_1) {
18
+ return __awaiter(this, arguments, void 0, function* (repoRoot, branch, head, runner = runGit) {
19
+ yield runner(['fetch', 'origin', branch], {
20
+ cwd: repoRoot,
21
+ allowFailure: true,
22
+ });
23
+ const remoteRef = yield runner(['rev-parse', '--verify', `refs/remotes/origin/${branch}`], {
24
+ cwd: repoRoot,
25
+ allowFailure: true,
26
+ });
27
+ if (remoteRef.exitCode !== 0) {
28
+ return 'missing';
29
+ }
30
+ const remoteSha = remoteRef.stdout.trim();
31
+ if (!remoteSha) {
32
+ return 'missing';
33
+ }
34
+ if (remoteSha === head) {
35
+ return 'same';
36
+ }
37
+ const ancestor = yield runner(['merge-base', '--is-ancestor', remoteSha, head], {
38
+ cwd: repoRoot,
39
+ allowFailure: true,
40
+ });
41
+ if (ancestor.exitCode === 0) {
42
+ return 'ahead';
43
+ }
44
+ throw new ManagedGitError('REMOTE_AHEAD_OR_DIVERGED', [
45
+ `Remote branch 'origin/${branch}' is ahead of or diverged from local HEAD.`,
46
+ 'The CLI never force-pushes, merges, or rebases.',
47
+ 'Fetch and reconcile intentionally, then retry:',
48
+ ` git fetch origin ${branch}`,
49
+ ' git log --oneline --left-right HEAD...origin/' + branch,
50
+ ' # merge or rebase by your choice, then:',
51
+ ' git push',
52
+ ].join('\n'));
53
+ });
54
+ }
55
+ /**
56
+ * Safe current-branch push with upstream setup.
57
+ * Never commits, merges, rebases, force-pushes, or discards local changes.
58
+ */
59
+ export function pushCurrentBranchSafe() {
60
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
61
+ var _a;
62
+ const runner = (_a = options.runner) !== null && _a !== void 0 ? _a : runGit;
63
+ const preflight = yield requireManagedGitPreflight({
64
+ appDir: options.appDir,
65
+ expectedOriginRemote: options.expectedOriginRemote,
66
+ requireMainBranch: options.requireMainBranch,
67
+ runner,
68
+ });
69
+ const remotes = yield listRemotes(preflight.repo.root, runner);
70
+ const origin = getOriginRemote(remotes);
71
+ if (!origin) {
72
+ throw new ManagedGitError('MISSING_MANAGED_ORIGIN', 'Managed source requires `origin` before push.');
73
+ }
74
+ if (options.expectedOriginRemote && !remoteUrlsEqual(origin.url, options.expectedOriginRemote)) {
75
+ throw new ManagedGitError('INCORRECT_MANAGED_ORIGIN', 'origin does not match the expected managed remote.');
76
+ }
77
+ const relation = yield assertFastForwardPush(preflight.repo.root, preflight.branch, preflight.head, runner);
78
+ if (relation === 'same') {
79
+ return {
80
+ branch: preflight.branch,
81
+ head: preflight.head,
82
+ action: 'already_up_to_date',
83
+ };
84
+ }
85
+ const upstream = yield runner(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], {
86
+ cwd: preflight.repo.root,
87
+ allowFailure: true,
88
+ });
89
+ const hasUpstream = upstream.exitCode === 0 && upstream.stdout.trim().length > 0;
90
+ if (hasUpstream) {
91
+ yield runner(['push', 'origin', `HEAD:${preflight.branch}`], {
92
+ cwd: preflight.repo.root,
93
+ });
94
+ }
95
+ else {
96
+ yield runner(['push', '-u', 'origin', `HEAD:${preflight.branch}`], {
97
+ cwd: preflight.repo.root,
98
+ });
99
+ }
100
+ return {
101
+ branch: preflight.branch,
102
+ head: preflight.head,
103
+ action: relation === 'missing' ? 'created_remote_branch' : 'pushed',
104
+ };
105
+ });
106
+ }
107
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/push.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAC,0BAA0B,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAiB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAe3C;;GAEG;AACH,MAAM,UAAgB,qBAAqB;yDACvC,QAAgB,EAChB,MAAc,EACd,IAAY,EACZ,SAAoB,MAAM;QAE1B,MAAM,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE;YACtC,GAAG,EAAE,QAAQ;YACb,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,uBAAuB,MAAM,EAAE,CAAC,EAAE;YACvF,GAAG,EAAE,QAAQ;YACb,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,IAAI,SAAS,K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AAI,EAAE,SAAS,CAAC,IAAI;YACpB,MAAM,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,QAAQ;SACtE,CAAC;IACN,CAAC;CAAA"}
@@ -0,0 +1,7 @@
1
+ import { type GitRunner } from './run-git.js';
2
+ /**
3
+ * Configures Artifacts as `origin` only after managed activation.
4
+ * Never modifies an existing external remote.
5
+ */
6
+ export declare function configureManagedOrigin(repoRoot: string, remote: string, appId: string, runner?: GitRunner): Promise<void>;
7
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/remote.ts"],"names":[],"mappings":"AAOA,OAAO,EAAS,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,SAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAqCf"}
@@ -0,0 +1,48 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getOriginRemote, isArtifactsRemoteUrl, listRemotes, remoteUrlsEqual, } from './inspect.js';
11
+ import { configureManagedCredentialHelper } from './credentials.js';
12
+ import { runGit } from './run-git.js';
13
+ import { ManagedGitError } from './types.js';
14
+ /**
15
+ * Configures Artifacts as `origin` only after managed activation.
16
+ * Never modifies an existing external remote.
17
+ */
18
+ export function configureManagedOrigin(repoRoot_1, remote_1, appId_1) {
19
+ return __awaiter(this, arguments, void 0, function* (repoRoot, remote, appId, runner = runGit) {
20
+ if (!isArtifactsRemoteUrl(remote)) {
21
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', 'Managed origin must be an Artifacts HTTPS remote.');
22
+ }
23
+ const remotes = yield listRemotes(repoRoot, runner);
24
+ const origin = getOriginRemote(remotes);
25
+ if (!origin) {
26
+ yield runner(['remote', 'add', 'origin', remote], { cwd: repoRoot });
27
+ }
28
+ else if (!origin.isArtifacts) {
29
+ throw new ManagedGitError('EXTERNAL_ORIGIN_PRESENT', [
30
+ 'Refusing to rewrite an external `origin` remote.',
31
+ `Current origin: ${origin.url}`,
32
+ 'Rename the external remote yourself if this clone should use managed source:',
33
+ ' git remote rename origin upstream',
34
+ ` git remote add origin ${remote}`,
35
+ ].join('\n'));
36
+ }
37
+ else if (!remoteUrlsEqual(origin.url, remote)) {
38
+ throw new ManagedGitError('INCORRECT_MANAGED_ORIGIN', [
39
+ 'An Artifacts `origin` already exists but does not match the registered remote.',
40
+ `Expected: ${remote}`,
41
+ `Actual: ${origin.url}`,
42
+ 'Resolve the mismatch manually. The CLI never rewrites remotes automatically.',
43
+ ].join('\n'));
44
+ }
45
+ yield configureManagedCredentialHelper(repoRoot, remote, appId, runner);
46
+ });
47
+ }
48
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/remote.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,eAAe,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gCAAgC,EAAC,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAC,MAAM,EAAiB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,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out: string;
3
+ stderr: string;
4
+ exitCode: number;
5
+ }
6
+ export interface GitRunOptions {
7
+ cwd?: string;
8
+ env?: NodeJS.ProcessEnv;
9
+ allowFailure?: boolean;
10
+ input?: string;
11
+ }
12
+ export type GitRunner = (args: string[], options?: GitRunOptions) => Promise<GitCommandResult>;
13
+ /**
14
+ * Runs a git subprocess. Never logs secrets from env or stdout.
15
+ */
16
+ export declare function runGit(args: string[], options?: GitRunOptions): Promise<GitCommandResult>;
17
+ //# sourceMappingURL=run-git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-git.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/run-git.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,aAAa,KACtB,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/B;;GAEG;AACH,wBAAsB,MAAM,CACxB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,aAAkB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAmD3B"}
@@ -0,0 +1,61 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { spawn } from 'child_process';
11
+ import { ManagedGitError } from './types.js';
12
+ /**
13
+ * Runs a git subprocess. Never logs secrets from env or stdout.
14
+ */
15
+ export function runGit(args_1) {
16
+ return __awaiter(this, arguments, void 0, function* (args, options = {}) {
17
+ return new Promise((resolve, reject) => {
18
+ const child = spawn('git', args, {
19
+ cwd: options.cwd,
20
+ env: Object.assign(Object.assign(Object.assign({}, process.env), options.env), { GIT_TERMINAL_PROMPT: '0' }),
21
+ stdio: ['pipe', 'pipe', 'pipe'],
22
+ });
23
+ let stdout = '';
24
+ let stderr = '';
25
+ child.stdout.on('data', (chunk) => {
26
+ stdout += chunk.toString();
27
+ });
28
+ child.stderr.on('data', (chunk) => {
29
+ stderr += chunk.toString();
30
+ });
31
+ if (options.input !== undefined) {
32
+ child.stdin.write(options.input);
33
+ }
34
+ child.stdin.end();
35
+ child.on('error', error => {
36
+ var _a;
37
+ reject(new ManagedGitError('GIT_COMMAND_FAILED', `Failed to run git ${(_a = args[0]) !== null && _a !== void 0 ? _a : ''}: ${error.message}`));
38
+ });
39
+ child.on('close', code => {
40
+ const exitCode = code !== null && code !== void 0 ? code : 1;
41
+ const result = { stdout: stdout.trimEnd(), stderr: stderr.trimEnd(), exitCode };
42
+ if (exitCode !== 0 && !options.allowFailure) {
43
+ reject(new ManagedGitError('GIT_COMMAND_FAILED', formatGitFailure(args, result)));
44
+ return;
45
+ }
46
+ resolve(result);
47
+ });
48
+ });
49
+ });
50
+ }
51
+ function formatGitFailure(args, result) {
52
+ const detail = result.stderr || result.stdout || `exit ${result.exitCode}`;
53
+ // Never include credential helper password protocol output in errors.
54
+ const redacted = detail
55
+ .split('\n')
56
+ .filter(line => !/^(username|password)=/i.test(line.trim()))
57
+ .join('\n')
58
+ .trim();
59
+ return `git ${args.join(' ')} failed: ${redacted || `exit ${result.exitCode}`}`;
60
+ }
61
+ //# sourceMappingURL=run-git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-git.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/run-git.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAoB3C;;GAEG;AACH,MAAM,UAAgB,MAAM;yDACxB,IAAc,EACd,UAAyB,EAAE;QAE3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE;gBAC7B,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,GAAG,gDACI,OAAO,CAAC,GAAG,GACX,OAAO,CAAC,GAAG,KACd,mBAAmB,EAAE,GAAG,GAC3B;gBACD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aAClC,CAAC,CAAC;YAEH,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,IAAI,MAAM,GAAG,EAAE,CAAC;YAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAsB,EAAE,EAAE;gBAC/C,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC/B,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAsB,EAAE,EAAE;gBAC/C,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC/B,CAAC,CAAC,CAAC;YAEH,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC9B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;YACD,KAAK,CAAC,KAAK,CAAC,G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