@maxiaochao/pi-toolkit 0.1.6 → 0.1.8
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/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
## 2026-08-
|
|
1
|
+
## 2026-08-31 - v0.1.8
|
|
2
|
+
|
|
3
|
+
- fix cache export branch attribution and update HTML artifact guidance
|
|
4
|
+
|
|
5
|
+
## 2026-08-21 - v0.1.7
|
|
6
|
+
|
|
7
|
+
- add the html-artifact skill for interactive HTML explanations and codebase visualizations
|
|
8
|
+
- register and package the skill for Pi discovery
|
|
9
|
+
- prefer `.cache/html/` for generated temporary HTML artifacts
|
|
10
|
+
|
|
2
11
|
|
|
3
12
|
- expand global agent guidance and reuse-before-writing rules
|
|
4
13
|
|
|
@@ -63,7 +63,10 @@ export default function (pi) {
|
|
|
63
63
|
pi.registerCommand("cache_export", {
|
|
64
64
|
description: "Export a tau-style interactive cache dashboard (hit-rate charts, per-request table, events)",
|
|
65
65
|
handler: async (args, ctx) => {
|
|
66
|
-
const
|
|
66
|
+
const sessionManager = ctx.sessionManager;
|
|
67
|
+
const entries = typeof sessionManager.getBranch === "function"
|
|
68
|
+
? sessionManager.getBranch()
|
|
69
|
+
: sessionManager.getEntries();
|
|
67
70
|
if (!entries || entries.length === 0) {
|
|
68
71
|
ctx.ui.notify("No session entries to analyze.", "error");
|
|
69
72
|
return;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// Deterministic test cases for analyzeStreaks / analyzeMisses / parseEntries.
|
|
2
2
|
// Run: node --experimental-strip-types tests/run-tests.mjs
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import registerCacheExport from "../index.ts";
|
|
3
7
|
import { parseEntries, analyzeStreaks, analyzeMisses, lineChartForTest } from "../render.ts";
|
|
4
8
|
|
|
5
9
|
let pass = 0, fail = 0;
|
|
@@ -314,6 +318,53 @@ const hitOf = (r) => r.cached / (r.fresh + r.cached + r.cacheWrite);
|
|
|
314
318
|
s.length === 2 && s.every((x) => x.hits.length === 3), JSON.stringify(s.map((x) => [x.from, x.to])));
|
|
315
319
|
}
|
|
316
320
|
|
|
321
|
+
// Q. subagent results remain visible as main-session tool input -----------
|
|
322
|
+
{
|
|
323
|
+
const entries = [
|
|
324
|
+
req({ cached: 0, fresh: 10000, min: 1, content: [
|
|
325
|
+
{ type: "toolCall", tool: "subagent", name: "subagent" },
|
|
326
|
+
{ type: "toolCall", tool: "bash", name: "bash" },
|
|
327
|
+
] }),
|
|
328
|
+
toolResult("delegated result", "subagent"),
|
|
329
|
+
toolResult("ordinary result", "bash"),
|
|
330
|
+
req({ cached: 9000, fresh: 10000, min: 2 }),
|
|
331
|
+
];
|
|
332
|
+
const d = parseEntries(entries);
|
|
333
|
+
check("Q subagent invocation remains in main-session tool counts",
|
|
334
|
+
d.toolCalls.some(([name]) => name === "subagent") && d.toolCalls.some(([name]) => name === "bash"),
|
|
335
|
+
JSON.stringify(d.toolCalls));
|
|
336
|
+
check("Q subagent result remains available for main fresh-input attribution",
|
|
337
|
+
d.requests[1].gapTools.length === 2 && d.requests[1].gapTools.some(({ tool }) => tool === "subagent"),
|
|
338
|
+
JSON.stringify(d.requests[1].gapTools));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// R. command exports only the current main-session branch ----------------
|
|
342
|
+
{
|
|
343
|
+
const root = mkdtempSync(join(tmpdir(), "cache-export-test-"));
|
|
344
|
+
const reportFile = join(root, "report.html");
|
|
345
|
+
const entry = (value, id, parentId) => ({ ...value, id, parentId });
|
|
346
|
+
const first = entry(req({ cached: 9000, fresh: 1000, min: 1, model: "main-first" }), "p1", null);
|
|
347
|
+
const abandoned = entry(req({ cached: 0, fresh: 9000, min: 2, model: "abandoned-model" }), "p2", "p1");
|
|
348
|
+
const active = entry(req({ cached: 8000, fresh: 2000, min: 3, model: "active-model" }), "p3", "p1");
|
|
349
|
+
|
|
350
|
+
let command;
|
|
351
|
+
registerCacheExport({ registerCommand: (name, definition) => { if (name === "cache_export") command = definition; } });
|
|
352
|
+
await command.handler(reportFile, {
|
|
353
|
+
sessionManager: {
|
|
354
|
+
getBranch: () => [first, active],
|
|
355
|
+
getEntries: () => [first, abandoned, active],
|
|
356
|
+
getSessionFile: () => join(root, "main.jsonl"),
|
|
357
|
+
getSessionId: () => "main",
|
|
358
|
+
},
|
|
359
|
+
ui: { notify: () => {} },
|
|
360
|
+
});
|
|
361
|
+
const html = readFileSync(reportFile, "utf8");
|
|
362
|
+
check("R current branch excludes abandoned requests",
|
|
363
|
+
html.includes("2 requests") && html.includes("active-model") && !html.includes("abandoned-model"));
|
|
364
|
+
check("R main-only report has no subagent dashboard", !html.includes("Subagent cache"));
|
|
365
|
+
rmSync(root, { recursive: true, force: true });
|
|
366
|
+
}
|
|
367
|
+
|
|
317
368
|
// K. degenerate inputs ---------------------------------------------------
|
|
318
369
|
{
|
|
319
370
|
check("K empty session -> no crash, no streaks", analyzeStreaks(parseEntries([]).requests).length === 0);
|
package/global/AGENTS.md
CHANGED
|
@@ -102,4 +102,9 @@ After each significant step:
|
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
|
|
106
|
+
## Output Format Preference
|
|
107
|
+
|
|
108
|
+
For complex explanations, prefer a runnable HTML artifact over a long Markdown-only response when the content benefits from visual structure or interaction. This includes workflows, code/module relationships, state machines, event/data flows, architecture maps, timelines, comparisons, dashboards, and interactive demonstrations. Keep ordinary prose, short answers, diffs, and focused code reviews in Markdown.
|
|
109
|
+
|
|
110
|
+
When using HTML, create a self-contained, responsive artifact in the project's established output location, or `.cache/html/<descriptive-name>.html` when no convention exists. Use semantic HTML, accessible controls, escaped code blocks, and small useful interactions. Return a concise Markdown summary with a clickable local file path; if a preview/server tool is available, start it and return the preview URL only after verifying the page is not blank and its assets load.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxiaochao/pi-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Personal pi coding agent toolkit: /todos extension + /cache_export interactive cache dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"README.md",
|
|
13
13
|
"CHANGELOG.md",
|
|
14
14
|
"global/AGENTS.md",
|
|
15
|
-
"scripts/install-agents.mjs"
|
|
15
|
+
"scripts/install-agents.mjs",
|
|
16
|
+
"skills"
|
|
16
17
|
],
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -22,6 +23,9 @@
|
|
|
22
23
|
"extensions": [
|
|
23
24
|
"./extensions/todo.ts",
|
|
24
25
|
"./extensions/cache-export/index.ts"
|
|
26
|
+
],
|
|
27
|
+
"skills": [
|
|
28
|
+
"./skills"
|
|
25
29
|
]
|
|
26
30
|
},
|
|
27
31
|
"peerDependencies": {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: html-artifact
|
|
3
|
+
description: Create self-contained, responsive HTML artifacts for complex explanations that benefit from visual structure or interaction, including workflows, code/module relationships, state machines, event/data flows, architecture maps, timelines, comparisons, dashboards, and interactive demonstrations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# HTML Artifact
|
|
7
|
+
|
|
8
|
+
## Decide the format
|
|
9
|
+
|
|
10
|
+
Use Markdown when the response is short, linear, text-first, or primarily a focused code review. Use an HTML artifact when visual layout, filtering, expanding details, tabs, highlighting, diagrams, timelines, or interactive state changes materially improve understanding.
|
|
11
|
+
|
|
12
|
+
Do not create HTML merely to wrap a small answer. The artifact should reduce cognitive load and make the subject easier to inspect.
|
|
13
|
+
|
|
14
|
+
## Create the artifact
|
|
15
|
+
|
|
16
|
+
1. Read the relevant code and verify names, relationships, and behavior before visualizing them.
|
|
17
|
+
2. Follow the project's existing output convention. If none exists, write to `.cache/html/<descriptive-name>.html`.
|
|
18
|
+
3. Prefer one self-contained HTML file with inline CSS and JavaScript so it can be opened or previewed without a build step.
|
|
19
|
+
4. Use semantic HTML, responsive layout, keyboard-accessible controls, visible focus states, and stable dimensions for interactive elements.
|
|
20
|
+
5. Use restrained styling suited to the domain. Keep diagrams and panels scannable; do not hide important information behind interaction.
|
|
21
|
+
6. Escape source code before placing it in `<pre><code>` blocks. Do not alter code identifiers, paths, or quoted source text for presentation.
|
|
22
|
+
7. Add only interactions that answer a real viewing need: tabs, expand/collapse, search/filter, step-through state, highlighting, or a reset control.
|
|
23
|
+
8. Keep external dependencies out unless the project already uses them. If a library is necessary, document the dependency and provide a usable fallback when practical.
|
|
24
|
+
|
|
25
|
+
## Verify and report
|
|
26
|
+
|
|
27
|
+
After writing the file, verify that it exists and contains a complete document. If a preview or dev-server tool is available, start it and check the returned health status before reporting success. Use the preview URL returned by that tool; never present `localhost` as a user-facing online URL when the environment uses a reverse proxy.
|
|
28
|
+
|
|
29
|
+
Respond with a concise Markdown summary and a clickable file path or verified preview URL. Mention any limitation, such as a preview service not being available. Do not paste the entire HTML into the chat unless the user explicitly asks for it.
|