Phase 10: rescan branch for tracked skills when state entry missing — SPEC §6.3.

Walk user messages and read tool calls on session_start to rebuild tracked
skills from history when no skill-reinject:state entry exists on the branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 12:45:51 +07:00
parent 1a690f921f
commit ee13faf285
2 changed files with 106 additions and 2 deletions
+7 -2
View File
@@ -22,6 +22,7 @@ import {
tryConsumeDeferredReinject,
} from "./reinject.js";
import { readSettings } from "./settings.js";
import { rescanSkillsFromBranch } from "./rescan.js";
import { findRegisteredSkillByName, resolveRegisteredSkills } from "./skills-registry.js";
import {
applyExtensionState,
@@ -99,9 +100,13 @@ export default function skillReinject(pi: ExtensionAPI): void {
pi.on("session_start", async (_event, ctx) => {
detectAndCachePiAutoCompact(pi, runtime);
readSettings(ctx);
const loaded = loadStateFromBranch(ctx.sessionManager.getBranch());
const settings = readSettings(ctx);
const branch = ctx.sessionManager.getBranch();
const loaded = loadStateFromBranch(branch);
applyExtensionState(state, loaded ?? createInitialState());
if (!loaded) {
rescanSkillsFromBranch(state, branch, ctx.cwd, registeredSkills, settings.trackReadPaths);
}
});
pi.on("session_before_compact", async () => {