mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-08 22:35:36 +02:00
0926e4b994
Splits scripts/resolvers/preamble.ts (841 lines, 18 generator functions + composition root) into one file per generator under scripts/resolvers/preamble/. Root preamble.ts becomes a thin composition layer (~80 lines of imports + generatePreamble). Before: scripts/resolvers/preamble.ts 841 lines After: scripts/resolvers/preamble.ts 83 lines scripts/resolvers/preamble/generate-preamble-bash.ts 97 lines scripts/resolvers/preamble/generate-upgrade-check.ts 48 lines scripts/resolvers/preamble/generate-lake-intro.ts 16 lines scripts/resolvers/preamble/generate-telemetry-prompt.ts 37 lines scripts/resolvers/preamble/generate-proactive-prompt.ts 25 lines scripts/resolvers/preamble/generate-routing-injection.ts 49 lines scripts/resolvers/preamble/generate-vendoring-deprecation.ts 36 lines scripts/resolvers/preamble/generate-spawned-session-check.ts 11 lines scripts/resolvers/preamble/generate-ask-user-format.ts 16 lines scripts/resolvers/preamble/generate-completeness-section.ts 19 lines scripts/resolvers/preamble/generate-repo-mode-section.ts 12 lines scripts/resolvers/preamble/generate-test-failure-triage.ts 108 lines scripts/resolvers/preamble/generate-search-before-building.ts 14 lines scripts/resolvers/preamble/generate-completion-status.ts 161 lines scripts/resolvers/preamble/generate-voice-directive.ts 60 lines scripts/resolvers/preamble/generate-context-recovery.ts 51 lines scripts/resolvers/preamble/generate-continuous-checkpoint.ts 48 lines scripts/resolvers/preamble/generate-context-health.ts 31 lines Byte-identity verification (the real gate per Codex correction): - Before refactor: snapshotted 135 generated SKILL.md files via `find -name SKILL.md -type f | grep -v /gstack/` across all hosts. - After refactor: regenerated with `bun run gen:skill-docs --host all` and re-snapshotted. - `diff -r baseline after` returned zero differences and exit 0. The `--host all --dry-run` gate passes too. No template or host behavior changes — purely a code-organization refactor. Test fix: audit-compliance.test.ts's telemetry check previously grepped preamble.ts directly for `_TEL != "off"`. After the refactor that logic lives in preamble/generate-preamble-bash.ts. Test now concatenates all preamble submodule sources before asserting — tracks the semantic contract, not the file layout. Doing the minimum rewrite preserves the test's intent (conditional telemetry) without coupling it to file boundaries. Why now: we were in-session with full context. Codex had downgraded this from mandatory to optional, but the preamble had grown to 841 lines and was getting harder to navigate. User asked "why not?" given the context was hot. Shipping it as a clean bisectable commit while all the prior preamble.ts changes are fresh reduces rebase pain later. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
2.8 KiB
TypeScript
49 lines
2.8 KiB
TypeScript
import type { TemplateContext } from '../types';
|
|
|
|
export function generateUpgradeCheck(ctx: TemplateContext): string {
|
|
return `If \`PROACTIVE\` is \`"false"\`, do not proactively suggest gstack skills AND do not
|
|
auto-invoke skills based on conversation context. Only run skills the user explicitly
|
|
types (e.g., /qa, /ship). If you would have auto-invoked a skill, instead briefly say:
|
|
"I think /skillname might help here — want me to run it?" and wait for confirmation.
|
|
The user opted out of proactive behavior.
|
|
|
|
If \`SKILL_PREFIX\` is \`"true"\`, the user has namespaced skill names. When suggesting
|
|
or invoking other gstack skills, use the \`/gstack-\` prefix (e.g., \`/gstack-qa\` instead
|
|
of \`/qa\`, \`/gstack-ship\` instead of \`/ship\`). Disk paths are unaffected — always use
|
|
\`${ctx.paths.skillRoot}/[skill-name]/SKILL.md\` for reading skill files.
|
|
|
|
If output shows \`UPGRADE_AVAILABLE <old> <new>\`: read \`${ctx.paths.skillRoot}/gstack-upgrade/SKILL.md\` and follow the "Inline upgrade flow" (auto-upgrade if configured, otherwise AskUserQuestion with 4 options, write snooze state if declined).
|
|
|
|
If output shows \`JUST_UPGRADED <from> <to>\` AND \`SPAWNED_SESSION\` is NOT set: tell
|
|
the user "Running gstack v{to} (just updated!)" and then check for new features to
|
|
surface. For each per-feature marker below, if the marker file is missing AND the
|
|
feature is plausibly useful for this user, use AskUserQuestion to let them try it.
|
|
Fire once per feature per user, NOT once per upgrade.
|
|
|
|
**In spawned sessions (\`SPAWNED_SESSION\` = "true"): SKIP feature discovery entirely.**
|
|
Just print "Running gstack v{to}" and continue. Orchestrators do not want interactive
|
|
prompts from sub-sessions.
|
|
|
|
**Feature discovery markers and prompts** (one at a time, max one per session):
|
|
|
|
1. \`${ctx.paths.skillRoot}/.feature-prompted-continuous-checkpoint\` →
|
|
Prompt: "Continuous checkpoint auto-commits your work as you go with \`WIP:\` prefix
|
|
so you never lose progress to a crash. Local-only by default — doesn't push
|
|
anywhere unless you turn that on. Want to try it?"
|
|
Options: A) Enable continuous mode, B) Show me first (print the section from
|
|
the preamble Continuous Checkpoint Mode), C) Skip.
|
|
If A: run \`${ctx.paths.binDir}/gstack-config set checkpoint_mode continuous\`.
|
|
Always: \`touch ${ctx.paths.skillRoot}/.feature-prompted-continuous-checkpoint\`
|
|
|
|
2. \`${ctx.paths.skillRoot}/.feature-prompted-model-overlay\` →
|
|
Inform only (no prompt): "Model overlays are active. \`MODEL_OVERLAY: {model}\`
|
|
shown in the preamble output tells you which behavioral patch is applied.
|
|
Override with \`--model\` when regenerating skills (e.g., \`bun run gen:skill-docs
|
|
--model gpt-5.4\`). Default is claude."
|
|
Always: \`touch ${ctx.paths.skillRoot}/.feature-prompted-model-overlay\`
|
|
|
|
After handling JUST_UPGRADED (prompts done or skipped), continue with the skill
|
|
workflow.`;
|
|
}
|
|
|