@mariozechner/pi-coding-agent 0.34.1 → 0.35.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/CHANGELOG.md +224 -18
- package/README.md +233 -105
- package/dist/cli/args.d.ts +3 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +13 -18
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +39 -50
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +166 -197
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +6 -5
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/index.d.ts +10 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +21 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +400 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +88 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/{hooks → extensions}/runner.js +52 -141
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +461 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/{hooks → extensions}/types.js +7 -4
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +25 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/{hooks/tool-wrapper.js → extensions/wrapper.js} +39 -24
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/messages.d.ts +7 -7
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +4 -4
- package/dist/core/messages.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +40 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/{slash-commands.js → prompt-templates.js} +31 -31
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/sdk.d.ts +29 -52
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +111 -211
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +17 -17
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +25 -10
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +4 -11
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +4 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +36 -33
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +7 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +93 -4
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -2
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -4
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +18 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/{hook-message.js → custom-message.js} +3 -3
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +2 -2
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +2 -2
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/{hook-editor.d.ts → extension-editor.d.ts} +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/{hook-editor.js → extension-editor.js} +4 -4
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/{hook-input.d.ts → extension-input.d.ts} +3 -3
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/{hook-input.js → extension-input.js} +3 -3
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/{hook-selector.d.ts → extension-selector.d.ts} +3 -3
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/{hook-selector.js → extension-selector.js} +3 -3
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +3 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -3
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +37 -44
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +143 -189
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +10 -33
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +3 -3
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +33 -57
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +16 -16
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +1053 -0
- package/docs/rpc.md +4 -4
- package/docs/sdk.md +62 -93
- package/docs/session.md +22 -19
- package/docs/skills.md +1 -1
- package/docs/tui.md +1 -1
- package/examples/README.md +9 -15
- package/examples/extensions/README.md +141 -0
- package/examples/{hooks → extensions}/auto-commit-on-exit.ts +3 -3
- package/examples/extensions/chalk-logger.ts +26 -0
- package/examples/{hooks → extensions}/confirm-destructive.ts +3 -3
- package/examples/{hooks → extensions}/custom-compaction.ts +6 -6
- package/examples/{hooks → extensions}/dirty-repo-guard.ts +8 -4
- package/examples/{hooks → extensions}/file-trigger.ts +3 -3
- package/examples/{hooks → extensions}/git-checkpoint.ts +3 -3
- package/examples/{hooks → extensions}/handoff.ts +3 -3
- package/examples/extensions/hello.ts +25 -0
- package/examples/{hooks → extensions}/permission-gate.ts +3 -3
- package/examples/{hooks → extensions}/pirate.ts +5 -5
- package/examples/{hooks → extensions}/plan-mode.ts +6 -6
- package/examples/{hooks → extensions}/protected-paths.ts +3 -3
- package/examples/{hooks → extensions}/qna.ts +3 -3
- package/examples/{custom-tools/question/index.ts → extensions/question.ts} +13 -17
- package/examples/{hooks → extensions}/snake.ts +3 -3
- package/examples/{hooks → extensions}/status-line.ts +3 -3
- package/examples/{custom-tools → extensions}/subagent/README.md +15 -15
- package/examples/{custom-tools → extensions}/subagent/index.ts +22 -43
- package/examples/{custom-tools/todo/index.ts → extensions/todo.ts} +122 -39
- package/examples/{hooks → extensions}/tools.ts +5 -5
- package/examples/extensions/with-deps/index.ts +40 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/05-tools.ts +7 -41
- package/examples/sdk/06-extensions.ts +81 -0
- package/examples/sdk/08-prompt-templates.ts +42 -0
- package/examples/sdk/12-full-control.ts +10 -29
- package/examples/sdk/README.md +5 -5
- package/package.json +4 -4
- package/dist/core/custom-tools/index.d.ts +0 -7
- package/dist/core/custom-tools/index.d.ts.map +0 -1
- package/dist/core/custom-tools/index.js +0 -6
- package/dist/core/custom-tools/index.js.map +0 -1
- package/dist/core/custom-tools/loader.d.ts +0 -30
- package/dist/core/custom-tools/loader.d.ts.map +0 -1
- package/dist/core/custom-tools/loader.js +0 -276
- package/dist/core/custom-tools/loader.js.map +0 -1
- package/dist/core/custom-tools/types.d.ts +0 -144
- package/dist/core/custom-tools/types.d.ts.map +0 -1
- package/dist/core/custom-tools/types.js +0 -8
- package/dist/core/custom-tools/types.js.map +0 -1
- package/dist/core/custom-tools/wrapper.d.ts +0 -15
- package/dist/core/custom-tools/wrapper.d.ts.map +0 -1
- package/dist/core/custom-tools/wrapper.js +0 -23
- package/dist/core/custom-tools/wrapper.js.map +0 -1
- package/dist/core/hooks/index.d.ts +0 -6
- package/dist/core/hooks/index.d.ts.map +0 -1
- package/dist/core/hooks/index.js +0 -6
- package/dist/core/hooks/index.js.map +0 -1
- package/dist/core/hooks/loader.d.ts +0 -146
- package/dist/core/hooks/loader.d.ts.map +0 -1
- package/dist/core/hooks/loader.js +0 -275
- package/dist/core/hooks/loader.js.map +0 -1
- package/dist/core/hooks/runner.d.ts +0 -173
- package/dist/core/hooks/runner.d.ts.map +0 -1
- package/dist/core/hooks/runner.js.map +0 -1
- package/dist/core/hooks/tool-wrapper.d.ts +0 -17
- package/dist/core/hooks/tool-wrapper.d.ts.map +0 -1
- package/dist/core/hooks/tool-wrapper.js.map +0 -1
- package/dist/core/hooks/types.d.ts +0 -767
- package/dist/core/hooks/types.d.ts.map +0 -1
- package/dist/core/hooks/types.js.map +0 -1
- package/dist/core/slash-commands.d.ts +0 -40
- package/dist/core/slash-commands.d.ts.map +0 -1
- package/dist/core/slash-commands.js.map +0 -1
- package/dist/modes/interactive/components/hook-editor.d.ts.map +0 -1
- package/dist/modes/interactive/components/hook-editor.js.map +0 -1
- package/dist/modes/interactive/components/hook-input.d.ts.map +0 -1
- package/dist/modes/interactive/components/hook-input.js.map +0 -1
- package/dist/modes/interactive/components/hook-message.d.ts +0 -18
- package/dist/modes/interactive/components/hook-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/hook-message.js.map +0 -1
- package/dist/modes/interactive/components/hook-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/hook-selector.js.map +0 -1
- package/docs/custom-tools.md +0 -514
- package/docs/extension-loading.md +0 -1004
- package/docs/hooks.md +0 -979
- package/docs/session-tree-plan.md +0 -441
- package/examples/custom-tools/README.md +0 -114
- package/examples/custom-tools/hello/index.ts +0 -21
- package/examples/hooks/README.md +0 -60
- package/examples/hooks/todo/index.ts +0 -134
- package/examples/sdk/06-hooks.ts +0 -61
- package/examples/sdk/08-slash-commands.ts +0 -42
- /package/examples/{custom-tools → extensions}/subagent/agents/planner.md +0 -0
- /package/examples/{custom-tools → extensions}/subagent/agents/reviewer.md +0 -0
- /package/examples/{custom-tools → extensions}/subagent/agents/scout.md +0 -0
- /package/examples/{custom-tools → extensions}/subagent/agents/worker.md +0 -0
- /package/examples/{custom-tools → extensions}/subagent/agents.ts +0 -0
- /package/examples/{custom-tools/subagent/commands → extensions/subagent/prompts}/implement-and-review.md +0 -0
- /package/examples/{custom-tools/subagent/commands → extensions/subagent/prompts}/implement.md +0 -0
- /package/examples/{custom-tools/subagent/commands → extensions/subagent/prompts}/scout-and-plan.md +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Todo Hook - Companion to the todo custom tool
|
|
3
|
-
*
|
|
4
|
-
* Registers a /todos command that displays all todos on the current branch
|
|
5
|
-
* with a nice custom UI.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { HookAPI, Theme } from "@mariozechner/pi-coding-agent";
|
|
9
|
-
import { matchesKey, truncateToWidth } from "@mariozechner/pi-tui";
|
|
10
|
-
|
|
11
|
-
interface Todo {
|
|
12
|
-
id: number;
|
|
13
|
-
text: string;
|
|
14
|
-
done: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface TodoDetails {
|
|
18
|
-
action: "list" | "add" | "toggle" | "clear";
|
|
19
|
-
todos: Todo[];
|
|
20
|
-
nextId: number;
|
|
21
|
-
error?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class TodoListComponent {
|
|
25
|
-
private todos: Todo[];
|
|
26
|
-
private theme: Theme;
|
|
27
|
-
private onClose: () => void;
|
|
28
|
-
private cachedWidth?: number;
|
|
29
|
-
private cachedLines?: string[];
|
|
30
|
-
|
|
31
|
-
constructor(todos: Todo[], theme: Theme, onClose: () => void) {
|
|
32
|
-
this.todos = todos;
|
|
33
|
-
this.theme = theme;
|
|
34
|
-
this.onClose = onClose;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
handleInput(data: string): void {
|
|
38
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
39
|
-
this.onClose();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
render(width: number): string[] {
|
|
44
|
-
if (this.cachedLines && this.cachedWidth === width) {
|
|
45
|
-
return this.cachedLines;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const lines: string[] = [];
|
|
49
|
-
const th = this.theme;
|
|
50
|
-
|
|
51
|
-
// Header
|
|
52
|
-
lines.push("");
|
|
53
|
-
const title = th.fg("accent", " Todos ");
|
|
54
|
-
const headerLine =
|
|
55
|
-
th.fg("borderMuted", "─".repeat(3)) + title + th.fg("borderMuted", "─".repeat(Math.max(0, width - 10)));
|
|
56
|
-
lines.push(truncateToWidth(headerLine, width));
|
|
57
|
-
lines.push("");
|
|
58
|
-
|
|
59
|
-
if (this.todos.length === 0) {
|
|
60
|
-
lines.push(truncateToWidth(` ${th.fg("dim", "No todos yet. Ask the agent to add some!")}`, width));
|
|
61
|
-
} else {
|
|
62
|
-
// Stats
|
|
63
|
-
const done = this.todos.filter((t) => t.done).length;
|
|
64
|
-
const total = this.todos.length;
|
|
65
|
-
const statsText = ` ${th.fg("muted", `${done}/${total} completed`)}`;
|
|
66
|
-
lines.push(truncateToWidth(statsText, width));
|
|
67
|
-
lines.push("");
|
|
68
|
-
|
|
69
|
-
// Todo items
|
|
70
|
-
for (const todo of this.todos) {
|
|
71
|
-
const check = todo.done ? th.fg("success", "✓") : th.fg("dim", "○");
|
|
72
|
-
const id = th.fg("accent", `#${todo.id}`);
|
|
73
|
-
const text = todo.done ? th.fg("dim", todo.text) : th.fg("text", todo.text);
|
|
74
|
-
const line = ` ${check} ${id} ${text}`;
|
|
75
|
-
lines.push(truncateToWidth(line, width));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
lines.push("");
|
|
80
|
-
lines.push(truncateToWidth(` ${th.fg("dim", "Press Escape to close")}`, width));
|
|
81
|
-
lines.push("");
|
|
82
|
-
|
|
83
|
-
this.cachedWidth = width;
|
|
84
|
-
this.cachedLines = lines;
|
|
85
|
-
return lines;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
invalidate(): void {
|
|
89
|
-
this.cachedWidth = undefined;
|
|
90
|
-
this.cachedLines = undefined;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export default function (pi: HookAPI) {
|
|
95
|
-
/**
|
|
96
|
-
* Reconstruct todos from session entries on the current branch.
|
|
97
|
-
*/
|
|
98
|
-
function getTodos(ctx: {
|
|
99
|
-
sessionManager: {
|
|
100
|
-
getBranch: () => Array<{ type: string; message?: { role?: string; toolName?: string; details?: unknown } }>;
|
|
101
|
-
};
|
|
102
|
-
}): Todo[] {
|
|
103
|
-
let todos: Todo[] = [];
|
|
104
|
-
|
|
105
|
-
for (const entry of ctx.sessionManager.getBranch()) {
|
|
106
|
-
if (entry.type !== "message") continue;
|
|
107
|
-
const msg = entry.message;
|
|
108
|
-
if (!msg || msg.role !== "toolResult" || msg.toolName !== "todo") continue;
|
|
109
|
-
|
|
110
|
-
const details = msg.details as TodoDetails | undefined;
|
|
111
|
-
if (details) {
|
|
112
|
-
todos = details.todos;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return todos;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
pi.registerCommand("todos", {
|
|
120
|
-
description: "Show all todos on the current branch",
|
|
121
|
-
handler: async (_args, ctx) => {
|
|
122
|
-
if (!ctx.hasUI) {
|
|
123
|
-
ctx.ui.notify("/todos requires interactive mode", "error");
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const todos = getTodos(ctx);
|
|
128
|
-
|
|
129
|
-
await ctx.ui.custom<void>((_tui, theme, done) => {
|
|
130
|
-
return new TodoListComponent(todos, theme, () => done());
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
}
|
package/examples/sdk/06-hooks.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hooks Configuration
|
|
3
|
-
*
|
|
4
|
-
* Hooks intercept agent events for logging, blocking, or modification.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createAgentSession, type HookFactory, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
8
|
-
|
|
9
|
-
// Logging hook
|
|
10
|
-
const loggingHook: HookFactory = (api) => {
|
|
11
|
-
api.on("agent_start", async () => {
|
|
12
|
-
console.log("[Hook] Agent starting");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
api.on("tool_call", async (event) => {
|
|
16
|
-
console.log(`[Hook] Tool: ${event.toolName}`);
|
|
17
|
-
return undefined; // Don't block
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
api.on("agent_end", async (event) => {
|
|
21
|
-
console.log(`[Hook] Done, ${event.messages.length} messages`);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Blocking hook (returns { block: true, reason: "..." })
|
|
26
|
-
const safetyHook: HookFactory = (api) => {
|
|
27
|
-
api.on("tool_call", async (event) => {
|
|
28
|
-
if (event.toolName === "bash") {
|
|
29
|
-
const cmd = (event.input as { command?: string }).command ?? "";
|
|
30
|
-
if (cmd.includes("rm -rf")) {
|
|
31
|
-
return { block: true, reason: "Dangerous command blocked" };
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Use inline hooks
|
|
39
|
-
const { session } = await createAgentSession({
|
|
40
|
-
hooks: [{ factory: loggingHook }, { factory: safetyHook }],
|
|
41
|
-
sessionManager: SessionManager.inMemory(),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
session.subscribe((event) => {
|
|
45
|
-
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
46
|
-
process.stdout.write(event.assistantMessageEvent.delta);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
await session.prompt("List files in the current directory.");
|
|
51
|
-
console.log();
|
|
52
|
-
|
|
53
|
-
// Disable all hooks:
|
|
54
|
-
// hooks: []
|
|
55
|
-
|
|
56
|
-
// Merge with discovered hooks:
|
|
57
|
-
// const discovered = await discoverHooks();
|
|
58
|
-
// hooks: [...discovered, { factory: myHook }]
|
|
59
|
-
|
|
60
|
-
// Add paths without replacing discovery:
|
|
61
|
-
// additionalHookPaths: ["/extra/hooks"]
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Slash Commands
|
|
3
|
-
*
|
|
4
|
-
* File-based commands that inject content when invoked with /commandname.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
createAgentSession,
|
|
9
|
-
discoverSlashCommands,
|
|
10
|
-
type FileSlashCommand,
|
|
11
|
-
SessionManager,
|
|
12
|
-
} from "@mariozechner/pi-coding-agent";
|
|
13
|
-
|
|
14
|
-
// Discover commands from cwd/.pi/commands/ and ~/.pi/agent/commands/
|
|
15
|
-
const discovered = discoverSlashCommands();
|
|
16
|
-
console.log("Discovered slash commands:");
|
|
17
|
-
for (const cmd of discovered) {
|
|
18
|
-
console.log(` /${cmd.name}: ${cmd.description}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Define custom commands
|
|
22
|
-
const deployCommand: FileSlashCommand = {
|
|
23
|
-
name: "deploy",
|
|
24
|
-
description: "Deploy the application",
|
|
25
|
-
source: "(custom)",
|
|
26
|
-
content: `# Deploy Instructions
|
|
27
|
-
|
|
28
|
-
1. Build: npm run build
|
|
29
|
-
2. Test: npm test
|
|
30
|
-
3. Deploy: npm run deploy`,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Use discovered + custom commands
|
|
34
|
-
await createAgentSession({
|
|
35
|
-
slashCommands: [...discovered, deployCommand],
|
|
36
|
-
sessionManager: SessionManager.inMemory(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
console.log(`Session created with ${discovered.length + 1} slash commands`);
|
|
40
|
-
|
|
41
|
-
// Disable slash commands:
|
|
42
|
-
// slashCommands: []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/examples/{custom-tools/subagent/commands → extensions/subagent/prompts}/implement.md
RENAMED
|
File without changes
|
/package/examples/{custom-tools/subagent/commands → extensions/subagent/prompts}/scout-and-plan.md
RENAMED
|
File without changes
|