pi-gsd 1.11.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,53 +81,67 @@ const syncReferenceToCore = (cwd: string, ref: string[]): void => {
81
81
  };
82
82
 
83
83
  export default function (pi: ExtensionAPI) {
84
- // ── before_agent_start: inject @file contents into the prompt ────────────
85
- // Replaces @.pi/gsd/... references with actual file contents so the LLM
86
- // gets the full context in the first message. No tool calls, no token
87
- // waste, provider-agnostic.
88
- pi.on("before_agent_start", async (event, ctx) => {
89
- const prompt = event.prompt;
90
- if (!prompt) return undefined;
91
-
92
- // Match @.pi/gsd/... and @.planning/... file references
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;
93
92
  const fileRefPattern = /@(\.pi\/gsd\/[^\s]+|\.planning\/[^\s]+)/g;
94
- const refs = [...prompt.matchAll(fileRefPattern)];
95
- if (refs.length === 0) return undefined;
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");
96
99
 
97
- const injected: string[] = [];
98
100
  const failed: string[] = [];
101
+ let transformed = text;
102
+
99
103
  for (const match of refs) {
100
104
  const relPath = match[1];
101
- const absPath = join(ctx.cwd, relPath);
102
- try {
103
- if (existsSync(absPath)) {
104
- const content = readFileSync(absPath, "utf8");
105
- injected.push(`<!-- @${relPath} -->\n${content}\n<!-- /@${relPath} -->`);
106
- } else {
107
- failed.push(relPath);
108
- }
109
- } catch {
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) {
110
126
  failed.push(relPath);
127
+ } else {
128
+ transformed = transformed.replace(
129
+ match[0],
130
+ `<!-- @${relPath} -->\n${fileContent}\n<!-- /@${relPath} -->`,
131
+ );
111
132
  }
112
133
  }
113
134
 
114
135
  if (failed.length > 0) {
115
136
  ctx.ui.notify(
116
- `❌ GSD context injection failed — missing files:\n${failed.map((f) => ` • ${f}`).join("\n")}\n\nCheck that .pi/gsd/ symlink exists and points to the harness.`,
137
+ `❌ GSD context injection failed — missing files:\n${failed.map((f) => ` • ${f}`).join("\n")}\n\nRun /gsd-setup-pi to reinstall the harness.`,
117
138
  "error",
118
139
  );
119
- return { abort: true };
140
+ return { action: "handled" }; // skip LLM entirely
120
141
  }
121
142
 
122
- return {
123
- message: {
124
- customType: "pi-gsd-context",
125
- content: injected.join("\n\n"),
126
- display: false,
127
- },
128
- };
143
+ return { action: "transform", text: transformed };
129
144
  });
130
-
131
145
  // ── session_start: GSD update check ──────────────────────────────────────
132
146
  pi.on("session_start", async (_event, ctx) => {
133
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.11.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": {