Conversation
A source rewriter for the deploy write-back: `source-file.ts` parses a
construct's file (acorn for JavaScript, typescript-estree for TypeScript
and JSX) with its tokens and comments, and finds the one
`new <Class>('<logicalId>', { … })` whose class is bound by an import or
require from a checkly package. `literal-edit.ts` resolves a property path
inside that options literal, accepts only plain literals, renders JSON
data in the file's own quote style, indentation, trailing-comma habit and
line ending, and splices it in by byte range, so nothing else in the file
changes. Commas are located through the token list, so a comma inside a
comment cannot mislead a splice. Everything it cannot write without
guessing is refused with a reason.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e [RED-985] `planWriteBack` turns the changes a deploy plan attributes to the Checkly account (`origin: 'remote'` or `'both'`) into literal edits of the construct files, and `applyWriteBack` writes them through a temporary file renamed into place. A per-class table names the properties whose import-format spelling and construct spelling are both literals; values come from the entry's full-detail `before`. Refused with a reason: references, secrets and anything the redaction table blanks, hashed or masked values, CLI-spelled paths, sub-minute frequencies, lists the code also changed since the last deploy, a change whose own report disagrees with `before`, and a construct that cannot be found or edited. Every edit is re-parsed and read back before a file is accepted, and a file that changed since the plan was made is not overwritten. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ng to apply [RED-985] When the plan shows a resource edited in Checkly and the code can take the edit, the interactive prompt becomes a list: apply the changes, update the code with the values from Checkly and deploy nothing, or cancel. The cursor starts on Cancel, so Enter alone applies nothing, as the yes/no question's default did. Choosing the update lists what could not be written and why, rewrites the files, reports each property with its old and new value once the files hold it, and ends the run so the user can review the diff and deploy again. A failed write is reported as an error naming the files already rewritten. `--force`, `--dry-run`, read-only commands and the agent/CI envelope are unchanged; a command that supplies its own confirmation keeps it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The mode assertion compares against what the platform stored after chmod rather than a literal, since Windows keeps no group bits; the partial failure message is matched as text, since a Windows path's backslashes would be read as escapes by a RegExp. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an interactive
checkly deployshows a plan in which a resource was edited outside the project (a change withorigin: 'remote'or'both'), the prompt now offers a third choice next to applying and cancelling:Choosing it writes the account's current values into the construct source files, prints each property with its old and new value, lists everything it could not update with the reason, and ends the run without deploying so the user can review the diff and deploy again.
Only what can be written without guessing is written:
name,description,activated,muted,shouldFail,tags,locations, whole-minutefrequency, response-time and packet-loss thresholds, an API check's or URL monitor'srequest.*exceptassertions, a heartbeat monitor's flat period/grace written together with their units,environmentVariables, a group'sconcurrencyandapiCheckDefaults.*). The table is keyed by exact class; a spec asserts every exported check and group class is listed, so a new construct cannot fall back to a base class's rules.new <Class>('<logicalId>', { … })where<Class>is bound by an import or top-levelrequirefrom a checkly package (aliases such asCheckGroupare resolved through the namescheckly/constructsexports for the class), with the options as an object literal without spreads.typescriptas TypeScript check files already do.Everything else is skipped with a reason: helper values (
Frequency.EVERY_5M,RetryStrategyBuilder,AssertionBuilder), references to other resources, secrets and values the redaction table blanks (decided by difference between the raw and blankedbefore, so a blanked credential is never written),$hash/$maskedvalues, scripts and code bundles, CLI-spelled paths (shape-changes.ts), sub-minute frequencies, a list the code also changed since the last deploy (a whole-list rewrite frombeforewould erase the local addition), options built from variables or spreads, constructs created dynamically, and a change whose own reported value disagrees withbefore. A file that changed between planning and writing is refused.--force,--dry-runand the agent/CIconfirmation_requiredenvelope are unchanged; the choice exists only in a terminal and has no flag.Changes
services/write-back/source-file.ts: parse a construct file (both parsers, tokens and comments included) and find the construct call.services/write-back/literal-edit.ts: resolve a property path inside the options literal, render values in the file's style, splice by range.services/write-back/plan.ts: map remote changes to edits per construct class, apply the skip rules, verify by re-parsing, write atomically.helpers/command-preview.ts,commands/authCommand.ts:CommandTerminalPreview.alternatives; the interactive prompt becomes a select when alternatives exist (cursor on Cancel, so Enter alone applies nothing, as before).interactiveConfirmkeeps precedence.commands/deploy.ts: offers the alternative when the plan has remote changes; prints the applied and skipped lines.ai-context/references/configure.md: one bullet describing the choice.Accepted limitations
checkly.config.tsdefaults is written into the construct, not the config.Testing
services/write-back/__tests__/literal-edit.spec.ts(parsing, locating, resolving, rendering, splicing incl. comment cases and read-back),plan.spec.ts(table, skip rules, redactions, cross-check, aliases, atomic write),confirm-or-abort.spec.tsandconfirm-flow-deploy.spec.ts(prompt shape, the choice rewriting a real file and deploying nothing).Stacked on #1493 (RED-984). Docs: checkly/docs#516, to merge with the CLI release.
🤖 Generated with Claude Code