pi-incise 0.5.0 → 0.7.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
@@ -19,23 +19,48 @@ Choose the profile when starting Pi:
19
19
  * **Ornith 1.5 9B (recommended):** `INCISE_PROFILE=auto pi --thinking off`
20
20
  * **Gemma (recommended):** `INCISE_PROFILE=auto pi`
21
21
  * **MiniCPM5 2B (recommended):** `INCISE_PROFILE=auto pi --thinking off`
22
+ * **Inkling 2 Mini Q3:** `INCISE_PROFILE=auto pi --thinking off`
22
23
  * **Unknown or changing model families:** `INCISE_PROFILE=standard pi`
23
24
 
24
25
  For Ornith, configure its Pi model entry with `maxTokens: 2048` and `samplingParams.parallel_tool_calls: false`. The measured result used temperature 0.6, top-p 0.95, top-k 20, min-p 0, presence penalty 0, and repeat penalty 1 through llama.cpp.
25
26
 
26
27
  For MiniCPM5, the measured result used the official Q8_0 checkpoint through llama.cpp, thinking off, a 65,536-token context, `maxTokens: 8192`, temperature 0.7, and top-p 0.95. The profile does not silently change provider decoding settings.
27
28
 
28
- The package default is `standard` for model-agnostic compatibility. `auto` enables the measured `safe-routed` profile for Gemma, MiniCPM, and Ornith; unknown families stay on `standard`. If a local provider exposes a generic model ID, set `INCISE_MODEL_FAMILY=gemma`, `INCISE_MODEL_FAMILY=minicpm`, `INCISE_MODEL_FAMILY=ornith`, or `INCISE_MODEL_FAMILY=unknown`.
29
+ The package default is `standard` for model-agnostic compatibility. `auto` enables the measured `safe-routed` profile for Gemma, MiniCPM, Ornith, and Inkling 2 Mini; unknown families stay on `standard`. If a local provider exposes a generic model ID, set `INCISE_MODEL_FAMILY=gemma`, `INCISE_MODEL_FAMILY=minicpm`, `INCISE_MODEL_FAMILY=ornith`, `INCISE_MODEL_FAMILY=inkling`, or `INCISE_MODEL_FAMILY=unknown`. Inkling detection is limited to 2 Mini identities; other generations remain unknown.
29
30
 
30
31
  After Pi starts, run `/incise-doctor`. It reports the requested and effective profiles, detected model family, selected binary, schema state, registered tools, and last route.
31
32
 
33
+ LFM3-specific support was abandoned on 25 November 2026 after the evaluation failed to demonstrate an overall editing benefit and incurred substantial latency overhead. No LFM3-specific profile or focus preview is provided. Historical evaluation records remain under `bench/`.
34
+
35
+ For Inkling 2 Mini, the measured local UD-Q3_K_XL setup used Pi SDK 1.0.4, a 32,768-token context, `maxTokens: 2048`, temperature 0.6, top-p 0.95, top-k 0, min-p 0, repeat penalty 1, and presence penalty 0. Send native `reasoning_effort: "none"`; the model still emitted reasoning in this runtime. Select the local model separately; the plugin does not change decoding settings. Inkling uses Pi’s structured prompt options to keep the prompt’s tool list aligned with the active route, and receives the existing hash-bound inspection for checkbox edits.
36
+
37
+ ## Experimental SenseNova Loop 9B Q8
38
+
39
+ Incise 0.7.0 adds an experimental Pi 1.7.0 path for the exact local model ID `sensenova-loop-9b-q8`. The broader qualification did not pass: eight of ten attempted tasks completed correctly, then the run stopped after two read loops left their files unchanged; 38 of the planned 48 tasks remain untested. Explicitly select `INCISE_PROFILE=safe-routed` to use structured framing and completed-operation context. The `auto` profile retains standard tools for this unqualified identity; other model identities retain their existing prompt paths.
40
+
41
+ Install with `pi install npm:pi-incise@0.7.0`. Merge the [provider example](../../bench/sensenova_loop_9b_q8_pi_models.example.json) into Pi's `models.json` without replacing other providers. It targets `http://127.0.0.1:8081/v1` and records context, output and sampling settings. This recipe explicitly sends `chat_template_kwargs.enable_thinking=false`; the recorded server template does not support native `reasoning_effort`.
42
+
43
+ For an isolated experiment after installation and provider setup:
44
+
45
+ ```bash
46
+ INCISE_PROFILE=safe-routed pi -e npm:pi-incise@0.7.0 \
47
+ --provider sensenova-local --model sensenova-loop-9b-q8 \
48
+ --tools 'read,table_*,list_*,section_*,frontmatter_*,md_*' \
49
+ --no-extensions --no-mcp --no-skills --no-context-files \
50
+ --no-prompt-templates --no-session --thinking off
51
+ ```
52
+
53
+ Keep the real built-in reader available and all writes through Incise. The actual CLI allowlist was checked against a fake provider with a byte-correct edit and real post-edit read; this is packaging evidence, not model accuracy. Live SDK tests additionally restrict reads to the current fixture and allow six assistant turns. The command above uses Pi's ordinary reader; it does not install the benchmark-only read restriction or turn cap. Unrestricted interactive use remains unqualified.
54
+
55
+ The selected feasibility screen completed four cases, one per editing family, with correct documents, resolved replies and no tool errors. Median latency was 99.43 seconds, range 38.94–192.32. Its list reply finished on turn six with the worker cap flag retained. Earlier configurations produced correct edits followed by unexecuted tool markup. The [experiment report](../../bench/SENSENOVA_LOOP_9B_Q8_20261130.md) retains these failures and records the separate full-population release gate at fresh seed 3. Automatic-family, multi-seed and Hermes support remain unqualified. Run `/incise-doctor` to inspect the effective profile and binary.
56
+
32
57
  ## Tools
33
58
 
34
59
  The default `standard` profile registers `table_edit`, `list_edit`, `section_edit`, `frontmatter_edit`, `table_get`, `md_tables`, `md_lists`, and `md_outline`. Inspect document structure with the relevant read tool before editing, and follow the remedy in any Incise refusal. The former `measured` profile name remains an alias for `standard`.
35
60
 
36
- Set `INCISE_PROFILE=safe-routed` to use guarded request routing directly, or use `auto` with a measured Gemma, MiniCPM, or Ornith identity. The routed profile retains standard tools as fallback. For requests it can prove unambiguous, it inspects current structure and replaces the broad surface for that turn with one small action-specific tool. Host-owned routes cover exact table reads and mutations, list relations and checkbox state, literal section insertion, append, deletion, rename, level changes and qualified body replacement, plus typed, create-only, delete, and compound frontmatter edits. Each write carries the inspected hash and permits one successful routed mutation. Ambiguous, unsupported, or structurally inconsistent requests fall back without reinterpretation.
61
+ Set `INCISE_PROFILE=safe-routed` to use guarded request routing directly, or use `auto` with a measured Gemma, MiniCPM, Ornith, or Inkling 2 Mini identity. The routed profile retains standard tools as fallback. For requests it can prove unambiguous, it inspects current structure and replaces the broad surface for that turn with one small action-specific tool. Host-owned routes cover exact table reads and mutations, list relations and checkbox state, literal section insertion, append, deletion, rename, level changes and qualified body replacement, plus typed, create-only, delete, and compound frontmatter edits. Each write carries the inspected hash and permits one successful routed mutation. Ambiguous, unsupported, or structurally inconsistent requests fall back without reinterpretation.
37
62
 
38
- `auto` selects once on the first model-bearing turn. Gemma, MiniCPM, and Ornith use `safe-routed`; unknown identities use `standard`. `/incise-doctor` reports the requested profile, effective profile, model family, selection reason, and last route.
63
+ `auto` selects once on the first model-bearing turn. Gemma, MiniCPM, Ornith, and Inkling 2 Mini use `safe-routed`; unknown identities use `standard`. `/incise-doctor` reports the requested profile, effective profile, model family, selection reason, and last route.
39
64
 
40
65
  Set `INCISE_PROFILE=safe-small` only to reproduce the earlier experimental small-model composition. It omits generic multi-action tools and destructive section/frontmatter operations, but that older MiniCPM5 run failed its family and safety gates and has been superseded by the measured `auto` route profile.
41
66
 
@@ -57,6 +82,8 @@ The current Gemma `auto` profile completed **475/479 usable trials (99.2%) with
57
82
 
58
83
  These results are tied to the recorded models, llama.cpp runtime, Pi version, prompts, schemas, tasks, seeds, graders, and inference settings. See [the full findings](../../bench/FINDINGS.md), [MiniCPM composition analysis](../../bench/results/minicpm5_safe_routed_composition_v3_20260925_corrected_analysis.json), [Ornith final analysis](../../bench/results/ornith_final_v2_safe_routed_20260923_analysis.json), and [Gemma v8 analysis](../../bench/results/gemma_safe_routed_full_v8_20260922_analysis.json).
59
84
 
85
+ Inkling 2 Mini UD-Q3_K_XL completed 48/48 tasks at fresh seed 2 after one recorded grader correction, including 42/42 edits and zero incorrect changed documents. The original 47/48 grades already passed the preregistered gate; the omitted ordinal-read case independently matched the Python oracle. Two sessions attempted unavailable shell tools before recovering through the guarded route. This is one 48-task host qualification, not the ten-seed stability measurement used for the other models. On the M4 Mac mini with 24 GB RAM, these full workflows averaged 68.5 seconds. See the [original analysis](../../bench/results/inkling2_mini_q3_checkbox_v4_20261129_analysis.json) and [separate regrade](../../bench/results/inkling2_mini_q3_checkbox_v4_20261129_held_auto_regraded_v1_analysis.json).
86
+
60
87
  ## Binary resolution
61
88
 
62
89
  The extension uses `INCISE_BIN` first, then the matching optional native package, then `incise` on `PATH`, and finally a release or debug binary from a development checkout. `/incise-doctor` reports the selected path, versions, schema status, and registered-tool count. Version mismatches from explicit overrides are warnings; a mismatched packaged binary disables the tools as an installation-integrity failure.
@@ -78,7 +78,7 @@ export function installCheckSkillTool(
78
78
  };
79
79
 
80
80
  pi.on("before_agent_start", async (event) => {
81
- if (!isExplicitCheckSkillPrompt(event.prompt)) return;
81
+ if (!("prompt" in event) || !isExplicitCheckSkillPrompt(event.prompt)) return;
82
82
  restore = pi.getActiveTools().filter((name) => name !== CHECK_TOOL_NAME);
83
83
  active = true;
84
84
  register();
@@ -7,6 +7,7 @@ import { installMiniCpmListProfile, MINICPM_LIST_TOOL_NAMES } from "./minicpm-li
7
7
  import { prepareInvocation, READ_SUBCOMMAND, type ToolArguments } from "./normalize.ts";
8
8
  import {
9
9
  requestedProfile,
10
+ modelFamily,
10
11
  selectProfile,
11
12
  type ProfileDecision,
12
13
  type RequestedProfile,
@@ -207,6 +208,17 @@ export default async function inciseExtension(pi: ExtensionAPI): Promise<void> {
207
208
  }
208
209
  installSafeRoutedProfile(pi, binary, {
209
210
  standardTools: schemas.map((schema) => schema.name),
211
+ useStructuredPrompt(ctx) {
212
+ return modelFamily(ctx.model, familyOverride) === "inkling" ||
213
+ ctx.model?.id === "sensenova-loop-9b-q8";
214
+ },
215
+ completionPrompt(ctx) {
216
+ if (ctx.model?.id !== "sensenova-loop-9b-q8") return undefined;
217
+ return "The bound Incise operation has completed successfully. " +
218
+ "Report the completed change or requested read result. " +
219
+ "Do not repeat the completed operation or invent additional work. " +
220
+ "Follow any remaining user-requested steps using only tools that are currently available.";
221
+ },
210
222
  isEnabled(ctx) {
211
223
  if (!decision && ctx.model) {
212
224
  decision = selectProfile(profile, ctx.model, familyOverride);
@@ -335,6 +335,10 @@ export function installMiniCpmListProfile(
335
335
 
336
336
  pi.on("before_agent_start", async (event, ctx) => {
337
337
  state = undefined;
338
+ if (!("prompt" in event)) {
339
+ pi.setActiveTools([]);
340
+ return;
341
+ }
338
342
  const found = extractMarkdownPath(event.prompt);
339
343
  if (!found) {
340
344
  pi.setActiveTools([]);
@@ -6,7 +6,7 @@ export type RequestedProfile =
6
6
  | "minicpm-list";
7
7
 
8
8
  export type EffectiveProfile = Exclude<RequestedProfile, "auto">;
9
- export type ModelFamily = "gemma" | "minicpm" | "ornith" | "unknown";
9
+ export type ModelFamily = "gemma" | "minicpm" | "ornith" | "inkling" | "unknown";
10
10
 
11
11
  export interface ModelIdentity {
12
12
  id?: string;
@@ -39,17 +39,18 @@ export function modelFamily(
39
39
  ): ModelFamily {
40
40
  if (override !== undefined && override !== "") {
41
41
  const normalized = override.toLowerCase();
42
- if (normalized === "gemma" || normalized === "minicpm" || normalized === "ornith" || normalized === "unknown") {
42
+ if (normalized === "gemma" || normalized === "minicpm" || normalized === "ornith" || normalized === "inkling" || normalized === "unknown") {
43
43
  return normalized;
44
44
  }
45
45
  throw new Error(
46
- `Unknown INCISE_MODEL_FAMILY ${JSON.stringify(override)}. Use gemma, minicpm, ornith, or unknown.`,
46
+ `Unknown INCISE_MODEL_FAMILY ${JSON.stringify(override)}. Use gemma, minicpm, ornith, inkling, or unknown.`,
47
47
  );
48
48
  }
49
49
  const identity = `${model?.provider ?? ""} ${model?.id ?? ""} ${model?.name ?? ""}`.toLowerCase();
50
50
  if (/mini[-_ ]?cpm/.test(identity)) return "minicpm";
51
51
  if (/gemma/.test(identity)) return "gemma";
52
52
  if (/ornith/.test(identity)) return "ornith";
53
+ if (/\binkling[-_ ]2[-_ ]mini(?:\b|[_-])/.test(identity)) return "inkling";
53
54
  return "unknown";
54
55
  }
55
56
 
@@ -74,7 +75,7 @@ export function selectProfile(
74
75
  reason: `explicit INCISE_PROFILE=${requested}`,
75
76
  };
76
77
  }
77
- if (family === "gemma" || family === "minicpm" || family === "ornith") {
78
+ if (family === "gemma" || family === "minicpm" || family === "ornith" || family === "inkling") {
78
79
  return {
79
80
  requested,
80
81
  effective: "safe-routed",
@@ -84,7 +85,9 @@ export function selectProfile(
84
85
  ? "auto selected the measured Gemma routing capabilities"
85
86
  : family === "minicpm"
86
87
  ? "auto selected the measured MiniCPM routing capabilities"
87
- : "auto selected the measured Ornith routing capabilities",
88
+ : family === "ornith"
89
+ ? "auto selected the measured Ornith routing capabilities"
90
+ : "auto selected the measured Inkling 2 Mini routing capabilities",
88
91
  };
89
92
  }
90
93
  return {
@@ -147,11 +147,13 @@ interface RouteSpec {
147
147
  }>;
148
148
  resolvedArguments?(params: Record<string, unknown>): Record<string, unknown>;
149
149
  systemPrompt: string;
150
+ inspection?: string;
150
151
  }
151
152
 
152
153
  interface RoutedState {
153
154
  spec: RouteSpec;
154
155
  completed: boolean;
156
+ completion?: { active: string; finished: string };
155
157
  }
156
158
 
157
159
  export function sectionIntent(prompt: string): { kind: "section-rename"; target: string; heading: string } |
@@ -1241,6 +1243,10 @@ async function routeForPrompt(
1241
1243
  checked: checked.checked,
1242
1244
  }),
1243
1245
  systemPrompt: `Incise resolved the exact checkbox item and requested state. Use ${schema.name} once with no arguments; the host supplies the file, list, item, state, and read hash.`,
1246
+ inspection: `Inspected ${JSON.stringify(path)} at read hash ${result.payload.hash}:\n${
1247
+ String(result.payload.text ?? "").length <= 2048 ? String(result.payload.text ?? "")
1248
+ : JSON.stringify({ checked: matches[0].checked, depth: matches[0].depth, parent: matches[0].parent })
1249
+ }`,
1244
1250
  };
1245
1251
  }
1246
1252
  const append = listAppendIntent(prompt);
@@ -1491,6 +1497,8 @@ function toolResult(text: string, details: Record<string, unknown>) {
1491
1497
  export interface SafeRoutedOptions {
1492
1498
  standardTools: string[];
1493
1499
  isEnabled(ctx: { model?: { id?: string; name?: string; provider?: string } }): boolean;
1500
+ useStructuredPrompt?(ctx: { model?: { id?: string; name?: string; provider?: string } }): boolean;
1501
+ completionPrompt?(ctx: { model?: { id?: string; name?: string; provider?: string } }): string | undefined;
1494
1502
  onRoute?(kind: SafeRouteKind | "standard"): void;
1495
1503
  }
1496
1504
 
@@ -1511,6 +1519,34 @@ export function installSafeRoutedProfile(
1511
1519
  ]);
1512
1520
  const ownedNames = new Set([...options.standardTools, ...routedNames]);
1513
1521
  let state: RoutedState | undefined;
1522
+ let completionHookInstalled = false;
1523
+
1524
+ const installCompletionHook = (): void => {
1525
+ if (completionHookInstalled) return;
1526
+ completionHookInstalled = true;
1527
+ pi.on("context_with_system", (event) => {
1528
+ const completion = state?.completed ? state.completion : undefined;
1529
+ if (!completion) return;
1530
+ let changed = false;
1531
+ const messages = event.messages.map((message) => {
1532
+ if (message.role !== "system") return message;
1533
+ const section = message.sections?.incise_route;
1534
+ if (typeof section !== "string") return message;
1535
+ const index = section.lastIndexOf(completion.active);
1536
+ if (index < 0) return message;
1537
+ changed = true;
1538
+ return {
1539
+ ...message,
1540
+ sections: {
1541
+ ...message.sections,
1542
+ incise_route: section.slice(0, index) + completion.finished +
1543
+ section.slice(index + completion.active.length),
1544
+ },
1545
+ };
1546
+ });
1547
+ return changed ? { messages } : undefined;
1548
+ });
1549
+ };
1514
1550
 
1515
1551
  const activate = (names: string[]): void => {
1516
1552
  const foreign = pi.getActiveTools().filter((name) => !ownedNames.has(name));
@@ -1526,6 +1562,7 @@ export function installSafeRoutedProfile(
1526
1562
  async execute(_toolCallId, params, signal) {
1527
1563
  if (!state || state.spec !== spec) throw new Error("No matching routed Incise request is active.");
1528
1564
  if (state.completed) throw new Error("The requested Incise operation already succeeded.");
1565
+ const binding = state;
1529
1566
  const args = spec.arguments(params as Record<string, unknown>);
1530
1567
  const followups = spec.followups?.(params as Record<string, unknown>) ?? [];
1531
1568
  const operations = [{ operation: spec.operation, arguments: args }, ...followups];
@@ -1555,8 +1592,8 @@ export function installSafeRoutedProfile(
1555
1592
  ? await withFileMutationQueue(spec.path, invoke)
1556
1593
  : await invoke();
1557
1594
  if (result.code !== 0 || result.payload.ok === false) throw processError(result);
1558
- state.completed = true;
1559
- activate([]);
1595
+ binding.completed = true;
1596
+ if (state === binding) activate([]);
1560
1597
  return toolResult(
1561
1598
  spec.write ? String(result.payload.description ?? "") : String(result.payload.text ?? ""),
1562
1599
  {
@@ -1578,7 +1615,7 @@ export function installSafeRoutedProfile(
1578
1615
 
1579
1616
  pi.on("before_agent_start", async (event, ctx) => {
1580
1617
  state = undefined;
1581
- if (!options.isEnabled(ctx)) {
1618
+ if (!options.isEnabled(ctx) || !("prompt" in event)) {
1582
1619
  options.onRoute?.("standard");
1583
1620
  activate(options.standardTools);
1584
1621
  return;
@@ -1593,6 +1630,30 @@ export function installSafeRoutedProfile(
1593
1630
  registerRoute(spec);
1594
1631
  options.onRoute?.(spec.kind);
1595
1632
  activate([spec.schema.name]);
1596
- return { systemPrompt: `${event.systemPrompt}\n\n${spec.systemPrompt}` };
1633
+ const structured = options.useStructuredPrompt?.(ctx);
1634
+ const routePrompt = structured && spec.inspection
1635
+ ? `${spec.inspection}\n\n${spec.systemPrompt}` : spec.systemPrompt;
1636
+ if (structured && event.systemPromptOptions &&
1637
+ event.systemPromptOptions.forceSystemPrompt === undefined) {
1638
+ const active = pi.getActiveTools();
1639
+ if (!active.includes(spec.schema.name)) {
1640
+ state = undefined;
1641
+ activate(options.standardTools);
1642
+ options.onRoute?.("standard");
1643
+ return;
1644
+ }
1645
+ event.systemPromptOptions.selectedTools = active;
1646
+ event.systemPromptOptions.toolSnippets[spec.schema.name] = spec.schema.description;
1647
+ const previous = event.systemPromptOptions.sections.incise_route;
1648
+ event.systemPromptOptions.sections.incise_route = previous
1649
+ ? `${previous}\n\n${routePrompt}` : routePrompt;
1650
+ const completion = options.completionPrompt?.(ctx);
1651
+ if (completion) {
1652
+ state.completion = { active: routePrompt, finished: completion };
1653
+ installCompletionHook();
1654
+ }
1655
+ return;
1656
+ }
1657
+ return { systemPrompt: `${event.systemPrompt}\n\n${routePrompt}` };
1597
1658
  });
1598
1659
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-incise",
3
- "version": "0.5.0",
4
- "description": "Semantic, byte-preserving Markdown editing tools for Pi and AI agents",
3
+ "version": "0.7.0",
4
+ "description": "Structured Markdown editing for Pi, with qualified local-model profiles and experimental SenseNova Loop 9B integration",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Peter Dalinis",
@@ -20,7 +20,10 @@
20
20
  "llm-tools",
21
21
  "frontmatter",
22
22
  "obsidian",
23
- "knowledge-base"
23
+ "knowledge-base",
24
+ "inkling",
25
+ "local-llm",
26
+ "sensenova"
24
27
  ],
25
28
  "engines": {
26
29
  "node": ">=22.19.0"
@@ -45,20 +48,21 @@
45
48
  "typebox": "*"
46
49
  },
47
50
  "devDependencies": {
48
- "@earendil-works/pi-coding-agent": "^0.99.1",
51
+ "@earendil-works/pi-coding-agent": "1.7.0",
49
52
  "@types/node": "^22.19.19",
50
53
  "typescript": "^5.9.3"
51
54
  },
52
55
  "optionalDependencies": {
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"
56
+ "@pdalinis/pi-incise-darwin-arm64": "0.7.0",
57
+ "@pdalinis/pi-incise-darwin-x64": "0.7.0",
58
+ "@pdalinis/pi-incise-linux-arm64-gnu": "0.7.0",
59
+ "@pdalinis/pi-incise-linux-x64-gnu": "0.7.0"
57
60
  },
58
61
  "scripts": {
59
62
  "test": "node --test --experimental-strip-types test/*.test.ts",
60
63
  "typecheck": "tsc --noEmit",
61
- "pack:check": "node --experimental-strip-types test/pack-check.ts"
64
+ "pack:check": "node --experimental-strip-types test/pack-check.ts",
65
+ "native:check": "node --experimental-strip-types test/native-install-smoke.ts"
62
66
  },
63
67
  "publishConfig": {
64
68
  "access": "public"