pi-gsd 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,6 +81,67 @@ const syncReferenceToCore = (cwd: string, ref: string[]): void => {
81
81
  };
82
82
 
83
83
  export default function (pi: ExtensionAPI) {
84
+ // ── input: inject @file contents before the LLM sees the message ──────────
85
+ // Replaces @.pi/gsd/... and @.planning/... references with actual file
86
+ // contents programmatically. Zero tool calls, provider-agnostic.
87
+ // Missing files → red error + action:"handled" skips the LLM entirely.
88
+ pi.on("input", async (event, ctx) => {
89
+ if (event.source === "extension") return { action: "continue" };
90
+
91
+ const text = event.text;
92
+ const fileRefPattern = /@(\.pi\/gsd\/[^\s]+|\.planning\/[^\s]+)/g;
93
+ const refs = [...text.matchAll(fileRefPattern)];
94
+ if (refs.length === 0) return { action: "continue" };
95
+
96
+ // Fallback lookup: package harness root via this extension file's location
97
+ // <pkg>/.gsd/extensions/pi-gsd-hooks.ts → <pkg>/.gsd/harnesses/pi/get-shit-done
98
+ const pkgHarness = join(dirname(__filename), "..", "harnesses", "pi", "get-shit-done");
99
+
100
+ const failed: string[] = [];
101
+ let transformed = text;
102
+
103
+ for (const match of refs) {
104
+ const relPath = match[1];
105
+ const subPath = relPath.replace(/^\.pi\/gsd\//, "");
106
+
107
+ // Lookup order:
108
+ // 1. Project symlink: <cwd>/.pi/gsd/<subPath>
109
+ // 2. Package harness: <pkg>/.gsd/harnesses/pi/get-shit-done/<subPath>
110
+ const candidates = [
111
+ join(ctx.cwd, relPath),
112
+ ...(relPath.startsWith(".pi/gsd/") ? [join(pkgHarness, subPath)] : []),
113
+ ];
114
+
115
+ let fileContent: string | null = null;
116
+ for (const candidate of candidates) {
117
+ try {
118
+ if (existsSync(candidate)) {
119
+ fileContent = readFileSync(candidate, "utf8");
120
+ break;
121
+ }
122
+ } catch { /* try next */ }
123
+ }
124
+
125
+ if (fileContent === null) {
126
+ failed.push(relPath);
127
+ } else {
128
+ transformed = transformed.replace(
129
+ match[0],
130
+ `<!-- @${relPath} -->\n${fileContent}\n<!-- /@${relPath} -->`,
131
+ );
132
+ }
133
+ }
134
+
135
+ if (failed.length > 0) {
136
+ ctx.ui.notify(
137
+ `❌ GSD context injection failed — missing files:\n${failed.map((f) => ` • ${f}`).join("\n")}\n\nRun /gsd-setup-pi to reinstall the harness.`,
138
+ "error",
139
+ );
140
+ return { action: "handled" }; // skip LLM entirely
141
+ }
142
+
143
+ return { action: "transform", text: transformed };
144
+ });
84
145
  // ── session_start: GSD update check ──────────────────────────────────────
85
146
  pi.on("session_start", async (_event, ctx) => {
86
147
  // Ensure harness files are reachable via .pi/gsd/ symlink
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-gsd",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "Get Shit Done - Unofficial port of the renowned AI-native project-planning spec-driven toolkit",
5
5
  "main": "dist/pi-gsd-tools.js",
6
6
  "bin": {