aboutsummaryrefslogtreecommitdiff
path: root/user/pi/extensions
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-10-07 06:59:42 +0200
committerMartin Fischer <martin@push-f.com>2026-10-29 06:53:27 +0100
commit7dc8285962df04d74f23efba26a0f55a839af45d (patch)
tree1c713aa4ed611254dbee299da5571295c268bc55 /user/pi/extensions
parent4e5ddc8e1f0aaf5206fe364919e61ee047b1fd10 (diff)
feat(workstation): add /doc
Diffstat (limited to 'user/pi/extensions')
-rw-r--r--user/pi/extensions/doc-list.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/user/pi/extensions/doc-list.ts b/user/pi/extensions/doc-list.ts
new file mode 100644
index 0000000..5d87352
--- /dev/null
+++ b/user/pi/extensions/doc-list.ts
@@ -0,0 +1,32 @@
+import { existsSync, readdirSync } from "node:fs";
+import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
+
+const docRoot = "/doc";
+
+function buildDocList(): string | undefined {
+ if (!existsSync(docRoot)) {
+ return undefined;
+ }
+
+ const entries = readdirSync(docRoot, { withFileTypes: true })
+ .filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
+ .map((entry) => entry.name)
+ .sort((a, b) => a.localeCompare(b));
+
+ if (entries.length === 0) {
+ return undefined;
+ }
+
+ return `/doc/ contains documentation for ${entries.join(", ")}. List files with \`find /doc/$name/\` (mind the trailing slash; don't use -type f).`;
+}
+
+export default function docList(pi: ExtensionAPI) {
+ pi.on("before_agent_start", (event) => {
+ const docList = buildDocList();
+ if (docList) {
+ event.systemPromptOptions.sections.documentation = docList;
+ } else {
+ delete event.systemPromptOptions.sections.documentation;
+ }
+ });
+}