pi-ultracode 0.10.2 → 0.10.4

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/package.json CHANGED
@@ -1,29 +1,28 @@
1
1
  {
2
2
  "name": "pi-ultracode",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Adaptive semantic-depth workflow orchestration for Pi, with focused, standard, and deep modes, isolated subagents, worktree delivery, structured output, and durable resume.",
5
- "type": "module",
6
5
  "keywords": [
7
- "pi-package",
6
+ "agents",
7
+ "orchestration",
8
8
  "pi",
9
9
  "pi-coding-agent",
10
+ "pi-package",
11
+ "subagents",
10
12
  "ultracode",
11
13
  "workflow",
12
- "workflows",
13
- "agents",
14
- "subagents",
15
- "orchestration"
14
+ "workflows"
16
15
  ],
17
- "author": "pi-ultracode",
16
+ "homepage": "https://github.com/ekil1100/pi-ultracode#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/ekil1100/pi-ultracode/issues"
19
+ },
18
20
  "license": "MIT",
21
+ "author": "pi-ultracode",
19
22
  "repository": {
20
23
  "type": "git",
21
24
  "url": "git+https://github.com/ekil1100/pi-ultracode.git"
22
25
  },
23
- "homepage": "https://github.com/ekil1100/pi-ultracode#readme",
24
- "bugs": {
25
- "url": "https://github.com/ekil1100/pi-ultracode/issues"
26
- },
27
26
  "files": [
28
27
  "extensions/",
29
28
  "src/",
@@ -31,35 +30,36 @@
31
30
  "examples/",
32
31
  "README.md"
33
32
  ],
34
- "publishConfig": {
35
- "access": "public",
36
- "registry": "https://registry.npmjs.org/"
37
- },
38
- "pi": {
39
- "extensions": [
40
- "./extensions/ultracode.ts"
41
- ]
42
- },
33
+ "type": "module",
43
34
  "exports": {
44
35
  "./workflow": {
45
36
  "types": "./types/workflow.d.ts"
46
37
  }
47
38
  },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org/"
42
+ },
48
43
  "scripts": {
49
- "test": "node --experimental-strip-types --test test/*.test.ts",
50
- "typecheck": "tsc --noEmit"
44
+ "test": "vp test run",
45
+ "check": "vp check",
46
+ "typecheck": "vp exec tsc --noEmit"
51
47
  },
52
48
  "dependencies": {
53
- "acorn": "^8.11.0"
49
+ "acorn": "^8.11.0",
50
+ "effect": "^4.0.0",
51
+ "js-beautify": "^2.0.3"
54
52
  },
55
53
  "devDependencies": {
56
54
  "@earendil-works/pi-agent-core": "^0.99.1",
57
55
  "@earendil-works/pi-ai": "^0.99.1",
58
56
  "@earendil-works/pi-coding-agent": "^0.99.1",
59
57
  "@earendil-works/pi-tui": "^0.99.1",
58
+ "@types/js-beautify": "^1.14.3",
60
59
  "@types/node": "^24.12.4",
61
60
  "typebox": "1.3.7",
62
- "typescript": "^5.9.3"
61
+ "typescript": "^5.9.3",
62
+ "vite-plus": "1.0.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@earendil-works/pi-agent-core": ">=0.99.1",
@@ -84,5 +84,21 @@
84
84
  "typebox": {
85
85
  "optional": true
86
86
  }
87
+ },
88
+ "overrides": {
89
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0"
90
+ },
91
+ "devEngines": {
92
+ "packageManager": {
93
+ "name": "npm",
94
+ "version": "11.19.0",
95
+ "onFail": "download"
96
+ }
97
+ },
98
+ "packageManager": "npm@11.19.0",
99
+ "pi": {
100
+ "extensions": [
101
+ "./extensions/ultracode.ts"
102
+ ]
87
103
  }
88
104
  }
package/src/commands.ts CHANGED
@@ -2,14 +2,22 @@
2
2
  * Slash commands: `/ultracode` (mode toggle) and `/workflows` (run manager).
3
3
  */
4
4
 
5
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
6
- import { ACTIVE_ULTRACODE_MODES, MODE_DESCRIPTIONS, isActiveUltracodeMode, isUltracodeModeName } from "./depth.ts";
5
+ import { Effect, Result } from "effect";
6
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
7
+ import {
8
+ ACTIVE_ULTRACODE_MODES,
9
+ MODE_DESCRIPTIONS,
10
+ isActiveUltracodeMode,
11
+ isUltracodeModeName,
12
+ } from "./depth.ts";
7
13
  import type { UltracodeMode } from "./mode.ts";
8
14
  import type { UltracodePreferenceStore } from "./preferences.ts";
9
15
  import type { WorkflowRegistry } from "./workflow/registry.ts";
10
16
  import { workflowRunsDir } from "./workflow/tool.ts";
11
17
  import { openWorkflowOverlay } from "./workflow/workflow-overlay.ts";
12
18
 
19
+ const attempt = <A>(thunk: () => A) => Effect.try({ try: thunk, catch: (error) => error });
20
+
13
21
  export function registerCommands(
14
22
  pi: ExtensionAPI,
15
23
  mode: UltracodeMode,
@@ -17,117 +25,157 @@ export function registerCommands(
17
25
  preferences: UltracodePreferenceStore,
18
26
  ): void {
19
27
  pi.registerCommand("ultracode", {
20
- description: "Analysis depth: auto routing, focused local checks, standard targeted verification, deep invariant/counterexample checks; off|status|default on|off",
28
+ description:
29
+ "Analysis depth: auto routing, focused local checks, standard targeted verification, deep invariant/counterexample checks; off|status|default on|off",
21
30
  getArgumentCompletions(prefix: string) {
22
31
  return [...ACTIVE_ULTRACODE_MODES, "off", "status", "default", "default on", "default off"]
23
32
  .filter((value) => value.startsWith(prefix))
24
- .map((value) => ({ value, label: value, description: isUltracodeModeName(value) ? MODE_DESCRIPTIONS[value] : undefined }));
33
+ .map((value) => ({
34
+ value,
35
+ label: value,
36
+ description: isUltracodeModeName(value) ? MODE_DESCRIPTIONS[value] : undefined,
37
+ }));
25
38
  },
26
- handler: async (args: string, ctx) => {
27
- const parts = args.trim().split(/\s+/).filter(Boolean);
28
- const sub = (parts[0] ?? "").toLowerCase();
39
+ handler: (args: string, ctx) =>
40
+ Effect.runPromise(
41
+ attempt(() => {
42
+ const parts = args.trim().split(/\s+/).filter(Boolean);
43
+ const sub = (parts[0] ?? "").toLowerCase();
29
44
 
30
- // Bare `/ultracode` enables auto from off and disables any active mode.
31
- if (sub === "") {
32
- const nowOn = mode.toggle(pi);
33
- ctx.ui.notify(
34
- nowOn
35
- ? `Ultracode auto — ${MODE_DESCRIPTIONS.auto}`
36
- : "Ultracode off — workflow tool disabled; parent effort unchanged.",
37
- "info",
38
- );
39
- ctx.ui.setStatus(
40
- "ultracode",
41
- nowOn ? mode.statusLine((label) => ctx.ui.theme.fg("accent", label)) : undefined,
42
- );
43
- return;
44
- }
45
+ // Bare `/ultracode` enables auto from off and disables any active mode.
46
+ if (sub === "") {
47
+ const nowOn = mode.toggle(pi);
48
+ ctx.ui.notify(
49
+ nowOn
50
+ ? `Ultracode auto — ${MODE_DESCRIPTIONS.auto}`
51
+ : "Ultracode off — workflow tool disabled; parent effort unchanged.",
52
+ "info",
53
+ );
54
+ ctx.ui.setStatus(
55
+ "ultracode",
56
+ nowOn ? mode.statusLine((text, color) => ctx.ui.theme.fg(color, text)) : undefined,
57
+ );
58
+ return;
59
+ }
45
60
 
46
- if (sub === "default") {
47
- const value = parts[1]?.toLowerCase();
48
- if (parts.length > 2 || (value !== undefined && value !== "on" && value !== "off")) {
49
- ctx.ui.notify("Usage: /ultracode default [on|off]", "error");
50
- return;
51
- }
52
- try {
53
- if (value !== undefined) preferences.setDefaultEnabled(value === "on");
54
- const enabled = preferences.getDefaultEnabled();
55
- if (value === "on") {
56
- if (!mode.isEnabled()) mode.enable(pi, "auto");
57
- ctx.ui.setStatus("ultracode", mode.statusLine((label) => ctx.ui.theme.fg("accent", label)));
61
+ if (sub === "default") {
62
+ const value = parts[1]?.toLowerCase();
63
+ if (parts.length > 2 || (value !== undefined && value !== "on" && value !== "off")) {
64
+ ctx.ui.notify("Usage: /ultracode default [on|off]", "error");
65
+ return;
66
+ }
67
+ Result.try({
68
+ try: () => {
69
+ if (value !== undefined) preferences.setDefaultEnabled(value === "on");
70
+ const enabled = preferences.getDefaultEnabled();
71
+ if (value === "on") {
72
+ if (!mode.isEnabled()) mode.enable(pi, "auto");
73
+ ctx.ui.setStatus(
74
+ "ultracode",
75
+ mode.statusLine((text, color) => ctx.ui.theme.fg(color, text)),
76
+ );
77
+ }
78
+ const sessionStatus =
79
+ value === "on"
80
+ ? `current session: ${mode.getMode()}`
81
+ : "current session unchanged";
82
+ ctx.ui.notify(
83
+ `Ultracode default ${enabled ? "on (auto)" : "off"} — global startup preference; ${sessionStatus}.`,
84
+ "info",
85
+ );
86
+ },
87
+ catch: (error) => error,
88
+ }).pipe(
89
+ Result.getOrElse((error) => {
90
+ ctx.ui.notify(
91
+ `Failed to ${value === undefined ? "read" : "save"} Ultracode default: ${String(error)}`,
92
+ "error",
93
+ );
94
+ }),
95
+ );
96
+ return;
58
97
  }
59
- const sessionStatus = value === "on" ? `current session: ${mode.getMode()}` : "current session unchanged";
60
- ctx.ui.notify(
61
- `Ultracode default ${enabled ? "on (auto)" : "off"} — global startup preference; ${sessionStatus}.`,
62
- "info",
63
- );
64
- } catch (error) {
65
- ctx.ui.notify(`Failed to ${value === undefined ? "read" : "save"} Ultracode default: ${String(error)}`, "error");
66
- }
67
- return;
68
- }
69
98
 
70
- if (parts.length > 1) {
71
- ctx.ui.notify(ultracodeUsage(), "error");
72
- return;
73
- }
99
+ if (parts.length > 1) {
100
+ ctx.ui.notify(ultracodeUsage(), "error");
101
+ return;
102
+ }
74
103
 
75
- if (sub === "status") {
76
- ctx.ui.notify(`${mode.statusLine()} — ${MODE_DESCRIPTIONS[mode.getMode()]} Depth is independent of model effort.`, "info");
77
- return;
78
- }
104
+ if (sub === "status") {
105
+ ctx.ui.notify(
106
+ `${mode.statusLine()} — ${MODE_DESCRIPTIONS[mode.getMode()]} Depth is independent of model effort.`,
107
+ "info",
108
+ );
109
+ return;
110
+ }
79
111
 
80
- if (sub === "off") {
81
- mode.disable(pi);
82
- ctx.ui.notify("Ultracode off — workflow tool disabled; parent effort unchanged.", "info");
83
- ctx.ui.setStatus("ultracode", undefined);
84
- return;
85
- }
112
+ if (sub === "off") {
113
+ mode.disable(pi);
114
+ ctx.ui.notify(
115
+ "Ultracode off — workflow tool disabled; parent effort unchanged.",
116
+ "info",
117
+ );
118
+ ctx.ui.setStatus("ultracode", undefined);
119
+ return;
120
+ }
86
121
 
87
- if (!isActiveUltracodeMode(sub)) {
88
- ctx.ui.notify(ultracodeUsage(), "error");
89
- return;
90
- }
122
+ if (!isActiveUltracodeMode(sub)) {
123
+ ctx.ui.notify(ultracodeUsage(), "error");
124
+ return;
125
+ }
91
126
 
92
- mode.enable(pi, sub);
93
- ctx.ui.notify(`Ultracode ${sub} — ${MODE_DESCRIPTIONS[sub]}`, "info");
94
- ctx.ui.setStatus(
95
- "ultracode",
96
- mode.statusLine((label) => ctx.ui.theme.fg("accent", label)),
97
- );
98
- },
127
+ mode.enable(pi, sub);
128
+ ctx.ui.notify(`Ultracode ${sub} — ${MODE_DESCRIPTIONS[sub]}`, "info");
129
+ ctx.ui.setStatus(
130
+ "ultracode",
131
+ mode.statusLine((text, color) => ctx.ui.theme.fg(color, text)),
132
+ );
133
+ }),
134
+ ),
99
135
  });
100
136
 
101
- const openWorkflows = async (ctx: any, runId?: string) => {
102
- registry.restoreRuns(workflowRunsDir(ctx));
103
- await openWorkflowOverlay(ctx, registry, runId);
104
- };
137
+ const openWorkflows = (ctx: ExtensionContext, runId?: string) =>
138
+ attempt(() => registry.restoreRuns(workflowRunsDir(ctx))).pipe(
139
+ Effect.andThen(
140
+ Effect.tryPromise({
141
+ try: () => openWorkflowOverlay(ctx, registry, runId),
142
+ catch: (error) => error,
143
+ }),
144
+ ),
145
+ );
105
146
 
106
147
  pi.registerCommand("workflows", {
107
- description: "Open the interactive workflow/task detail overlay. Usage: /workflows [runId | abort]",
148
+ description:
149
+ "Open the interactive workflow/task detail overlay. Usage: /workflows [runId | abort]",
108
150
  getArgumentCompletions(prefix: string) {
109
151
  const values = [
110
152
  "abort",
111
- ...registry.list().map((handle) => handle.snapshot.runId).filter((runId): runId is string => Boolean(runId)),
153
+ ...registry
154
+ .list()
155
+ .map((handle) => handle.snapshot.runId)
156
+ .filter((runId): runId is string => Boolean(runId)),
112
157
  ];
113
158
  return [...new Set(values)]
114
159
  .filter((value) => value.startsWith(prefix))
115
160
  .map((value) => ({ value, label: value }));
116
161
  },
117
- handler: async (args: string, ctx) => {
118
- const arg = args.trim();
119
- if (arg.toLowerCase() === "abort") {
120
- registry.abortAll();
121
- ctx.ui.notify("Requested abort of all active workflow runs.", "warning");
122
- return;
123
- }
124
- await openWorkflows(ctx, arg || undefined);
125
- },
162
+ handler: (args: string, ctx) =>
163
+ Effect.runPromise(
164
+ Effect.suspend(() => {
165
+ const arg = args.trim();
166
+ return arg.toLowerCase() === "abort"
167
+ ? attempt(() => {
168
+ registry.abortAll();
169
+ ctx.ui.notify("Requested abort of all active workflow runs.", "warning");
170
+ })
171
+ : openWorkflows(ctx, arg || undefined);
172
+ }),
173
+ ),
126
174
  });
127
175
 
128
176
  pi.registerShortcut("f6", {
129
177
  description: "Open workflow task details",
130
- handler: async (ctx) => openWorkflows(ctx),
178
+ handler: (ctx) => Effect.runPromise(openWorkflows(ctx)),
131
179
  });
132
180
  }
133
181
 
package/src/depth.ts CHANGED
@@ -12,12 +12,15 @@ export type AnalysisDepth = (typeof ANALYSIS_DEPTHS)[number];
12
12
 
13
13
  /** Canonical applicability and evidence requirements shared by all analysis-depth modes. */
14
14
  export const DEPTH_CRITERIA: Record<AnalysisDepth, string> = {
15
- focused: "Bounded work with a known approach and locally verifiable results. Follow one line of inquiry and check the changed behavior or key claim directly (for example, a specified validation rule and its regression test). Do not skip verification; no broad investigation or adversarial panel by default.",
16
- standard: "Multiple independent dimensions or unresolved hypotheses can materially change the answer. Investigate those dimensions or compare plausible causes, then use targeted verification to resolve disputed or weakly evidenced claims (for example, diagnosing a fault with several plausible causes). Known multi-step work alone does not require this depth.",
15
+ focused:
16
+ "Bounded work with a known approach and locally verifiable results. Follow one line of inquiry and check the changed behavior or key claim directly (for example, a specified validation rule and its regression test). Do not skip verification; no broad investigation or adversarial panel by default.",
17
+ standard:
18
+ "Multiple independent dimensions or unresolved hypotheses can materially change the answer. Investigate those dimensions or compare plausible causes, then use targeted verification to resolve disputed or weakly evidenced claims (for example, diagnosing a fault with several plausible causes). Known multi-step work alone does not require this depth.",
17
19
  deep: "Tightly interacting hard constraints or critical invariants require independent evidence and counterexamples. Trace the interactions, test boundary and failure cases, and challenge the key claims with a distinct check (for example, cancellation racing a durable commit). Risk keywords, file count, or a request for a review alone do not qualify; deep does not mandate extra agents or repeated rounds.",
18
20
  };
19
21
 
20
- export const DEPTH_SELECTION_RULES = "Choose the smallest depth that can establish correctness from the stated task and available evidence. Missing information is not proof of hidden complexity. Risk determines which claims need verification; security, concurrency, data loss, and other risk keywords alone never mandate deep. Depth determines investigation and evidence requirements, not model effort, agent count, or a mandatory number of rounds.";
22
+ export const DEPTH_SELECTION_RULES =
23
+ "Choose the smallest depth that can establish correctness from the stated task and available evidence. Missing information is not proof of hidden complexity. Risk determines which claims need verification; security, concurrency, data loss, and other risk keywords alone never mandate deep. Depth determines investigation and evidence requirements, not model effort, agent count, or a mandatory number of rounds.";
21
24
 
22
25
  export const MODE_DESCRIPTIONS: Record<UltracodeModeName, string> = {
23
26
  off: "Workflow tool disabled; parent effort unchanged.",
@@ -3,11 +3,14 @@ import { THINKING_LEVELS, type ThinkingLevel } from "./thinking.ts";
3
3
  /** Task-based effort criteria shared by workflow prompts and Jev selection. */
4
4
  const EFFORT_CRITERIA: Record<ThinkingLevel, string> = {
5
5
  off: "Fully specified mechanical work with no implementation decision or hidden-impact reasoning. Excludes finding where to change something or checking its meaning. Example: fix a typo at an exact location using a supplied replacement.",
6
- minimal: "One clear local judgment in a single scope with no unresolved dependencies. Excludes cross-file tracing or multi-step implementation. Example: explain a short self-contained expression by checking its direct condition.",
6
+ minimal:
7
+ "One clear local judgment in a single scope with no unresolved dependencies. Excludes cross-file tracing or multi-step implementation. Example: explain a short self-contained expression by checking its direct condition.",
7
8
  low: "Small implementation or direct question with a clear goal, known approach, and straightforward checks. Excludes faults with an unknown root cause. Example: add a specified input validation rule and its test to an existing function.",
8
- medium: "Bounded multi-step implementation or investigation coordinating several known constraints. Excludes interacting unresolved hypotheses requiring deeper investigation. Example: add a configuration option through loading, usage, and tests within an established architecture.",
9
+ medium:
10
+ "Bounded multi-step implementation or investigation coordinating several known constraints. Excludes interacting unresolved hypotheses requiring deeper investigation. Example: add a configuration option through loading, usage, and tests within an established architecture.",
9
11
  high: "Test multiple plausible hypotheses, trace cross-module effects, or reason about critical correctness constraints. Excludes escalation based solely on security or architecture keywords. Example: diagnose state desynchronization across modules by testing competing causes.",
10
- xhigh: "Interacting hard problems requiring deep reasoning, comparison of approaches, and validation of cross-module invariants. Excludes escalation based only on file count or unsupported claims of complexity. Example: investigate an intermittent bug involving lifecycle, caching, and cancellation interactions.",
12
+ xhigh:
13
+ "Interacting hard problems requiring deep reasoning, comparison of approaches, and validation of cross-module invariants. Excludes escalation based only on file count or unsupported claims of complexity. Example: investigate an intermittent bug involving lifecycle, caching, and cancellation interactions.",
11
14
  max: "Exceptionally difficult synthesis requiring sustained rigorous argument and adversarial validation, or concrete evidence that lower-effort reasoning is insufficient. Excludes escalation from risk keywords alone; prior lower-level failure is not required. Example: prove and repair system-wide invariants involving concurrency, memory safety, and low-level semantics.",
12
15
  };
13
16
 
package/src/index.ts CHANGED
@@ -21,8 +21,17 @@ export {
21
21
  } from "./prompts.ts";
22
22
 
23
23
  export { createWorkflowTool, type WorkflowToolDeps } from "./workflow/tool.ts";
24
- export { runWorkflow, type WorkflowRunOptions, type WorkflowRunResult } from "./workflow/runtime.ts";
25
- export { parseWorkflowScript, normalizeScript, type WorkflowMeta, type WorkflowMetaPhase } from "./workflow/parser.ts";
24
+ export {
25
+ runWorkflow,
26
+ type WorkflowRunOptions,
27
+ type WorkflowRunResult,
28
+ } from "./workflow/runtime.ts";
29
+ export {
30
+ parseWorkflowScript,
31
+ normalizeScript,
32
+ type WorkflowMeta,
33
+ type WorkflowMetaPhase,
34
+ } from "./workflow/parser.ts";
26
35
  export { jsonSchemaToTypeBox } from "./workflow/json-schema.ts";
27
36
  export {
28
37
  WorkflowAgentRunner,
@@ -40,7 +49,10 @@ export {
40
49
  type ModelRuntimeFactory,
41
50
  type ModelRuntimeLike,
42
51
  } from "./workflow/agent-runner.ts";
43
- export { createStructuredOutputTool, type StructuredOutputCapture } from "./workflow/structured-output.ts";
52
+ export {
53
+ createStructuredOutputTool,
54
+ type StructuredOutputCapture,
55
+ } from "./workflow/structured-output.ts";
44
56
  export {
45
57
  discoverAgentTypes,
46
58
  resolveAgentType,