Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: init commands #112

Merged
merged 6 commits into from
Jan 6, 2025
Merged

feat!: init commands #112

merged 6 commits into from
Jan 6, 2025

Conversation

Yohe-Am
Copy link
Contributor

@Yohe-Am Yohe-Am commented Jan 4, 2025

  • Rewrites init commands from docs!: user manual + 0.3.0-rc.1 #106 in rust
  • Fixes issue with installer.sh
  • sophon object is now re-exported from mod.ts
  • BREAKING ghjk print config has been replaced with ghjk print serialized. print config now shows the cli config.
  • BREAKING: $GHJK_DIR has been renamed to $GHJKDIR. Difficult to support both at once due to usage in multiple langs including shell code.
  • Fixes issue with npmi where parent package.json was being resolved.
  • Bumps to version v0.3.0-rc.2
  • Support for import maps for cleaner starter experience
  • Adds GITHUB_TOKEN support for asdf_plugin_git port

Migration notes

  • Rename usages of $GHJK_DIR to $GHJKDIR.

  • Replace usage of ghjk print config with ghjk print serialized

  • The change comes with new or modified tests

  • Hard-to-understand functions have explanatory comments

  • End-user documentation is updated to reflect the change

Summary by CodeRabbit

Based on the comprehensive summary of changes, here are the high-level release notes:

  • New Features

    • Added new CLI commands for initialization and configuration management.
    • Enhanced TypeScript project setup with LSP support.
    • Improved command-line interface for printing configurations and system paths.
    • Introduced a new configuration file for Deno integration.
    • Added support for GitHub-related functionality in plugin management.
  • Improvements

    • Refactored configuration handling and export mechanisms.
    • Updated error handling and logging.
    • Improved file and path existence checks.
    • Enhanced modularity in command processing.
  • Bug Fixes

    • Corrected file permission and path resolution issues.
    • Fixed configuration serialization and export behaviors.
  • Documentation

    • Updated installation instructions.
    • Clarified command usage and configuration processes.
    • Revised environment variable declarations for clarity.
  • Chores

    • Migrated and restructured code across multiple modules.
    • Updated dependency and import management.
    • Renamed variables for consistency in scripts and configuration files.

This was linked to issues Jan 4, 2025
Copy link

coderabbitai bot commented Jan 4, 2025

📝 Walkthrough

Walkthrough

This pull request introduces substantial changes to the ghjk project, focusing on enhancing package configurations, updating CLI commands, and improving documentation. Key modifications include the addition of the cargo-bloat package in the lock file, updates to various task commands in GitHub Actions workflows, and restructuring of the README.md and manual documentation. The changes also involve the introduction of new CLI modules for initialization and printing configurations, along with significant updates to type definitions for better validation and error handling.

Changes

File/Group Change Summary
.ghjk/lock.json Added cargo-bloat package, restored asdf_plugin_git entry, modified mold_ghrel entry, updated installation sets and environment configurations
.github/actionlint.yaml Added new runner-labels configuration option
.github/workflows/tests.yml Updated task commands in test-pre-commit and test-e2e jobs
README.md, docs/manual.md Updated installation instructions, modified export statements from sophon to ghjk
deno.jsonc Added new tasks test-rust, modified existing tasks
.pre-commit-config.yaml Updated hook entry commands for ghjk-resolve and lock-sed hooks
ghjk.ts Restructured configuration management using ghjk object, consolidated environment and installation configurations
hack.ts Changed export handling for sophon to be directly from mod.ts
mod.ts Introduced sophon property with configuration and task execution methods
src/ghjk/cli/* Added new CLI modules for init, print, and sys commands with enhanced functionality
Type-related files Updated type definitions to use nullish() instead of optional(), improved type safety
install.sh, install/hook.* Renamed environment variables for consistency, improved installation scripts
tests/* Updated test cases to reflect changes in exports and commands

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant GhjkConfig
    participant Systems
    participant Tasks

    User->>CLI: Execute command
    CLI->>GhjkConfig: Load configuration
    GhjkConfig-->>CLI: Return configuration
    CLI->>Systems: Initialize systems
    Systems-->>CLI: System configurations
    CLI->>Tasks: Execute tasks
    Tasks-->>CLI: Task results
    CLI->>User: Display output
Loading

Possibly related PRs


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (17)
ghjk.ts (4)

14-14: Consider centralizing version constants.
Placing version constants like DENO_VERSION in a shared config module could help maintain them more systematically.


46-51: Conditional installation of mold is Linux-specific.
Consider adding a graceful fallback or explicit behavior for Windows if needed.


74-101: Verbose RUST_LOG setup.
This approach is fine, but consider extracting log modules to a helper or config if frequent changes are expected.


103-103: Caching V8 builds.
This is practical, but note that Windows is designated as NOT_SUPPORTED. If Windows support is needed, handle it gracefully.

tests/examples.ts (1)

1-28: Comprehensive new test file for example workflows.
This approach for end-to-end tests looks good. Consider adding negative or edge-case tests to further ensure reliability.

modules/types.ts (1)

14-19: Refined the blackboard schema to a record-based structure.
Adopting a dynamic record of string keys mapped to unknown provides flexible storage without prematurely constraining the data shape. This can simplify or complicate type safety, so enforce additional validation as needed.

tools/dev.ts (1)

52-52: Confirm necessity of commented-out code.

The lines for print serialized are commented out. If this code is no longer needed, consider removing it. Otherwise, add a brief comment explaining why it should remain commented for future reference.

src/ghjk/main.rs (1)

59-75: Enhanced error handling approach.

Wrapping the block_on(cli::cli()) in a match statement and filtering out specific backtrace lines provides a cleaner user experience by hiding boilerplate. However, be mindful that users may occasionally benefit from these lines when debugging elusive issues. Consider offering a configurable verbose mode to reveal the full backtrace when needed.

ports/npmi.ts (1)

86-87: Confirm the prefix-based install approach.

Using --prefix ${args.tmpDirPath} --no-fund in a single command string improves clarity, preventing lookups of parent directories. As a next step, consider whether npm ci might be a better option for deterministic installs if lockfiles are used.

ports/cargobi.ts (1)

178-184: Ensure bin folder existence and permission handling.

The code properly sets executable permissions on downloaded binaries. However, consider gracefully handling cases where the bin directory might not exist to avoid potential runtime errors. Also verify that changing file permissions is valid on all targeted platforms (e.g., Windows).

src/ghjk/host.rs (1)

115-115: Consistent file existence checks using file_exists utility.
This approach improves error distinction. Make sure to handle any concurrency scenario where multiple tasks may create or remove the file simultaneously.

modules/envs/mod.ts (1)

421-421: Clarify the envName conditional.

The conditional returns a string if there's only one element and an array otherwise. This might confuse consumers expecting a consistent type. Consider returning an array always or documenting why it's sometimes a string.

src/ghjk/cli.rs (2)

236-236: Typographical fix.

"discovored" in this docstring seems misspelled. Consider "discovered" for clarity.


345-379: Add documentation for the side effects.

This block writes a new ghjk.ts if it doesn't exist and then configures LSP. Document the side effects—like file creation—to help users anticipate changes to their workspace.

install.sh (2)

33-35: Enhance the warning message for version prefix.

While the warning is helpful, it could be more informative by explaining the implications or suggesting the correct format.

-WARN: Resolved version "$VERSION" doesn't have "v" prefix.
+WARN: Resolved version "$VERSION" doesn't have "v" prefix. This may affect asset resolution. Expected format: v0.1.0

96-96: Make the example command more generic.

The example uses a specific version (v0.1.10) which may become outdated. Consider using a placeholder version.

-$ curl -fsSL $INSTALLER_URL | PLATFORM=x86_64-unknown-linux-musl VERSION=v0.1.10 bash
+$ curl -fsSL $INSTALLER_URL | PLATFORM=x86_64-unknown-linux-musl VERSION=v<version> bash
docs/manual.md (1)

414-415: Use ARG value in Docker installation URL.

The Docker example defines GHJK_VERSION as an ARG but doesn't use it consistently in the URL.

-RUN curl -fsSL "https://raw.github.com/metatypedev/ghjk/$GHJK_VERSION/install.sh" \
+RUN curl -fsSL "https://raw.github.com/metatypedev/ghjk/\${GHJK_VERSION}/install.sh" \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eaf4d8 and 5504688.

⛔ Files ignored due to path filters (1)
  • .ghjk/deno.lock is excluded by !**/*.lock
📒 Files selected for processing (51)
  • .ghjk/lock.json (7 hunks)
  • .github/actionlint.yaml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • README.md (2 hunks)
  • deno.jsonc (1 hunks)
  • deps/cli.ts (0 hunks)
  • docs/manual.md (4 hunks)
  • examples/env_vars/ghjk.ts (1 hunks)
  • examples/envs/ghjk.ts (1 hunks)
  • examples/kitchen/ghjk.ts (1 hunks)
  • examples/many_installs/ghjk.ts (1 hunks)
  • examples/tasks/ghjk.ts (1 hunks)
  • examples/template.ts (1 hunks)
  • files/deno/bindings.ts (1 hunks)
  • files/deno/worker.ts (0 hunks)
  • files/mod.ts (1 hunks)
  • files/types.ts (1 hunks)
  • ghjk.ts (3 hunks)
  • hack.ts (1 hunks)
  • host/init/mod.ts (1 hunks)
  • host/types.ts (0 hunks)
  • install.sh (4 hunks)
  • mod.ts (1 hunks)
  • modules/envs/mod.ts (4 hunks)
  • modules/mod.ts (1 hunks)
  • modules/ports/mod.ts (1 hunks)
  • modules/ports/types.ts (1 hunks)
  • modules/tasks/deno.ts (1 hunks)
  • modules/tasks/mod.ts (1 hunks)
  • modules/tasks/types.ts (1 hunks)
  • modules/types.ts (2 hunks)
  • ports/cargobi.ts (1 hunks)
  • ports/npmi.ts (1 hunks)
  • src/deno_systems/bindings.ts (2 hunks)
  • src/deno_systems/types.ts (6 hunks)
  • src/ghjk/cli.rs (5 hunks)
  • src/ghjk/config.rs (3 hunks)
  • src/ghjk/host.rs (1 hunks)
  • src/ghjk/host/hashfile.rs (4 hunks)
  • src/ghjk/log.rs (2 hunks)
  • src/ghjk/main.rs (2 hunks)
  • src/ghjk/systems/deno.rs (1 hunks)
  • src/ghjk/utils.rs (1 hunks)
  • tests/envHooks.ts (1 hunks)
  • tests/examples.ts (1 hunks)
  • tests/hashfile.ts (2 hunks)
  • tests/tasks.ts (2 hunks)
  • tests/utils.ts (2 hunks)
  • tools/dev.ts (1 hunks)
  • utils/mod.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • files/deno/worker.ts
  • host/types.ts
  • deps/cli.ts
✅ Files skipped from review due to trivial changes (3)
  • .github/actionlint.yaml
  • files/mod.ts
  • utils/mod.ts
🔇 Additional comments (94)
ghjk.ts (15)

3-3: No issues found on the import statement.


4-4: No issues found on the blank line.


6-6: No issues found on the import statement.


12-12: Exporting the primary 'ghjk' object.
This aligns with the stated requirement to directly export ghjk.


13-13: No issues found on the blank line.


18-25: Main environment installation logic looks good.
No immediate concerns. This straightforward code appears aligned with the new approach.


26-26: No issues found on the blank line.


35-35: Configuration setup appears correct.
The parameters are consistent with the new design.


41-41: Defining the '_rust' environment.
No issues found; naming is consistent with typical environment usage.


54-54: Dev environment definition is valid.
No issues detected with the environment config.


57-57: Cargo-bloat installation.
This is a helpful debugging tool for Rust projects. Implementation looks correct.


63-64: CI environment inherits from '_rust'.
This is consistent with layering environment configurations.


67-67: Installing asdf plugin.
No issues found; the usage is straightforward.


148-148: Lock-sed task.
No issues found; the logic for updating version strings appears sound.


60-60: Ensure the path for RUSTY_V8_MIRROR is always valid.
If used in non-local environments or on CI, confirm that .dev directory is present or appropriately handled.

✅ Verification successful

Let me gather more information about the context and usage of this path.


Let me try one more verification to check for directory creation and CI setup.


The .dev directory is properly handled in the codebase

Based on the verification results, the .dev directory is well-managed:

  • It's explicitly created through tools/dev.ts which ensures the directory exists using ensureDir()
  • It's properly listed in deno.jsonc configuration
  • The README documents that this directory is used for development setup: "This will setup a separate installation at .dev"
  • The path is used consistently with import.meta.dirname which ensures correct relative path resolution
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching for references to RUSTY_V8_MIRROR across the codebase
rg -A 3 "RUSTY_V8_MIRROR"

Length of output: 344


Script:

#!/bin/bash
# Check for .dev directory references and creation
rg -A 3 "\.dev"

# Check for directory creation or setup scripts
fd -t f "setup|init|install" --exec rg -l "\.dev"

# Look for CI configuration files
fd -g "*ci*" -g "*.y*ml"

Length of output: 2393


Script:

#!/bin/bash
# Check for .dev directory creation in the codebase
ast-grep --pattern 'ensureDir'

# Look for CI configuration files with correct syntax
fd -g "*.yml" -g "*.yaml"

# Check the tools/dev.ts file content as it seems relevant
cat tools/dev.ts

Length of output: 2301

files/types.ts (5)

1-1: Importing zod from common dependencies.
No issues identified.


2-2: Importing module validators.
No issues identified.


4-9: Defining the serialized configuration schema.
This structure is clear and well-validated using Zod.


11-11: Exporting inferred type.
Good usage of zod.infer for typed schemas.


13-15: Default export object with serializedConfig.
This is a neat and concise way to expose the schema.

examples/env_vars/ghjk.ts (1)

3-3: Exporting 'ghjk' from the example.
This change aligns with the new design requiring direct export of the main object.

examples/template.ts (5)

3-3: Import statement for the file function.
No issues identified.


4-4: No concerns with the commented-out import.


6-6: No concerns with the comment.


7-7: Exporting 'ghjk' for TypeScript referencing.
Implementation looks correct.


15-15: Optional ports usage remains commented out.
No issues found.

modules/mod.ts (2)

1-1: Adopted type-only import ensures tree-shaking and clarity.
This change to use import type helps reduce runtime overhead and clarifies that CliCommand is only used in a type context, which is a good practice in Deno and TypeScript for improved performance.


3-3: Well-structured import for typed parameters.
Importing Blackboard, GhjkCtx, and ModuleManifest as types ensures that the runtime behavior remains minimal while retaining strong typechecking.

examples/envs/ghjk.ts (1)

1-1: Export re-aligned to the new ghjk object.
Replacing sophon with ghjk aligns with the PR’s objective to deprecate sophon in favor of ghjk. Make sure other references in documentation or code are updated accordingly.

examples/tasks/ghjk.ts (1)

1-1: Switched export from sophon to ghjk.
This change modernizes the tasks example, matching the new object-based approach across the codebase.

modules/types.ts (2)

20-20: Newly introduced Blackboard type.
Using zod.infer directly from the schema keeps types in sync with runtime validation, a recommended pattern for robust type safety.


34-34: Including blackboard in the default export.
Exposing the schema helps external modules rely on the same definitions for consistent usage. Confirm that consumers import only what they need to keep code usage minimal.

examples/many_installs/ghjk.ts (1)

1-1: Ensure downstream imports are updated accordingly.

You replaced the export of sophon with ghjk. Make sure dependent files that imported sophon from "../../hack.ts" are updated to avoid broken imports.

deno.jsonc (2)

4-5: Validate usage of new tasks.

You added "test-doc" and renamed "self" to "ghjk". Verify that any references to "test-doc" and "self" in the documentation or scripts are updated accordingly.


10-24: Check test exclusions for coverage gaps.

Excluding .dev, .ghjk/**, ./tools, or other directories may hide important test paths. Confirm that ignoring these files complements your CI steps and does not hamper coverage.

files/deno/bindings.ts (1)

23-31: Robust error handling checks.

These additional checks for mod.ghjk and mod.ghjk.sophon help detect misconfiguration early. Good job. Ensure that the error messages remain consistent with future refactors if you rename or restructure exports again.

tests/envHooks.ts (1)

83-83: Confirm correct object export in tests.

Switching from sophon to ghjk must mirror the rest of the codebase’s references to avoid confusion or broken tests.

tests/hashfile.ts (1)

54-60: Potential typo in environment variable name and logic verification.

Notice the environment variable GHJK_DENO_LOCKFILLE in this new test scenario. If the intention was GHJK_DENO_LOCKFILE, then this might be a spelling error. Please verify the upstream code that references this variable to ensure consistency in naming and correct behavior of the test.

src/ghjk/main.rs (2)

11-11: Re-exporting additional traits from color_eyre looks good.

Re-exporting Section and SectionExt broadens the functionality you can leverage in error handling. This seems beneficial and aligns with robust error reporting practices.


78-78: Introduction of itertools is straightforward.

Adding use itertools::Itertools; is a concise method for advanced iterator functionality. Ensure that all references to Itertools in downstream code are tested thoroughly.

modules/tasks/types.ts (1)

16-16: Allowing null for the env field.

Switching from .optional() to .nullish() broadens the permissible values. Verify downstream logic to ensure that null values are handled appropriately, preventing potential runtime errors where non-null assumptions might be made.

modules/tasks/mod.ts (1)

8-8: Consolidate type imports for maintainability.
Pulling Blackboard and ModuleManifest together from ../types.ts is a good step. Verify that all references to Blackboard from other locations have been updated to point here consistently to avoid confusion.

examples/kitchen/ghjk.ts (1)

5-8: Documentation aligns with new export approach.
The added comments and export const ghjk clarify usage. This consistent naming better reflects current architecture. Good job on adding the descriptive comment block.

src/ghjk/log.rs (2)

9-9: Clarify default error location settings in release builds.

By changing .unwrap_or(true) to .unwrap_or(cfg!(debug_assertions)), this now checks whether the code is compiled in debug mode before enabling location reporting. In release builds, it defaults to false. This may hide important info in production if unintentional. Verify that this aligns with the desired behavior for production-ready error reporting.


19-19: Ensure consistency with updated CLI commands.

The instructions now reference ghjk print config, whereas the high-level summary suggests that ghjk print serialized may be the new command. Ensure that this panic message is consistent with the final CLI naming conventions.

src/deno_systems/types.ts (6)

12-12: Validate handling for newly nullable fields.

Multiple fields have been updated to .nullish(). This expands flexibility but may risk runtime errors if the rest of the codebase assumes non-null values. Confirm that all consumers are updated to handle null or undefined correctly, particularly when performing string or boolean checks.

Also applies to: 27-27, 39-39, 41-45, 47-47, 49-50, 54-56, 58-60, 66-67, 69-70, 72-74, 76-77


86-86: Check for consistent nullish handling in flags and args.

flagsAndArgs now permits a nullish() value for each union member. Ensure downstream usage accounts for the possibility of null or undefined, preventing type errors or unintended behavior when flags or args are missing.


97-97: Verify function return types with nullish usage.

The action function can now return either a Promise<void> or void, and this entire return is .nullish(). Confirm that callers handle the possibility that there is no return (and no promise). This might complicate error handling if the function is unexpectedly omitted.


101-101: Consider naming consistency for action callback reference.

action_cb_key now allows null or undefined, which may complicate referencing this callback key at runtime. Ensure the code gracefully handles a missing key without raising unexpected errors.


105-105: Careful with sub_commands being nullish.

sub_commands may now be null or undefined. Confirm the code that enumerates or executes subcommands accounts for this possibility to avoid empty iteration or unexpected crashes.

Also applies to: 110-110


120-120: Align type definitions with usage patterns in subcommands.

Similar to the updates above, these exported types now support optional or null sub_commands. Validate references in the codebase to ensure no assumptions are made about subcommands always being defined.

Also applies to: 123-123, 127-127, 130-130

tests/tasks.ts (2)

125-125: Confirm removal of the old 'sophon' export references.

This change exports { ghjk } but also removes or bypasses any sophon exports. Review any tests or scripts still referencing sophon to ensure they are fully updated.


152-152: Exporting ghjk directly for dynamic variables.

Exporting ghjk here is consistent with the broader refactor. Just confirm that no references to a local ghjk overshadow this export in other modules.

src/deno_systems/bindings.ts (2)

23-27: Imports appear consistent with usage.

Importing Blackboard alongside GhjkCtx and ModuleManifest seems proper, aligning with the rest of the file's references. No issues found here.


47-50: Check for consistent usage of .nullish() vs. .optional().

Switching from .optional() to .nullish() is valid for allowing null in addition to undefined values. Ensure that any downstream code accounts for both null and undefined states properly. If only undefined is needed, .optional() might be simpler.

host/init/mod.ts (1)

109-114: Verify nullish array handling in Deno LSP settings.

Changing these array properties from .optional() to .nullish() looks correct for scenarios where the config might explicitly set them to null. Ensure that all references to enablePaths/disablePaths handle both null and undefined states without errors.

tests/utils.ts (2)

84-84: Confirm command usage switch.

You've replaced ghjk print config with ghjk print serialized. This aligns with the updated CLI changes. Confirm that no remaining references to the old command exist to avoid potential confusion.


166-166: Export refactor is consistent with PR objectives.

Replacing export const sophon with export const ghjk = file(confObj); aligns with the shift toward the ghjk object. Make sure no external code still relies on the previous sophon export.

src/ghjk/utils.rs (1)

242-252: Implementation and Error Handling Look Great

This new file_exists function provides a more intuitive approach by returning Ok(false) specifically for non-existent files. It helps clarify file status in edge cases. The logic is clear and neatly handles NotFound errors.

mod.ts (2)

113-116: Excellent Addition of sophon Property

Defining sophon as a Readonly<object> helps ensure immutability and safety for integration points. This is a solid design choice for bridging the host and ghjkfile worlds.


119-127: Documentation Tag Update

Switching from {@inheritdoc ...} to {@inheritDoc ...} is presumably for compatibility with your documentation tooling. Just confirm that the doc generator recognizes {@inheritDoc ...}.

src/ghjk/host/hashfile.rs (4)

8-9: New cli_config Field

Adding the CLI config to the HashObj will simplify consistency checks of user settings versus actual usage. This helps detect stale or mismatched configurations.


59-59: Cloning the Config

Cloning hcx.gcx.config to store in cli_config is straightforward. Just ensure the config is not overly large or frequently mutated.


78-83: Config Comparison for Staleness

Checking if self.cli_config != hcx.gcx.config is a clear approach to detect changed settings. Good use of early return to mark it stale.


96-96: Use of file_exists for Listed Files

Replacing direct try_exists calls with crate::utils::file_exists makes the code more consistent with centralized file handling and error distinctions.

src/ghjk/systems/deno.rs (1)

129-131: Error Handling Enhancement

Capturing exception_line.recv() and returning an immediate error clarifies failure conditions. This robust approach ensures any initialization exception is surfaced early and meaningfully.

src/ghjk/config.rs (3)

3-3: Great addition of Serialize, Deserialize, and comparison traits.
This enhancement expands the Config struct capabilities, allowing for easy serialization, deep copies, and straightforward comparisons.


144-144: Improved error handling for file existence check.
Switching to a unified utility function crate::utils::file_exists clarifies logic and may handle errors more consistently.


95-95: Confirm the updated BASE_URL.
Ensure that the new URL is correct and accessible for all runtime environments.

modules/ports/mod.ts (1)

31-31: Successful realignment of type import path.
The updated import path for Blackboard helps avoid a deeper dependency chain. Just confirm there’s no circular dependency introduced.

✅ Verification successful

Let me verify the potential circular dependencies by checking the contents of types.ts and its imports.


Let me check if there are any imports in the files that import from ports/mod.ts to complete the circular dependency verification.


Import path change is safe with no circular dependencies
The import of Blackboard type from ../types.ts in modules/ports/mod.ts is safe. After analyzing the imports:

  • types.ts only imports from deps/common.ts and utils/mod.ts
  • Files importing from ports/mod.ts don't create any circular paths back to types.ts
  • The Blackboard type is properly defined in types.ts as a zod record type
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check contents of ../types.ts usage references and ensure no circular dependencies.
rg -A 5 'import.*Blackboard' 

Length of output: 1568


Script:

#!/bin/bash
# Check contents of types.ts and its imports
cat modules/types.ts

Length of output: 962


Script:

#!/bin/bash
# Check for imports from ports/mod.ts
rg -l "from.*ports/mod" 

Length of output: 256

modules/ports/types.ts (1)

121-121: Flexible acceptance of null for versionSpecified.
Allowing null can be beneficial if that state is meaningful. Just ensure all consumers handle null consistently.

modules/envs/mod.ts (3)

11-11: No issues with the new import.

The additional import of Blackboard does not appear to introduce any conflicts, and it aligns well with the usage pattern in this module.


214-222: Ensure sensitive information is not logged.

These lines print environment details to the console. Verify that no sensitive information (e.g., credentials, tokens) is included in the output, considering user privacy and security best practices.


353-353: Check function signature changes.

Changing the parameter envName from a string to a string array impacts all calls to this function. Ensure that all call sites and related logic now provide an array of environment names.

src/ghjk/cli.rs (7)

134-138: Confirm unreachable logic.

Both Init and Deno subcommands are handled in try_quick_cli. These unreachable! calls rely on that logic. Ensure no future changes in the CLI inadvertently bypass this code block.


241-245: Appropriate reorganization for Init.

Introducing Init as a subcommand clarifies the workflow for new users. This separation helps maintain clarity between printing info and performing environment setup tasks.


255-265: Refined printing instructions.

The docstrings on these PrintCommands variants look concise and user-friendly. The addition of Serialized clarifies the difference between "real-time config" vs. "extracted & serialized config."


303-306: Check JSON serialization behavior.

Please ensure that any confidential values within the config do not appear when printing. If secret masking is needed, apply it here.


311-315: Consistent naming and structure.

Naming this print command Config helps keep it self-explanatory. Good practice to keep the usage consistent with other commands like GhjkdirPath or Serialized.


320-335: Well-organized subcommands for initialization.

Splitting out Ts and TsLsp clarifies how users can proceed with environment scaffolding and advanced LSP support. This distinction improves maintainability and discoverability.


337-343: Solid asynchronous structure in action.

Sequentially handling Ts vs. TsLsp keeps the logic clear. Good separation of concerns for the two tasks.

.pre-commit-config.yaml (2)

41-41: Targeting the correct ghjk task.

Switching from self to ghjk aligns with the new CLI structure. Ensure that all references to these commands are also updated across documentation or scripts.


46-46: Consistent naming with ghjk tasks.

Likewise, referencing ghjk x lock-sed matches the restructured tasks. This consistency simplifies maintenance.

.github/workflows/tests.yml (1)

45-45: Updated pre-commit test command.

Using deno task ghjk envs cook -t lock-sed aligns with the PR objective of centralizing commands under ghjk. Looks consistent with .pre-commit-config.yaml.

install.sh (2)

123-123: Good improvements to cleanup and execution!

The addition of temporary directory cleanup and the correct executable path usage are good improvements.

Also applies to: 131-131


82-83: Verify URL construction for all version formats.

The URL construction has been updated to handle versions with and without the "v" prefix. Let's verify this works for all cases.

✅ Verification successful

Let me check the actual releases to understand the correct URL pattern.


Let me check the actual assets in one of these releases to verify the naming pattern.


Let me try a different approach to check the release assets.


Let me check the actual install script to understand the URL construction better.


URL construction is correct and handles version prefixes properly

The URL construction in the install script is correct and handles versions with and without the "v" prefix appropriately:

  1. The script warns users when a version without "v" prefix is provided (lines 31-35)
  2. The asset name and download URL construction (lines 82-83) correctly uses the version as-is, which is the expected behavior because:
    • For latest version, it uses the redirected URL from GitHub which includes the correct version format
    • For explicit versions, it preserves the user's input format, showing a warning if "v" prefix is missing
  3. The script includes proper error handling with helpful messages if the download fails (lines 85-97)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Test URL construction for different version formats
echo "Testing URLs for different version formats..."
for version in "v0.1.0" "0.1.0" "v1.0.0-alpha" "1.0.0-beta"; do
  echo "Version: $version"
  echo "URL: https://github.com/metatypedev/ghjk/releases/download/$version/ghjk-$version-x86_64-unknown-linux-gnu.tar.gz"
  # Verify if the release exists
  curl -s -I "https://github.com/metatypedev/ghjk/releases/download/$version/ghjk-$version-x86_64-unknown-linux-gnu.tar.gz" | head -n 1
done

Length of output: 2071


Script:

#!/bin/bash
# Check the repository's releases
gh release list -L 5

Length of output: 205


Script:

#!/bin/bash
# Check assets for a specific release
gh release view v0.2.1 --json assets | jq -r '.assets[].name'

Length of output: 63


Script:

#!/bin/bash
# Check the full release information
gh release view v0.2.1

Length of output: 872


Script:

#!/bin/bash
# Check the install script
cat install.sh

Length of output: 4758

README.md (2)

68-69: Clear documentation of the new export requirement.

The note clearly explains the expectation to export the ghjk object, which aligns with the breaking changes mentioned in the PR objectives.


49-49: Ensure version consistency across documentation.

The installation command uses a specific version (v0.3.0-rc.1). Ensure this version is consistent with the latest release and other documentation references.

✅ Verification successful

Let me check if there are any other version references that might be inconsistent.


Version references are consistent across the documentation

The version v0.3.0-rc.1 is consistently referenced across:

  • Installation commands in both README.md and docs/manual.md
  • Import statements in README.md
  • Docker configuration in docs/manual.md
  • Package version in Cargo.toml (as "0.3.0-rc.1")

All version references are aligned with the same release version, showing proper version consistency throughout the documentation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check version consistency across documentation
echo "Checking version references..."
rg -n "v0.3.0-rc.1" --type md

Length of output: 619


Script:

#!/bin/bash
# Check for other version patterns in markdown files
echo "Checking for other version patterns..."
rg -n "v\d+\.\d+\.\d+" --type md

# Check version in Cargo.toml
echo -e "\nChecking version in Cargo.toml..."
rg -n "^version\s*=" Cargo.toml

Length of output: 782

docs/manual.md (1)

Line range hint 1-500: Documentation thoroughly updated for breaking changes.

The manual has been comprehensively updated to reflect the new ghjk object usage and removal of sophon object, with consistent examples and clear explanations throughout.

.ghjk/lock.json (5)

299-335: LGTM: cargo-bloat configuration is well-structured.

The configuration for cargo-bloat is properly set up with:

  • Correct version pinning (0.12.1)
  • Required build dependencies (cargo_binstall_ghrel and rust_rustup)
  • Appropriate version specifications and components

496-496: LGTM: CI environment configuration is appropriate.

The new "ci" environment reuses the _rust configuration, which is a good practice for maintaining consistency between development and CI environments.


357-358: LGTM: Install set modifications maintain consistency.

The changes to install sets are consistent across main, _rust, and dev environments. The addition and reordering of dependencies maintain proper reference integrity.

Also applies to: 367-367, 371-372, 379-379, 383-383, 387-388


1109-1144: LGTM: cargobi_cratesio configuration provides good platform coverage.

The cargobi_cratesio port configuration:

  • Supports a comprehensive range of platforms
  • Has proper build dependencies (cargo_binstall_ghrel, rust_rustup)
  • Correctly specifies the cargo-bloat crate

1053-1071: Verify platform compatibility for mold_ghrel.

The mold_ghrel configuration is limited to Linux platforms only (aarch64-linux, x86_64-linux). Ensure this limitation is intentional and documented.

Run this script to check for any usage on unsupported platforms:

✅ Verification successful

Platform limitation for mold_ghrel is intentional and correctly implemented

The platform limitation for mold_ghrel to Linux (aarch64 and x86_64) is intentional and properly implemented:

  1. The code in ports/mold.ts explicitly defines supported platforms using osXarch(["linux"], ["aarch64", "x86_64"]).
  2. This aligns with mold's nature as it's a Linux-specific linker (https://github.com/rui314/mold).
  3. The implementation correctly handles platform-specific artifacts by constructing appropriate download URLs for Linux builds.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for mold usage in platform-specific code

# Search for mold references in the codebase
rg -l 'mold' | while read -r file; do
  # Extract any platform-specific markers in the same file
  echo "=== $file ==="
  rg -A 5 -B 5 '(windows|darwin|macos|freebsd|netbsd)' "$file"
done

Length of output: 1219


Script:

#!/bin/bash
# Let's check the mold.ts port file content to understand the implementation
cat ports/mold.ts

# Also check if there are any platform-specific checks or documentation
rg -l "mold_ghrel" | xargs rg -A 5 -B 5 "mold_ghrel"

Length of output: 2888

hack.ts Outdated Show resolved Hide resolved
modules/tasks/deno.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (33)
ghjk.ts (3)

18-25: Pin dependency versions for reproducible builds.

Using generic version references for pre-commit, vale, and Deno can lead to non-deterministic installs if a new version introduces breaking changes.


54-60: Development environment layering is sensible.

Inheriting _rust ensures consistency, but consider pinning version for cargo-bloat to prevent unexpected updates.


74-101: Logging configuration is verbose.

The multi-line array for RUST_LOG is valid but can be streamlined. Consider extracting the module-level log settings into a helper if it grows further.

examples/template.ts (1)

15-15: Commented-out port references.

Leaving commented lines may cause confusion. Consider removing or adding a short note explaining why these lines are commented.

modules/types.ts (2)

14-19: Transition to record-based blackboard is reasonable.

By switching from an object-based approach to a record-based schema, the code gains flexibility in defining arbitrary keys. This approach is simpler to maintain if the schema is expected to grow. Ensure you have enough validation for any nested objects that might go beyond a single level.


34-34: Include usage examples for blackboard in documentation.

You’ve added blackboard to the default export, but without additional explanatory comments or usage examples, new contributors might be unclear about how to fully leverage this feature. Consider expanding the docstrings or the project’s README to cover typical use cases of blackboard.

deno.jsonc (1)

4-4: Validate doc tests coverage.
The new "test-doc" command is a welcome addition. Consider extending it to run across more comprehensive targets if your documentation or code comments exist in deeper folders or hidden directories.

files/deno/bindings.ts (1)

23-30: Enhance error clarity for missing exports.
Throwing an error if ghjk or ghjk.sophon is missing makes debugging straightforward. Consider adding potential causes and next steps in the error messages, such as instructions on updating a particular file or verifying the import paths.

tools/dev.ts (1)

52-52: Remove or restore commented-out lines to maintain clean code.

Consider removing these commented-out lines if they are no longer needed:

-// await $`${ghjkDataDir.join("ghjk").toString()} print serialized`
-//   .cwd(devDir.toString())
-//   .clearEnv()
-//   .env(env);
-
-// await $`${ghjkDataDir.join("ghjk").toString()} envs cook`
-//   .cwd(devDir.toString())
-//   .clearEnv()
-//   .env(env);
src/ghjk/main.rs (1)

78-78: Ensure library usage is strictly necessary.

use itertools::Itertools; is introduced, presumably for .join. Just confirm you aren’t bringing in an entire library for a single method that could be replaced by standard library code. If you foresee more functionality from itertools, keep it; otherwise, you might reduce dependencies.

hack.ts (1)

Line range hint 11-16: Consider clarifying the immutability rationale.

Exporting these objects frozen ensures they cannot be mutated by malicious callers, which is good. However, it might cause confusion for consumers who expect to adjust the objects. Adding brief inline comments or docstrings clarifying why these exports are immutable can improve maintainability.

src/deno_systems/types.ts (10)

39-45: Ensure boolean nullish fields are handled gracefully.
Properties like required and global might now be null. If the logic expects strictly true or false, ensure it handles null without error.


47-50: Refine help-related fields to avoid confusion.
Allowing help and long_help to be null might complicate UI scaffolding or CLI usage. Consider using defaults or placeholders to minimize user confusion if documentation is absent.


54-56: Recommend consistent default values for array fields.
long_aliases and visible_long_aliases can be null. If array operations are expected, ensure the code initializes these fields to an empty array where appropriate.


58-60: Clarify short alias usage when null.
To prevent edge cases, consider a default empty array for short_aliases and visible_short_aliases. This will reduce potential null checks.


69-70: Hiding commands must handle null booleans.
When hide is null, the CLI might not know whether to show or hide commands. Consider using a default fallback.


72-74: Ensure fallback strings for about/help fields.
These descriptive fields going null may confuse users seeking more context. Provide fallback text for better user experience.


76-77: Nullish record types might introduce missing arguments/flags logic.
If args or flags is null, ensure the surrounding logic dynamically checks existence.


97-97: Check callback usage with .nullish().
If action can be null, the CLI may skip essential logic. Ensure you handle or alert if no callback is set.


110-110: Binded sub-commands might be null as well.
Double-check any references or enumerations of sub-commands in the CLI to avoid runtime null dereferences.


123-123: Potential mismatch with interface usage.
sub_commands for CliCommandX is now optional or null. Validate any library code that consumes CliCommandX to handle both.

tests/tasks.ts (1)

152-152: Made ghjk export public.
This allows external modules or other tests to import and reuse. Verify any existing references to the old local definition are removed.

ports/npmi.ts (1)

86-87: Clarify command usage and comment placement for maintainability.
The inline comment clarifies why --prefix is used, which is good. Carefully placing comments just before the command improves readability.

host/init/mod.ts (1)

109-114: Allowing explicit null for VSCode config paths
Switching from .optional() to .nullish() allows these properties to be set to null instead of simply omitted. Ensure that all relevant code paths and documentation are updated so users know they can explicitly set these fields to null.

ports/cargobi.ts (1)

178-184: Setting file permissions to 0o700
The added code sets downloaded binaries to 0o700. If multiple users need execution privileges, consider using 0o755. Otherwise, this is fine for single-user scenarios.

src/ghjk/cli.rs (5)

210-210: Consider robust error handling or logging here.
While this line nicely delegates to commands.action(config).await?, if there's any chance of partial failures or incomplete initialization, you could catch & log more context around potential initialization issues before returning the error.


236-236: *Spelling correction.
The comment has a minor spelling issue: "discovored" → "discovered".

-    /// Print different discovored or built values to stdout
+    /// Print different discovered or built values to stdout

241-245: Improve comment clarity.
The comment is concise, but clarifying what "ghjk usage" entails (e.g., creating a default ghjk.ts file or setting up directory structure) could be beneficial for new contributors.


255-265: Consistent doc comments.
Each doc comment is clear, but they can be improved by adding a consistent concluding statement or ensuring uniform capitalization (some lines start uppercase, some don't). For example, "Print the path" vs. "Print the extracted."


303-315: Graceful fallback for missing config.
When serialized_config is None, we return false. Consider printing a short message acknowledging that there's no serialized config. This helps the user understand why nothing was printed.

-            None => false,
+            None => {
+                eprintln!("No serialized config found. Nothing to print.");
+                false
+            },
install.sh (3)

33-35: Clarify if this warning is mandatory.
Alerting the user when the version lacks a 'v' prefix can be helpful, but consider clarifying whether or not the process will auto-append 'v' or require the user to cancel and re-run. This improves user experience by offering a clear next action.


96-96: Clarify environment variables in usage prompt.
It’s great that you demonstrate the PLATFORM and VERSION variables in this fallback message. Adding a second example for macOS or Windows could further guide inexperienced users.


131-131: Consider fallback if Deno is unavailable.
If the extracted executable or the Deno environment is missing or fails to run, you might want to catch that failure to provide a user-friendly error.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eaf4d8 and 5504688.

⛔ Files ignored due to path filters (1)
  • .ghjk/deno.lock is excluded by !**/*.lock
📒 Files selected for processing (51)
  • .ghjk/lock.json (7 hunks)
  • .github/actionlint.yaml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • README.md (2 hunks)
  • deno.jsonc (1 hunks)
  • deps/cli.ts (0 hunks)
  • docs/manual.md (4 hunks)
  • examples/env_vars/ghjk.ts (1 hunks)
  • examples/envs/ghjk.ts (1 hunks)
  • examples/kitchen/ghjk.ts (1 hunks)
  • examples/many_installs/ghjk.ts (1 hunks)
  • examples/tasks/ghjk.ts (1 hunks)
  • examples/template.ts (1 hunks)
  • files/deno/bindings.ts (1 hunks)
  • files/deno/worker.ts (0 hunks)
  • files/mod.ts (1 hunks)
  • files/types.ts (1 hunks)
  • ghjk.ts (3 hunks)
  • hack.ts (1 hunks)
  • host/init/mod.ts (1 hunks)
  • host/types.ts (0 hunks)
  • install.sh (4 hunks)
  • mod.ts (1 hunks)
  • modules/envs/mod.ts (4 hunks)
  • modules/mod.ts (1 hunks)
  • modules/ports/mod.ts (1 hunks)
  • modules/ports/types.ts (1 hunks)
  • modules/tasks/deno.ts (1 hunks)
  • modules/tasks/mod.ts (1 hunks)
  • modules/tasks/types.ts (1 hunks)
  • modules/types.ts (2 hunks)
  • ports/cargobi.ts (1 hunks)
  • ports/npmi.ts (1 hunks)
  • src/deno_systems/bindings.ts (2 hunks)
  • src/deno_systems/types.ts (6 hunks)
  • src/ghjk/cli.rs (5 hunks)
  • src/ghjk/config.rs (3 hunks)
  • src/ghjk/host.rs (1 hunks)
  • src/ghjk/host/hashfile.rs (4 hunks)
  • src/ghjk/log.rs (2 hunks)
  • src/ghjk/main.rs (2 hunks)
  • src/ghjk/systems/deno.rs (1 hunks)
  • src/ghjk/utils.rs (1 hunks)
  • tests/envHooks.ts (1 hunks)
  • tests/examples.ts (1 hunks)
  • tests/hashfile.ts (2 hunks)
  • tests/tasks.ts (2 hunks)
  • tests/utils.ts (2 hunks)
  • tools/dev.ts (1 hunks)
  • utils/mod.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • deps/cli.ts
  • host/types.ts
  • files/deno/worker.ts
✅ Files skipped from review due to trivial changes (3)
  • files/mod.ts
  • utils/mod.ts
  • .github/actionlint.yaml
🔇 Additional comments (80)
ghjk.ts (11)

3-4: Imports look straightforward.

No issues identified.


6-6: Validate usage of switchMap.

Ensure that downstream callers are adapted to the newly introduced switchMap import.


12-13: Central export looks good.

Declaring ghjk as the main export is consistent with the PR’s objective of shifting to the ghjk namespace.


14-14: Confirm Deno version.

DENO_VERSION = "2.1.2" might be a placeholder or future version. Verify that this aligns with the actual release you intend to use.


35-35: Configuration object structure is clear.

Nice job specifying defaultEnv, enableRuntimes, and allowedBuildDeps.


41-41: Environment _rust configuration approved.

No immediate concerns with installing Rust-related tools here.


46-51: Conditional Mold installation.

For Linux systems, confirm that replacing ld with Mold aligns with your deployment environment. It can require additional housekeeping for cross-compilation scenarios.


63-64: Basic CI environment configuration looks fine.

No specific issues to address.


67-67: ASDF plugin usage note.

Confirm the plugin's stability and availability to avoid CI failures if the repository is ever removed or renamed.


103-103: Potential missing error handling in cache-v8.

If a download fails, the task proceeds without fallback or retry logic. Encourage robust error handling for production reliability.


148-148: lock-sed task version references.

Keeping GHJK_VERSION in sync is critical for generating consistent artifacts. Current approach appears workable.

files/types.ts (1)

1-15: Schema definition and Zod usage look solid.

Ensuring the serializedConfig structure matches the codebase’s needs is crucial. Consider documenting the blackboard field usage for clarity.

examples/env_vars/ghjk.ts (1)

3-3: Exporting ghjk ensures external usage.

This matches the new pattern of centralizing logic under ghjk.

examples/template.ts (2)

3-4: Module import alignment.

The updated relative import path from "../mod.ts" is correct for this file’s location.


7-7: Exporting ghjk from template.

This follows the standardized approach for examples, reducing confusion for new users.

tests/examples.ts (1)

1-28: New E2E test cases look promising.

Your CustomE2eTestCase type is suitably extending E2eTestCase. Ensure coverage includes additional scenarios for multi-environment interactions.

modules/mod.ts (1)

1-3: Adopt consistent type usage across the module.

Nice work converting imports to type-only references and introducing the Blackboard type parameter in loadConfig. This aligns well with the broader shift toward improved type safety in the codebase. Please verify that other references to GhjkCtx and ModuleManifest are also updated to ensure consistency in all related files.

examples/envs/ghjk.ts (1)

1-1: Re-export aligns with the new ghjk namespace.

Replacing sophon with ghjk as the primary export is consistent with the documented shift in the PR objectives. This helps unify the code under the ghjk namespace. Please confirm that all dependent files and references have also been updated.

examples/tasks/ghjk.ts (1)

1-1: Modernized export from hack.ts.

Exporting ghjk instead of sophon matches the new design. Good job making sure the tasks remain compatible with this updated export. Double-check the tasks in other example directories to avoid any missed references to the old sophon name.

examples/many_installs/ghjk.ts (1)

1-1: Ensure consistent usage of ghjk throughout the codebase.
Replacing sophon with ghjk is a breaking change for downstream consumers. Make sure all references to sophon have been updated accordingly to avoid dead references or runtime errors.

Run the script below to search for any remaining references to sophon in the codebase:

deno.jsonc (2)

5-5: Rename the task or clarify usage if necessary.
Renaming "self" to "ghjk" is a good move for clarity, but ensure that team members or CI pipelines relying on the old "self" task are updated.


10-24: Test configuration exclusions look appropriate.
The introduction of "test": { "exclude": [...] } helps skip directories that are often irrelevant for automated testing. However, verify that crucial test or utility files aren’t unintentionally excluded.

Use this script to confirm that there are no test files in the excluded directories:

✅ Verification successful

Let me gather more information to check if any of these TypeScript files are test-related.


Let me do one final check to look for test files in a different way since the previous command didn't show all test files.


Test exclusions are appropriate and don't skip any test files

Based on the verification:

  • The excluded directories don't contain any test files - the TypeScript files found in ./src/ghjk/js/ are type definitions and mock implementations
  • The files in ./tools/ are development utilities for checking and development environment setup
  • The actual test files are located in the tests/ directory, which is not excluded from testing
  • Most excluded paths are either build artifacts (.deno-dir, target, vendor), development tools (.dev, tools), or specific implementation files that don't need testing (bindings.ts)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Ensure no relevant test files exist in excluded directories
for e in .git .dev install.ts ./target .ghjk .deno-dir vendor ./src/deno_systems/bindings.ts ./src/ghjk/js ./files/deno/bindings.ts ./tools; do
  fd --extension ts --search-path "$e"
done

Length of output: 2858


Script:

#!/bin/bash
# Check content of TypeScript files found in excluded directories
echo "=== Content of ./src/ghjk/js/mock.sfx.ts ==="
cat "./src/ghjk/js/mock.sfx.ts"
echo -e "\n=== Content of ./src/ghjk/js/runtime.d.ts ==="
cat "./src/ghjk/js/runtime.d.ts"
echo -e "\n=== Content of ./tools/check.ts ==="
cat "./tools/check.ts"
echo -e "\n=== Content of ./tools/dev.ts ==="
cat "./tools/dev.ts"

# Also search for test files in the project root to understand test patterns
echo -e "\n=== Looking for test files in the project ==="
fd -e ts "test.*" -t f

Length of output: 4418


Script:

#!/bin/bash
# Search for test-related files using ripgrep
echo "=== Files containing test functions or Deno.test ==="
rg -l "Deno\.test|function test" --type ts

# Check if any of the excluded TypeScript files contain test-related code
echo -e "\n=== Checking test content in excluded files ==="
rg "Deno\.test|function test" ./src/ghjk/js/mock.sfx.ts ./src/ghjk/js/runtime.d.ts ./tools/check.ts ./tools/dev.ts

Length of output: 419

tests/envHooks.ts (1)

83-83: Confirm the new export references in tests.
Exporting ghjk instead of sophon aligns with the breaking changes. Double-check that the test environment doesn’t rely on removed or deprecated APIs.

src/ghjk/main.rs (2)

11-11: Confirm necessity of additional re-exports.

You are now re-exporting Section and SectionExt from color_eyre. This can be beneficial if you plan to attach context to errors. Otherwise, consider removing any unused re-exports:


59-75: Good error handling and user-friendly backtrace elision.

The match statement that collects and filters out backtrace-related lines is a neat approach. It improves user experience by providing a cleaner error output. Great work!

modules/tasks/types.ts (1)

16-16: Verify schema logic for nullable environment property.

Changing .optional() to .nullish() allows the env property to be explicitly set to null (vs. merely omitted). Ensure downstream code handles null properly to avoid unexpected edge cases.

modules/tasks/mod.ts (1)

8-8: Validate the lifecycle of bb: Blackboard.

Passing the blackboard into loadConfig() implies it plays a key role in configuration logic. Confirm the blackboard remains valid throughout the module’s lifecycle. If bb can be undefined or stale, you may want guards or fallback logic.

modules/tasks/deno.ts (1)

77-77: Ensure correct nesting for sophon under ghjk.

Referencing mod.ghjk.sophon implies that sophon is meant to remain accessible under ghjk. Confirm that your refactor or removal of sophon in other files doesn’t break this call site. Consider renaming it if it’s purely historical.

examples/kitchen/ghjk.ts (1)

5-8: Great introduction to the new ghjk export.

Declaring the purpose of this export clarifies its importance in the hosting workflow. As a minor improvement, you could expand on how consumers should use it, perhaps linking relevant docs or referencing other usage examples to guide new contributors.

src/ghjk/log.rs (1)

9-9: Consider verifying non-debug build behavior.
Modifying display_location_section to .unwrap_or(cfg!(debug_assertions)) can hide important location data in non-debug builds, potentially hindering debugging in production.

src/deno_systems/types.ts (7)

Line range hint 12-27: Check for potential downstream impact of nullish fields in cliArg.
By changing value_name and value_hint to .nullish(), the code must now explicitly handle null. This can introduce runtime errors in code expecting a string or a defined enum value.


66-67: Aliases now allow null values.
If your CLI logic processes aliases, ensure null fields are handled or replaced by an empty array to prevent errors in command resolution.


86-86: Nullish union in flagsAndArgs.
Allowing union fields to be null might simplify some usage but can complicate validation. Confirm the rest of the code properly interprets null values.


101-101: action_cb_key can be null.
If your system references this key elsewhere, confirm the logic gracefully handles absent values.


120-120: Definition drift for sub_commands?: CliCommand[] | null;
Ensure the TypeScript type system in other modules still matches the new signature.


127-127: CliCommandBinded can lack sub-commands
If logic previously assumed the presence of sub_commands, ensure it’s updated to handle null.
[approve]


130-130: CliCommandBindedX matches the same approach
Enabling null for sub-commands ensures consistency across interfaces.

tests/tasks.ts (1)

125-125: Switched from exporting sophon to ghjk.
This aligns with the PR's stated deprecation of sophon. Ensure all references in the test harness are updated for consistency.

src/deno_systems/bindings.ts (3)

23-27: Importing Blackboard looks correct.
No objections — ensure it is consistently used throughout the code.


47-47: Switching ghjkfile to .nullish()
This change broadens accepted values to include null. Verify all callers properly handle null, not just undefined.


50-50: Switching deno_lockfile to .nullish()
As above, verify downstream code gracefully handles null references.

tests/utils.ts (2)

84-84: Updated command usage to ghjk print serialized
This aligns with the PR’s note that the old command ghjk print config was replaced. Confirm that any other references or documentation are updated accordingly.


166-166: Exporting ghjk object
Replacing export const sophon with export const ghjk follows the shift away from the old sophon export. Looks good.

mod.ts (3)

119-119: Documentation annotation update looks good.
Switching to {@inheritDoc} preserves clarity and consistency.


123-123: Documentation annotation update looks good.
Switching to {@inheritDoc} preserves clarity and consistency.


127-127: Documentation annotation update looks good.
Switching to {@inheritDoc} preserves clarity and consistency.

src/ghjk/host/hashfile.rs (4)

8-9: Validate any sensitive fields in cli_config.
Storing CLI configuration for serialization is useful, but be cautious about exposing sensitive data. Consider documenting or verifying that no secrets end up in logs or artifacts.


59-59: Consider the potential impact of cloning large or sensitive configs.
Cloning the entire config might be expensive if it's large or could risk exposing sensitive fields if not carefully managed.


78-83: Double-check partial equality logic.
Comparing self.cli_config to hcx.gcx.config may invalidate the cache on any minor difference. Ensure this matches the intended behavior (e.g., ignoring fields that do not affect staleness).


96-96: File existence check approach is fine.
Switching to a custom file_exists function can centralize and standardize file-check error handling.

src/ghjk/systems/deno.rs (1)

129-131: Robust error handling addition.
Catching exceptions from the exception_line channel before the worker’s exit code ensures that errors are reported promptly. Good improvement.

src/ghjk/config.rs (3)

3-3: Confirm added traits align with config structure.
Adding Serialize, Deserialize, Clone, PartialEq, and Eq is convenient, but validate that no ephemeral or device-specific fields will break equality or serialization.


95-95: Updated BASE_URL is consistent with the new repository location.
This aligns with the switch from metatypedev/metatype to metatypedev/ghjk.


144-144: Centralized file existence check is good.
Using file_exists in place of try_exists keeps the codebase consistent and possibly improves error handling.

modules/ports/mod.ts (1)

31-31: Import path update
The new relative path for the Blackboard import looks correct and aligns with the shift in your codebase. Ensure other references to ../../host/types.ts have also been addressed or removed to maintain consistency.

modules/ports/types.ts (1)

121-121: Changing from optional to nullish
Switching versionSpecified from .optional() to .nullish() can clarify the intended schema by allowing explicit null instead of just omitting the field. Make sure you handle null values in the consuming code if any usage could break under null.

src/ghjk/host.rs (1)

115-115: Migration to file_exists
Replacing tokio::fs::try_exists with crate::utils::file_exists centralizes file-existence checks. Confirm that exceptions or non-200 statuses are handled gracefully by file_exists for all usage scenarios (e.g., permission errors).

modules/envs/mod.ts (4)

11-11: Expanded import
Importing Blackboard alongside GhjkCtx and ModuleManifest indicates a deeper usage of the type definitions from ../types.ts. Check that any references to the older import path have been updated to avoid confusion or duplication.


214-222: Verifying expanded environment string array usage
The function call to showableEnv now passes an array of environment name strings (ecx.keyToName[envKey] ?? [envKey]). Be sure that showableEnv can handle one or multiple names properly and that the return type meets all call-site expectations.


353-353: showableEnv parameter change
showableEnv now accepts an array of strings for envName. Check downstream usage to confirm that all-consuming code expects an array (or a single string fallback).


421-421: Conditional return of single or multiple env names
Returning envName[0] when the length is less than 2 could cause subtle differences in data formatting or JSON output. If these outputs are consumed elsewhere, ensure that code interpreting envName can handle both string and array types.

src/ghjk/cli.rs (2)

134-138: Double-check unreachable logic.
Calling unreachable!() is a valid safeguard if you are certain that the code path is never reached (as the quick_cli presumably intercepts these subcommands). However, if there's a chance the control flow could arrive here due to future alterations or unexpected usage, consider gracefully handling the error or logging an appropriate message.


320-380: Overall structure looks good.
The InitCommands enum and related methods provide a well-structured approach to subcommand handling. It might be worthwhile to add expanded logging for each operation (e.g., when creating or skipping the creation of ghjk.ts, or verifying existing contexts) to make the user experience more traceable.

.pre-commit-config.yaml (2)

41-41: Adjusted hook entry looks correct.
Pointing the ghjk-resolve hook to deno task ghjk p resolve aligns with the newly introduced naming changes. Ensure that any references in your documentation or scripts referencing the old self command are updated accordingly.


46-46: Updated hook entry is consistent with the rename.
Similarly, referencing ghjk x lock-sed is now consistent with the broader naming convention. Looks good.

.github/workflows/tests.yml (1)

45-45: Command rename to 'ghjk' is consistent.
Renaming the deno task self envs cook -t lock-sed call to deno task ghjk envs cook -t lock-sed keeps it in sync with the new naming. No issues spotted here.

install.sh (3)

82-83: Ensure backward compatibility with earlier tags.
By removing the 'v' prefix in the asset names, older releases that use 'v' in their filenames may no longer be accessible. If supporting older versions is important, consider an alternate fallback or a version check.


101-101: Verbosity is beneficial.
Using -xvzf instead of -xzf helps the user see what’s being extracted. Good change.


123-123: Removing temporary directory ensures cleanliness.
This helps mitigate potential clutter. Good practice.

README.md (2)

49-49: LGTM! Improved shell safety.

Adding quotes around the URL in the curl command prevents potential issues with URL interpretation in different shells.


68-69: Breaking change: Update API export.

The change from exporting sophon to exporting ghjk is a breaking change that will require updates to existing configurations.

Let's check for potential impacts:

src/ghjk/utils.rs (1)

242-252: LGTM! Well-implemented error handling.

The new file_exists function provides improved error handling by:

  • Explicitly handling the NotFound case
  • Using proper error propagation
  • Including clear documentation
docs/manual.md (3)

20-20: LGTM! Consistent shell safety improvement.

The addition of quotes around the URL matches the change in README.md, maintaining consistency across documentation.


47-48: Breaking change: API export update in documentation.

The documentation correctly reflects the breaking change from sophon to ghjk export.


95-95: Breaking change: CLI command update.

The command has been changed from ghjk print config to ghjk print serialized. This is a breaking change that will require users to update their scripts.

Let's check for potential impacts:

.ghjk/lock.json (5)

299-335: LGTM: New cargo-bloat package configuration.

The configuration for cargo-bloat v0.12.1 is properly structured with all necessary build dependencies.


604-653: LGTM: Restored asdf_plugin_git configuration.

The restored configuration is complete with proper build and resolution dependencies, and platform support.


496-496: LGTM: Added CI environment configuration.

Good practice to reuse the existing Rust environment configuration for CI, ensuring consistency across environments.


357-358: LGTM: Installation sets updated consistently.

The installation sets have been updated consistently across all environments (main, rust, and dev) with the new identifiers.

Also applies to: 367-372, 379-388


1053-1071: Verify platform support limitations.

The mold_ghrel configuration only supports Linux platforms (aarch64-linux, x86_64-linux). Please confirm if this platform limitation is intentional, as most other entries support a broader range of platforms.

Run the following script to check if mold supports other platforms:

✅ Verification successful

Platform limitation for mold is intentional and correct

The platform limitation to Linux (aarch64 and x86_64) is intentional and correct based on the source code of the mold port. The implementation in mold.ts explicitly defines the supported platforms using osXarch(["linux"], ["aarch64", "x86_64"]), which aligns with the upstream mold linker that is specifically designed for Linux systems. This is not a limitation of the configuration but rather reflects the actual platform support of the tool itself.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if mold supports other platforms in the codebase

# Search for mold platform support documentation or configuration
rg -A 5 "mold.*platforms" 

Length of output: 27


Script:

#!/bin/bash
# Let's try a broader search for mold-related configurations and documentation
rg -i "mold" .ghjk/ -A 5

# Also search for any documentation about platform support
fd README -e md -X cat {} 

Length of output: 6013


Script:

#!/bin/bash
# Let's check the mold.ts port file to understand the platform limitations
fd mold.ts -X cat {}

# Also search for any other mold-related configurations
rg -i "mold.*supported" 

Length of output: 2501

tests/hashfile.ts Outdated Show resolved Hide resolved
src/deno_systems/types.ts Show resolved Hide resolved
@Yohe-Am Yohe-Am changed the title fix!: init commands feat!: init commands Jan 5, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (18)
src/ghjk/host/hashfile.rs (2)

8-9: Fix typo in documentation comment

The documentation comment contains a typo: "serializatin" should be "serialization".

-    /// The cli config used during serializatin
+    /// The cli config used during serialization

The addition of cli_config field aligns well with the PR's objective of enhancing configuration management.


Line range hint 1-256: Consider documenting the CLI config invalidation strategy

The addition of CLI config to cache invalidation logic represents a significant architectural decision. Consider documenting:

  1. What aspects of CLI config changes should trigger invalidation
  2. The rationale behind treating all config changes as cache-invalidating
  3. Any performance implications of frequent config changes

This documentation would help maintain the codebase as it evolves and ensure the caching strategy remains effective.

src/ghjk/cli/sys.rs (2)

50-50: Correct the typographical error in the error message.

Within the string "system commannd conflict...", there is an extra 'n' in "commannd". Consider fixing this minor typographical error to maintain clarity and consistency in user-facing error messages.

-                    "system commannd conflict under name {:?} for modules {conflict:?} and {id:?}",
+                    "system command conflict under name {:?} for modules {conflict:?} and {id:?}",

17-36: Consider further error handling for subcommand recursion.

The inline function inner(cmd: SystemCliCommand) recursively creates subcommands and may fail if invalid subcommand data exists. While the wrap_err_with calls help identify which system has failed, consider surfacing more specific error details, such as the subcommand name or path, to expedite debugging.

src/ghjk/cli/init.rs (3)

32-62: Review the fallback strategy for creating and overwriting ghjk.ts.

When the ghjk.ts file does not exist, this code writes a template file. However, if a partial or corrupted file exists (e.g., from a prior interruption), this logic doesn't attempt to repair or ask for user confirmation before overwriting. You might consider a prompt or version check to avoid accidental overwrites in edge cases.


64-161: Refine user prompts and give more context in confirmations.

Several user prompts (e.g., “Configure deno lsp...”, “Mark file with @ts-nocheck?”) default to true. In some scenarios, a user might skip reading the prompt, accept defaults, and inadvertently make undesired changes. Consider clarifying the consequences of each change in the prompt text or requiring explicit confirmation from the user, to reduce the chance of misconfiguration.


226-236: Avoid informal messages in error handling.

Error messages like "Confused :/" may undermine the professional feel of the CLI and complicate support or debugging. Prefer more descriptive language to direct users toward a resolution.

-                "{} detected in \"deno.disablePaths\". Confused :/",
+                "{} was detected in \"deno.disablePaths\" and cannot be enabled simultaneously.",
src/ghjk/cli/print.rs (1)

55-62: Ensure consistent CLI output on missing serialized config.

When the serialized_config is None, the code returns false but provides no further message. Consider notifying the user why no serialized config was printed, or clarify the usage instructions if printed via help text.

deno.jsonc (1)

4-6: Document the new test tasks in your README or dev guide.

The "test-doc" and "test-rust" tasks are welcomed additions that expand coverage to doc tests and Rust tests. Ensure these are explained in your project documentation so team members understand how and when to run them.

src/ghjk/main.rs (1)

58-74: Consider enhancing error handling.

While the current error handling is good, it could be improved by:

  1. Using structured error types instead of string manipulation
  2. Leveraging color_eyre's built-in formatting capabilities

Consider this alternative implementation:

-    match tokio::runtime::Builder::new_current_thread()
-        .enable_all()
-        .build()?
-        .block_on(cli::cli())
-    {
-        Ok(code) => Ok(code),
-        Err(err) => {
-            let err_msg = format!("{err:?}");
-            let err_msg = err_msg.split('\n').filter(
-                |&line|
-                line != "Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it." 
-                && line != "Run with RUST_BACKTRACE=full to include source snippets."
-            ).join("\n");
-            println!("{err_msg}");
-            Ok(std::process::ExitCode::FAILURE)
-        }
-    }
+    tokio::runtime::Builder::new_current_thread()
+        .enable_all()
+        .build()
+        .wrap_err("Failed to build runtime")?
+        .block_on(cli::cli())
+        .map_err(|e| {
+            eprintln!("{:?}", e.strip_backtrace());
+            std::process::ExitCode::FAILURE
+        })
install.sh (1)

82-83: Consider validating version format.

While the warning about version format is helpful, consider adding validation to ensure the version format is correct before constructing the URLs.

+if ! echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+'; then
+  echo "Error: Invalid version format. Expected format: v0.1.0" >&2
+  exit 1
+fi
 ASSET="$NAME-$VERSION-$PLATFORM"
 DOWNLOAD_URL="$RELEASE_URL/download/$VERSION/$ASSET.$EXT"
README.md (1)

Line range hint 160-170: Simplify the example code.

While the code is correct, it could be more concise and clearer for new users.

-export { sophon } from "$ghjk/mod.ts";
-import { file } from "$ghjk/mod.ts";
+import { file } from "$ghjk/mod.ts";
 
-const confStr = `
-${serializedSecConf}
-`;
-const confObj = JSON.parse(confStr);
-const ghjk = file(confObj);
+const ghjk = file({
+  // Your configuration here
+});
tests/utils.ts (2)

84-86: Add error handling for command execution.

While the command change from print config to print serialized is correct, the command execution lacks error handling.

-  await $`ghjk print serialized`
-    .cwd(tmpDir.toString())
-    .clearEnv()
-    .env(env);
+  try {
+    await $`ghjk print serialized`
+      .cwd(tmpDir.toString())
+      .clearEnv()
+      .env(env);
+  } catch (error) {
+    throw new Error(`Failed to print serialized config: ${error.message}`);
+  }

160-160: Enhance type safety for module imports.

Consider using a more type-safe approach for the module imports.

-export { sophon } from "$ghjk/mod.ts";
+export type { Sophon } from "$ghjk/mod.ts";
+export { sophon } from "$ghjk/mod.ts";
ghjk.ts (2)

15-16: Consider centralizing version management.

Version constants like DENO_VERSION and RUST_VERSION should be centralized in a separate configuration file for easier maintenance.

Consider moving these to a versions.ts file:

// versions.ts
export const VERSIONS = {
  deno: "2.1.2",
  rust: "1.82.0",
} as const;

75-102: Simplify RUST_LOG configuration.

The current RUST_LOG configuration is verbose and hard to maintain. Consider using a more structured approach.

-  .vars({
-    RUST_LOG: [
-      "info",
-      Object.entries({
-        "TRACE": [
-          // "denort",
-          // "deno",
-        ],
-        "DEBUG": [
-          "runtime",
-          "tokio",
-        ],
-        // ... more entries
-      }).flatMap(([level, modules]) =>
-        modules.map((module) => `${module}=${level.toLowerCase()}`)
-      ),
-    ].join(),
-  });
+  .vars({
+    RUST_LOG: createLogConfig({
+      defaultLevel: "info",
+      modules: {
+        runtime: "DEBUG",
+        tokio: "DEBUG",
+        "deno::npm": "INFO",
+        // ... more entries
+      }
+    })
+  });

Consider adding a helper function:

function createLogConfig({ defaultLevel, modules }: {
  defaultLevel: string;
  modules: Record<string, string>;
}): string {
  return [
    defaultLevel,
    ...Object.entries(modules)
      .map(([module, level]) => `${module}=${level.toLowerCase()}`)
  ].join(',');
}
mod.ts (1)

136-140: Consider using a more robust state management approach.

The use of module-level variables for state management could lead to issues in more complex scenarios.

Consider using a singleton pattern or context object:

-const builder = new Ghjkfile();
-let args: FileArgs | undefined;
+class GhjkState {
+  private static instance: GhjkState;
+  private builder: Ghjkfile;
+  private args?: FileArgs;
+
+  private constructor() {
+    this.builder = new Ghjkfile();
+  }
+
+  public static getInstance(): GhjkState {
+    if (!GhjkState.instance) {
+      GhjkState.instance = new GhjkState();
+    }
+    return GhjkState.instance;
+  }
+}
docs/manual.md (1)

217-217: Fix grammar issues in documentation.

There are some minor grammatical issues that should be addressed:

Apply these changes:

-Inheritance is additive on most env properties
+Inheritance is additive to most env properties
-environment won't be activated for that CWD nor will any changes occur
+environment won't be activated for that CWD, nor will any changes occur

Also applies to: 424-424

🧰 Tools
🪛 LanguageTool

[uncategorized] ~217-~217: The preposition ‘to’ seems more likely in this position.
Context: ...n` environment. Inheritance is additive on most env properties and allows easy com...

(AI_HYDRA_LEO_REPLACE_ON_TO)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5504688 and ecfedaa.

📒 Files selected for processing (31)
  • .ghjk/lock.json (9 hunks)
  • .github/workflows/tests.yml (2 hunks)
  • README.md (2 hunks)
  • deno.jsonc (1 hunks)
  • docs/installation-vars.md (1 hunks)
  • docs/manual.md (7 hunks)
  • examples/env_vars/ghjk.ts (1 hunks)
  • examples/kitchen/ghjk.ts (1 hunks)
  • examples/template.ts (1 hunks)
  • files/deno/bindings.ts (2 hunks)
  • files/mod.ts (2 hunks)
  • ghjk.ts (3 hunks)
  • hack.ts (1 hunks)
  • host/init/mod.ts (2 hunks)
  • install.sh (5 hunks)
  • mod.ts (3 hunks)
  • modules/envs/mod.ts (3 hunks)
  • modules/envs/posix.ts (2 hunks)
  • modules/tasks/deno.ts (1 hunks)
  • src/ghjk/cli.rs (6 hunks)
  • src/ghjk/cli/init.rs (1 hunks)
  • src/ghjk/cli/print.rs (1 hunks)
  • src/ghjk/cli/sys.rs (1 hunks)
  • src/ghjk/host.rs (2 hunks)
  • src/ghjk/host/hashfile.rs (4 hunks)
  • src/ghjk/main.rs (2 hunks)
  • src/ghjk/utils.rs (2 hunks)
  • tests/examples.ts (1 hunks)
  • tests/hashfile.ts (1 hunks)
  • tests/tasks.ts (1 hunks)
  • tests/utils.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • modules/envs/posix.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • host/init/mod.ts
  • modules/tasks/deno.ts
  • files/deno/bindings.ts
  • files/mod.ts
  • examples/env_vars/ghjk.ts
  • examples/kitchen/ghjk.ts
  • hack.ts
  • tests/examples.ts
  • .github/workflows/tests.yml
  • src/ghjk/host.rs
  • tests/tasks.ts
  • modules/envs/mod.ts
  • examples/template.ts
  • tests/hashfile.ts
🧰 Additional context used
🪛 Gitleaks (8.21.2)
.ghjk/lock.json

406-406: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
docs/manual.md

[uncategorized] ~217-~217: The preposition ‘to’ seems more likely in this position.
Context: ...n` environment. Inheritance is additive on most env properties and allows easy com...

(AI_HYDRA_LEO_REPLACE_ON_TO)


[uncategorized] ~424-~424: Possible missing comma found.
Context: ...environment won't be activated for that CWD nor will any changes occur on changing ...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (26)
src/ghjk/host/hashfile.rs (3)

96-96: Verify behavior of file_exists utility function

The code switches from tokio::fs::try_exists to crate::utils::file_exists. This change could affect async behavior or error handling.

Let's check the implementation:

✅ Verification successful

Implementation of file_exists is safe and maintains async behavior

The implementation of crate::utils::file_exists is a thin wrapper around tokio::fs::try_exists that maintains the same async behavior and error handling:

pub async fn file_exists(path: &Path) -> Result<bool, std::io::Error> {
    match tokio::fs::try_exists(path).await {
        Ok(true) => Ok(true),
        // ...
    }
}

The function is consistently used across the codebase for file existence checks in async contexts:

  • In config initialization
  • During CLI init operations
  • For ghjkfile validation
  • In hashfile verification
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check implementation of file_exists utility
ast-grep --pattern 'fn file_exists($$$) {
  $$$
}'

# Check for other usages of this utility
rg 'file_exists' -C 2

Length of output: 2691


78-83: Verify Config comparison implementation

The code uses direct comparison (!=) which implies Config implements PartialEq. This is crucial for correct cache invalidation.

Let's verify the implementation:

✅ Verification successful

Config comparison is properly implemented

The Config struct in src/ghjk/config.rs correctly derives PartialEq and Eq traits, ensuring that the direct comparison (!=) used in the cache invalidation check is safe and will work as intended. The implementation is derived automatically which is appropriate for a struct containing standard types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if Config properly implements PartialEq
ast-grep --pattern 'impl $$ for Config {
  $$$
}'

# Check for custom implementations of comparison
rg 'impl.*PartialEq.*for Config' -A 5

Length of output: 91


Script:

#!/bin/bash
# Let's try a different approach to find Config struct and its derives
ast-grep --pattern '#[derive($$$)]
struct Config'

# Also search for manual implementations
rg 'struct Config' -A 10

# Search for any Config comparison usage
rg '\.config.*==' -A 2
rg '\.config.*!=' -A 2

Length of output: 1987


Script:

#!/bin/bash
# Let's check for PartialEq derive or implementation specifically for the Config in config.rs
rg -B 5 'struct Config' src/ghjk/config.rs

# Check if there are any derives for this struct
ast-grep --pattern '#[derive($$$)]
struct Config {
  $$$
}'

# Let's also check for any Debug or Display implementations that might show how equality is handled
rg 'impl.*(Debug|Display|PartialEq).*for Config' src/ghjk/config.rs

Length of output: 285


59-59: Verify if cloning the config is necessary

The code clones the entire config object. Consider if a reference would suffice here, depending on the lifetime requirements.

Let's check the Config struct definition and its usage patterns:

✅ Verification successful

Let me gather more information about the Config struct and its usage.


Let me gather more specific information about how the Config is used in the hashfile context.


Based on the gathered information, I can now provide the final response:

Clone is necessary for HashObj serialization

The cli_config is a field in the HashObj struct that needs to maintain its own copy of the configuration for serialization and staleness checking purposes. The clone is necessary because:

  1. It's used to detect configuration changes by comparing the stored config with the current one in is_stale() method
  2. The HashObj needs to own its data for serialization and persistence
  3. The config is used across async boundaries and needs to outlive the original reference

Relevant code evidence:

  • HashObj::is_stale() compares stored cli_config with current config
  • cli_config is used in a struct that needs owned data for serialization
  • The config comparison is used for invalidation of cached data
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Config struct definition and impl blocks
ast-grep --pattern 'struct Config {
  $$$
}'

# Check for other places where Config is cloned
rg '\.clone\(\)' -C 2 | grep -C 2 'config'

Length of output: 4965


Script:

#!/bin/bash
# Find Config struct definition
ast-grep --pattern 'struct Config'

# Check where Config is used as reference vs owned
rg 'Config' -A 3 -B 1

# Check for impl blocks of Config
ast-grep --pattern 'impl Config'

Length of output: 68482


Script:

#!/bin/bash
# Check the struct containing cli_config
ast-grep --pattern 'struct $_ {
  $$$
  cli_config: $$$
  $$$
}'

# Check where cli_config is used
rg 'cli_config' -A 2 -B 2

# Check if Config is used as reference elsewhere
rg '&Config' -A 2 -B 2

Length of output: 6423

src/ghjk/cli/sys.rs (1)

61-93: Validate subcommand usage.

The action_for_match function uses swap_remove on current.sub_commands. This effectively removes subcommands by name from the map. If the subcommand needs to remain in the list for reuse, consider a different approach (e.g., _remove_entry or referencing subcommands without removing them). Otherwise, confirm that reusing these subcommands won't be required after this match action.

src/ghjk/utils.rs (1)

242-252: Good practice handling file existence checks.

Returning Ok(false) specifically for NotFound or non-existent files is a clear and robust approach. This differentiates genuine I/O errors from a simple absence of the file, improving user experience and error handling flows.

deno.jsonc (1)

11-25: Verify excluded paths for testing.

Excluding directories like "./target", ".ghjk/**", and ".deno-dir/**" may be intentional. However, confirm that no relevant coverage is missed. Some subdirectories (e.g., ./src/ghjk/js) might hold important testable modules if usage patterns change.

docs/installation-vars.md (1)

5-6: LGTM! Clear and well-documented variable changes.

The renaming of variables improves clarity:

  1. GHJK_VERSIONVERSION: Simplifies the name while maintaining context
  2. GHJK_SHARE_DIRGHJK_DATA_DIR: Better reflects the directory's purpose
src/ghjk/main.rs (1)

3-4: LGTM! Enhanced module exports.

The addition of JsonExt and expanded color_eyre exports improve the module's functionality while maintaining good organization.

Also applies to: 10-10

install.sh (4)

28-28: LGTM! Consistent variable naming.

The rename from GHJK_INSTALL_EXEC_DIR to GHJK_INSTALL_EXE_DIR maintains consistency with other changes in the codebase.


32-35: LGTM! Helpful version prefix warning.

Good addition of a warning message when the version lacks the "v" prefix, helping users understand potential asset resolution issues.


101-101: LGTM! Improved extraction and cleanup.

Good improvements:

  1. Added verbose flag to tar extraction for better debugging
  2. Added cleanup step to remove temporary directory

Also applies to: 122-123


131-131: Verify executable path handling.

Ensure that the executable is accessible in the installation directory before running it.

Let's verify the executable permissions and path handling:

✅ Verification successful

Executable path handling is properly implemented

The installation script has proper checks and validations for the executable path:

  • Creates the installation directory if it doesn't exist: if [ ! -d "${GHJK_INSTALL_EXE_DIR}" ]; then mkdir -p "$GHJK_INSTALL_EXE_DIR"; fi
  • Verifies write permissions: if [ -w "${GHJK_INSTALL_EXE_DIR}" ]; then
  • Sets executable permissions before moving: chmod +x "$TMP_DIR/$EXE"
  • Moves the executable only after these checks: mv "$TMP_DIR/$EXE" "$GHJK_INSTALL_EXE_DIR"
  • Provides clear error messages if the directory is not writable
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar executable path handling patterns in the codebase
rg --type shell 'GHJK_INSTALL_EXE_DIR.*\$EXE' -A 5 -B 5

Length of output: 87


Script:

#!/bin/bash
# Check for executable path handling patterns
rg 'GHJK_INSTALL_EXE_DIR.*\$EXE'

# Check the context around the installation directory setup
rg 'GHJK_INSTALL_EXE_DIR' -A 5 -B 5

# Check if there's any validation or checks before using the executable
rg 'test.*\$GHJK_INSTALL_EXE_DIR'

Length of output: 6638

README.md (1)

49-49: LGTM! URL quoting improvement.

Adding quotes around the URL in the curl command is a good practice to handle special characters safely.

ghjk.ts (1)

3-13: ⚠️ Potential issue

Remove @ts-nocheck and fix type issues.

Using @ts-nocheck is not recommended as it bypasses TypeScript's type checking. Consider fixing the underlying type issues instead.

src/ghjk/cli.rs (3)

10-12: LGTM! Good modularization of CLI components.

The separation into distinct modules (init, print, sys) improves code organization and maintainability.


Line range hint 110-164: Verify error handling in system command processing.

The refactored system command handling includes proper error handling with lockfile writes, which is good. However, ensure that all error cases are properly propagated.

✅ Verification successful

The previous command didn't yield results, possibly due to an incorrect path. Let's verify the correct path and search for error handling patterns in the broader codebase.


Let's examine the specific system command processing functions mentioned in the code to verify their error handling.


Error handling in system command processing is properly implemented

Based on the code analysis, the error handling in the system command processing is comprehensive and well-implemented:

  1. The commands_from_systems and action_for_match functions both return Res<T> type, indicating proper error propagation
  2. All error cases in the CLI flow properly call systems.write_lockfile_or_log().await before propagating errors
  3. Different types of errors are handled appropriately:
    • Command parsing errors (try_get_matches)
    • System command errors (commands_from_systems)
    • Action matching errors (action_for_match)
    • Special handling for specific Clap error kinds (InvalidSubcommand, InvalidValue, etc.)

The error handling ensures that the lockfile is properly written in all error cases before exiting or propagating the error, which maintains system state consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential error handling gaps in command processing
rg -A 3 'Err\(' src/ghjk/cli/sys.rs

Length of output: 37


Script:

#!/bin/bash
# Let's check if the file exists first and then try different paths
fd cli.rs

# Then let's search for error handling patterns in the codebase
rg -A 3 'Err\(' src/ghjk/

Length of output: 8714


Script:

#!/bin/bash
# Let's check the sys module's error handling specifically
rg -A 3 'commands_from_systems|action_for_match' src/ghjk/

# And let's look for the implementation of these functions
ast-grep --pattern 'pub async fn commands_from_systems'
ast-grep --pattern 'pub async fn action_for_match'

Length of output: 1179


137-139: Ensure init command documentation is updated.

The init command handling has been modified with new unreachable cases. This is a breaking change as mentioned in the PR objectives.

Run this script to check if all documentation is updated:

Also applies to: 213-213

✅ Verification successful

Documentation is already up to date

After reviewing the code and documentation, I can confirm that the documentation for the init command is properly maintained:

  1. The Init command in QuickComands enum is documented with "/// Setup your working directory for ghjk usage"
  2. The InitCommands enum in init.rs has proper documentation for both subcommands:
    • Ts is documented with "Create a starter typescript ghjkfile (ghjk.ts) in the current directory"
    • TsLsp is documented with "Interactively configure working directory for best LSP support of ghjk.ts"

The unreachable case mentioned in the review is actually a runtime protection, not a change in the command's functionality or interface, so it doesn't require documentation updates. The command's behavior and documentation remain consistent with its implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for init command documentation
rg -A 5 'init.*command' docs/

Length of output: 31


Script:

#!/bin/bash
# Let's check for init command documentation in different locations and formats
# Check README and other markdown files
fd -e md -x rg -l 'init.*command|initialization.*command'

# Check for init command in CLI help text or source code
rg -i "init.*command|initialization.*command" src/

# Check specifically in the CLI module and related files
fd "cli\.(rs|md)" -x rg -l "init"

# Look for any init-related documentation
rg --type rust "Init.*{" src/

Length of output: 705


Script:

#!/bin/bash
# Let's check the actual enum definition and its documentation
rg -A 10 "QuickComands.*{" src/

# Check for any help text or documentation strings related to init
rg -i "help.*init|init.*help" src/

# Look for command descriptions or documentation
rg "description.*init" src/

# Check the init module more thoroughly
cat src/ghjk/cli/init.rs

Length of output: 10134


Script:

#!/bin/bash
# Let's check the QuickCommands enum definition
rg -A 10 "enum QuickComands" src/

# Check for any command-line help text
rg -A 5 "struct Cli" src/

Length of output: 1739

mod.ts (2)

147-172: LGTM! Well-structured sophon object implementation.

The frozen sophon object with clear separation of concerns between config retrieval and task execution is a good design choice.


333-350: Good addition of file creation protection.

The implementation prevents multiple invocations of the file function, which could lead to inconsistent states. The error message is clear and helpful.

docs/manual.md (2)

20-20: LGTM! Improved installation command formatting.

The addition of quotes around the URL in the curl command improves reliability and readability.


44-51: Update documentation to reflect breaking changes.

The documentation has been updated to reflect the new ghjk object approach, replacing the sophon object. This aligns with the PR objectives.

.ghjk/lock.json (5)

299-335: LGTM: New cargo-bloat package configuration.

The new entry for cargo-bloat is properly configured with:

  • Version: 0.12.1
  • Required build dependencies: cargo_binstall_ghrel and rust_rustup
  • Appropriate version specifications and component configurations

Line range hint 357-388: LGTM: Installation sets are consistently updated.

The installation sets (main, _rust, and dev) have been updated consistently to include the new packages while maintaining the existing configuration structure.


Line range hint 604-1144: LGTM: Port configurations are well-structured.

The port configurations include:

  • Properly restored asdf_plugin_git configuration
  • Comprehensive platform support
  • Correct dependency specifications

406-406: False positive: Not an API key.

The flagged value follows the standard format used for environment keys throughout the configuration file.

🧰 Tools
🪛 Gitleaks (8.21.2)

406-406: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


Line range hint 433-497: LGTM: Environment configurations with CI addition.

The new 'ci' environment is properly configured to reuse the _rust environment settings, maintaining consistency across environments.

Run this script to verify environment consistency:

✅ Verification successful

LGTM: Environment configurations are consistent

After examining the lock.json file, I can confirm that:

  1. The new 'ci' environment correctly reuses the '_rust' environment configuration (ID: bciqm23m6kl7m2mdbjmcjoleysme4gwtkzeeqrbyrpydpm3fvx3bn25a)
  2. All environments (main, _rust/ci, and dev) have identical RUST_LOG settings with the value "info,runtime=debug,tokio=debug,deno::npm=info,deno::file_fetcher=info,swc_ecma_transforms_base=info,swc_common=info,h2=info,rustls=info,mio=info,hyper_util=info"
  3. The dev environment has an additional RUSTY_V8_MIRROR variable, which is expected
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all environments have consistent RUST_LOG settings

# Search for all RUST_LOG configurations
rg -A 1 '"key": "RUST_LOG",' | grep -A 1 '"val":'

Length of output: 51


Script:

#!/bin/bash
# Let's try a different approach to verify environment configurations
# Search for RUST_LOG configurations with more context and without requiring exact JSON formatting

rg -U "RUST_LOG.*val.*info,runtime=debug" .ghjk/

Length of output: 50


Script:

#!/bin/bash
# Let's try a simpler approach to find the lock.json file first and then examine its content
fd "lock.json" .ghjk/ --exec cat {}

Length of output: 37207

src/ghjk/utils.rs Show resolved Hide resolved
src/ghjk/cli/print.rs Outdated Show resolved Hide resolved
src/ghjk/main.rs Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ghjk.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (10)
deno.jsonc (2)

2-5: Consider more specific import paths

The current import mappings might be too broad and potentially confusing:

  1. "ghjk/": "/" maps to the root directory which could lead to unintended imports
  2. Having both "ghjk/" and "ghjk" might cause confusion about which to use

Consider using more specific paths:

  "imports": {
-   "ghjk/": "/",
+   "ghjk/": "./src/",
    "ghjk": "./mod.ts"
  },

15-29: Standardize path formats in exclusions

The test exclusions are comprehensive but have inconsistent path formats:

  • Some paths use "./" prefix (./target, ./src/...)
  • Others use relative paths without prefix (vendor/**)

Standardize the path format for better maintainability:

  "test": {
    "exclude": [
      ".git",
      ".dev",
      "install.ts",
-     "./target",
+     "target",
-     "./src/deno_systems/bindings.ts",
+     "src/deno_systems/bindings.ts",
-     "./src/ghjk/js",
+     "src/ghjk/js",
-     "./files/deno/bindings.ts",
+     "files/deno/bindings.ts",
-     "./tools"
+     "tools"
    ]
  },
docs/manual.md (6)

40-42: Update import statement to match the new API.

The export statement has been updated to reflect the new API, but the comment above it needs to be updated for consistency.

-// all ghjk.ts files are expected to export this special `sophon` object
+// all ghjk.ts files are expected to export the `sophon` object from ghjk
 export { sophon } from "ghjk";
 import { file } from "ghjk";

110-113: Fix grammar in cache invalidation section.

The sentence structure needs improvement for clarity.

-Configuration used by the ghjk cli
+Configuration used by the ghjk CLI,

-This doesn't cover everything though and the `ghjk.ts` implementation generally assumes a declarative paradigm of programming.
+This doesn't cover everything though, and the `ghjk.ts` implementation generally assumes a declarative paradigm of programming.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~112-~112: Possible missing comma found.
Context: ...ghjk cli This doesn't cover everything though and the ghjk.ts implementation genera...

(AI_HYDRA_LEO_MISSING_COMMA)


128-129: Improve clarity in lockfile description.

The sentence about version numbers needs better structure.

-The lockfile is what the different systems of ghjk use to store transient information that needs to be tracked across serializations.
-Currently, this is mainly used by the ports system to retain version numbers resolved during installation which is important for the basic need of reproducibility.
+The lockfile is what the different systems of ghjk use to store transient information that needs to be tracked across serializations.
+Currently, this is mainly used by the ports system to retain version numbers resolved during installation, which is important for the basic need of reproducibility.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~129-~129: Possible missing comma found.
Context: ... retain version numbers resolved during installation which is important for the basic need o...

(AI_HYDRA_LEO_MISSING_COMMA)


216-216: Fix preposition usage in inheritance description.

The sentence about inheritance properties needs a preposition change.

-Inheritance is additive on most env properties and allows easy composition.
+Inheritance is additive to most env properties and allows easy composition.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~216-~216: The preposition ‘to’ seems more likely in this position.
Context: ...n` environment. Inheritance is additive on most env properties and allows easy com...

(AI_HYDRA_LEO_REPLACE_ON_TO)


423-424: Fix grammar in non-interactive shell documentation.

The sentence about CWD activation needs better punctuation.

-This means that the default environment won't be activated for that CWD nor will any changes occur on changing directories.
+This means that the default environment won't be activated for that CWD, nor will any changes occur on changing directories.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~423-~423: Possible missing comma found.
Context: ...environment won't be activated for that CWD nor will any changes occur on changing ...

(AI_HYDRA_LEO_MISSING_COMMA)


484-537: Fix grammar issues in configuration documentation.

Several grammar issues need to be addressed in the new configuration section.

-These is mostly set of paths to resolve ghjkfiles or other values that need to be resolved before the serializaiton process.
+These are mostly paths to resolve ghjkfiles or other values that need to be resolved before the serialization process.

-Most of these settings can be configured through the `config.json` file which is looked for at `.ghjk/config.json` by default.
+Most of these settings can be configured through the `config.json` file, which is looked for at `.ghjk/config.json` by default.

-Additionaly, most of these values can be configured through environment variables under keys that are the name of the config value prefixed by `GHJK_`.
+Additionally, most of these values can be configured through environment variables under keys that are the name of the config value prefixed by `GHJK_`.

-The following snippet shows current config set, their defafults and an explanation of their purpose.
+The following snippet shows the current config set, their defaults, and an explanation of their purpose.
🧰 Tools
🪛 LanguageTool

[grammar] ~494-~494: The verb ‘is’ is singular. Did you mean: “this is” or “These are”?
Context: ...{ # /* json rep of config */ # } ``` These is mostly set of paths to resolve ghjkfile...

(SINGULAR_VERB_AFTER_THESE_OR_THOSE)

src/ghjk/config.rs (2)

9-13: Field additions look consistent
The newly introduced fields (deno_json, deno_lockfile, import_map, deno_no_lockfile) are coherent with the rest of the struct. Consider renaming deno_no_lockfile to a more positive wording (e.g., ignore_lockfile) for clarity.


90-96: Remove commented-out import_map code if obsolete
Lines 92–94 suggest a default import_map.json but are commented out. If no longer needed, consider removing them to maintain code clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecfedaa and bb0c538.

📒 Files selected for processing (20)
  • .ghjk/config.json (1 hunks)
  • README.md (2 hunks)
  • deno.jsonc (1 hunks)
  • docs/installation-vars.md (1 hunks)
  • docs/manual.md (15 hunks)
  • host/init/mod.ts (3 hunks)
  • install/hook.fish (2 hunks)
  • install/hook.sh (2 hunks)
  • install/utils.ts (2 hunks)
  • src/deno_systems/bindings.ts (2 hunks)
  • src/ghjk/cli.rs (7 hunks)
  • src/ghjk/cli/print.rs (1 hunks)
  • src/ghjk/config.rs (12 hunks)
  • src/ghjk/systems/deno.rs (2 hunks)
  • tests/envHooks.ts (1 hunks)
  • tests/examples.ts (1 hunks)
  • tests/hashfile.ts (2 hunks)
  • tests/tasks.ts (2 hunks)
  • tests/todo.ts (1 hunks)
  • tests/utils.ts (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/todo.ts
  • .ghjk/config.json
🚧 Files skipped from review as they are similar to previous changes (8)
  • host/init/mod.ts
  • src/ghjk/systems/deno.rs
  • docs/installation-vars.md
  • tests/examples.ts
  • src/deno_systems/bindings.ts
  • tests/utils.ts
  • tests/tasks.ts
  • src/ghjk/cli/print.rs
🧰 Additional context used
🪛 LanguageTool
docs/manual.md

[uncategorized] ~112-~112: Possible missing comma found.
Context: ...ghjk cli This doesn't cover everything though and the ghjk.ts implementation genera...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~129-~129: Possible missing comma found.
Context: ... retain version numbers resolved during installation which is important for the basic need o...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~216-~216: The preposition ‘to’ seems more likely in this position.
Context: ...n` environment. Inheritance is additive on most env properties and allows easy com...

(AI_HYDRA_LEO_REPLACE_ON_TO)


[uncategorized] ~423-~423: Possible missing comma found.
Context: ...environment won't be activated for that CWD nor will any changes occur on changing ...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~494-~494: The verb ‘is’ is singular. Did you mean: “this is” or “These are”?
Context: ...{ # /* json rep of config */ # } ``` These is mostly set of paths to resolve ghjkfile...

(SINGULAR_VERB_AFTER_THESE_OR_THOSE)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test-e2e (macos-14, darwin/aarch64)
  • GitHub Check: test-e2e (macos-latest, darwin/x86_64)
  • GitHub Check: test-e2e (custom-arm, linux/aarch64)
  • GitHub Check: test-e2e (ubuntu-latest, linux/x86_64)
  • GitHub Check: test-pre-commit
🔇 Additional comments (30)
deno.jsonc (2)

8-10: Verify test coverage and CI integration

The new test tasks look good, but a few points to consider:

  1. The glob pattern **/*.ts in test-doc might include unnecessary files
  2. These tasks should be integrated into CI/CD workflows

Let's verify the CI integration and potential glob pattern matches:

✅ Verification successful

Test tasks are properly integrated and glob pattern is appropriate

The verification shows that:

  1. Both test-doc and test-rust tasks are properly integrated into CI/CD workflows in .github/workflows/tests.yml
  2. The glob pattern **/*.ts is appropriate as all listed TypeScript files are relevant to the project:
    • Core modules in modules/
    • Port implementations in ports/
    • Test files in tests/
    • Examples and utilities

No changes are needed as the current implementation is correct and well-integrated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if these tasks are referenced in CI workflows
echo "Checking CI integration..."
rg "test-doc|test-rust" .github/

# List all .ts files that would be included in test-doc
echo "Files that would be included in test-doc:"
fd -e ts --exclude target --exclude .git

Length of output: 2380


1-29: Verify CLI command configuration

The PR mentions changing ghjk print config to ghjk print serialized, but this configuration change isn't directly visible in this file.

Let's verify the CLI command changes:

✅ Verification successful

Let's gather more specific information about the command changes.


Let's check one more thing to verify if there are any other relevant command definitions.


CLI command change appears to be properly implemented

The verification shows that:

  • The old command print config appears only in error message templates
  • The new command print serialized is being used in the test suite (tests/utils.ts)
  • The command change is consistent with the PR objectives

The configuration in deno.jsonc doesn't need to explicitly reflect this CLI command change as it's handled in the Rust implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for command definitions and usages
echo "Searching for CLI command definitions..."
rg -l "print config|print serialized" src/

# Check for any test files covering these commands
echo "Checking test coverage for CLI commands..."
rg -l "print config|print serialized" tests/

Length of output: 308


Script:

#!/bin/bash
# Check the actual command implementation in log.rs
echo "Checking log.rs for command implementation:"
rg -A 5 -B 5 "print.*config|print.*serialized" src/ghjk/log.rs

# Check test coverage details
echo "Checking test coverage details:"
rg -A 5 -B 5 "print.*config|print.*serialized" tests/utils.ts

Length of output: 1018


Script:

#!/bin/bash
# Search for CLI command structure definitions
echo "Checking CLI command structures:"
rg -A 10 "Command::new\(|SubCommand::new\(" src/

# Check for any print-related command handlers
echo "Checking print command handlers:"
ast-grep --pattern 'fn print'

Length of output: 898

install/utils.ts (2)

14-14: Rename consistency looks good.
Renaming GHJK_DIR to GHJKDIR matches the broader changes in the codebase for environment variables.


28-28: Confirm references to the renamed variable.
Ensure all references to GHJK_DIR are updated to GHJKDIR throughout the codebase for consistency.

✅ Verification successful

Let me verify this with a more comprehensive search strategy.


No update needed - variable naming is consistent

The search results show that GHJKDIR is the consistently used form throughout the codebase, while GHJK_DIR only appears as part of other variable names (GHJK_LAST_GHJKDIR) or in local variables with different purposes (local_ghjk_dir, ghjk_dir_var). The line in question:

GHJKDIR="${gcx.ghjkDir}" \\

follows the established naming convention in the codebase. No changes are needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that GHJK_DIR references are fully updated
rg "GHJK_DIR"

Length of output: 13


Script:

#!/bin/bash
# Search for both GHJK_DIR and GHJKDIR to understand the variable usage
echo "Searching for GHJK_DIR:"
rg -i "GHJK_DIR"

echo -e "\nSearching for GHJKDIR:"
rg -i "GHJKDIR"

# Also search in shell scripts and configuration files
echo -e "\nSearching in shell scripts and config files:"
fd -e sh -e bash -e conf -e config -e env . -x rg -i "GHJK_DIR|GHJKDIR" {}

Length of output: 7063

tests/envHooks.ts (1)

83-84: Validate new import path.
Switching from a path with a $ prefix to a plain module path is acceptable, but confirm that your runtime or bundler can correctly resolve "ghjk/hack.ts".

✅ Verification successful

Import path ghjk/hack.ts is correctly resolved within the test environment

The verification shows that:

  • The import path ghjk/hack.ts is consistently used across multiple test files (tests/hashfile.ts, tests/tasks.ts, tests/envHooks.ts)
  • The module exists at the repository root as hack.ts, which exports sophon from ./mod.ts
  • The test files are using this import path specifically in test fixture contexts (within template strings defining fs or ghjkTs properties)
  • This is a valid test setup as the import path is part of the test fixtures and not actual runtime imports
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check all references to "ghjk/hack.ts", confirming it exists and is properly imported
rg "ghjk/hack.ts" -A 2 -B 2
fd -e ts | xargs rg 'export .*\{.*sophon.*\}'

Length of output: 1747

tests/hashfile.ts (3)

52-53: No changes requiring review.


54-59: New CLI config test case is a solid addition.
This scenario verifies hash invalidation when a CLI config environment variable changes. Good move for robust coverage.


68-69: Check that “ghjk/hack.ts” import resolves properly.
Ensure build or runtime tooling supports the new import path for sophon.

✅ Verification successful

The import path "ghjk/hack.ts" is valid and consistent with the codebase

The verification shows that:

  • Multiple test files in the codebase use the same import path ghjk/hack.ts for importing sophon
  • The sophon export chain is properly set up:
    • mod.ts defines and exports the sophon object
    • hack.ts re-exports sophon from ./mod.ts
    • Test files import sophon from ghjk/hack.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Confirm that "ghjk/hack.ts" is resolvable and that "sophon" is exported
rg 'export { sophon } from "ghjk/hack.ts"'

Length of output: 173


Script:

#!/bin/bash
# Search for files containing "ghjk/hack.ts"
rg -l "ghjk/hack\.ts"

# Search for files that export 'sophon'
rg "export.*sophon"

# Find any TypeScript files with "hack.ts" in the name
fd "hack\.ts"

Length of output: 1267

install/hook.fish (3)

36-37: Rename of local variable is consistent.
The shift from $GHJK_DIR to $GHJKDIR matches naming changes elsewhere.


62-62: Consistent global export.
Renaming GHJK_LAST_GHJK_DIR to GHJK_LAST_GHJKDIR aligns seamlessly with the new naming scheme.


41-41: Confirm fallback logic.
Previously, it checked if $GHJK_DIR was unset. Now it checks $GHJKDIR. Make sure all references remain aligned so that directories are discovered correctly.

install/hook.sh (1)

32-33: LGTM! Variable renaming for consistency.

The renaming of environment variables from GHJK_DIR to GHJKDIR and GHJK_LAST_GHJK_DIR to GHJK_LAST_GHJKDIR improves naming consistency.

Let's verify that these variable names are used consistently across the codebase:

Also applies to: 57-58

✅ Verification successful

Let me verify the new variable names are used consistently:


Variable renaming verification successful

The search results confirm that the new variable names GHJKDIR and GHJK_LAST_GHJKDIR are used consistently throughout the codebase in:

  • Shell scripts (install/hook.sh)
  • Fish shell scripts (install/hook.fish)
  • TypeScript files (install/utils.ts, host/init/mod.ts)
  • Rust code (src/ghjk/config.rs)
  • Documentation (docs/manual.md)

No instances of the old variable names (GHJK_DIR or GHJK_LAST_GHJK_DIR) were found, confirming the complete and consistent renaming across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of the old variable names
rg "GHJK_DIR[^A-Z]" || echo "No occurrences of GHJK_DIR found"
rg "GHJK_LAST_GHJK_DIR" || echo "No occurrences of GHJK_LAST_GHJK_DIR found"

Length of output: 215


Script:

#!/bin/bash
# Search for the new variable names to ensure they are used
rg "GHJKDIR" -A 1
rg "GHJK_LAST_GHJKDIR" -A 1

Length of output: 2038

README.md (1)

49-49: LGTM! Improved safety in installation command.

Adding quotes around the URL in the curl command prevents potential issues with URL parsing and special characters.

src/ghjk/cli.rs (4)

10-12: LGTM! Improved modularity with new modules.

The addition of init, print, and sys modules improves code organization and separation of concerns.


51-59: LGTM! Enhanced configuration handling.

The configuration handling is now more robust with explicit handling of:

  • Deno lockfile settings
  • Configuration flags
  • Import map paths

Line range hint 118-172: Verify error handling in system commands.

The refactored system commands handling looks good, but ensure that lockfile operations are properly handled in all error paths.

Let's verify the error handling paths:

✅ Verification successful

Lockfile operations are properly handled in all error paths

The verification shows that write_lockfile_or_log() is consistently called in all error paths and critical execution points:

  • When system commands initialization fails
  • When command-line argument matching fails
  • When handling non-help related command errors
  • When system action matching fails
  • When action is missing
  • At the end of command execution

The implementation in GhjkfileSystems properly logs any errors that occur during lockfile writing, ensuring graceful handling of lockfile operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for lockfile write operations to ensure consistency
rg "write_lockfile_or_log" -A 3 -B 3

Length of output: 2393


247-255: LGTM! Well-structured Init command implementation.

The new Init command structure is well-documented and properly integrated into the CLI hierarchy.

Let's verify the command documentation:

✅ Verification successful

Command documentation is consistent and well-structured across the codebase

The verification shows that the Init command and its subcommands are properly documented with clear descriptions:

  • The main Init command is documented as "Setup your working directory for ghjk usage"
  • Its subcommands in InitCommands enum have detailed documentation:
    • Ts: "Create a starter typescript ghjkfile (ghjk.ts) in the current directory"
    • TsLsp: "Interactively configure working directory for best LSP support of ghjk.ts"

The documentation style is consistent with other command structures in the codebase (like Print commands), following the same pattern of using doc comments for clear descriptions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent command documentation
ast-grep --pattern '#[derive(clap::Subcommand)]
enum $_ {
  $$$
}'

Length of output: 68


Script:

#!/bin/bash
# Let's try a different approach to check command documentation
rg -A 10 "derive.*Subcommand" --type rust

Length of output: 2253

docs/manual.md (3)

20-20: LGTM! Installation command updated with proper URL quoting.

The installation command now properly quotes the URL, which is a good practice to handle special characters in URLs.


408-409: LGTM! CI installation instructions are clear and accurate.

The CI installation section properly emphasizes version consistency and provides clear instructions for Docker environments.

Also applies to: 416-416


Line range hint 1-537: Verify documentation completeness.

While the documentation is comprehensive, we should verify that all breaking changes mentioned in the PR objectives are properly documented.

✅ Verification successful

Let me verify the content of these files to ensure the breaking changes are properly documented.


Breaking changes are properly documented

The documentation in docs/manual.md correctly covers both breaking changes:

  1. The ghjk print serialized command is documented in the "Serialized" section with a clear example.
  2. The required sophon object export is documented in multiple places, including the initial ghjk.ts example with a clear explanation that it's a special object that must be exported.

Additionally, the documentation maintains consistency by using these updated patterns in all examples throughout the manual.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all breaking changes are documented

# Check if the command change from 'ghjk print config' to 'ghjk print serialized' is documented
rg -l "ghjk print (config|serialized)" 

# Check if the sophon object re-export is documented
rg -l "export.*sophon.*from.*[\"']ghjk[\"']"

Length of output: 180


Script:

#!/bin/bash
# Check the content of files mentioning 'ghjk print' commands
rg "ghjk print (config|serialized)" -B2 -A2

# Check the content of files mentioning sophon export
rg "export.*sophon.*from.*[\"']ghjk[\"']" -B2 -A2

Length of output: 1798

🧰 Tools
🪛 LanguageTool

[grammar] ~494-~494: The verb ‘is’ is singular. Did you mean: “this is” or “These are”?
Context: ...{ # /* json rep of config */ # } ``` These is mostly set of paths to resolve ghjkfile...

(SINGULAR_VERB_AFTER_THESE_OR_THOSE)

src/ghjk/config.rs (10)

3-3: Ensure deriving Eq with PathBuf is intentional
While deriving Eq is often useful, be aware that paths can differ in string representation between platforms (e.g., case sensitivity). Verify that strict equality is desired here.


27-29: Confirm type variance for deno_lockfile
Here, deno_lockfile is Option<String> while in Config it is Option<PathBuf>. Ensure that the difference is intentional and that string-based “off” logic is consistently handled.


38-38: Environment variable approach
Using path_from_env to locate GHJKDIR is valid. No concerns found.


53-53: Check for missing parent gracefully
Calling .parent() and using expect_or_log will panic if no parent path exists. If the path can be relative or unusual, consider a friendlier error or fallback.


67-67: Overriding GHJKDIR when GHJKFILE is set
The logic cleanly overrides GHJKDIR if GHJKFILE is provided. This matches the documented intent.


104-104: New BASE_URL
Switching to “https://raw.githubusercontent.com/metatypedev/ghjk/” is consistent with the repository name.


151-154: New file_exists utility
Replacing tokio::fs::try_exists with crate::utils::file_exists is consistent. The logic for creating a default .gitignore remains unchanged.


222-231: Global config path resolution
The approach of merging file-based configuration into Config is correct. No issues found.


250-292: Local config: Disabling default deno.json if import_map is set
Line 273 sets self.deno_json = None when import_map is present and deno_json is absent. Verify that this is the desired behavior, as it prevents both from coexisting.


Line range hint 308-340: Environment overrides
Mirrors the local config approach for import_map and deno_lockfile. The same logic of forcibly disabling deno_json if import_map is set applies here. Confirm that it matches the intended design.

README.md Show resolved Hide resolved
src/ghjk/config.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (10)
ports/asdf_plugin_git.ts (2)

85-85: Potential error handling for git commands.
It might be helpful to handle potential network or authentication errors during git ls-remote calls, in case the remote is unreachable or the credential is invalid, to provide more explicit feedback.


103-110: Duplicated logic for authenticating GitHub repos.
The same approach to setting repoUrl.username/password is repeated. Consider abstracting out the GitHub authentication logic into a helper function to avoid code duplication and reduce possible inconsistencies.

-      if (ghConf.ghToken) {
-        repoUrl.username = ghConf.ghToken;
-        repoUrl.password = ghConf.ghToken;
-      }
+      applyGhTokenIfNeeded(repoUrl, ghConf);
src/ghjk/config.rs (3)

151-151: Creating .gitignore if missing.
Auto-generating a .gitignore inside .ghjk is convenient. If users want to preserve a custom ignore config, maybe check for an existing file content instead of overwriting.

Also applies to: 154-154


254-255: Local config override logic.
Local configs can override data_dir, deno_dir, import_map, etc. The step to disable default deno.jsonc if import_map is set might surprise some users. Consider clarifying this in docs or logs.

Also applies to: 263-265, 268-268, 272-273, 274-283, 284-285, 288-293, 296-296


312-313: Environment config layering.
Reading GHJK_* environment variables is highly flexible, letting users override local or global configs. The same caution applies: document precedence rules (env → local → global).

Also applies to: 327-329, 330-333, 334-335, 336-339, 344-344

examples/template.ts (2)

2-4: Confirm the new sophon export usage and remove commented-out code if unnecessary.

The new export of sophon from "ghjk" is consistent with the updated module strategy. Consider removing or uncommenting the line for ports if you intend to use it.


15-15: Remove or update commented code.

The commented-out ports.pnpm() line can be removed if no longer needed. Leaving stale references can lead to confusion.

ghjk.ts (2)

6-11: Consolidate imports if possible.

Multiple imports from "ghjk" subpaths might be consolidated to simplify maintenance. However, if you prefer explicit separate imports, it’s also fine.


75-102: Ensure logs do not leak sensitive data.

The RUST_LOG environment variable includes various modules for debugging. Double-check that no sensitive or private data might end up in logs, especially in production environments.

docs/manual.md (1)

494-494: Fix grammatical error.

These is mostly set of paths...” should read “These are mostly a set of paths...”

- These is mostly set of paths to resolve ghjkfiles
+ These are mostly a set of paths to resolve ghjkfiles
🧰 Tools
🪛 LanguageTool

[grammar] ~494-~494: The verb ‘is’ is singular. Did you mean: “this is” or “These are”?
Context: ...{ # /* json rep of config */ # } ``` These is mostly set of paths to resolve ghjkfile...

(SINGULAR_VERB_AFTER_THESE_OR_THOSE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb0c538 and c1f4c9b.

📒 Files selected for processing (16)
  • deno.jsonc (1 hunks)
  • docs/manual.md (15 hunks)
  • examples/env_vars/ghjk.ts (1 hunks)
  • examples/envs/ghjk.ts (1 hunks)
  • examples/kitchen/ghjk.ts (1 hunks)
  • examples/many_installs/ghjk.ts (1 hunks)
  • examples/tasks/ghjk.ts (1 hunks)
  • examples/template.ts (1 hunks)
  • ghjk.ts (3 hunks)
  • ports/asdf_plugin_git.ts (5 hunks)
  • src/ghjk/cli/print.rs (1 hunks)
  • src/ghjk/cli/sys.rs (1 hunks)
  • src/ghjk/config.rs (12 hunks)
  • src/ghjk/host/hashfile.rs (4 hunks)
  • tests/tasks.ts (2 hunks)
  • tests/utils.ts (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • examples/tasks/ghjk.ts
  • examples/envs/ghjk.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • examples/env_vars/ghjk.ts
  • src/ghjk/cli/print.rs
  • tests/utils.ts
  • src/ghjk/cli/sys.rs
  • examples/kitchen/ghjk.ts
  • tests/tasks.ts
🧰 Additional context used
🪛 LanguageTool
docs/manual.md

[grammar] ~494-~494: The verb ‘is’ is singular. Did you mean: “this is” or “These are”?
Context: ...{ # /* json rep of config */ # } ``` These is mostly set of paths to resolve ghjkfile...

(SINGULAR_VERB_AFTER_THESE_OR_THOSE)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test-e2e (macos-14, darwin/aarch64)
  • GitHub Check: test-e2e (macos-latest, darwin/x86_64)
  • GitHub Check: test-e2e (custom-arm, linux/aarch64)
  • GitHub Check: test-e2e (ubuntu-latest, linux/x86_64)
  • GitHub Check: test-pre-commit
🔇 Additional comments (33)
ports/asdf_plugin_git.ts (5)

17-21: Import additions look aligned with GH integration.
These imports facilitate authenticated GitHub access using tokens. Everything seems consistent with the new functionality.


43-43: Excellent extension of config types.
Allowing AsdfPluginInstallConf to extend GithubReleasesInstConf is beneficial for standardizing GitHub-based release configurations, ensuring consistency across different ports.


62-62: Good approach to reading GH environment variables.
Decoupling the retrieval of GitHub variables via readGhVars() is a neat design choice. Just ensure that the returned environment variables do not accidentally leak sensitive data.


73-82: Proper conditional for GitHub tokens.
The code checks if repoUrl is hosted on GitHub and applies credentials only if ghToken is present. This is a good practice, ensuring minimal risk of leaking tokens to non-GitHub domains.


113-113: Consider deeper clone-depth configuration.
Cloning with --depth 1 is beneficial for performance. However, be aware that certain operations (e.g., retrieving older commits or tags) will be unavailable. Confirm this aligns with the plugin’s intended usage.

deno.jsonc (5)

2-5: Useful "imports" for local development.
Mapping "ghjk" to "./mod.ts" and "ghjk/" to "./" helps to simplify import statements. Make sure to reflect these changes in documentation or code comments if other contributors rely on them to understand the local path structure.


8-8: Comprehensive test-doc task.
The test-doc task integrates building Rust code and then running Deno tests with --doc. This ensures your documentation stays in sync with the code.


9-9: Rust tests addition is beneficial.
Including "test-rust": "cargo test" aligns the CLI with Rust-based test suites. Good for consistency across the project.


10-10: Renaming “self” to “ghjk” clarifies usage.
Renaming the task is a more intuitive approach for new contributors who might have been confused by the self-referential naming.


15-29: Selective test exclusion is well-considered.
Excluding large or irrelevant directories (e.g., .deno-dir, vendor) helps to maintain a clean testing environment. Ensure that any critical code is not accidentally excluded from tests.

src/ghjk/host/hashfile.rs (4)

8-9: New cli_config field in HashObj.
Storing and serializing the CLI configuration helps detect changes that require re-serialization. This is an effective approach to guaranteeing relevant config changes cause a fresh build.


59-59: Cloning config ensures immutability.
Using hcx.gcx.config.clone() is important for avoiding reference sharing pitfalls. This approach is consistent with the struct's existing design.


78-83: Accurate stale check for config drift.
If self.cli_config != hcx.gcx.config, the code logs “stale cli config” and returns true. This forces re-serialization whenever the CLI config changes, which is desirable.


96-96: Using file_exists is more readable.
Switching from try_exists to file_exists centralizes the logic for determining file existence. This ensures consistent error handling.

src/ghjk/config.rs (14)

3-3: Enhanced derive macros.
Adding Serialize, Deserialize, Clone, PartialEq, and Eq gives Config more versatility for serialization, comparisons, and usage in caching systems.


9-9: Optional deno_json field introduced.
This new field can simplify references to your Deno configuration. Confirm you’re covering the scenario where deno.json is absent but needed.


11-11: Optional import_map is flexible.
Allows the user to supply a custom import map. If not supplied, you have fallback logic in the code. Ensure the fallback is documented for new users.


13-13: deno_no_lockfile clarifies lockfile usage.
This greatly helps configuration states that explicitly do not require a lockfile. However, check for potential conflicts where deno_no_lockfile is true but a lock path is still auto-generated.


27-27: Local config references.
Reading partially from a flattened GlobalConfigFile ensures local overrides remain consistent. Good approach for layering config.


29-29: Optional import_map recognized in LocalConfigFile.
Keeps local environment flexible. Just ensure no collisions occur when the global config sets an import_map as well.


38-38: Locating the .ghjk directory.
Recursively searching helps new users who might have placed the .ghjk directory at different depths. Double-check performance in large repos.


53-53: Ensuring a .ghjk directory near ghjkfile_path
Linking a ghjkfile with its directory fosters consistency. If multiple .ghjk directories exist, confirm that the correct directory is identified.


67-67: Overriding GHJKDIR if GHJKFILE is set.
Appropriate fallback logic. This ensures that the .ghjk directory co-locates with the discovered ghjk.ts script.


90-91: Defaulting deno.json path to .ghjk/deno.jsonc
This is a sensible default. Still, ensure no conflicts arise if a user explicitly sets an alternative deno.json path.


92-96: Lockfile path logic.
By default, you place it in .ghjk/deno.lock. This is consistent with your directory’s structure. Confirm no collisions with prior lockfile usage in other directories.


104-104: Updated BASE_URL for new repo.
Pointing to metatypedev/ghjk is logical if your main repository changed. Make sure references and doc references to the old repo are removed throughout the codebase.


167-168: Creating deno.json conditionally.
This block handles new config creation. Overall logic is solid:
• Resolves parent dir, ensures the directory exists, and writes a minimal JSON structure.
• Adjusts importMap and lock properties.
• Respects deno_no_lockfile.
Be sure to log user-friendly messages if the file already exists or if a user wants to override the default generation.

Also applies to: 169-172, 173-175, 176-177, 178-181, 182-189, 190-190, 191-193, 194-199, 200-203, 204-210, 211-211


226-228: Global config path resolution.
Using resolve_config_path improves consistency. Logging any path resolution error can help debug config misplacements.

Also applies to: 231-231, 235-235

examples/template.ts (1)

6-6: Clarify the necessity of this comment.

The line mentions that the export is necessary for TypeScript ghjkfiles, but if sophon is now used differently across the codebase, confirm this statement’s accuracy.

ghjk.ts (4)

3-4: Verify that sophon and $ are used.

export { sophon } from "ghjk"; plus importing $ from "ghjk" is valid if the main CLI usage depends on them. Check for references to these exports/imports throughout the file to ensure they are actually used.


15-15: Confirm pinned Deno version.

Deno 2.1.2 is pinned. Ensure that no code within your project or dependencies depends on newer or older Deno features.


47-52: Validate NO_MOLD usage.

Verifying that ignoring mold installation via NO_MOLD is indeed intended. Use caution if partial environment variables could cause confusion later.


149-149: Ensure version consistency across tasks.

Keep the GHJK_VERSION consistent with the rest of the codebase.

examples/many_installs/ghjk.ts Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
ghjk.ts (2)

75-102: Consider extracting log level configuration.

While the current implementation is functional, consider extracting the log level configuration into a separate constant for improved readability and maintainability.

+const LOG_LEVELS = {
+  TRACE: [
+    // "denort",
+    // "deno",
+  ],
+  DEBUG: [
+    "runtime",
+    "tokio",
+  ],
+  INFO: [
+    "deno::npm",
+    "deno::file_fetcher",
+    "swc_ecma_transforms_base",
+    "swc_common",
+    "h2",
+    "rustls",
+    "mio",
+    "hyper_util",
+  ],
+};

 ghjk.env("main")
   .vars({
     RUST_LOG: [
       "info",
-      Object.entries({
-        "TRACE": [
-          // "denort",
-          // "deno",
-        ],
-        "DEBUG": [
-          "runtime",
-          "tokio",
-        ],
-        "INFO": [
-          "deno::npm",
-          "deno::file_fetcher",
-          "swc_ecma_transforms_base",
-          "swc_common",
-          "h2",
-          "rustls",
-          "mio",
-          "hyper_util",
-        ],
-      })
+      Object.entries(LOG_LEVELS)
       .flatMap(([level, modules]) =>
         modules.map((module) => `${module}=${level.toLowerCase()}`)
       ),
     ].join(),
   });

Line range hint 104-148: Add error handling for V8 cache operations.

The task implementation is thorough, but consider adding error handling for:

  • Failed cargo tree command execution
  • Failed downloads
  • Failed file operations

Example improvement:

 ghjk.task(
   "cache-v8",
   {
     desc: "Install the V8 builds to a local cache.",
     inherit: false,
     fn: async ($) => {
       const tmpDirPath = await Deno.makeTempDir({});
+      try {
         const v8Versions = [
-          ...(await $`cargo tree -p v8 --depth 0 --locked`
-            .text())
+          ...(await $`cargo tree -p v8 --depth 0 --locked`.noThrow()
+            .text() || '')
             .matchAll(/^v8 (v[\d.]*)/g)
             .map((match) => match[1]),
         ];
+        if (v8Versions.length === 0) {
+          console.warn("No V8 versions found");
+          return;
+        }
         // ... rest of the implementation
+      } catch (error) {
+        console.error("Failed to cache V8 builds:", error);
+        throw error;
+      } finally {
+        try {
           await $.path(tmpDirPath).remove({ recursive: true });
+        } catch (error) {
+          console.warn("Failed to cleanup temp directory:", error);
+        }
+      }
     },
   },
 );
docs/manual.md (2)

115-115: Fix missing punctuation.

Add a period after "cli":

-used by the ghjk cli
+used by the ghjk cli.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~115-~115: Possible missing comma found.
Context: ...sed by the ghjk cli This doesn't cover everything though, and the ghjk.ts implementatio...

(AI_HYDRA_LEO_MISSING_COMMA)


427-427: Fix sentence structure.

Add a comma after "functioning":

-commands from functioning which requires
+commands from functioning, which requires
🧰 Tools
🪛 LanguageTool

[uncategorized] ~427-~427: Possible missing comma found.
Context: ... and ghjk envs activate commands from functioning which requires that these hooks be run ...

(AI_HYDRA_LEO_MISSING_COMMA)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1f4c9b and f5099b7.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .github/workflows/tests.yml (2 hunks)
  • Cargo.toml (1 hunks)
  • README.md (4 hunks)
  • deno.jsonc (1 hunks)
  • docs/manual.md (15 hunks)
  • ghjk.ts (3 hunks)
  • host/init/mod.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • host/init/mod.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/tests.yml
🧰 Additional context used
🪛 LanguageTool
docs/manual.md

[uncategorized] ~115-~115: Possible missing comma found.
Context: ...sed by the ghjk cli This doesn't cover everything though, and the ghjk.ts implementatio...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~219-~219: The preposition ‘to’ seems more likely in this position.
Context: ...n` environment. Inheritance is additive on most env properties and allows easy com...

(AI_HYDRA_LEO_REPLACE_ON_TO)


[uncategorized] ~427-~427: Possible missing comma found.
Context: ... and ghjk envs activate commands from functioning which requires that these hooks be run ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~540-~540: Possible missing comma found.
Context: ...nfiles,config.json5` files are also supported which is a [friendlier superset of JSON...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (13)
Cargo.toml (1)

7-7: LGTM! Version bump is appropriate.

The version increment from rc.1 to rc.2 aligns with the breaking changes introduced in this PR.

deno.jsonc (3)

2-5: LGTM! Import mappings align with new architecture.

The new imports section properly maps the "ghjk" module, supporting the architectural changes mentioned in the PR objectives where sophon is re-exported from mod.ts.


7-9: LGTM! Enhanced test configuration.

Good improvements to the test setup:

  1. Added documentation testing to the main test task
  2. Separated Rust tests into their own task
  3. Renamed "self" to "ghjk" for better clarity

14-29: LGTM! Comprehensive test exclusions.

The test exclusions are well-structured and cover all necessary paths:

  • Build artifacts and dependencies
  • Generated files
  • Development and example directories
  • Specific modules that shouldn't be tested
README.md (4)

49-49: LGTM! Version updated consistently.

The install script version has been updated to match the new version in Cargo.toml.


64-68: Export pattern is inconsistent across the codebase

The verification reveals inconsistencies in how sophon is imported from ghjk. While the README shows the new pattern export { sophon } from "ghjk", the codebase uses multiple different import paths.


108-109: LGTM! Added task documentation.

Good addition of documentation for CLI tasks, which is particularly relevant given the breaking changes to the ghjk print commands mentioned in the PR objectives.


139-141: LGTM! Enhanced contributing guidelines.

The contributing section has been improved with:

  • Clear instructions for development environment setup
  • Test running guidelines
  • Link to open issues
ghjk.ts (5)

3-13: LGTM! Clean imports and initialization.

The imports are well-organized and follow a clear pattern. The file initialization with file({}) is correct.


19-26: LGTM! Well-organized development tools setup.

Good practice to group development tools in the main environment.


42-52: LGTM! Well-structured Rust environment configuration.

Good separation of concerns by isolating Rust tooling in its own environment. The conditional inclusion of mold for Linux systems is well-implemented.


55-61: LGTM! Dev environment properly extends Rust setup.

Good use of environment inheritance and proper path construction for RUSTY_V8_MIRROR.


Line range hint 149-197: Centralize version management.

The GHJK_VERSION is hardcoded. Consider importing it from a central version management file.

docs/manual.md Show resolved Hide resolved
@Yohe-Am Yohe-Am merged commit 6fe2461 into main Jan 6, 2025
9 of 11 checks passed
@Yohe-Am Yohe-Am deleted the fix/0.3.0.-rc.2 branch January 6, 2025 15:02
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.

Disable typescript if detected Enable deno in vscode
2 participants