@oh-my-pi/pi-coding-agent 15.5.15 → 15.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/CHANGELOG.md +81 -0
- package/dist/types/capability/rule-buckets.d.ts +30 -0
- package/dist/types/capability/rule.d.ts +7 -0
- package/dist/types/cli/classify-install-target.d.ts +0 -10
- package/dist/types/cli/completion-gen.d.ts +80 -0
- package/dist/types/cli/initial-message.d.ts +1 -1
- package/dist/types/cli/tiny-models-cli.d.ts +9 -0
- package/dist/types/commands/complete.d.ts +6 -0
- package/dist/types/commands/completions.d.ts +13 -0
- package/dist/types/commands/setup.d.ts +10 -1
- package/dist/types/commands/tiny-models.d.ts +22 -0
- package/dist/types/commit/analysis/conventional.d.ts +1 -1
- package/dist/types/commit/analysis/summary.d.ts +1 -1
- package/dist/types/commit/changelog/generate.d.ts +1 -1
- package/dist/types/commit/changelog/index.d.ts +2 -2
- package/dist/types/commit/map-reduce/map-phase.d.ts +1 -1
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +1 -1
- package/dist/types/config/model-id-affixes.d.ts +10 -0
- package/dist/types/config/settings-schema.d.ts +402 -17
- package/dist/types/discovery/builtin-defaults.d.ts +1 -0
- package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
- package/dist/types/discovery/helpers.d.ts +1 -1
- package/dist/types/discovery/index.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +0 -4
- package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
- package/dist/types/edit/hashline/index.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +16 -1
- package/dist/types/eval/py/kernel.d.ts +3 -0
- package/dist/types/eval/py/runtime.d.ts +11 -1
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/internal-urls/agent-protocol.d.ts +2 -1
- package/dist/types/internal-urls/artifact-protocol.d.ts +2 -1
- package/dist/types/internal-urls/local-protocol.d.ts +2 -1
- package/dist/types/internal-urls/memory-protocol.d.ts +2 -1
- package/dist/types/internal-urls/omp-protocol.d.ts +2 -1
- package/dist/types/internal-urls/router.d.ts +8 -1
- package/dist/types/internal-urls/rule-protocol.d.ts +2 -1
- package/dist/types/internal-urls/skill-protocol.d.ts +2 -1
- package/dist/types/internal-urls/types.d.ts +26 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/memory-backend/index.d.ts +1 -0
- package/dist/types/memory-backend/resolve.d.ts +2 -1
- package/dist/types/memory-backend/types.d.ts +7 -1
- package/dist/types/mnemosyne/backend.d.ts +4 -0
- package/dist/types/mnemosyne/config.d.ts +29 -0
- package/dist/types/mnemosyne/index.d.ts +3 -0
- package/dist/types/mnemosyne/state.d.ts +72 -0
- package/dist/types/modes/components/custom-editor.d.ts +2 -3
- package/dist/types/modes/components/hook-selector.d.ts +27 -0
- package/dist/types/modes/components/index.d.ts +2 -0
- package/dist/types/modes/components/segment-track.d.ts +22 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +6 -0
- package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
- package/dist/types/modes/components/welcome.d.ts +22 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +4 -1
- package/dist/types/modes/gradient-highlight.d.ts +23 -0
- package/dist/types/modes/interactive-mode.d.ts +7 -4
- package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
- package/dist/types/modes/orchestrate.d.ts +10 -0
- package/dist/types/modes/setup-wizard/index.d.ts +16 -0
- package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +19 -0
- package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
- package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +43 -0
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +19 -0
- package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +14 -0
- package/dist/types/modes/theme/defaults/index.d.ts +8406 -8406
- package/dist/types/modes/theme/shimmer.d.ts +2 -0
- package/dist/types/modes/theme/theme.d.ts +11 -0
- package/dist/types/modes/types.d.ts +5 -1
- package/dist/types/modes/ultrathink.d.ts +3 -3
- package/dist/types/modes/utils/keybinding-matchers.d.ts +5 -0
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/session/agent-session.d.ts +33 -0
- package/dist/types/system-prompt.d.ts +2 -0
- package/dist/types/task/executor.d.ts +2 -0
- package/dist/types/task/render.d.ts +5 -1
- package/dist/types/tiny/device.d.ts +78 -0
- package/dist/types/tiny/dtype.d.ts +85 -0
- package/dist/types/tiny/models.d.ts +185 -0
- package/dist/types/tiny/text.d.ts +19 -0
- package/dist/types/tiny/title-client.d.ts +32 -0
- package/dist/types/tiny/title-protocol.d.ts +74 -0
- package/dist/types/tiny/worker.d.ts +2 -0
- package/dist/types/tools/bash.d.ts +3 -2
- package/dist/types/tools/eval.d.ts +1 -1
- package/dist/types/tools/index.d.ts +7 -4
- package/dist/types/tools/memory-edit.d.ts +40 -0
- package/dist/types/tools/{hindsight-recall.d.ts → memory-recall.d.ts} +6 -6
- package/dist/types/tools/{hindsight-reflect.d.ts → memory-reflect.d.ts} +6 -6
- package/dist/types/tools/memory-render.d.ts +60 -0
- package/dist/types/tools/{hindsight-retain.d.ts → memory-retain.d.ts} +6 -6
- package/dist/types/tools/todo-write.d.ts +8 -0
- package/dist/types/tools/tool-result.d.ts +2 -0
- package/dist/types/tui/code-cell.d.ts +2 -0
- package/dist/types/tui/output-block.d.ts +17 -0
- package/dist/types/utils/title-generator.d.ts +3 -0
- package/package.json +18 -14
- package/scripts/build-binary.ts +1 -0
- package/src/capability/rule-buckets.ts +64 -0
- package/src/capability/rule.ts +8 -0
- package/src/cli/completion-gen.ts +550 -0
- package/src/cli/setup-cli.ts +5 -3
- package/src/cli/tiny-models-cli.ts +127 -0
- package/src/cli-commands.ts +3 -0
- package/src/cli.ts +9 -15
- package/src/commands/complete.ts +66 -0
- package/src/commands/completions.ts +60 -0
- package/src/commands/setup.ts +29 -4
- package/src/commands/tiny-models.ts +36 -0
- package/src/config/model-equivalence.ts +43 -2
- package/src/config/model-id-affixes.ts +64 -0
- package/src/config/model-registry.ts +84 -10
- package/src/config/settings-schema.ts +275 -15
- package/src/discovery/builtin-defaults.ts +39 -0
- package/src/discovery/builtin-rules/index.ts +48 -0
- package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
- package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
- package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
- package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
- package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
- package/src/discovery/builtin-rules/rs-result-type.md +19 -0
- package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
- package/src/discovery/builtin-rules/ts-import-type.md +42 -0
- package/src/discovery/builtin-rules/ts-no-any.md +56 -0
- package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
- package/src/discovery/builtin-rules/ts-no-return-type.md +45 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +50 -0
- package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
- package/src/discovery/builtin-rules/ts-set-map.md +28 -0
- package/src/discovery/index.ts +1 -0
- package/src/edit/hashline/block-resolver.ts +14 -0
- package/src/edit/hashline/diff.ts +9 -8
- package/src/edit/hashline/execute.ts +2 -1
- package/src/edit/hashline/index.ts +1 -0
- package/src/eval/__tests__/shared-executors.test.ts +36 -0
- package/src/eval/js/shared/local-module-loader.ts +13 -1
- package/src/eval/js/shared/rewrite-imports.ts +31 -26
- package/src/eval/py/kernel.ts +37 -15
- package/src/eval/py/runtime.ts +57 -28
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +0 -12
- package/src/export/ttsr.ts +2 -0
- package/src/internal-urls/agent-protocol.ts +18 -1
- package/src/internal-urls/artifact-protocol.ts +19 -1
- package/src/internal-urls/docs-index.generated.ts +8 -7
- package/src/internal-urls/local-protocol.ts +14 -1
- package/src/internal-urls/memory-protocol.ts +6 -1
- package/src/internal-urls/omp-protocol.ts +5 -1
- package/src/internal-urls/router.ts +20 -1
- package/src/internal-urls/rule-protocol.ts +8 -1
- package/src/internal-urls/skill-protocol.ts +8 -1
- package/src/internal-urls/types.ts +27 -0
- package/src/lsp/render.ts +1 -1
- package/src/main.ts +18 -1
- package/src/mcp/oauth-flow.ts +2 -2
- package/src/memory-backend/index.ts +1 -0
- package/src/memory-backend/resolve.ts +4 -1
- package/src/memory-backend/types.ts +8 -1
- package/src/mnemosyne/backend.ts +374 -0
- package/src/mnemosyne/config.ts +160 -0
- package/src/mnemosyne/index.ts +3 -0
- package/src/mnemosyne/state.ts +548 -0
- package/src/modes/acp/acp-agent.ts +11 -6
- package/src/modes/components/agent-dashboard.ts +4 -4
- package/src/modes/components/custom-editor.ts +3 -2
- package/src/modes/components/diff.ts +2 -2
- package/src/modes/components/extensions/extension-list.ts +3 -2
- package/src/modes/components/footer.ts +5 -6
- package/src/modes/components/history-search.ts +3 -3
- package/src/modes/components/hook-selector.ts +92 -8
- package/src/modes/components/index.ts +2 -0
- package/src/modes/components/mcp-add-wizard.ts +3 -3
- package/src/modes/components/model-selector.ts +5 -4
- package/src/modes/components/oauth-selector.ts +3 -3
- package/src/modes/components/segment-track.ts +52 -0
- package/src/modes/components/session-observer-overlay.ts +19 -13
- package/src/modes/components/session-selector.ts +3 -3
- package/src/modes/components/settings-defs.ts +7 -0
- package/src/modes/components/status-line/context-thresholds.ts +11 -0
- package/src/modes/components/status-line/segments.ts +2 -2
- package/src/modes/components/tiny-title-download-progress.ts +90 -0
- package/src/modes/components/tips.txt +13 -0
- package/src/modes/components/tool-execution.ts +72 -4
- package/src/modes/components/tree-selector.ts +3 -3
- package/src/modes/components/user-message-selector.ts +3 -3
- package/src/modes/components/welcome.ts +102 -43
- package/src/modes/controllers/command-controller.ts +16 -1
- package/src/modes/controllers/extension-ui-controller.ts +3 -1
- package/src/modes/controllers/input-controller.ts +69 -21
- package/src/modes/gradient-highlight.ts +70 -0
- package/src/modes/interactive-mode.ts +75 -114
- package/src/modes/internal-url-autocomplete.ts +143 -0
- package/src/modes/orchestrate.ts +36 -0
- package/src/modes/prompt-action-autocomplete.ts +12 -0
- package/src/modes/setup-wizard/index.ts +88 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +96 -0
- package/src/modes/setup-wizard/scenes/outro.ts +35 -0
- package/src/modes/setup-wizard/scenes/providers.ts +69 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +193 -0
- package/src/modes/setup-wizard/scenes/splash.ts +201 -0
- package/src/modes/setup-wizard/scenes/theme.ts +299 -0
- package/src/modes/setup-wizard/scenes/types.ts +48 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +128 -0
- package/src/modes/setup-wizard/wizard-overlay.ts +275 -0
- package/src/modes/theme/shimmer.ts +5 -0
- package/src/modes/theme/theme.ts +44 -20
- package/src/modes/types.ts +6 -1
- package/src/modes/ultrathink.ts +9 -53
- package/src/modes/utils/keybinding-matchers.ts +11 -0
- package/src/prompts/system/memory-consolidation-system.md +8 -0
- package/src/prompts/system/memory-extraction-system.md +26 -0
- package/src/prompts/{commands/orchestrate.md → system/orchestrate-notice.md} +6 -17
- package/src/prompts/system/system-prompt.md +2 -0
- package/src/prompts/system/tiny-title-system.md +8 -0
- package/src/prompts/tools/memory-edit.md +8 -0
- package/src/prompts/tools/read.md +4 -0
- package/src/prompts/tools/task.md +4 -7
- package/src/sdk.ts +13 -21
- package/src/session/agent-session.ts +128 -44
- package/src/slash-commands/builtin-registry.ts +18 -1
- package/src/system-prompt.ts +4 -0
- package/src/task/commands.ts +1 -5
- package/src/task/executor.ts +8 -0
- package/src/task/index.ts +2 -0
- package/src/task/render.ts +69 -26
- package/src/tiny/device.ts +117 -0
- package/src/tiny/dtype.ts +101 -0
- package/src/tiny/models.ts +218 -0
- package/src/tiny/text.ts +54 -0
- package/src/tiny/title-client.ts +395 -0
- package/src/tiny/title-protocol.ts +51 -0
- package/src/tiny/worker.ts +587 -0
- package/src/tools/bash.ts +74 -29
- package/src/tools/browser/tab-worker.ts +1 -1
- package/src/tools/eval.ts +9 -4
- package/src/tools/index.ts +17 -22
- package/src/tools/memory-edit.ts +59 -0
- package/src/tools/memory-recall.ts +100 -0
- package/src/tools/memory-reflect.ts +88 -0
- package/src/tools/memory-render.ts +185 -0
- package/src/tools/memory-retain.ts +91 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/renderers.ts +4 -2
- package/src/tools/todo-write.ts +128 -29
- package/src/tools/tool-result.ts +8 -0
- package/src/tui/code-cell.ts +6 -1
- package/src/tui/output-block.ts +199 -38
- package/src/utils/title-generator.ts +115 -13
- package/dist/types/tools/recipe/index.d.ts +0 -46
- package/dist/types/tools/recipe/render.d.ts +0 -36
- package/dist/types/tools/recipe/runner.d.ts +0 -60
- package/dist/types/tools/recipe/runners/cargo.d.ts +0 -16
- package/dist/types/tools/recipe/runners/index.d.ts +0 -2
- package/dist/types/tools/recipe/runners/just.d.ts +0 -2
- package/dist/types/tools/recipe/runners/make.d.ts +0 -2
- package/dist/types/tools/recipe/runners/pkg.d.ts +0 -2
- package/dist/types/tools/recipe/runners/task.d.ts +0 -2
- package/src/prompts/tools/recipe.md +0 -16
- package/src/tools/hindsight-recall.ts +0 -69
- package/src/tools/hindsight-reflect.ts +0 -58
- package/src/tools/hindsight-retain.ts +0 -57
- package/src/tools/recipe/index.ts +0 -81
- package/src/tools/recipe/render.ts +0 -19
- package/src/tools/recipe/runner.ts +0 -219
- package/src/tools/recipe/runners/cargo.ts +0 -131
- package/src/tools/recipe/runners/index.ts +0 -8
- package/src/tools/recipe/runners/just.ts +0 -73
- package/src/tools/recipe/runners/make.ts +0 -101
- package/src/tools/recipe/runners/pkg.ts +0 -167
- package/src/tools/recipe/runners/task.ts +0 -72
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { TinyLocalModelKey, TinyTitleLocalModelKey } from "./models";
|
|
2
|
+
export type TinyTitleProgressStatus = "initiate" | "download" | "progress" | "progress_total" | "done" | "ready" | "error";
|
|
3
|
+
export interface TinyTitleProgressFileState {
|
|
4
|
+
loaded: number;
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TinyTitleProgressEvent {
|
|
8
|
+
modelKey: TinyLocalModelKey;
|
|
9
|
+
status: TinyTitleProgressStatus;
|
|
10
|
+
name?: string;
|
|
11
|
+
file?: string;
|
|
12
|
+
progress?: number;
|
|
13
|
+
loaded?: number;
|
|
14
|
+
total?: number;
|
|
15
|
+
files?: Record<string, TinyTitleProgressFileState>;
|
|
16
|
+
task?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
}
|
|
19
|
+
export type TinyTitleWorkerInbound = {
|
|
20
|
+
type: "ping";
|
|
21
|
+
id: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: "generate";
|
|
24
|
+
id: string;
|
|
25
|
+
modelKey: TinyTitleLocalModelKey;
|
|
26
|
+
message: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "complete";
|
|
29
|
+
id: string;
|
|
30
|
+
modelKey: TinyLocalModelKey;
|
|
31
|
+
prompt: string;
|
|
32
|
+
maxTokens?: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: "download";
|
|
35
|
+
id: string;
|
|
36
|
+
modelKey: TinyLocalModelKey;
|
|
37
|
+
} | {
|
|
38
|
+
type: "close";
|
|
39
|
+
};
|
|
40
|
+
export type TinyTitleWorkerOutbound = {
|
|
41
|
+
type: "pong";
|
|
42
|
+
id: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: "title";
|
|
45
|
+
id: string;
|
|
46
|
+
title: string | null;
|
|
47
|
+
} | {
|
|
48
|
+
type: "completion";
|
|
49
|
+
id: string;
|
|
50
|
+
text: string | null;
|
|
51
|
+
} | {
|
|
52
|
+
type: "downloaded";
|
|
53
|
+
id: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: "error";
|
|
56
|
+
id: string;
|
|
57
|
+
error: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "progress";
|
|
60
|
+
id: string;
|
|
61
|
+
event: TinyTitleProgressEvent;
|
|
62
|
+
} | {
|
|
63
|
+
type: "log";
|
|
64
|
+
level: "debug" | "warn" | "error";
|
|
65
|
+
msg: string;
|
|
66
|
+
meta?: Record<string, unknown>;
|
|
67
|
+
} | {
|
|
68
|
+
type: "closed";
|
|
69
|
+
};
|
|
70
|
+
export interface TinyTitleTransport {
|
|
71
|
+
send(message: TinyTitleWorkerOutbound): void;
|
|
72
|
+
onMessage(handler: (message: TinyTitleWorkerInbound) => void): () => void;
|
|
73
|
+
close(): void;
|
|
74
|
+
}
|
|
@@ -43,6 +43,8 @@ export interface BashToolDetails {
|
|
|
43
43
|
timeoutSeconds?: number;
|
|
44
44
|
requestedTimeoutSeconds?: number;
|
|
45
45
|
wallTimeMs?: number;
|
|
46
|
+
/** Exit code of a command that ran to completion but failed (non-zero). */
|
|
47
|
+
exitCode?: number;
|
|
46
48
|
terminalId?: string;
|
|
47
49
|
async?: {
|
|
48
50
|
state: "running" | "completed" | "failed";
|
|
@@ -70,7 +72,7 @@ export declare class BashTool implements AgentTool<BashToolSchema, BashToolDetai
|
|
|
70
72
|
readonly concurrency = "exclusive";
|
|
71
73
|
readonly strict = true;
|
|
72
74
|
constructor(session: ToolSession);
|
|
73
|
-
execute(_toolCallId: string, { command: rawCommand, env: rawEnv, timeout: rawTimeout, cwd, async: asyncRequested, pty }: BashToolInput, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<BashToolDetails>, ctx?: AgentToolContext): Promise<AgentToolResult<BashToolDetails>>;
|
|
75
|
+
execute(_toolCallId: string, { command: rawCommand, env: rawEnv, timeout: rawTimeout, cwd, async: asyncRequested, pty, }: BashToolInput, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<BashToolDetails>, ctx?: AgentToolContext): Promise<AgentToolResult<BashToolDetails>>;
|
|
74
76
|
}
|
|
75
77
|
export interface BashRenderArgs {
|
|
76
78
|
command?: string;
|
|
@@ -99,7 +101,6 @@ export interface ShellRendererConfig<TArgs> {
|
|
|
99
101
|
resolveEnv?: (args: TArgs | undefined) => Record<string, string> | undefined;
|
|
100
102
|
}
|
|
101
103
|
export declare function getBashEnvForDisplay(args: BashRenderArgs): Record<string, string> | undefined;
|
|
102
|
-
export declare function formatBashCommand(args: BashRenderArgs): string;
|
|
103
104
|
/**
|
|
104
105
|
* Returns the bash command formatted for the result body: the dim `$ cd … &&`
|
|
105
106
|
* prefix joined with syntax-highlighted command lines. The prefix is applied
|
|
@@ -94,7 +94,7 @@ interface EvalRenderContext {
|
|
|
94
94
|
timeout?: number;
|
|
95
95
|
}
|
|
96
96
|
export declare const evalToolRenderer: {
|
|
97
|
-
renderCall(args: EvalRenderArgs,
|
|
97
|
+
renderCall(args: EvalRenderArgs, options: RenderResultOptions, uiTheme: Theme): Component;
|
|
98
98
|
renderResult(result: {
|
|
99
99
|
content: Array<{
|
|
100
100
|
type: string;
|
|
@@ -6,6 +6,7 @@ import type { Settings } from "../config/settings";
|
|
|
6
6
|
import type { Skill } from "../extensibility/skills";
|
|
7
7
|
import type { GoalModeState, GoalRuntime } from "../goals";
|
|
8
8
|
import type { HindsightSessionState } from "../hindsight/state";
|
|
9
|
+
import type { MnemosyneSessionState } from "../mnemosyne/state";
|
|
9
10
|
import type { PlanModeState } from "../plan-mode/state";
|
|
10
11
|
import { type AgentRegistry } from "../registry/agent-registry";
|
|
11
12
|
import type { ArtifactManager } from "../session/artifacts";
|
|
@@ -36,15 +37,15 @@ export * from "./debug";
|
|
|
36
37
|
export * from "./eval";
|
|
37
38
|
export * from "./find";
|
|
38
39
|
export * from "./gh";
|
|
39
|
-
export * from "./hindsight-recall";
|
|
40
|
-
export * from "./hindsight-reflect";
|
|
41
|
-
export * from "./hindsight-retain";
|
|
42
40
|
export * from "./image-gen";
|
|
43
41
|
export * from "./inspect-image";
|
|
44
42
|
export * from "./irc";
|
|
45
43
|
export * from "./job";
|
|
44
|
+
export * from "./memory-edit";
|
|
45
|
+
export * from "./memory-recall";
|
|
46
|
+
export * from "./memory-reflect";
|
|
47
|
+
export * from "./memory-retain";
|
|
46
48
|
export * from "./read";
|
|
47
|
-
export * from "./recipe";
|
|
48
49
|
export * from "./render-mermaid";
|
|
49
50
|
export * from "./report-tool-issue";
|
|
50
51
|
export * from "./resolve";
|
|
@@ -106,6 +107,8 @@ export interface ToolSession {
|
|
|
106
107
|
getSessionId?: () => string | null;
|
|
107
108
|
/** Get Hindsight runtime state for this agent session. */
|
|
108
109
|
getHindsightSessionState?: () => HindsightSessionState | undefined;
|
|
110
|
+
/** Get Mnemosyne runtime state for this agent session. */
|
|
111
|
+
getMnemosyneSessionState?: () => MnemosyneSessionState | undefined;
|
|
109
112
|
/** Agent identity used for IRC routing. Returns the registry id (e.g. "0-Main", "0-AuthLoader"). */
|
|
110
113
|
getAgentId?: () => string | null;
|
|
111
114
|
/** Look up a registered tool by name (used by the eval js backend's tool bridge). */
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import * as z from "zod/v4";
|
|
3
|
+
import type { ToolSession } from ".";
|
|
4
|
+
declare const memoryEditSchema: z.ZodObject<{
|
|
5
|
+
op: z.ZodEnum<{
|
|
6
|
+
forget: "forget";
|
|
7
|
+
invalidate: "invalidate";
|
|
8
|
+
update: "update";
|
|
9
|
+
}>;
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
content: z.ZodOptional<z.ZodString>;
|
|
12
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
replacement_id: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type MemoryEditParams = z.infer<typeof memoryEditSchema>;
|
|
16
|
+
export declare class MemoryEditTool implements AgentTool<typeof memoryEditSchema> {
|
|
17
|
+
private readonly session;
|
|
18
|
+
readonly name = "memory_edit";
|
|
19
|
+
readonly approval: "read";
|
|
20
|
+
readonly label = "Memory Edit";
|
|
21
|
+
readonly description: string;
|
|
22
|
+
readonly parameters: z.ZodObject<{
|
|
23
|
+
op: z.ZodEnum<{
|
|
24
|
+
forget: "forget";
|
|
25
|
+
invalidate: "invalidate";
|
|
26
|
+
update: "update";
|
|
27
|
+
}>;
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
content: z.ZodOptional<z.ZodString>;
|
|
30
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
replacement_id: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
readonly strict = true;
|
|
34
|
+
readonly loadMode = "discoverable";
|
|
35
|
+
readonly summary = "Update, forget, or invalidate Mnemosyne memories";
|
|
36
|
+
constructor(session: ToolSession);
|
|
37
|
+
static createIf(session: ToolSession): MemoryEditTool | null;
|
|
38
|
+
execute(_id: string, params: MemoryEditParams): Promise<AgentToolResult>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import * as z from "zod/v4";
|
|
3
3
|
import type { ToolSession } from ".";
|
|
4
|
-
declare const
|
|
4
|
+
declare const memoryRecallSchema: z.ZodObject<{
|
|
5
5
|
query: z.ZodString;
|
|
6
6
|
}, z.core.$strip>;
|
|
7
|
-
export type
|
|
8
|
-
export declare class
|
|
7
|
+
export type MemoryRecallParams = z.infer<typeof memoryRecallSchema>;
|
|
8
|
+
export declare class MemoryRecallTool implements AgentTool<typeof memoryRecallSchema> {
|
|
9
9
|
private readonly session;
|
|
10
10
|
readonly name = "recall";
|
|
11
11
|
readonly approval: "read";
|
|
@@ -16,9 +16,9 @@ export declare class HindsightRecallTool implements AgentTool<typeof hindsightRe
|
|
|
16
16
|
}, z.core.$strip>;
|
|
17
17
|
readonly strict = true;
|
|
18
18
|
readonly loadMode = "discoverable";
|
|
19
|
-
readonly summary = "Search
|
|
19
|
+
readonly summary = "Search memory for relevant prior context";
|
|
20
20
|
constructor(session: ToolSession);
|
|
21
|
-
static createIf(session: ToolSession):
|
|
22
|
-
execute(_id: string, params:
|
|
21
|
+
static createIf(session: ToolSession): MemoryRecallTool | null;
|
|
22
|
+
execute(_id: string, params: MemoryRecallParams, signal?: AbortSignal): Promise<AgentToolResult>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import * as z from "zod/v4";
|
|
3
3
|
import type { ToolSession } from ".";
|
|
4
|
-
declare const
|
|
4
|
+
declare const memoryReflectSchema: z.ZodObject<{
|
|
5
5
|
query: z.ZodString;
|
|
6
6
|
context: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
|
-
export type
|
|
9
|
-
export declare class
|
|
8
|
+
export type MemoryReflectParams = z.infer<typeof memoryReflectSchema>;
|
|
9
|
+
export declare class MemoryReflectTool implements AgentTool<typeof memoryReflectSchema> {
|
|
10
10
|
private readonly session;
|
|
11
11
|
readonly name = "reflect";
|
|
12
12
|
readonly approval: "read";
|
|
@@ -18,9 +18,9 @@ export declare class HindsightReflectTool implements AgentTool<typeof hindsightR
|
|
|
18
18
|
}, z.core.$strip>;
|
|
19
19
|
readonly strict = true;
|
|
20
20
|
readonly loadMode = "discoverable";
|
|
21
|
-
readonly summary = "
|
|
21
|
+
readonly summary = "Synthesize an answer from long-term memory";
|
|
22
22
|
constructor(session: ToolSession);
|
|
23
|
-
static createIf(session: ToolSession):
|
|
24
|
-
execute(_id: string, params:
|
|
23
|
+
static createIf(session: ToolSession): MemoryReflectTool | null;
|
|
24
|
+
execute(_id: string, params: MemoryReflectParams, signal?: AbortSignal): Promise<AgentToolResult>;
|
|
25
25
|
}
|
|
26
26
|
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline TUI renderers for the long-term memory tools (`retain`, `recall`,
|
|
3
|
+
* `reflect`).
|
|
4
|
+
*
|
|
5
|
+
* These keep the transcript terse — one status line plus, for `retain`, one
|
|
6
|
+
* `Remember: …` line per stored item — instead of the generic JSON arg tree,
|
|
7
|
+
* which exploded multi-line memory blobs into an unreadable wall.
|
|
8
|
+
*/
|
|
9
|
+
import type { Component } from "@oh-my-pi/pi-tui";
|
|
10
|
+
import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
|
11
|
+
import type { Theme } from "../modes/theme/theme";
|
|
12
|
+
interface RetainRenderArgs {
|
|
13
|
+
items?: Array<{
|
|
14
|
+
content?: string;
|
|
15
|
+
context?: string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
interface QueryRenderArgs {
|
|
19
|
+
query?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const retainToolRenderer: {
|
|
22
|
+
inline: boolean;
|
|
23
|
+
mergeCallAndResult: boolean;
|
|
24
|
+
renderCall(args: RetainRenderArgs, options: RenderResultOptions, theme: Theme): Component;
|
|
25
|
+
renderResult(result: {
|
|
26
|
+
content: Array<{
|
|
27
|
+
type: string;
|
|
28
|
+
text?: string;
|
|
29
|
+
}>;
|
|
30
|
+
details?: {
|
|
31
|
+
count?: number;
|
|
32
|
+
};
|
|
33
|
+
isError?: boolean;
|
|
34
|
+
}, options: RenderResultOptions, theme: Theme, args?: RetainRenderArgs): Component;
|
|
35
|
+
};
|
|
36
|
+
export declare const recallToolRenderer: {
|
|
37
|
+
inline: boolean;
|
|
38
|
+
mergeCallAndResult: boolean;
|
|
39
|
+
renderCall(args: QueryRenderArgs, _options: RenderResultOptions, theme: Theme): Component;
|
|
40
|
+
renderResult(result: {
|
|
41
|
+
content: Array<{
|
|
42
|
+
type: string;
|
|
43
|
+
text?: string;
|
|
44
|
+
}>;
|
|
45
|
+
isError?: boolean;
|
|
46
|
+
}, options: RenderResultOptions, theme: Theme, args?: QueryRenderArgs): Component;
|
|
47
|
+
};
|
|
48
|
+
export declare const reflectToolRenderer: {
|
|
49
|
+
inline: boolean;
|
|
50
|
+
mergeCallAndResult: boolean;
|
|
51
|
+
renderCall(args: QueryRenderArgs, _options: RenderResultOptions, theme: Theme): Component;
|
|
52
|
+
renderResult(result: {
|
|
53
|
+
content: Array<{
|
|
54
|
+
type: string;
|
|
55
|
+
text?: string;
|
|
56
|
+
}>;
|
|
57
|
+
isError?: boolean;
|
|
58
|
+
}, options: RenderResultOptions, theme: Theme, args?: QueryRenderArgs): Component;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import * as z from "zod/v4";
|
|
3
3
|
import type { ToolSession } from ".";
|
|
4
|
-
declare const
|
|
4
|
+
declare const memoryRetainSchema: z.ZodObject<{
|
|
5
5
|
items: z.ZodArray<z.ZodObject<{
|
|
6
6
|
content: z.ZodString;
|
|
7
7
|
context: z.ZodOptional<z.ZodString>;
|
|
8
8
|
}, z.core.$strip>>;
|
|
9
9
|
}, z.core.$strip>;
|
|
10
|
-
export type
|
|
11
|
-
export declare class
|
|
10
|
+
export type MemoryRetainParams = z.infer<typeof memoryRetainSchema>;
|
|
11
|
+
export declare class MemoryRetainTool implements AgentTool<typeof memoryRetainSchema> {
|
|
12
12
|
private readonly session;
|
|
13
13
|
readonly name = "retain";
|
|
14
14
|
readonly approval: "read";
|
|
@@ -22,9 +22,9 @@ export declare class HindsightRetainTool implements AgentTool<typeof hindsightRe
|
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
readonly strict = true;
|
|
24
24
|
readonly loadMode = "discoverable";
|
|
25
|
-
readonly summary = "Store important facts in
|
|
25
|
+
readonly summary = "Store important facts in long-term memory";
|
|
26
26
|
constructor(session: ToolSession);
|
|
27
|
-
static createIf(session: ToolSession):
|
|
28
|
-
execute(_id: string, params:
|
|
27
|
+
static createIf(session: ToolSession): MemoryRetainTool | null;
|
|
28
|
+
execute(_id: string, params: MemoryRetainParams): Promise<AgentToolResult>;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -21,9 +21,14 @@ export interface TodoPhase {
|
|
|
21
21
|
name: string;
|
|
22
22
|
tasks: TodoItem[];
|
|
23
23
|
}
|
|
24
|
+
export interface TodoCompletionTransition {
|
|
25
|
+
phase: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}
|
|
24
28
|
export interface TodoWriteToolDetails {
|
|
25
29
|
phases: TodoPhase[];
|
|
26
30
|
storage: "session" | "memory";
|
|
31
|
+
completedTasks?: TodoCompletionTransition[];
|
|
27
32
|
}
|
|
28
33
|
declare const todoWriteSchema: z.ZodObject<{
|
|
29
34
|
ops: z.ZodArray<z.ZodObject<{
|
|
@@ -137,6 +142,9 @@ type TodoWriteRenderArgs = {
|
|
|
137
142
|
export declare function phaseRomanNumeral(oneBasedIndex: number): string;
|
|
138
143
|
/** Display-only phase header: `I. Foundation`. State and prompts never see this. */
|
|
139
144
|
export declare function formatPhaseDisplayName(name: string, oneBasedIndex: number): string;
|
|
145
|
+
export declare const TODO_WRITE_STRIKE_HOLD_FRAMES = 2;
|
|
146
|
+
export declare const TODO_WRITE_STRIKE_REVEAL_FRAMES = 12;
|
|
147
|
+
export declare const TODO_WRITE_STRIKE_TOTAL_FRAMES: number;
|
|
140
148
|
export declare const todoWriteToolRenderer: {
|
|
141
149
|
renderCall(args: TodoWriteRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component;
|
|
142
150
|
renderResult(result: {
|
|
@@ -24,6 +24,8 @@ export declare class ToolResultBuilder<TDetails extends DetailsWithMeta> {
|
|
|
24
24
|
sourcePath(value: string): this;
|
|
25
25
|
sourceInternal(value: string): this;
|
|
26
26
|
diagnostics(summary: string, messages: string[]): this;
|
|
27
|
+
/** Flag the result as a non-throwing failure (agent-loop surfaces it as a tool error). */
|
|
28
|
+
error(value?: boolean): this;
|
|
27
29
|
done(): AgentToolResult<TDetails>;
|
|
28
30
|
}
|
|
29
31
|
export declare function toolResult<TDetails extends DetailsWithMeta>(details?: TDetails): ToolResultBuilder<TDetails>;
|
|
@@ -12,6 +12,8 @@ export interface CodeCellOptions {
|
|
|
12
12
|
outputMaxLines?: number;
|
|
13
13
|
codeMaxLines?: number;
|
|
14
14
|
expanded?: boolean;
|
|
15
|
+
/** Animate the cell border with a sweeping segment while pending/running. */
|
|
16
|
+
animate?: boolean;
|
|
15
17
|
width: number;
|
|
16
18
|
}
|
|
17
19
|
export declare function renderCodeCell(options: CodeCellOptions, theme: Theme): string[];
|
|
@@ -10,7 +10,24 @@ export interface OutputBlockOptions {
|
|
|
10
10
|
}>;
|
|
11
11
|
width: number;
|
|
12
12
|
applyBg?: boolean;
|
|
13
|
+
/** Animate the border with a sweeping dark segment (pending/running state). */
|
|
14
|
+
animate?: boolean;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Monotonic frame counter for animated borders. Quantized coarse enough to
|
|
18
|
+
* coalesce multiple render passes inside one frame, fine enough to advance on
|
|
19
|
+
* every spinner interval so cached blocks re-render while the segment travels.
|
|
20
|
+
*/
|
|
21
|
+
export declare function borderShimmerTick(): number;
|
|
22
|
+
/**
|
|
23
|
+
* Perimeter index of the moving segment's head for a box of inner width `W` and
|
|
24
|
+
* height `H` at time `now`. The lap is split across the four edges in proportion
|
|
25
|
+
* to their length (so the average speed is uniform) and each edge is eased, for a
|
|
26
|
+
* deliberate, non-linear glide that slows at every corner. Position is derived
|
|
27
|
+
* from the wall clock against a fixed lap duration, so a perimeter change (new
|
|
28
|
+
* row / resize) shifts the head by at most a cell or two — no reset.
|
|
29
|
+
*/
|
|
30
|
+
export declare function borderSegmentHead(W: number, H: number, now: number): number;
|
|
14
31
|
export declare function renderOutputBlock(options: OutputBlockOptions, theme: Theme): string[];
|
|
15
32
|
/**
|
|
16
33
|
* Cached wrapper around `renderOutputBlock`.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Api, type Model } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import type { ModelRegistry } from "../config/model-registry";
|
|
3
3
|
import type { Settings } from "../config/settings";
|
|
4
|
+
export declare const TITLE_LOCAL_FALLBACK_DELAY_MS = 10000;
|
|
5
|
+
export declare function raceFirstNonNull<T>(primary: Promise<T | null>, startFallback: () => Promise<T | null>, delayMs?: number, onPrimaryWinAfterFallback?: () => void): Promise<T | null>;
|
|
4
6
|
/**
|
|
5
7
|
* Generate a title for a session based on the first user message.
|
|
6
8
|
*
|
|
@@ -15,6 +17,7 @@ import type { Settings } from "../config/settings";
|
|
|
15
17
|
* reflects the credential actually selected for this request.
|
|
16
18
|
*/
|
|
17
19
|
export declare function generateSessionTitle(firstMessage: string, registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined): Promise<string | null>;
|
|
20
|
+
export declare function generateTitleOnline(firstMessage: string, registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined, signal?: AbortSignal): Promise<string | null>;
|
|
18
21
|
export declare function formatSessionTerminalTitle(sessionName: string | undefined, cwd?: string): string;
|
|
19
22
|
/**
|
|
20
23
|
* Set the terminal title using OSC 0 (sets both tab and window title). Unsupported terminals ignore it.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-coding-agent",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.7.0",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -44,31 +44,35 @@
|
|
|
44
44
|
"generate-template": "bun scripts/generate-template.ts"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@agentclientprotocol/sdk": "0.
|
|
48
|
-
"@babel/parser": "^7.29.
|
|
47
|
+
"@agentclientprotocol/sdk": "0.22.1",
|
|
48
|
+
"@babel/parser": "^7.29.7",
|
|
49
49
|
"@mozilla/readability": "^0.6.0",
|
|
50
|
-
"@oh-my-pi/hashline": "15.
|
|
51
|
-
"@oh-my-pi/omp-stats": "15.
|
|
52
|
-
"@oh-my-pi/pi-agent-core": "15.
|
|
53
|
-
"@oh-my-pi/pi-ai": "15.
|
|
54
|
-
"@oh-my-pi/pi-
|
|
55
|
-
"@oh-my-pi/pi-
|
|
56
|
-
"@oh-my-pi/pi-
|
|
57
|
-
"@
|
|
50
|
+
"@oh-my-pi/hashline": "15.7.0",
|
|
51
|
+
"@oh-my-pi/omp-stats": "15.7.0",
|
|
52
|
+
"@oh-my-pi/pi-agent-core": "15.7.0",
|
|
53
|
+
"@oh-my-pi/pi-ai": "15.7.0",
|
|
54
|
+
"@oh-my-pi/pi-mnemosyne": "15.7.0",
|
|
55
|
+
"@oh-my-pi/pi-natives": "15.7.0",
|
|
56
|
+
"@oh-my-pi/pi-tui": "15.7.0",
|
|
57
|
+
"@oh-my-pi/pi-utils": "15.7.0",
|
|
58
|
+
"@puppeteer/browsers": "^3.0.4",
|
|
58
59
|
"@types/turndown": "5.0.6",
|
|
59
60
|
"@xterm/headless": "^6.0.0",
|
|
60
61
|
"chalk": "^5.6.2",
|
|
61
62
|
"diff": "^9.0.0",
|
|
62
|
-
"fflate": "0.8.
|
|
63
|
+
"fflate": "0.8.3",
|
|
63
64
|
"handlebars": "^4.7.9",
|
|
64
65
|
"linkedom": "^0.18.12",
|
|
65
|
-
"lru-cache": "11.
|
|
66
|
+
"lru-cache": "11.5.1",
|
|
66
67
|
"markit-ai": "0.5.3",
|
|
67
|
-
"puppeteer-core": "^
|
|
68
|
+
"puppeteer-core": "^25.1.0",
|
|
68
69
|
"turndown": "7.2.4",
|
|
69
70
|
"turndown-plugin-gfm": "1.0.2",
|
|
70
71
|
"zod": "4.4.3"
|
|
71
72
|
},
|
|
73
|
+
"optionalDependencies": {
|
|
74
|
+
"@huggingface/transformers": "^4.2.0"
|
|
75
|
+
},
|
|
72
76
|
"devDependencies": {
|
|
73
77
|
"@types/bun": "^1.3.14"
|
|
74
78
|
},
|
package/scripts/build-binary.ts
CHANGED
|
@@ -56,6 +56,7 @@ async function main(): Promise<void> {
|
|
|
56
56
|
"../stats/src/sync-worker.ts",
|
|
57
57
|
"./src/tools/browser/tab-worker-entry.ts",
|
|
58
58
|
"./src/eval/js/worker-entry.ts",
|
|
59
|
+
"./src/tiny/worker.ts",
|
|
59
60
|
// Legacy pi-* extension compat entrypoints served by
|
|
60
61
|
// `legacy-pi-compat.ts`. These are reached via computed bunfs paths
|
|
61
62
|
// (which `--compile`'s static analyzer cannot trace), so each must be
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule bucketing
|
|
3
|
+
*
|
|
4
|
+
* Single funnel that every discovered rule passes through on its way into a
|
|
5
|
+
* session. It applies the user's disable levers, registers TTSR rules with the
|
|
6
|
+
* manager, and splits the rest into the always-apply and rulebook buckets.
|
|
7
|
+
*
|
|
8
|
+
* Bucket precedence (matches docs/rulebook-matching-pipeline.md §5):
|
|
9
|
+
* 1. TTSR — non-empty `condition` that `TtsrManager.addRule` accepts
|
|
10
|
+
* 2. always — `alwaysApply === true`
|
|
11
|
+
* 3. rulebook — has a `description`
|
|
12
|
+
*/
|
|
13
|
+
import type { TtsrManager } from "../export/ttsr";
|
|
14
|
+
import { BUILTIN_DEFAULTS_PROVIDER_ID, type Rule } from "./rule";
|
|
15
|
+
|
|
16
|
+
export interface RuleBuckets {
|
|
17
|
+
rulebookRules: Rule[];
|
|
18
|
+
alwaysApplyRules: Rule[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BucketRulesOptions {
|
|
22
|
+
/** Rule names to drop entirely (bundled defaults and user rules alike). */
|
|
23
|
+
disabledRules?: readonly string[];
|
|
24
|
+
/** When false, drop every rule from the bundled `builtin-defaults` provider. */
|
|
25
|
+
builtinRules?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Filter and bucket rules, registering TTSR rules on `ttsrManager` as a side
|
|
30
|
+
* effect. Disabled rules are dropped before any bucket assignment, so a
|
|
31
|
+
* disabled rule is neither matched as TTSR nor surfaced via `rule://`.
|
|
32
|
+
*/
|
|
33
|
+
export function bucketRules(
|
|
34
|
+
rules: readonly Rule[],
|
|
35
|
+
ttsrManager: TtsrManager,
|
|
36
|
+
options: BucketRulesOptions = {},
|
|
37
|
+
): RuleBuckets {
|
|
38
|
+
const includeBuiltin = options.builtinRules !== false;
|
|
39
|
+
const disabled = new Set<string>();
|
|
40
|
+
for (const raw of options.disabledRules ?? []) {
|
|
41
|
+
const name = raw.trim();
|
|
42
|
+
if (name.length > 0) disabled.add(name);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const rulebookRules: Rule[] = [];
|
|
46
|
+
const alwaysApplyRules: Rule[] = [];
|
|
47
|
+
|
|
48
|
+
for (const rule of rules) {
|
|
49
|
+
if (disabled.has(rule.name)) continue;
|
|
50
|
+
if (!includeBuiltin && rule._source?.provider === BUILTIN_DEFAULTS_PROVIDER_ID) continue;
|
|
51
|
+
|
|
52
|
+
const isTtsrRule = rule.condition && rule.condition.length > 0 ? ttsrManager.addRule(rule) : false;
|
|
53
|
+
if (isTtsrRule) continue;
|
|
54
|
+
if (rule.alwaysApply === true) {
|
|
55
|
+
alwaysApplyRules.push(rule);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (rule.description) {
|
|
59
|
+
rulebookRules.push(rule);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { rulebookRules, alwaysApplyRules };
|
|
64
|
+
}
|
package/src/capability/rule.ts
CHANGED
|
@@ -9,6 +9,14 @@ import type { SourceMeta } from "./types";
|
|
|
9
9
|
|
|
10
10
|
const CONDITION_GLOB_SCOPE_TOOLS = ["edit", "write"] as const;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Provider id for the bundled default rules shipped with the agent.
|
|
14
|
+
* Lowest priority, so any user/project/tool rule of the same name overrides
|
|
15
|
+
* a bundled default. Also used to gate the whole bundled set via
|
|
16
|
+
* `ttsr.builtinRules`.
|
|
17
|
+
*/
|
|
18
|
+
export const BUILTIN_DEFAULTS_PROVIDER_ID = "builtin-defaults";
|
|
19
|
+
|
|
12
20
|
/**
|
|
13
21
|
* Parsed frontmatter from rule files.
|
|
14
22
|
*/
|