pi-incise 0.3.3 → 0.5.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.
package/README.md CHANGED
@@ -41,6 +41,12 @@ Set `INCISE_PROFILE=safe-small` only to reproduce the earlier experimental small
41
41
 
42
42
  Set `INCISE_PROFILE=minicpm-list` only to reproduce the earlier MiniCPM-specific list-addition pipeline. It supports list additions only; the general MiniCPM recommendation is now `auto`.
43
43
 
44
+ The version-matched native binary also contains the confirmed `incise table-delete` CLI operation for automation and direct shell use. It is not an action in the Pi `table_edit` schema: three preregistered model-facing candidates missed the required confirmation-recovery gate, so the measured standard and fallback surfaces remain unchanged.
45
+
46
+ ## Structural check skill
47
+
48
+ The package includes the explicit-only `/skill:incise-check` skill. When that skill starts, the extension registers a read-only `md_check` tool backed by the same version-matched binary, then enables only the semantic repair tool named by the report. Ordinary runs never register or activate `md_check`, and the previous active tool surface is restored when the skill run ends. The skill handles `automatic`, `explicit`, and `manual` findings without reconstructing the file; `disable-model-invocation: true` keeps it out of automatic selection.
49
+
44
50
  ## Measured results
45
51
 
46
52
  The current MiniCPM5 2B `auto` profile completed **480/480 full-composition trials (100%) with zero harmful outcomes**. Tables were 60/60, lists 100/100, sections 150/150, frontmatter 110/110, and table reads 60/60. All **470/470 routed trials** passed exact tool-surface and host-resolved-argument audits; all 10 standard fallbacks exposed the unchanged eight-tool surface. The recorded configuration used the official Q8_0 checkpoint through llama.cpp with thinking off, a 65,536-token context, `maxTokens: 8192`, temperature 0.7, and top-p 0.95.
@@ -0,0 +1,94 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { TSchema } from "typebox";
3
+
4
+ import type { ResolvedBinary } from "./binary.ts";
5
+ import { resolveToolPath, type ToolArguments } from "./normalize.ts";
6
+ import { processError, runIncise, type IncisePayload } from "./runner.ts";
7
+
8
+ export const CHECK_TOOL_NAME = "md_check";
9
+
10
+ export const CHECK_TOOL_SCHEMA = {
11
+ name: CHECK_TOOL_NAME,
12
+ description: "Check one Markdown file for Incise structural hazards. Read-only. Returns the exact versioned JSON report. Available only while the explicit incise-check skill is active.",
13
+ parameters: {
14
+ type: "object",
15
+ properties: {
16
+ path: { type: "string", description: "Markdown file to check." },
17
+ },
18
+ required: ["path"],
19
+ additionalProperties: false,
20
+ },
21
+ } as const;
22
+
23
+ const SKILL_WRAPPER = /^<skill name="incise-check" location="[^"]+">\n/;
24
+
25
+ export function isExplicitCheckSkillPrompt(prompt: string): boolean {
26
+ return SKILL_WRAPPER.test(prompt);
27
+ }
28
+
29
+ export function repairTools(report: IncisePayload, available: ReadonlySet<string>): string[] {
30
+ const mapped = new Set<string>();
31
+ const findings = Array.isArray(report.findings) ? report.findings : [];
32
+ for (const finding of findings) {
33
+ if (!finding || typeof finding !== "object" || Array.isArray(finding)) continue;
34
+ const repair = (finding as Record<string, unknown>).repair;
35
+ if (!repair || typeof repair !== "object" || Array.isArray(repair)) continue;
36
+ const operation = (repair as Record<string, unknown>).operation;
37
+ if (typeof operation !== "string") continue;
38
+ const name = operation.startsWith("table-") ? "table_edit"
39
+ : operation.startsWith("list-") ? "list_edit"
40
+ : operation.startsWith("section-") ? "section_edit"
41
+ : operation.startsWith("frontmatter-") ? "frontmatter_edit"
42
+ : undefined;
43
+ if (name && available.has(name)) mapped.add(name);
44
+ }
45
+ return [...mapped];
46
+ }
47
+
48
+ export function installCheckSkillTool(
49
+ pi: ExtensionAPI,
50
+ binary: ResolvedBinary,
51
+ standardTools: readonly string[],
52
+ ): void {
53
+ const available = new Set(standardTools);
54
+ let active = false;
55
+ let registered = false;
56
+ let restore: string[] | undefined;
57
+
58
+ const register = (): void => {
59
+ if (registered) return;
60
+ pi.registerTool({
61
+ name: CHECK_TOOL_SCHEMA.name,
62
+ label: CHECK_TOOL_SCHEMA.name,
63
+ description: CHECK_TOOL_SCHEMA.description,
64
+ parameters: CHECK_TOOL_SCHEMA.parameters as TSchema,
65
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
66
+ if (!active) throw new Error("md_check is available only while the explicit incise-check skill is active.");
67
+ const located = resolveToolPath(params as ToolArguments, ctx.cwd);
68
+ const result = await runIncise(pi.exec.bind(pi), binary.path, ["check", located.path], signal);
69
+ if (result.code !== 0 || result.payload.ok === false) throw processError(result);
70
+ pi.setActiveTools([CHECK_TOOL_NAME, ...repairTools(result.payload, available)]);
71
+ return {
72
+ content: [{ type: "text", text: JSON.stringify(result.payload) }],
73
+ details: result.payload,
74
+ };
75
+ },
76
+ });
77
+ registered = true;
78
+ };
79
+
80
+ pi.on("before_agent_start", async (event) => {
81
+ if (!isExplicitCheckSkillPrompt(event.prompt)) return;
82
+ restore = pi.getActiveTools().filter((name) => name !== CHECK_TOOL_NAME);
83
+ active = true;
84
+ register();
85
+ pi.setActiveTools([CHECK_TOOL_NAME]);
86
+ });
87
+
88
+ pi.on("agent_end", async () => {
89
+ if (!active) return;
90
+ active = false;
91
+ pi.setActiveTools(restore ?? standardTools.slice());
92
+ restore = undefined;
93
+ });
94
+ }
@@ -2,6 +2,7 @@ import { withFileMutationQueue, type ExtensionAPI } from "@earendil-works/pi-cod
2
2
  import type { TSchema } from "typebox";
3
3
 
4
4
  import { packageVersion, resolveBinary, type ResolvedBinary } from "./binary.ts";
5
+ import { installCheckSkillTool } from "./check-skill.ts";
5
6
  import { installMiniCpmListProfile, MINICPM_LIST_TOOL_NAMES } from "./minicpm-list.ts";
6
7
  import { prepareInvocation, READ_SUBCOMMAND, type ToolArguments } from "./normalize.ts";
7
8
  import {
@@ -216,5 +217,6 @@ export default async function inciseExtension(pi: ExtensionAPI): Promise<void> {
216
217
  onRoute(route) { diagnostics.activeRoute = route; },
217
218
  });
218
219
  }
220
+ installCheckSkillTool(pi, binary, schemas.map((schema) => schema.name));
219
221
  registerDoctor(pi, diagnostics);
220
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-incise",
3
- "version": "0.3.3",
3
+ "version": "0.5.0",
4
4
  "description": "Semantic, byte-preserving Markdown editing tools for Pi and AI agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "files": [
29
29
  "extension",
30
+ "skills",
30
31
  "LICENSE",
31
32
  "README.md"
32
33
  ],
@@ -34,6 +35,9 @@
34
35
  "extensions": [
35
36
  "./extension/index.ts"
36
37
  ],
38
+ "skills": [
39
+ "./skills/incise-check"
40
+ ],
37
41
  "image": "https://pdalinis.github.io/incise/assets/incise-preview.png"
38
42
  },
39
43
  "peerDependencies": {
@@ -41,15 +45,15 @@
41
45
  "typebox": "*"
42
46
  },
43
47
  "devDependencies": {
44
- "@earendil-works/pi-coding-agent": "^0.85.1",
48
+ "@earendil-works/pi-coding-agent": "^0.99.1",
45
49
  "@types/node": "^22.19.19",
46
50
  "typescript": "^5.9.3"
47
51
  },
48
52
  "optionalDependencies": {
49
- "@pdalinis/pi-incise-darwin-arm64": "0.3.3",
50
- "@pdalinis/pi-incise-darwin-x64": "0.3.3",
51
- "@pdalinis/pi-incise-linux-arm64-gnu": "0.3.3",
52
- "@pdalinis/pi-incise-linux-x64-gnu": "0.3.3"
53
+ "@pdalinis/pi-incise-darwin-arm64": "0.5.0",
54
+ "@pdalinis/pi-incise-darwin-x64": "0.5.0",
55
+ "@pdalinis/pi-incise-linux-arm64-gnu": "0.5.0",
56
+ "@pdalinis/pi-incise-linux-x64-gnu": "0.5.0"
53
57
  },
54
58
  "scripts": {
55
59
  "test": "node --test --experimental-strip-types test/*.test.ts",
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: incise-check
3
+ description: Check Markdown for structural hazards that affect Incise addressing or byte-preserving edits, and handle Incise checker findings without broad rewrites.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Incise structural check
8
+
9
+ Use this skill when the user explicitly asks to validate a Markdown file, inspect an Incise checker finding, or verify an Incise edit. This is not a style-lint workflow.
10
+
11
+ Call `md_check` with the Markdown path. It is the version-matched, read-only
12
+ checker supplied by the host integration and returns the versioned JSON report.
13
+ Do not search for a launcher or use terminal commands in place of `md_check`.
14
+
15
+ For a report:
16
+
17
+ - Stop when `status` is `clean`.
18
+ - Treat the check itself as successful even when findings exist; branch on `status` and finding `code`, not the process exit code.
19
+ - For an `automatic` finding, use only the report's named Incise repair mechanism with its exact `hash`. Never construct a patch from the prose message.
20
+ - For an `explicit` finding, use the repair descriptor's named Incise semantic operation only when the user's request supplies the necessary intent or confirmation.
21
+ - For a `manual` finding, explain the ambiguity or ask for intent. Do not raw-patch or reconstruct the document.
22
+ - Recheck with `md_check` after a mutation. Stop if the report makes no progress; do not retry a mutation loop indefinitely.
23
+
24
+ Do not broaden the task to unrelated files or style changes.
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Thin host-owned launcher. Detection and repair remain in the Incise binary;
4
+ // this file only reuses pi-incise's version-matched binary resolution.
5
+ import { spawnSync } from "node:child_process";
6
+ import { resolveBinary } from "../../../extension/binary.ts";
7
+
8
+ const binary = resolveBinary();
9
+ if (!binary) {
10
+ process.stderr.write("No Incise binary is available for this platform. Reinstall pi-incise or set INCISE_BIN.\n");
11
+ process.exit(2);
12
+ }
13
+
14
+ const args = process.argv.slice(2);
15
+ if (args.length === 0) {
16
+ process.stderr.write("usage: check.mjs PATH [--fix-safe --if-match HASH]\n");
17
+ process.exit(2);
18
+ }
19
+ const result = spawnSync(binary.path, ["check", ...args, "--json"], {
20
+ encoding: "utf8",
21
+ stdio: ["ignore", "pipe", "pipe"],
22
+ });
23
+ process.stdout.write(result.stdout ?? "");
24
+ process.stderr.write(result.stderr ?? "");
25
+ if (result.error) {
26
+ process.stderr.write(`${result.error.message}\n`);
27
+ process.exit(2);
28
+ }
29
+ process.exit(result.status ?? 2);