@xynogen/pix-skills 0.4.1 → 0.4.3

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/README.md CHANGED
@@ -7,7 +7,7 @@ Pi coding agent extension — skill loader tool + skills bundle.
7
7
  | Resource | Type | Description |
8
8
  |---|---|---|
9
9
  | `read_skills` | tool | Browse and load bundled skills. No args → list all. `name` only → description. `name + full=true` → full instructions. |
10
- | `skills/` | skills | 22 bundled skills (auto-loaded by pi at startup — names + descriptions in system prompt) |
10
+ | `skills/` | skills | 23 bundled skills (auto-loaded by pi at startup — names + descriptions in system prompt) |
11
11
 
12
12
  ## How it works
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-skills",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Pi extension — agent skill loader (skill tool + skills bundle)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: ask-user
3
+ description: "MUST use before high-stakes/irreversible decisions or when requirements are ambiguous. Gather context, present 2-5 options via ask_user, get explicit choice, then proceed."
4
+ metadata:
5
+ short-description: Decision gate for ambiguity and high-stakes choices
6
+ ---
7
+
8
+ # ask_user decision gate
9
+
10
+ Decision control, not chit-chat.
11
+
12
+ ## Gate (call ask_user before proceeding if ANY true)
13
+ - changes architecture/schema/API/deploy/security
14
+ - costly to undo (big refactor, migration, destructive edit, prod behavior)
15
+ - requirements unclear/conflicting/missing
16
+ - multiple valid options, trade-off is preference-dependent
17
+ - about to assume something that changes implementation
18
+
19
+ Skip only if user already gave an explicit decision for THIS exact trade-off.
20
+
21
+ ## Handshake
22
+ 1. classify step: high_stakes | ambiguous | both | clear. clear → no gate.
23
+ 2. gather evidence first (read/bash/web/ref). don't ask blind.
24
+ 3. synthesize: 3-7 bullets — state, constraints, trade-offs, recommendation.
25
+ 4. ask ONE focused question: `question`, `context`(summary), `options`(2-5),
26
+ `allowMultiple:false` unless truly independent, `allowFreeform:true`.
27
+ `inline` displayMode when the preceding summary must stay visible.
28
+ 5. commit: restate decision, say next step, proceed.
29
+ 6. re-ask only on materially new ambiguity. no confirm loops.
30
+
31
+ ## Budget (anti-overasking)
32
+ - max 1 call per boundary normally; max 2 if first is unclear/cancelled.
33
+ - never re-ask same trade-off without new evidence.
34
+ - attempt 2 = narrower question: [Proceed w/ recommended] [Choose other (freeform)] [Stop].
35
+ - after attempt 2: high_stakes/both → STOP, mark blocked.
36
+ ambiguous-only + user says "your call" → take most reversible default, state assumptions.
37
+
38
+ ## Quality
39
+ - question: concrete decision boundary, one decision only.
40
+ - options: short, outcome-oriented, explicit trade-offs; add description when non-obvious.
41
+
42
+ ## Anti-patterns
43
+ asking without context · trivial formatting choices · forcing options when freeform fits ·
44
+ repeat questions w/o new info · proceeding high-stakes after unclear/cancelled answer.
45
+
46
+ ## On cancel / unclear
47
+ Pause, explain what's blocked. At most one narrower follow-up.
48
+ Then: high-stakes → stay blocked until explicit decision; ambiguity-only → proceed only if user delegated.
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: notion
3
+ description: Efficient Notion workspace retrieval. Use when user asks to fetch, search, or read data from Notion — pages, databases, or project lists.
4
+ disable-model-invocation: true
5
+ ---
6
+ # Notion Retrieval Directive
7
+
8
+ ## Core Rule
9
+
10
+ **Data already in context → answer immediately. Zero extra tool calls.**
11
+ If a previous fetch/search already returned the rows, filter/reason over them inline.
12
+ Only call MCP tools when data is genuinely absent from context.
13
+
14
+ ## Tool Map
15
+
16
+ | Goal | Tool | Notes |
17
+ |---|---|---|
18
+ | Find a database/page by name | `notion_notion-search` | filter `{"value":"database"}` for DBs |
19
+ | Get schema + views of a DB | `notion_notion-fetch` with DB UUID | returns schema, SQLite DDL, view configs |
20
+ | Get all rows with properties | batch `notion_notion-fetch` per page UUID | fetch all pages concurrently in ONE message |
21
+ | Search within a data source | `notion_notion-search` with `data_source_url` | semantic; `filters.created_date_range` = creation date only, NOT schedule |
22
+
23
+ ## Retrieval Protocol
24
+
25
+ ### Step 1 — Locate (1 call)
26
+
27
+ Search for the database:
28
+
29
+ ```
30
+ notion_notion-search(query="<name>", filter={value:"database"})
31
+ ```
32
+
33
+ Note the DB `id` and `data-source` collection URL from results.
34
+
35
+ ### Step 2 — Schema (1 call, optional)
36
+
37
+ Only if you need field names / option values:
38
+
39
+ ```
40
+ notion_notion-fetch(id="<db-uuid>")
41
+ ```
42
+
43
+ The response contains full schema + SQLite DDL — read it, don't re-fetch.
44
+
45
+ ### Step 3 — Rows (1 batch)
46
+
47
+ Fetch all known page UUIDs **concurrently in a single message** (parallel tool calls).
48
+ Each call returns full `<properties>` block — Status, Category, Schedule, Stack, etc.
49
+
50
+ **Never re-fetch a page whose properties are already in context.**
51
+
52
+ ## Date / Schedule Filtering
53
+
54
+ - `filters.created_date_range` in `notion_notion-search` = **page creation date**, not schedule field.
55
+ - To filter by schedule/deadline: fetch all rows (Step 3), then filter in-context by `date:📅 Schedule:end` or `date:📅 Schedule:start`.
56
+ - Pattern: `end = "YYYY-MM-30"` or range overlap check — do this mentally/inline, no extra calls.
57
+
58
+ ## Answer Pattern
59
+
60
+ Once rows are in context:
61
+
62
+ ```
63
+ Filter rows where Schedule.end overlaps target month → present table directly.
64
+ ```
65
+
66
+ No re-search, no re-fetch, no confirmation calls.
67
+
68
+ ## Efficiency Rules
69
+
70
+ 1. **Batch parallel**: all page fetches go in one message, not sequential calls.
71
+ 2. **Schema once**: read the DDL from the DB fetch — never fetch schema twice.
72
+ 3. **Search is fuzzy**: `notion_notion-search` is semantic. Use a representative keyword, not empty string (min length 1).
73
+ 4. **Collection URL**: data source URL format is `collection://UUID` — use for `data_source_url` param in search.
74
+ 5. **No re-fetch loop**: if a batch already ran and data is present, stop. Answer from context.
75
+
76
+ ## Common Pitfalls
77
+
78
+ - `notion_notion-search` with `query=""` → error (min 1 char). Use `"project"` or topic keyword.
79
+ - `notion_notion-fetch` requires `id` param (UUID or collection:// URL), not `url`.
80
+ - `filters.created_date_range` ≠ schedule filter — don't use it to find deadline-based rows.
81
+ - Relying on `notion_notion-search` filters for any field-level filtering — internal search is broken, always dump + script.
82
+ - Fetching the database again after already having rows in context = wasted call.
83
+ - Running searches sequentially when they can be parallel = wasted turns.
84
+
85
+ ## Default: Always Dump to File
86
+
87
+ **Notion's internal search is unreliable** — date filters, keyword filters, and empty queries all behave inconsistently. Do not rely on search for filtering. Always:
88
+
89
+ 1. **Fetch all rows** — batch all page UUIDs in one parallel message
90
+ 2. **Dump to `/tmp/notion-<db-name>.json`** — write full properties as JSON array
91
+ 3. **Query with Python/jq** — filter, sort, aggregate locally
92
+ 4. **Answer from script output** — never re-fetch, never re-search
93
+
94
+ ```python
95
+ import json
96
+ rows = json.load(open("/tmp/notion-projects.json"))
97
+
98
+ # filter by deadline month
99
+ june = [r for r in rows if r.get("date:📅 Schedule:end", "").startswith("2026-06")]
100
+ for r in june:
101
+ print(r["Name"], r["Status"], r["date:📅 Schedule:end"])
102
+ ```
103
+
104
+ **Write once, query many** — follow-up questions on same DB: reuse `/tmp/` file, run new script. Zero re-fetches.
105
+
106
+ If `/tmp/notion-<db>.json` already exists from this session → skip fetch entirely, go straight to script.
107
+
108
+ ## Minimal Call Budget
109
+
110
+ | Task | Calls |
111
+ |---|---|
112
+ | List all projects | 2 (search DB → batch fetch → dump `/tmp/`) |
113
+ | Filter by any field | 2 (fetch all → dump) + 1 (python script) |
114
+ | Follow-up on same DB | 0 fetches (reuse `/tmp/`) + 1 (new script) |
115
+ | Get one page's properties | 1 |
116
+ | Get one page's properties | 1 |
117
+ | Check schema only | 1 |
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ import { fileURLToPath } from "node:url";
16
16
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
17
17
  import { Text } from "@earendil-works/pi-tui";
18
18
  import { Type } from "typebox";
19
+ import { once } from "./once.ts";
19
20
 
20
21
  // ─── Skill resolution ─────────────────────────────────────────────────────────
21
22
 
@@ -141,7 +142,7 @@ const ParamsSchema = Type.Object({
141
142
  ),
142
143
  });
143
144
 
144
- export default function registerSkillLoader(pi: ExtensionAPI): void {
145
+ function registerSkillLoader(pi: ExtensionAPI): void {
145
146
  pi.registerTool({
146
147
  name: "read_skills",
147
148
  label: "Read Skills",
@@ -244,3 +245,7 @@ export default function registerSkillLoader(pi: ExtensionAPI): void {
244
245
  },
245
246
  });
246
247
  }
248
+
249
+ export default function (pi: ExtensionAPI): void {
250
+ once("pix-skills", () => registerSkillLoader(pi));
251
+ }
package/src/once.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Idempotency guard for extension activation.
3
+ *
4
+ * pix-core (the meta-package) invokes this package's factory in addition to a
5
+ * possible direct install. Pi's loader uses jiti with `moduleCache: false`, so
6
+ * each load pass re-evaluates modules — a plain module-level flag would not be
7
+ * shared. The dedupe key therefore lives on `globalThis`, which persists for
8
+ * the lifetime of the process across all load passes.
9
+ */
10
+ export function once(key: string, fn: () => void): void {
11
+ const g = globalThis as { __pixLoaded?: Set<string> };
12
+ const loaded = (g.__pixLoaded ??= new Set<string>());
13
+ if (loaded.has(key)) return;
14
+ loaded.add(key);
15
+ fn();
16
+ }