pi-gsd 1.11.0 → 1.11.2
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.
- package/.gsd/extensions/pi-gsd-hooks.ts +42 -31
- package/package.json +1 -1
|
@@ -81,53 +81,64 @@ const syncReferenceToCore = (cwd: string, ref: string[]): void => {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export default function (pi: ExtensionAPI) {
|
|
84
|
-
// ──
|
|
85
|
-
// Replaces @.pi/gsd/... references with actual file
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
pi.on("
|
|
89
|
-
|
|
90
|
-
|
|
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 = [...
|
|
95
|
-
if (refs.length === 0) return
|
|
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
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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(match[0], fileContent);
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
if (failed.length > 0) {
|
|
115
133
|
ctx.ui.notify(
|
|
116
|
-
`❌ GSD context injection failed — missing files:\n${failed.map((f) => ` • ${f}`).join("\n")}\n\
|
|
134
|
+
`❌ GSD context injection failed — missing files:\n${failed.map((f) => ` • ${f}`).join("\n")}\n\nRun /gsd-setup-pi to reinstall the harness.`,
|
|
117
135
|
"error",
|
|
118
136
|
);
|
|
119
|
-
return {
|
|
137
|
+
return { action: "handled" }; // skip LLM entirely
|
|
120
138
|
}
|
|
121
139
|
|
|
122
|
-
return {
|
|
123
|
-
message: {
|
|
124
|
-
customType: "pi-gsd-context",
|
|
125
|
-
content: injected.join("\n\n"),
|
|
126
|
-
display: false,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
140
|
+
return { action: "transform", text: transformed };
|
|
129
141
|
});
|
|
130
|
-
|
|
131
142
|
// ── session_start: GSD update check ──────────────────────────────────────
|
|
132
143
|
pi.on("session_start", async (_event, ctx) => {
|
|
133
144
|
// Ensure harness files are reachable via .pi/gsd/ symlink
|