@remogram/core 0.1.0-beta.1 → 0.1.0-beta.10

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 (45) hide show
  1. package/auth-classes.js +73 -0
  2. package/branch-protection.js +155 -0
  3. package/caps.js +162 -14
  4. package/change-request-merge-execute.js +148 -0
  5. package/check-diagnostics.js +92 -0
  6. package/check-pagination.js +216 -0
  7. package/config-schema.js +21 -0
  8. package/contracts/envelope.js +26 -2
  9. package/contracts/errors.js +14 -2
  10. package/contracts/forge-error-fields.js +124 -0
  11. package/contracts/observer-fact-inventory.js +64 -0
  12. package/contracts/semantic-diff-facts.js +168 -0
  13. package/cr-comments.js +93 -0
  14. package/cr-files.js +62 -0
  15. package/cr-inventory-cursor.js +64 -0
  16. package/cr-inventory.js +136 -0
  17. package/cr-open.js +38 -0
  18. package/effective-write-policy.js +68 -0
  19. package/forge-changes-cursor.js +88 -0
  20. package/forge-changes.js +181 -0
  21. package/forge-identity.js +42 -0
  22. package/git-args.js +19 -0
  23. package/git-local.js +20 -0
  24. package/http.js +36 -2
  25. package/idempotency.js +69 -0
  26. package/index.js +255 -3
  27. package/issue-open.js +50 -0
  28. package/merge-blockers.js +68 -0
  29. package/merge-plan-forge.js +63 -0
  30. package/merge-plan.js +82 -0
  31. package/merge-policy.js +55 -0
  32. package/open-pull-list.js +256 -0
  33. package/operator-config.js +260 -0
  34. package/package.json +1 -1
  35. package/path-allowlist.js +114 -0
  36. package/pr-head-reconcile.js +38 -0
  37. package/provider-health.js +93 -0
  38. package/ref-inventory.js +98 -0
  39. package/resolve.js +53 -4
  40. package/status-set.js +92 -0
  41. package/stub-provider.js +11 -8
  42. package/whoami.js +114 -0
  43. package/write-config.js +63 -0
  44. package/write-field-policy.js +93 -0
  45. package/write-readiness.js +91 -0
@@ -0,0 +1,91 @@
1
+ import { AUTH_CLASS, API_PROVIDER_COMMAND_AUTH } from './auth-classes.js';
2
+ import {
3
+ isWriteCommandAllowed,
4
+ writeSourceForCommand,
5
+ buildOperatorConfigSnippet,
6
+ buildRepoConfigSnippet,
7
+ normalizeWritePolicyInput,
8
+ } from './effective-write-policy.js';
9
+
10
+ const WRITE_ID_TO_AUTH_COMMAND = Object.freeze({
11
+ merge: 'merge_execute',
12
+ });
13
+
14
+ function authCommandForWriteId(commandId) {
15
+ return WRITE_ID_TO_AUTH_COMMAND[commandId] ?? commandId;
16
+ }
17
+
18
+ function commandNeedsToken(commandId) {
19
+ return API_PROVIDER_COMMAND_AUTH[authCommandForWriteId(commandId)] === AUTH_CLASS.TOKEN_REQUIRED;
20
+ }
21
+
22
+ function providerImplementsWrite(commandId, providerCapabilities) {
23
+ const authCommand = authCommandForWriteId(commandId);
24
+ const command = providerCapabilities?.commands?.find(
25
+ (entry) => entry.name === commandId || entry.name === authCommand,
26
+ );
27
+ if (command) return command.implemented !== false;
28
+ return (providerCapabilities?.write_commands || []).includes(commandId);
29
+ }
30
+
31
+ /**
32
+ * @param {object} configOrPolicy repo config or resolved write policy
33
+ * @param {object | null} providerCapabilities
34
+ * @param {{ authPresent?: boolean }} [opts]
35
+ */
36
+ export function buildWriteReadiness(configOrPolicy, providerCapabilities, opts = {}) {
37
+ const authPresent = opts.authPresent === true;
38
+ const policy = normalizeWritePolicyInput(configOrPolicy);
39
+ const providerWrites = [...new Set((providerCapabilities?.write_commands || []).filter(Boolean))].sort(
40
+ (a, b) => a.localeCompare(b),
41
+ );
42
+ const repoWrites = policy.repoWriteCommands ?? [];
43
+ const operatorWrites = policy.operatorWriteCommands ?? [];
44
+ const commandIds = [...new Set([...providerWrites, ...repoWrites, ...operatorWrites])].sort((a, b) =>
45
+ a.localeCompare(b),
46
+ );
47
+
48
+ const commands = commandIds.map((id) => {
49
+ const provider_supported = providerWrites.includes(id) && providerImplementsWrite(id, providerCapabilities);
50
+ const repo_configured = repoWrites.includes(id);
51
+ const operator_configured = operatorWrites.includes(id);
52
+ const configured = repo_configured || operator_configured;
53
+ const source = writeSourceForCommand(repo_configured, operator_configured);
54
+ const auth_present = commandNeedsToken(id) ? authPresent : true;
55
+ const ready = provider_supported && configured && auth_present && !policy.operatorError;
56
+ const entry = {
57
+ id,
58
+ provider_supported,
59
+ configured,
60
+ repo_configured,
61
+ operator_configured,
62
+ source,
63
+ auth_present,
64
+ ready,
65
+ };
66
+ if (provider_supported && !configured) {
67
+ entry.next_config_snippet = buildRepoConfigSnippet(id, repoWrites);
68
+ entry.next_operator_config_snippet = buildOperatorConfigSnippet(id, operatorWrites);
69
+ }
70
+ return entry;
71
+ });
72
+
73
+ return {
74
+ configured_write_commands: policy.effectiveWriteCommands ?? [],
75
+ repo_write_commands: repoWrites,
76
+ operator_write_commands: operatorWrites,
77
+ operator_config: policy.operatorMeta ?? null,
78
+ operator_error: policy.operatorError ?? null,
79
+ provider_write_commands: providerWrites,
80
+ commands,
81
+ };
82
+ }
83
+
84
+ /** True when any provider-supported write is not ready (config or auth). */
85
+ export function writeReadinessHasWarnings(writeConfig) {
86
+ if (!writeConfig?.commands?.length) return false;
87
+ if (writeConfig.operator_error) return true;
88
+ return writeConfig.commands.some(
89
+ (entry) => entry.provider_supported === true && entry.ready !== true,
90
+ );
91
+ }