Skip to content

Add core script initializer - #155

Open
t-kalinowski wants to merge 4 commits into
mainfrom
feat/script-init-core
Open

t-kalinowski wants to merge 4 commits into
mainfrom
feat/script-init-core

Conversation

@t-kalinowski

Copy link
Copy Markdown
Member

Summary

Adds ir init --file FILE to turn an existing R script into a self-describing, executable ir script. This separates the core initializer from the project-provenance work in #154 so the in-place rewrite and static dependency discovery can be reviewed and released independently. The branch is based directly on main.

Closes #149.

User-facing changes

  • Statically discovers direct package uses, omits packages supplied by the active R, and writes quoted bare package references.
  • Records the active R requirement, isolated: true, and the current UTC exclude-newer date.
  • Replaces any existing shebang with #!/usr/bin/env -S ir run and makes the script executable on Unix.
  • Refuses existing or malformed ir frontmatter, UTF-8 byte order marks, symbolic links, and non-regular files without modifying them.
  • Stages the replacement beside the source, syncs it, rechecks the source contents and current permissions, and atomically replaces the file.

Static analysis cannot find package names computed at runtime, so users should inspect the generated metadata.

Scope

This PR deliberately does not inspect renv.lock, pin installed package versions, or preserve repository or remote-source provenance. A nearby lockfile is ignored, and a public CLI regression covers that boundary. It does not add --no-project, project initialization, or Quarto initialization. Project-aware version and source conversion will be separate follow-up changes.

Concurrent-edit detection covers changes between the initial read and the final pre-rename recheck. Portable filesystems do not provide a content-aware compare-and-replace operation, so a writer racing the final atomic rename itself is outside this command's concurrency contract.

Internal changes

  • Embeds a small R driver for renv::dependencies() static scanning and active-R classification.
  • Reuses the existing tooling restart and crash-retry helpers, with private temporary result files.
  • Adds public CLI coverage for generated metadata, R release channels, file preservation, atomic replacement checks, permissions, symbolic links, line endings, direct execution, errors, help output, and the explicit lockfile boundary.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0aab09770b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread driver/init.R Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command to generate the frontmatter?

1 participant