Add caching system, random generators, and plugin cache API#577
Open
theoephraim wants to merge 8 commits intofeature/secure-enclave-pluginfrom
Open
Add caching system, random generators, and plugin cache API#577theoephraim wants to merge 8 commits intofeature/secure-enclave-pluginfrom
theoephraim wants to merge 8 commits intofeature/secure-enclave-pluginfrom
Conversation
First-class caching for varlock with encrypted storage: - cache() resolver function wraps any resolver to persist values across invocations. Supports ttl (defaults to forever), custom key, and auto-invalidation when the wrapped resolver expression changes. - Encrypted JSON cache store at ~/.config/varlock/cache/ using the existing local-encrypt system. Values are JSON-serialized to preserve types (numbers, booleans, objects). - AsyncLocalStorage-based resolution context threads cache store and current item to resolvers without modifying the Resolver class. - Plugin cache API via plugin.cache.get/set with automatic plugin:name:key namespacing. Random value generator resolvers: - randomInt(min?, max?) - cryptographically secure random integer - randomFloat(min?, max?, precision=N) - random float - randomUuid() - UUID v4 - randomHex(bytes?) - random hex string - randomString(length?, charset=S) - random alphanumeric string CLI additions: - varlock cache / varlock cache clear commands - --clear-cache and --skip-cache flags on load/run/printenv - Cache hit indicators in varlock load pretty output - Cache section in varlock explain output Documentation for all new functions and CLI commands. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@initOp() now accepts a cacheTtl option that caches op() and opLoadEnvironment() results via the plugin cache API. The TTL is resolved at runtime so it can be dynamic — e.g., cacheTtl=if(forEnv(dev), "1h") to only cache during development. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Display cache hit (📦) and process.env override (🟡) indicators on the same line as the resolved value instead of separate lines, making the varlock load pretty output more compact and scannable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add expiresAt to cache hit info so varlock explain can show the actual TTL for any cached value — including plugin-cached values that don't use the cache() resolver. TTLs over ~50 years display as "forever". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Running `varlock cache` now shows an interactive list of all cached entries with TTL and age info. Users can scroll through entries and delete individual ones, or clear all at once. `varlock cache clear` still works as a non-interactive fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TTL strings now accept shorthand and full-word variants: s/sec/secs/second/seconds, m/min/mins/minute/minutes, h/hr/hrs/hour/hours, d/day/days, w/wk/wks/week/weeks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…er plugins Same pattern as 1password: add cacheTtl option to each plugin's init decorator. The TTL is resolved at runtime so it can be dynamic (e.g., cacheTtl=if(forEnv(dev), "1h")). Cache keys are scoped per plugin and instance. - aws-secrets: caches awsSecret() and awsParam() calls - bitwarden: caches bitwarden() calls - google-secret-manager: caches gsm() calls Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract resolveCacheTtl() helper that validates the TTL format during the plugin's execute() phase. Invalid values (like "xyz") now show as plugin-level warnings rather than surfacing as per-item resolution errors. All 4 plugins (1password, aws-secrets, bitwarden, gsm) updated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 0a5bbad The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | 0a5bbad | Commit Preview URL Branch Preview URL |
Apr 09 2026, 11:33 PM |
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
cache()resolver function, and plugin cache API (plugin.cache.get/set)randomInt(),randomFloat(),randomUuid(),randomHex(),randomString()— all cryptographically securecacheTtloption on init decorators (1password, aws-secrets, bitwarden, google-secret-manager)varlock cacheCLI for browsing and managing cached entries--clear-cache/--skip-cacheflags onvarlock load,varlock run,varlock printenvvarlock loadpretty output andvarlock explain1h,1hr,30mins,2days,1week, etc.cache()(e.g.,cache(randomInt())infers number type)cache()cacheTtlon plugins surfaces as a proper init error that halts before resolutionTest plan
varlock loadwithcache()wrapped resolvers — verify cached indicator shows on second runvarlock cacheinteractive browser — verify entries display and can be deletedvarlock load --clear-cacheand--skip-cacheflagscacheTtl="1hr"— verify cache hit on second loadcacheTtlhalts with error before resolution🤖 Generated with Claude Code