@remogram/core 0.1.0-beta.6 → 0.1.0-beta.9
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/auth-classes.js +6 -0
- package/change-request-merge-execute.js +148 -0
- package/check-diagnostics.js +92 -0
- package/check-pagination.js +1 -0
- package/config-schema.js +6 -0
- package/contracts/envelope.js +8 -0
- package/contracts/errors.js +3 -0
- package/contracts/forge-error-fields.js +1 -0
- package/contracts/semantic-diff-facts.js +24 -12
- package/cr-inventory-cursor.js +64 -0
- package/cr-inventory.js +33 -15
- package/cr-open.js +6 -1
- package/forge-changes-cursor.js +88 -0
- package/forge-changes.js +2 -2
- package/forge-identity.js +42 -0
- package/idempotency.js +69 -0
- package/index.js +53 -0
- package/issue-open.js +50 -0
- package/merge-blockers.js +28 -3
- package/merge-plan-forge.js +2 -1
- package/merge-plan.js +9 -3
- package/merge-policy.js +55 -0
- package/package.json +1 -1
- package/pr-head-reconcile.js +3 -3
- package/provider-health.js +93 -0
- package/ref-inventory.js +2 -2
- package/resolve.js +4 -0
- package/status-set.js +6 -1
- package/write-config.js +1 -1
- package/write-readiness.js +76 -0
package/write-config.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ERROR_CODES, forgeError } from './contracts/errors.js';
|
|
3
3
|
|
|
4
4
|
/** Canonical v1 consumer write command ids (schema + gate single source). */
|
|
5
|
-
export const WRITE_COMMAND_IDS = Object.freeze(['cr_open', 'status_set']);
|
|
5
|
+
export const WRITE_COMMAND_IDS = Object.freeze(['cr_open', 'status_set', 'merge', 'issue_open']);
|
|
6
6
|
|
|
7
7
|
export const writeCommandSchema = z.enum(WRITE_COMMAND_IDS);
|
|
8
8
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isWriteCommandConfigured } from './write-config.js';
|
|
2
|
+
import { API_PROVIDER_COMMAND_AUTH, AUTH_CLASS } from './auth-classes.js';
|
|
3
|
+
|
|
4
|
+
const WRITE_ID_TO_AUTH_COMMAND = Object.freeze({
|
|
5
|
+
merge: 'merge_execute',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
function authCommandForWriteId(commandId) {
|
|
9
|
+
return WRITE_ID_TO_AUTH_COMMAND[commandId] ?? commandId;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function commandNeedsToken(commandId) {
|
|
13
|
+
return API_PROVIDER_COMMAND_AUTH[authCommandForWriteId(commandId)] === AUTH_CLASS.TOKEN_REQUIRED;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function providerImplementsWrite(commandId, providerCapabilities) {
|
|
17
|
+
const authCommand = authCommandForWriteId(commandId);
|
|
18
|
+
const command = providerCapabilities?.commands?.find(
|
|
19
|
+
(entry) => entry.name === commandId || entry.name === authCommand,
|
|
20
|
+
);
|
|
21
|
+
if (command) return command.implemented !== false;
|
|
22
|
+
return (providerCapabilities?.write_commands || []).includes(commandId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function buildNextConfigSnippet(commandId, configuredWrites) {
|
|
26
|
+
const next = [...new Set([...(configuredWrites || []), commandId])].sort((a, b) => a.localeCompare(b));
|
|
27
|
+
return `"write_commands": ${JSON.stringify(next)}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {object} config
|
|
32
|
+
* @param {object | null} providerCapabilities
|
|
33
|
+
* @param {{ authPresent?: boolean }} [opts]
|
|
34
|
+
*/
|
|
35
|
+
export function buildWriteReadiness(config, providerCapabilities, opts = {}) {
|
|
36
|
+
const authPresent = opts.authPresent === true;
|
|
37
|
+
const providerWrites = [...new Set((providerCapabilities?.write_commands || []).filter(Boolean))].sort(
|
|
38
|
+
(a, b) => a.localeCompare(b),
|
|
39
|
+
);
|
|
40
|
+
const configuredWrites = [...new Set((Array.isArray(config?.write_commands) ? config.write_commands : []).filter(Boolean))].sort(
|
|
41
|
+
(a, b) => a.localeCompare(b),
|
|
42
|
+
);
|
|
43
|
+
const commandIds = [...new Set([...providerWrites, ...configuredWrites])].sort((a, b) => a.localeCompare(b));
|
|
44
|
+
|
|
45
|
+
const commands = commandIds.map((id) => {
|
|
46
|
+
const provider_supported = providerWrites.includes(id) && providerImplementsWrite(id, providerCapabilities);
|
|
47
|
+
const configured = isWriteCommandConfigured(config, id);
|
|
48
|
+
const auth_present = commandNeedsToken(id) ? authPresent : true;
|
|
49
|
+
const ready = provider_supported && configured && auth_present;
|
|
50
|
+
const entry = {
|
|
51
|
+
id,
|
|
52
|
+
provider_supported,
|
|
53
|
+
configured,
|
|
54
|
+
auth_present,
|
|
55
|
+
ready,
|
|
56
|
+
};
|
|
57
|
+
if (provider_supported && !configured) {
|
|
58
|
+
entry.next_config_snippet = buildNextConfigSnippet(id, configuredWrites);
|
|
59
|
+
}
|
|
60
|
+
return entry;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
configured_write_commands: configuredWrites,
|
|
65
|
+
provider_write_commands: providerWrites,
|
|
66
|
+
commands,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** True when any provider-supported write is not ready (config or auth). */
|
|
71
|
+
export function writeReadinessHasWarnings(writeConfig) {
|
|
72
|
+
if (!writeConfig?.commands?.length) return false;
|
|
73
|
+
return writeConfig.commands.some(
|
|
74
|
+
(entry) => entry.provider_supported === true && entry.ready !== true,
|
|
75
|
+
);
|
|
76
|
+
}
|