ultimate-pi 0.1.0

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.
Files changed (51) hide show
  1. package/.agents/skills/caveman/SKILL.md +67 -0
  2. package/.agents/skills/compress/SKILL.md +111 -0
  3. package/.agents/skills/compress/scripts/__init__.py +9 -0
  4. package/.agents/skills/compress/scripts/__main__.py +3 -0
  5. package/.agents/skills/compress/scripts/benchmark.py +78 -0
  6. package/.agents/skills/compress/scripts/cli.py +73 -0
  7. package/.agents/skills/compress/scripts/compress.py +227 -0
  8. package/.agents/skills/compress/scripts/detect.py +121 -0
  9. package/.agents/skills/compress/scripts/validate.py +189 -0
  10. package/.agents/skills/context7-cli/SKILL.md +73 -0
  11. package/.agents/skills/context7-cli/references/docs.md +121 -0
  12. package/.agents/skills/context7-cli/references/setup.md +43 -0
  13. package/.agents/skills/context7-cli/references/skills.md +118 -0
  14. package/.agents/skills/emil-design-eng/SKILL.md +679 -0
  15. package/.agents/skills/lean-ctx/SKILL.md +149 -0
  16. package/.agents/skills/lean-ctx/scripts/install.sh +95 -0
  17. package/.agents/skills/scrapling-official/LICENSE.txt +28 -0
  18. package/.agents/skills/scrapling-official/SKILL.md +390 -0
  19. package/.agents/skills/scrapling-official/examples/01_fetcher_session.py +26 -0
  20. package/.agents/skills/scrapling-official/examples/02_dynamic_session.py +26 -0
  21. package/.agents/skills/scrapling-official/examples/03_stealthy_session.py +26 -0
  22. package/.agents/skills/scrapling-official/examples/04_spider.py +58 -0
  23. package/.agents/skills/scrapling-official/examples/README.md +45 -0
  24. package/.agents/skills/scrapling-official/references/fetching/choosing.md +78 -0
  25. package/.agents/skills/scrapling-official/references/fetching/dynamic.md +352 -0
  26. package/.agents/skills/scrapling-official/references/fetching/static.md +432 -0
  27. package/.agents/skills/scrapling-official/references/fetching/stealthy.md +255 -0
  28. package/.agents/skills/scrapling-official/references/mcp-server.md +214 -0
  29. package/.agents/skills/scrapling-official/references/migrating_from_beautifulsoup.md +86 -0
  30. package/.agents/skills/scrapling-official/references/parsing/adaptive.md +212 -0
  31. package/.agents/skills/scrapling-official/references/parsing/main_classes.md +586 -0
  32. package/.agents/skills/scrapling-official/references/parsing/selection.md +494 -0
  33. package/.agents/skills/scrapling-official/references/spiders/advanced.md +344 -0
  34. package/.agents/skills/scrapling-official/references/spiders/architecture.md +94 -0
  35. package/.agents/skills/scrapling-official/references/spiders/getting-started.md +164 -0
  36. package/.agents/skills/scrapling-official/references/spiders/proxy-blocking.md +235 -0
  37. package/.agents/skills/scrapling-official/references/spiders/requests-responses.md +196 -0
  38. package/.agents/skills/scrapling-official/references/spiders/sessions.md +205 -0
  39. package/.github/banner.png +0 -0
  40. package/.pi/SYSTEM.md +40 -0
  41. package/.pi/settings.json +5 -0
  42. package/PLAN.md +11 -0
  43. package/README.md +58 -0
  44. package/extensions/lean-ctx-enforce.ts +166 -0
  45. package/package.json +17 -0
  46. package/skills-lock.json +35 -0
  47. package/wiki/README.md +10 -0
  48. package/wiki/decisions/0001-establish-project-wiki-and-decision-record-format.md +25 -0
  49. package/wiki/decisions/0002-add-project-banner-to-readme.md +26 -0
  50. package/wiki/decisions/0003-remove-redundant-readme-title-heading.md +26 -0
  51. package/wiki/decisions/0004-publish-package-to-npm-as-ultimate-pi.md +26 -0
package/PLAN.md ADDED
@@ -0,0 +1,11 @@
1
+ # Plan
2
+
3
+ ## Harness execution model improvements
4
+ 1. Make harness mimic enterprise software engineering team execution.
5
+ 2. Require project wiki creation at project start.
6
+ 3. Require every design decision to be documented in wiki with rationale.
7
+ 4. Before code changes, require referencing relevant wiki design decisions/guidelines to maintain continuity.
8
+ 5. Reference https://handbook.gitlab.com/handbook/engineering/ while building the harness architecture.
9
+
10
+ ## Tracking note
11
+ - New execution-model requirements are now tracked here for implementation.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ ![Ultimate PI banner](.github/banner.png)
2
+
3
+ > (Beta) The **ultimate AI coding harness** on top of [**pi.dev**](https://pi.dev).
4
+
5
+ ## Goal
6
+
7
+ Ship a production-grade coding harness where the agent:
8
+ 1. uses compressed context before raw tool spam,
9
+ 2. stays concise and deterministic in output style,
10
+ 3. remains easy to extend with skills and extensions.
11
+
12
+ ### Included skills (upstream repositories)
13
+
14
+ | Skill | Upstream repo | What it does |
15
+ |---|---|---|
16
+ | caveman | [juliusbrussee/caveman](https://github.com/juliusbrussee/caveman) | Ultra-compressed response style for token-efficient, high-signal communication. |
17
+ | compress | [juliusbrussee/caveman](https://github.com/juliusbrussee/caveman) | Compresses memory/context files into caveman format while preserving technical content. |
18
+ | lean-ctx | [yvgude/lean-ctx](https://github.com/yvgude/lean-ctx) | Context runtime and compression toolkit for reads/search/shell/edit flows. |
19
+ | context7-cli | [upstash/context7](https://github.com/upstash/context7) | Pulls current library docs and manages Context7 skills/config from CLI. |
20
+ | emil-design-eng | [emilkowalski/skill](https://github.com/emilkowalski/skill) | UI/design craftsmanship guidance: interaction polish, motion, and component quality. |
21
+ | scrapling-official | [D4Vinci/Scrapling](https://github.com/D4Vinci/Scrapling) | Official Scrapling skill for web extraction/scraping with adaptive parsing, JS rendering, stealth fetchers, and anti-bot handling. |
22
+
23
+ ### Runtime guardrail extension
24
+
25
+ - `extensions/lean-ctx-enforce.ts`
26
+ - Detects `lean-ctx` availability.
27
+ - Blocks built-ins (`read`, `write`, `edit`, `grep`, `find`, `ls`, raw `bash`) when `lean-ctx` exists.
28
+ - Allows shell only via `lean-ctx -c <command>`.
29
+ - Adds status commands:
30
+ - `/lean-ctx-status`
31
+ - `/system-prompt-status`
32
+
33
+ ## Design choices (concise)
34
+
35
+ 1. **Lean-ctx-first execution**
36
+ Reason: cut context/token waste and keep tool usage structured.
37
+
38
+ 2. **Caveman-by-default response style**
39
+ Reason: short, exact, low-noise outputs for coding loops.
40
+
41
+ 3. **Policy in system prompt + enforcement in extension**
42
+ Reason: prompt sets intent; extension guarantees behavior.
43
+
44
+ 4. **Skill-based composition**
45
+ Reason: easy to swap/upgrade capabilities without rewiring core package.
46
+
47
+ 5. **Model-agnostic compression path**
48
+ Reason: `compress` skill calls PI CLI, so provider/model can change per environment.
49
+
50
+ ## Use locally
51
+
52
+ From repo root:
53
+
54
+ ```bash
55
+ pi install . -l
56
+ ```
57
+
58
+ Then restart PI or run `/reload`.
@@ -0,0 +1,166 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
2
+ import { readFile, stat } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+
5
+ const GUARDED_TOOLS = new Set(["read", "write", "edit", "grep", "find", "ls", "bash"]);
6
+ const CACHE_TTL_MS = 10_000;
7
+
8
+ type LeanCtxState = {
9
+ checkedAt: number;
10
+ available: boolean;
11
+ bin?: string;
12
+ };
13
+
14
+ type SystemPromptCache = {
15
+ path: string;
16
+ mtimeMs: number;
17
+ text: string;
18
+ };
19
+
20
+ let cachedLeanCtx: LeanCtxState = {
21
+ checkedAt: 0,
22
+ available: false,
23
+ };
24
+
25
+ let cachedSystemPrompt: SystemPromptCache | undefined;
26
+
27
+ async function detectLeanCtx(pi: ExtensionAPI): Promise<LeanCtxState> {
28
+ const now = Date.now();
29
+ if (now - cachedLeanCtx.checkedAt < CACHE_TTL_MS) return cachedLeanCtx;
30
+
31
+ try {
32
+ const result = await pi.exec(
33
+ "bash",
34
+ [
35
+ "-lc",
36
+ 'if command -v lean-ctx >/dev/null 2>&1; then command -v lean-ctx; elif [ -x "$HOME/.local/bin/lean-ctx" ]; then echo "$HOME/.local/bin/lean-ctx"; else exit 1; fi',
37
+ ],
38
+ { timeout: 2000 },
39
+ );
40
+
41
+ cachedLeanCtx = {
42
+ checkedAt: now,
43
+ available: result.code === 0,
44
+ bin: result.code === 0 ? result.stdout.trim().split("\n")[0] : undefined,
45
+ };
46
+ } catch {
47
+ cachedLeanCtx = { checkedAt: now, available: false };
48
+ }
49
+
50
+ return cachedLeanCtx;
51
+ }
52
+
53
+ function bashUsesLeanCtx(command: string): boolean {
54
+ const trimmed = command.trim();
55
+ if (!trimmed) return false;
56
+ return /(^|\s|&&|\|\|)lean-ctx(\s|$)/.test(trimmed);
57
+ }
58
+
59
+ async function loadProjectSystemPrompt(cwd: string): Promise<string | undefined> {
60
+ const path = resolve(cwd, ".pi", "SYSTEM.md");
61
+
62
+ try {
63
+ const info = await stat(path);
64
+ if (cachedSystemPrompt && cachedSystemPrompt.path === path && cachedSystemPrompt.mtimeMs === info.mtimeMs) {
65
+ return cachedSystemPrompt.text;
66
+ }
67
+
68
+ const text = await readFile(path, "utf8");
69
+ const trimmed = text.trim();
70
+ if (!trimmed) return undefined;
71
+
72
+ cachedSystemPrompt = {
73
+ path,
74
+ mtimeMs: info.mtimeMs,
75
+ text: trimmed,
76
+ };
77
+ return trimmed;
78
+ } catch {
79
+ return undefined;
80
+ }
81
+ }
82
+
83
+ function pickVerificationMarker(promptText: string): string | undefined {
84
+ for (const line of promptText.split("\n")) {
85
+ const trimmed = line.trim();
86
+ if (!trimmed) continue;
87
+ if (trimmed.startsWith("#")) continue;
88
+ if (trimmed.startsWith("- ")) continue;
89
+ if (trimmed.length < 12) continue;
90
+ return trimmed.slice(0, 120);
91
+ }
92
+ return undefined;
93
+ }
94
+
95
+ async function reportSystemPromptStatus(ctx: ExtensionContext): Promise<"missing" | "verified" | "uncertain"> {
96
+ const projectPrompt = await loadProjectSystemPrompt(ctx.cwd);
97
+ if (!projectPrompt) {
98
+ ctx.ui.notify(".pi/SYSTEM.md not found. Pi default system prompt active.", "warning");
99
+ return "missing";
100
+ }
101
+
102
+ const effectivePrompt = ctx.getSystemPrompt();
103
+ const marker = pickVerificationMarker(projectPrompt);
104
+ if (marker && effectivePrompt.includes(marker)) {
105
+ ctx.ui.notify(".pi/SYSTEM.md detected and present in effective system prompt.", "success");
106
+ return "verified";
107
+ }
108
+
109
+ ctx.ui.notify(".pi/SYSTEM.md found. Verification uncertain; reload and re-check.", "info");
110
+ return "uncertain";
111
+ }
112
+
113
+ export default function (pi: ExtensionAPI) {
114
+ pi.on("session_start", async (_event, ctx) => {
115
+ const state = await detectLeanCtx(pi);
116
+ if (state.available) {
117
+ ctx.ui.notify(`lean-ctx enforcement active (${state.bin ?? "lean-ctx"})`, "info");
118
+ } else {
119
+ ctx.ui.notify("lean-ctx not found. Built-in tools allowed until installed.", "warning");
120
+ }
121
+
122
+ await reportSystemPromptStatus(ctx);
123
+ });
124
+
125
+ pi.registerCommand("lean-ctx-status", {
126
+ description: "Show lean-ctx enforcement status",
127
+ handler: async (_args, ctx) => {
128
+ cachedLeanCtx.checkedAt = 0;
129
+ const state = await detectLeanCtx(pi);
130
+ if (state.available) {
131
+ ctx.ui.notify(`lean-ctx available: ${state.bin ?? "lean-ctx"}. Built-ins blocked.`, "success");
132
+ } else {
133
+ ctx.ui.notify("lean-ctx unavailable. Built-ins currently allowed.", "warning");
134
+ }
135
+ },
136
+ });
137
+
138
+ pi.registerCommand("system-prompt-status", {
139
+ description: "Check .pi/SYSTEM.md replacement status",
140
+ handler: async (_args, ctx) => {
141
+ await reportSystemPromptStatus(ctx);
142
+ },
143
+ });
144
+
145
+ pi.on("tool_call", async (event) => {
146
+ if (!GUARDED_TOOLS.has(event.toolName)) return;
147
+
148
+ const state = await detectLeanCtx(pi);
149
+ if (!state.available) return;
150
+
151
+ if (event.toolName === "bash") {
152
+ const command = String((event.input as { command?: unknown })?.command ?? "");
153
+ if (bashUsesLeanCtx(command)) return;
154
+
155
+ return {
156
+ block: true,
157
+ reason: "Blocked by lean-ctx enforcement. Use `lean-ctx -c <command>` for shell commands.",
158
+ };
159
+ }
160
+
161
+ return {
162
+ block: true,
163
+ reason: `Blocked by lean-ctx enforcement. Use lean-ctx tools/flows instead of built-in \`${event.toolName}\`.`,
164
+ };
165
+ });
166
+ }
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "ultimate-pi",
3
+ "version": "0.1.0",
4
+ "description": "Custom pi package starter with caveman and impeccable.style skills",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "license": "MIT",
9
+ "pi": {
10
+ "extensions": [
11
+ "./extensions"
12
+ ],
13
+ "skills": [
14
+ "./.agents/skills"
15
+ ]
16
+ }
17
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": 1,
3
+ "skills": {
4
+ "caveman": {
5
+ "source": "juliusbrussee/caveman",
6
+ "sourceType": "github",
7
+ "computedHash": "a818cdc41dcfaa50dd891c5cb5e5705968338de02e7e37949ca56e8c30ad4176"
8
+ },
9
+ "compress": {
10
+ "source": "juliusbrussee/caveman",
11
+ "sourceType": "github",
12
+ "computedHash": "05c97bc3120108acd0b80bdef7fb4fa7c224ba83c8d384ccbc97f92e8a065918"
13
+ },
14
+ "context7-cli": {
15
+ "source": "upstash/context7",
16
+ "sourceType": "github",
17
+ "computedHash": "525bfb31161c3f8866920a28fb2d9a3003a23b449aa8619b1b1add0da2cc3300"
18
+ },
19
+ "emil-design-eng": {
20
+ "source": "emilkowalski/skill",
21
+ "sourceType": "github",
22
+ "computedHash": "8bdf9e4e6de7a4969147bf4828a4ad2c5aacd9fba4b690b250a85e0467ca387d"
23
+ },
24
+ "lean-ctx": {
25
+ "source": "yvgude/lean-ctx",
26
+ "sourceType": "github",
27
+ "computedHash": "3d29c02c1c3928c838228cf11635c8041e52acc2e804ba2dd19450530a34c53e"
28
+ },
29
+ "scrapling-official": {
30
+ "source": "D4Vinci/Scrapling",
31
+ "sourceType": "github",
32
+ "computedHash": "af9bee8b531aa5b4d499eeebca66edb0224b1ed9b61540588765140628bd7ff2"
33
+ }
34
+ }
35
+ }
package/wiki/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # Project Wiki
2
+
3
+ ## Purpose
4
+ Track architecture and implementation decisions for this repo.
5
+
6
+ ## Decision log
7
+ - [0001 - Establish project wiki and decision record format](decisions/0001-establish-project-wiki-and-decision-record-format.md)
8
+ - [0002 - Add project banner to README](decisions/0002-add-project-banner-to-readme.md)
9
+ - [0003 - Remove redundant README title heading when banner already contains title](decisions/0003-remove-redundant-readme-title-heading.md)
10
+ - [0004 - Publish package to npm as ultimate-pi](decisions/0004-publish-package-to-npm-as-ultimate-pi.md)
@@ -0,0 +1,25 @@
1
+ # 0001 - Establish project wiki and decision record format
2
+
3
+ - Date: 2026-04-25
4
+ - Status: Accepted
5
+
6
+ ## Context
7
+ Execution model requires project wiki and documented design decisions.
8
+ No wiki existed in repository.
9
+
10
+ ## Alternatives
11
+ 1. Keep decisions in ad-hoc commit messages.
12
+ 2. Store decisions in a single PLAN.md section.
13
+ 3. Create dedicated wiki/ with ADR-style files.
14
+
15
+ ## Chosen option
16
+ Create wiki/ with numbered decision files in wiki/decisions/.
17
+
18
+ ## Rationale
19
+ - Gives stable place for all implementation decisions.
20
+ - Scales better than one growing plan file.
21
+ - Easy to reference before each code change.
22
+
23
+ ## Consequences
24
+ - Every implementation change must cite relevant decision docs.
25
+ - Small overhead: keep decision log updated.
@@ -0,0 +1,26 @@
1
+ # 0002 - Add project banner to README
2
+
3
+ - Date: 2026-04-25
4
+ - Status: Accepted
5
+
6
+ ## Context
7
+ User requested adding .github/banner.png to README.md as project banner.
8
+ README currently has no image banner.
9
+
10
+ ## Alternatives
11
+ 1. Keep no banner.
12
+ 2. Use HTML img tag for size/alignment control.
13
+ 3. Use standard Markdown image link.
14
+
15
+ ## Chosen option
16
+ Use standard Markdown image syntax near top of README:
17
+ ![Ultimate PI banner](.github/banner.png)
18
+
19
+ ## Rationale
20
+ - Minimal diff.
21
+ - Renders on GitHub without extra HTML.
22
+ - Keeps README portable and simple.
23
+
24
+ ## Consequences
25
+ - Large image may dominate first screen on some displays.
26
+ - Future size control would require switching to HTML tag.
@@ -0,0 +1,26 @@
1
+ # 0003 - Remove redundant README title heading when banner already contains title
2
+
3
+ - Date: 2026-04-25
4
+ - Status: Accepted
5
+
6
+ ## Context
7
+ README shows an H1 title and a banner image.
8
+ Banner already contains the same project title text (Ultimate Pi).
9
+ User requested removing redundant headings.
10
+
11
+ ## Alternatives
12
+ 1. Keep H1 and keep banner unchanged.
13
+ 2. Keep H1 and replace banner with non-title artwork.
14
+ 3. Remove H1 and keep banner as top title element.
15
+
16
+ ## Chosen option
17
+ Remove top-level H1 from README and keep banner at top.
18
+
19
+ ## Rationale
20
+ - Directly satisfies user request with minimal diff.
21
+ - Avoids duplicate title presentation.
22
+ - Preserves remaining README structure.
23
+
24
+ ## Consequences
25
+ - README no longer has explicit Markdown H1.
26
+ - Banner becomes primary title element.
@@ -0,0 +1,26 @@
1
+ # 0004 - Publish package to npm as ultimate-pi
2
+
3
+ - Date: 2026-04-25
4
+ - Status: Accepted
5
+
6
+ ## Context
7
+ User requested npm publication under package name ultimate-pi.
8
+ Current package metadata blocks publish (private true) and uses different name (ultimate-pi-package).
9
+
10
+ ## Alternatives
11
+ 1. Keep current package name and publish under existing metadata.
12
+ 2. Publish under scoped name (for example @owner/ultimate-pi).
13
+ 3. Rename package to ultimate-pi and remove publish block.
14
+
15
+ ## Chosen option
16
+ Rename package.json name to ultimate-pi and remove private field so npm publish can succeed.
17
+
18
+ ## Rationale
19
+ - Matches explicit user requirement.
20
+ - Keeps package unscoped and discoverable.
21
+ - Smallest metadata diff needed for publish.
22
+
23
+ ## Consequences
24
+ - Package name must stay unique in npm registry.
25
+ - Future publishes require version bumps.
26
+ - Publish operation depends on local npm authentication.