@codeyam-editor/codeyam-editor 0.1.4 → 0.1.6

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 (97) hide show
  1. package/npm/cli.js +5 -1
  2. package/npm/cloud-branch-switch.js +1 -1
  3. package/npm/cloud.js +3166 -150
  4. package/npm/codesign-plan.js +68 -0
  5. package/npm/container.js +3 -0
  6. package/npm/disk-pressure.js +78 -0
  7. package/npm/editor-dev.js +96 -15
  8. package/npm/editor.js +85 -37
  9. package/npm/empty-project-dir.js +92 -7
  10. package/npm/fleet-add-failure.js +252 -0
  11. package/npm/fleet-asset-version.js +37 -0
  12. package/npm/fleet-auth-health.js +213 -0
  13. package/npm/fleet-auth.js +6 -1
  14. package/npm/fleet-build-data.js +109 -5
  15. package/npm/fleet-cleanup.js +232 -16
  16. package/npm/fleet-destroy-safety.js +272 -0
  17. package/npm/fleet-early-roster.js +87 -0
  18. package/npm/fleet-effect-poll.js +110 -0
  19. package/npm/fleet-effect-status.js +33 -32
  20. package/npm/fleet-env.js +86 -0
  21. package/npm/fleet-ghcr-secret.js +129 -0
  22. package/npm/fleet-git-maintenance.js +142 -0
  23. package/npm/fleet-host-op-limiter.js +68 -0
  24. package/npm/fleet-host.js +74 -0
  25. package/npm/fleet-iap-token.js +165 -0
  26. package/npm/fleet-job-badge.js +1 -1
  27. package/npm/fleet-launchd.js +171 -0
  28. package/npm/fleet-live-status.js +155 -0
  29. package/npm/fleet-memory.js +245 -9
  30. package/npm/fleet-plans.js +233 -4
  31. package/npm/fleet-pool.js +75 -16
  32. package/npm/fleet-prewarm.js +241 -0
  33. package/npm/fleet-project-drift.js +58 -0
  34. package/npm/fleet-public-url.js +394 -0
  35. package/npm/fleet-queue.js +95 -1
  36. package/npm/fleet-reachability-debounce.js +69 -0
  37. package/npm/fleet-reachability.js +80 -0
  38. package/npm/fleet-reconcile.js +43 -1
  39. package/npm/fleet-reset.js +330 -13
  40. package/npm/fleet-roster.js +6 -8
  41. package/npm/fleet-running-plan.js +85 -0
  42. package/npm/fleet-self-update.js +142 -0
  43. package/npm/fleet-session-token-cache.js +65 -0
  44. package/npm/fleet-setup-steps.js +112 -0
  45. package/npm/fleet-sleep-status.js +33 -0
  46. package/npm/fleet-status-refs.js +96 -0
  47. package/npm/fleet-strand.js +181 -0
  48. package/npm/fleet-stuck-status.js +117 -0
  49. package/npm/fleet-vm-access.js +404 -0
  50. package/npm/fleet-vm-probe-target.js +282 -0
  51. package/npm/fleet-vm-readiness.js +237 -0
  52. package/npm/fleet-vm-slugs.js +116 -0
  53. package/npm/google-ingress.js +226 -0
  54. package/npm/ingress-invoke.js +770 -0
  55. package/npm/launch-config.js +386 -9
  56. package/npm/scenario-check.js +880 -37
  57. package/npm/scenario-handlers.js +154 -30
  58. package/npm/scenario-interactivity.js +145 -6
  59. package/npm/scenario-issues.js +13 -1
  60. package/npm/scenario-metrics.js +116 -1
  61. package/npm/scenario-mocks.js +144 -21
  62. package/npm/scenario-playwright.js +649 -38
  63. package/npm/script-drift.js +152 -0
  64. package/npm/utils.js +365 -52
  65. package/npm/vm-urls.js +69 -8
  66. package/package.json +5 -5
  67. package/ui/dist/assets/ContainerInspector-DgM0pTAx.js +2 -0
  68. package/ui/dist/assets/EditorShell-B7Q06uJ_.js +252 -0
  69. package/ui/dist/assets/EditorShell-DP5UY20G.css +1 -0
  70. package/ui/dist/assets/{Markdown-BHBqz-Mj.js → Markdown-Chgdf3PW.js} +1 -1
  71. package/ui/dist/assets/ProjectLauncherScreen-BRrEr8Ng.js +1 -0
  72. package/ui/dist/assets/ScenarioDataPanel-BeQfa28g.js +9 -0
  73. package/ui/dist/assets/{ScenarioDataPanel-DYP7pi_n.css → ScenarioDataPanel-C1LukYI6.css} +1 -1
  74. package/ui/dist/assets/ScenarioDataPanelFullPage-BLqRCxQX.js +1 -0
  75. package/ui/dist/assets/ScenarioRenderer-CIAxfHPh.js +21 -0
  76. package/ui/dist/assets/StepsSimulator-CymGgfbu.js +1 -0
  77. package/ui/dist/assets/index-BygCiJSb.css +1 -0
  78. package/ui/dist/assets/{index-BuK0lizt.js → index-DCHqRrwO.js} +9 -9
  79. package/ui/dist/assets/{markdown-v0F0UEt3.js → markdown-C9tbsVHX.js} +1 -1
  80. package/ui/dist/assets/react-nrLBr15I.js +28 -0
  81. package/ui/dist/assets/useEvents-S3Qk1Y_d.js +1 -0
  82. package/ui/dist/assets/useServerIdentity-B7rI0u3O.js +1 -0
  83. package/ui/dist/codeyam-mark.svg +4 -0
  84. package/ui/dist/codeyam-wordmark.svg +5 -0
  85. package/ui/dist/index.html +4 -4
  86. package/ui/dist/open-source/codeyam-counter.png +0 -0
  87. package/ui/dist/open-source/el-carot.png +0 -0
  88. package/ui/dist/open-source/tabcommand.png +0 -0
  89. package/ui/dist/assets/ContainerInspector-C8EkH4PP.js +0 -2
  90. package/ui/dist/assets/EditorShell-tMMdarZD.js +0 -187
  91. package/ui/dist/assets/ScenarioDataPanel-xWYGZOpo.js +0 -5
  92. package/ui/dist/assets/ScenarioDataPanelFullPage-5G6KuZgw.js +0 -1
  93. package/ui/dist/assets/ScenarioRenderer-CSdhX1Ak.js +0 -1
  94. package/ui/dist/assets/StepsSimulator-CRtmlyNZ.js +0 -1
  95. package/ui/dist/assets/index-BGqairFV.css +0 -1
  96. package/ui/dist/assets/react-CSS0HapR.js +0 -28
  97. package/ui/dist/assets/useEvents-DggWrtHe.js +0 -1
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Given a list of files with their hash values, decide if there is any script drift.
5
+ * @param {Object} options
6
+ * @param {Array<Object>} options.files
7
+ * Each file entry has:
8
+ * {
9
+ * path: string,
10
+ * localHash: string,
11
+ * remoteHash: string | null, // null indicates fetch/hash failure
12
+ * baseHash: string | null,
13
+ * dirty: boolean
14
+ * }
15
+ *
16
+ * Returns:
17
+ * {
18
+ * verdict: 'clean' | 'local-ahead' | 'stale' | 'diverged',
19
+ * staleFiles: string[] // List of paths that are stale/diverged
20
+ * }
21
+ */
22
+ function classifyScriptDrift({ files }) {
23
+ if (!files || files.length === 0) {
24
+ return { verdict: 'clean', staleFiles: [] };
25
+ }
26
+
27
+ let hasStale = false;
28
+ let hasDiverged = false;
29
+ let hasLocalAhead = false;
30
+ const staleFiles = [];
31
+
32
+ for (const f of files) {
33
+ // If remoteHash or baseHash is missing/null/undefined, we treat it as fetch/hash failure.
34
+ // In that case, we cannot safely declare the file stale/diverged, so we pass through.
35
+ if (f.remoteHash === null || f.baseHash === null || f.remoteHash === undefined || f.baseHash === undefined) {
36
+ continue;
37
+ }
38
+
39
+ const localHash = f.localHash;
40
+ const remoteHash = f.remoteHash;
41
+ const baseHash = f.baseHash;
42
+ const dirty = !!f.dirty;
43
+
44
+ // 1. Identical local and remote, and not dirty locally -> clean
45
+ if (localHash === remoteHash && !dirty) {
46
+ continue;
47
+ }
48
+
49
+ // 2. Remote hasn't changed from base, but local has changed (or is dirty)
50
+ if (remoteHash === baseHash) {
51
+ if (localHash !== baseHash || dirty) {
52
+ hasLocalAhead = true;
53
+ }
54
+ }
55
+ // 3. Local hasn't changed from base, but remote has changed from base
56
+ else if (localHash === baseHash && !dirty) {
57
+ hasStale = true;
58
+ staleFiles.push(f.path);
59
+ }
60
+ // 4. Both local and remote have changed from base and they differ from each other
61
+ else {
62
+ hasDiverged = true;
63
+ staleFiles.push(f.path);
64
+ }
65
+ }
66
+
67
+ if (hasDiverged) {
68
+ return { verdict: 'diverged', staleFiles };
69
+ }
70
+ if (hasStale) {
71
+ return { verdict: 'stale', staleFiles };
72
+ }
73
+ if (hasLocalAhead) {
74
+ return { verdict: 'local-ahead', staleFiles: [] };
75
+ }
76
+ return { verdict: 'clean', staleFiles: [] };
77
+ }
78
+
79
+ /**
80
+ * Decide, for one streamed provisioning script, whether the VM should receive the
81
+ * canonical remote-tip bytes or the local on-disk copy. The remote tip is the
82
+ * reviewed, canonical source: a checkout that is merely *behind* origin (a normal,
83
+ * expected consequence of an active fleet landing commits to these scripts) then
84
+ * streams exactly the bytes the drift guard expects — never stale on-disk bytes,
85
+ * never a false STALE abort. The local copy wins only when the operator authored
86
+ * content the remote tip does not have — an uncommitted (dirty) edit or a committed
87
+ * local-ahead change (developer mode / diverged) — or when the remote facts are
88
+ * unavailable (offline fallback, so an offline operator can still provision).
89
+ *
90
+ * @param {Object} file
91
+ * @param {string|null} file.localHash
92
+ * @param {string|null} file.remoteHash null/undefined ⇒ remote unreachable
93
+ * @param {string|null} file.baseHash
94
+ * @param {boolean} file.dirty
95
+ * @returns {'remote' | 'local'}
96
+ */
97
+ function streamedScriptSource({ localHash, remoteHash, baseHash, dirty }) {
98
+ // Remote unreachable / ref missing → the only bytes we have are on disk.
99
+ if (remoteHash === null || remoteHash === undefined) {
100
+ return 'local';
101
+ }
102
+ // Uncommitted local edit → the operator is provisioning unreviewed bytes on
103
+ // purpose (developer mode, or an explicit CODEYAM_SKIP_SCRIPT_DRIFT_CHECK bypass).
104
+ if (dirty) {
105
+ return 'local';
106
+ }
107
+ // Local content the remote tip does not have (committed local-ahead, or a genuine
108
+ // divergence): local differs from the remote tip AND from the merge base → honor
109
+ // the local commit rather than silently overwriting it with the remote tip.
110
+ if (localHash !== remoteHash && localHash !== baseHash) {
111
+ return 'local';
112
+ }
113
+ // Clean, or merely behind the remote tip → stream the canonical remote-tip bytes.
114
+ return 'remote';
115
+ }
116
+
117
+ /**
118
+ * Decide what the streamed-script drift preflight should do, from the classifier
119
+ * verdict plus which streamed files carry uncommitted edits. A checkout that is
120
+ * merely *behind* origin (verdict 'stale') is benign — the add streams the
121
+ * canonical remote-tip bytes (see streamedScriptSource), so it never blocks. The
122
+ * guard fires ('block') only for local content the remote tip does not have: an
123
+ * uncommitted (dirty) edit, or a genuine divergence. A committed local-ahead
124
+ * change is developer mode — warn, don't block.
125
+ *
126
+ * @param {Object} o
127
+ * @param {string} o.verdict classifyScriptDrift verdict
128
+ * @param {string[]} [o.staleFiles] files the classifier flagged (the diverged set)
129
+ * @param {string[]} [o.dirtyFiles] streamed files with uncommitted local edits
130
+ * @returns {{ block: boolean, reason: 'clean'|'behind'|'local-ahead'|'dirty'|'diverged', blockedFiles: string[] }}
131
+ */
132
+ function scriptDriftGuardAction({ verdict, staleFiles = [], dirtyFiles = [] }) {
133
+ if (verdict === 'diverged') {
134
+ return { block: true, reason: 'diverged', blockedFiles: staleFiles };
135
+ }
136
+ if (dirtyFiles.length > 0) {
137
+ return { block: true, reason: 'dirty', blockedFiles: dirtyFiles };
138
+ }
139
+ if (verdict === 'stale') {
140
+ return { block: false, reason: 'behind', blockedFiles: [] };
141
+ }
142
+ if (verdict === 'local-ahead') {
143
+ return { block: false, reason: 'local-ahead', blockedFiles: [] };
144
+ }
145
+ return { block: false, reason: 'clean', blockedFiles: [] };
146
+ }
147
+
148
+ module.exports = {
149
+ classifyScriptDrift,
150
+ streamedScriptSource,
151
+ scriptDriftGuardAction
152
+ };