Files
gstack/scripts/resolvers/shared-libs.ts
T
garrytan a367a1f265 feat(deslop-shared-libs): route every Git read through bin/gstack-safe-git
The skill made the model retype a long safe-Git prefix on each call and a
dropped flag failed shared-libs-read-only. bin/gstack-safe-git applies the
fixed env + flag prefix, adds --no-ext-diff --no-textconv to log/show/diff,
allows diff only between two explicit object IDs and ls-files only in the
NUL-delimited overlay form, and refuses every other shape with one line
naming the allowed forms. The template now points at the installed helper
(host global runtime via {{SAFE_GIT}}) and drops the prose it enforces.

Fixtures resolve the helper to this checkout, the git shim records the safety
environment, and isGuardedGitRequest requires the complete prefix (env
included) for every repository read.
2026-09-30 17:59:23 +00:00

36 lines
2.6 KiB
TypeScript

import type { ResolverFn } from './types';
import { getHostConfig } from '../../hosts/index';
/** The installed read-only Git helper. Always the trusted global runtime, never a repo-local root. */
export const generateSafeGitPath: ResolverFn = (ctx) => `~/${getHostConfig(ctx.host).globalRoot}/bin/gstack-safe-git`;
/** Shared criteria only: the caller owns scope, output, and permission to act. */
export const generateSharedLibsRubric: ResolverFn = () => `### Shared-code evaluation rubric
- **Prove the callers.** Require at least two verified, first-party authored source
locations, with functions and lines. Actual added or uncommitted source qualifies.
Only an engineering-plan review may use proposed callers; label those assumptions
and distinguish them from existing source. Similar names or formatting alone do
not establish equivalent behavior. Generated and third-party copies cannot qualify
as callers or contribute savings. Follow generated copies back to authored
templates/resolvers. Existing dependencies remain valid reuse targets.
- **Reuse before extracting.** Inspect existing libraries and helpers first. Compare
behavior, inputs, outputs, error handling, side effects, security requirements,
dependencies, and deployment/runtime boundaries. Preserve differences callers need;
do not bridge languages or isolated deployments without a practical shared contract.
- **Keep the helper small.** Name its destination and contract, the callers to migrate,
and the smallest adoption sequence. Avoid option-heavy helpers and coupling unrelated
components. Point to existing tests or established use, specify shared-contract and
caller-integration coverage, and describe the blast radius of a shared failure.
- **Account for the whole change.** Name removed blocks and their replacements. Show
estimated implementation lines removed, added, and saved separately from total lines
removed, added, and saved including tests and integration. Savings = removed - added.
Count moved code on both sides, exclude generated/vendor lines, use ranges when
uncertain, and do not count overlapping removals twice across opportunities. State
when tests or integration may make the total change grow.
- **Rank useful changes.** Favor reliability gains and total net savings, then low
adoption and testing risk. Prefer proven code used by several callers. Use recent
activity to break ties between comparable benefits, not as evidence by itself.
Explain choices centered on older code. Reject similarities with incompatible
contracts and opportunities whose benefits do not justify the abstraction.`;