feat: add construct-runtime.ts shared utility and script conventions#9
Merged
feat: add construct-runtime.ts shared utility and script conventions#9
Conversation
Ships scripts/lib/construct-runtime.ts — zero-dependency shared utility for credential cascade, pack-aware output dirs, and Nakamoto stdout/stderr separation. Extracted from construct-k-hole dig-search.ts (the canonical reference implementation). Updates: - CONTRIBUTING.md: new "Adding Scripts" section with Nakamoto protocol docs - install.sh: template with credential check pattern and CONSTRUCT_DIR Closes #8 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/lib/construct-runtime.ts— zero-dependency shared utility for construct scriptsCONTRIBUTING.mdwith "Adding Scripts" section documenting the Nakamoto protocolscripts/install.shwith credential check template andCONSTRUCT_DIRsetupWhat's in construct-runtime.ts
Extracted from
construct-k-hole/scripts/dig-search.ts(the reference implementation that runs in production across 4 consumer repos).loadEnvFile(startDir)resolveCredential(...names)resolveOutputDir(scriptDir, slug)progress(tag, msg)[tag] msgto stderroutput(data)fatal(error, extra?)Zero external dependencies. Node.js stdlib only.
Why
Every construct that ships scripts was reimplementing .env loading and output routing independently. K-hole had identical
loadEnv()in two scripts that drifted when one was fixed and the other wasn't — causing credential failures in downstream consumers. This utility prevents that class of bug for all future constructs.Related
docs/guides/script-conventions.md— full convention docTest plan
npx tsx --eval "import './scripts/lib/construct-runtime.ts'"compiles cleanlyscripts/lib/construct-runtime.ts🤖 Generated with Claude Code