Commit Graph

104 Commits

Author SHA1 Message Date
grayhook 0f06e0e45b Phase 8: add shouldReinject gate and consume on session_compact — SPEC §8.
Evaluates enabled layer and compaction source, records lastCompactionSource, clears pending flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:04:47 +07:00
grayhook 18dd600d2d Phase 8: mark auto compaction before_compact — default source unless manual.
session_before_compact sets pendingCompactionSource to auto when input did not mark /compact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:03:33 +07:00
grayhook 7bbe2370d7 Phase 8: mark manual compaction from /compact input — SPEC §8 input hook.
Sets pendingCompactionSource before expansion when user text starts with /compact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:02:48 +07:00
grayhook cf2eedb85b Phase 8: add compaction runtime state — pendingCompactionSource container for §8.
Transient CompactionRuntime holds pending source between input, before_compact, and session_compact hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:01:36 +07:00
grayhook 3bab1f802b TODO: mark phase 7 complete — reinject orchestration plan, defer, immediate, skip missing, now.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:59:32 +07:00
grayhook d637722ea5 Phase 7: add reinjectNow — force immediate re-inject of all tracked skills for debug.
Uses idle vs followUp delivery based on ctx.isIdle(); skips unregistered skills via existing buildReinjectBlocks warnings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:59:24 +07:00
grayhook 9a197aee10 Phase 7: skip missing skills with ui.notify warning on expand.
buildReinjectBlocks checks registration and file presence before expandSkill; warns via ctx.ui when hasUI, no-op in RPC/print mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:59:12 +07:00
grayhook dc73ea9747 Phase 7: add sendImmediateReinjectAllFollowUp — queue all blocks when streaming or willRetry.
Uses deliverAs followUp for every skill block so re-inject does not interrupt an active agent turn or overflow recovery.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:58:29 +07:00
grayhook 446a186431 Phase 7: add sendImmediateReinjectIdle — first skill triggers turn, rest as followUp.
Extracts buildReinjectBlocks for shared expand logic; immediate delivery when the agent is idle uses sendUserMessage without deliverAs for the first block only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:58:15 +07:00
grayhook 2059f6033b Phase 7: add defer inject on before_agent_start — combined skill blocks, clear queue.
Builds one injected custom message from pendingReinject via expandSkill, clears the queue only after content is built successfully.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:57:48 +07:00
grayhook e0daa50cce Phase 7: add enqueueDeferredReinjectFromCompact — queue plan on session_compact without sendUserMessage.
Defer delivery stores planned skill names in pendingReinject for injection on the next before_agent_start, avoiding races with pi-auto-compact follow-ups.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:55:13 +07:00
grayhook 23d580b6d2 Phase 7: add planReinject — kept-window and registration filter for post-compaction skills.
Computes which tracked skills need re-inject after compaction by slicing the kept branch and excluding skills still present in kept user messages or unregistered on disk.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:54:01 +07:00
grayhook ab315d899b TODO: mark phase 6 complete — pi-auto-compact detect, delivery mode, constants, hint.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:47:38 +07:00
grayhook bf862656ae Phase 6: add compaction coexistence hint — one-time notify when both compactors run.
Shows ui.notify once when pi-auto-compact is detected while Pi compaction.enabled stays true.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:47:27 +07:00
grayhook 2e6d36a855 Phase 6: add PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES — document pi-auto-compact phrases.
Constants match SPEC §16.9 for tests and docs; runtime v1 does not match follow-up text.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:46:38 +07:00
grayhook e56f81d25c Phase 6: add resolveDeliveryMode — defer vs immediate from integration table.
Wraps effectiveIntegration with RuntimeFlags.autoCompactDetected so reinject wiring reads delivery mode from one place.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:46:19 +07:00
grayhook 776345a238 Phase 6: add detectPiAutoCompact — detect pi-auto-compact via getCommands.
Uses the public ExtensionAPI command list and caches the result in RuntimeFlags for session_start wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:45:22 +07:00
grayhook b54b8f98bf TODO: mark phase 5 complete — kept-window helpers and tests.
Phase 5 delivers getKeptEntries, presence scan, filter, and kept-window.test.ts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:21:55 +07:00
grayhook a8e07fdd6f Phase 5: add kept-window tests — slice, presence, filter, empty kept.
Covers kept-window dedup helpers per SPEC §6.4 and §12.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:21:38 +07:00
grayhook a0e6d204a6 Phase 5: add filterSkillsNeedingReinject — kept-window dedup input for pendingReinject.
Returns tracked registered skills absent from kept user messages per SPEC §5.2 and §6.4.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:20:11 +07:00
grayhook 9896e7efa6 Phase 5: add skillsPresentInKeptWindow — detect skill blocks in kept user messages.
Scans kept entries for expanded skill blocks so re-inject skips duplicates per SPEC §6.4.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:19:05 +07:00
grayhook 6ccb580ca1 Phase 5: add getKeptEntries — branch slice from firstKeptEntryId.
Implements kept-window boundary per SPEC §6.4 for dedup before re-inject.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:17:30 +07:00
grayhook 1296090909 TODO: mark phase 4 complete — skill block expand helpers and tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:32:32 +07:00
grayhook 1382e3f66f Phase 4: add expand tests — frontmatter strip, paths, suffix.
Cover readSkillBody, formatBlock, appendSuffix, and expandSkill per SPEC §12.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:32:23 +07:00
grayhook 9d32cdffb1 Phase 4: add expandSkill — skill meta to injectable user text.
Compose readBody, formatBlock, and appendSuffix for reinject and /skill-reinject now (SPEC §5.3).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:31:45 +07:00
grayhook 049a11a7d5 Phase 4: add appendSuffix — optional reinject message suffix.
Configurable trailing note after skill block per settings.suffix (SPEC §5.3).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:31:37 +07:00
grayhook 68b7d018cc Phase 4: add formatBlock — XML skill block matching Pi expand.
Mirror _expandSkillCommand output shape with name, location, and baseDir hint (SPEC §5.3).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:31:21 +07:00
grayhook 584a8fa342 Phase 4: add readSkillBody — SKILL.md read with frontmatter strip.
Mirror agent-session _expandSkillCommand body extraction via public stripFrontmatter API (SPEC §5.3, §10).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:30:58 +07:00
grayhook 69611685d4 TODO: mark phase 3 complete — skill detection helpers and tests.
Phases 0–3 done; next up is expand.ts (phase 4).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:25:09 +07:00
grayhook 6e55990bfb Phase 3: add detect tests — slash, blocks, read match, trackReadPaths gate.
Cover detection helpers from SPEC §6.2 for regression safety.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:24:49 +07:00
grayhook cc5ffc47bf Phase 3: add trackReadPaths gate — skip read-path detection when disabled.
Honor skillReinject.trackReadPaths before matching read tool paths to skills.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:24:49 +07:00
grayhook 9cd60a2534 Phase 3: add matchReadPathToSkill — read tool path to skill mapping.
Match read paths against registered SKILL.md filePath for the read tracking source.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:23:51 +07:00
grayhook ccb39c413d Phase 3: add parseSkillBlocksFromText — skill-block scan per SPEC §6.2.
Mirror agent-session parseSkillBlock regex for detecting expanded skill blocks in user messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:21:00 +07:00
grayhook 2d7392f5ed Phase 3: add detectSlashSkill — slash command detection per SPEC §6.2.
Detect /skill:name at the start of raw user input for the slash tracking source.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:18:04 +07:00
grayhook 884fee99a5 TODO: mark phase 2 complete — settings types, read, write, effective, tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:14:05 +07:00
grayhook 36cafc4405 Phase 2: add settings tests — defaults, merge, effective helpers.
Covers layered settings merge, incremental global file writes, and
delivery-mode resolution per SPEC §6.5.3.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:13:56 +07:00
grayhook 00ffdff578 Phase 2: add effective helpers — enabled and delivery mode resolution.
Implements SPEC §5.1 session/global layering and §6.5.3 integration
table for defer vs immediate delivery decisions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:12:21 +07:00
grayhook 9b0264f687 Phase 2: add writeGlobalSettings — merge into global settings.json.
Preserves unrelated keys in ~/.pi/agent/settings.json when persisting
/skill-reinject global on|off and other skillReinject fields.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:12:04 +07:00
grayhook d8abd46f90 Phase 2: add settings read — merge global and project via SettingsManager.
Parses skillReinject from Pi settings layers with defaults and project-trust
aware loading so extension code shares one merged settings view.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:11:43 +07:00
grayhook 04dcab5b42 Phase 2: add settings types — SPEC §7.3 contract and defaults.
Defines SkillReinjectSettings and default values so read/merge/effective
helpers share one source of truth.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:08:04 +07:00
grayhook 6050ca98ea TODO: mark phase 1 complete — state types, persist, load, trackSkill.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:05:02 +07:00
grayhook a671a6dc35 Phase 1: add trackSkill — dedupe tracked skills by name.
Upsert merges sources without reordering the skills list per SPEC §6.1
dedupe and insertion-order rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:04:55 +07:00
grayhook edcf5352c4 Phase 1: add loadStateFromBranch — restore last state entry.
Walk branch backwards for skill-reinject:state custom entries per SPEC §6.3;
return structuredClone of valid v1 snapshot or null for full rescan.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:04:11 +07:00
grayhook db04a1dd01 Phase 1: add saveState — persist ExtensionState via appendEntry.
STATE_ENTRY_TYPE skill-reinject:state matches SPEC §6.1 so state survives
/resume and branch reload without a full rescan.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:02:42 +07:00
grayhook 195ed026ff Phase 1: add state factories — predictable session bootstrap.
createInitialState and createRuntimeFlags return SPEC §6.1 defaults
before load, detect, and settings merge on session_start.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:00:46 +07:00
grayhook 57d96e8b46 Phase 1: add state.ts types — shared SPEC §6.1 contract.
TrackedSkill, ExtensionState (version 1), and RuntimeFlags with union
aliases for skill sources, compaction source, and auto-compact integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 09:59:51 +07:00
grayhook 645a46c0e9 TODO: mark phase 0 complete — package manifest, tsconfig, scripts, index shell.
AGENTS status table updated; next up is phase 1 (state and persistence).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 09:56:31 +07:00
grayhook 2ddb9431b5 Phase 0: add src/index.ts shell — minimal ExtensionAPI entry for pi -e smoke.
Register empty session_start handler; real tracking and reinject logic follow in later phases.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 09:56:20 +07:00
grayhook 3ed38d7e1e Phase 0: add npm scripts — typecheck, test, and build entry points.
Vitest with passWithNoTests keeps CI green before test files land in later phases.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 09:54:57 +07:00
grayhook 311c329f87 Phase 0: add tsconfig.json — strict typecheck aligned with jiti ESM load.
Use ESNext/Bundler resolution so extension imports match Pi's jiti runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 09:53:47 +07:00