bkper 4.28.1 → 4.29.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.
Files changed (28) hide show
  1. package/README.md +2 -0
  2. package/lib/agent/extensions/handoff-goal-editor.d.ts +11 -0
  3. package/lib/agent/extensions/handoff-goal-editor.d.ts.map +1 -1
  4. package/lib/agent/extensions/handoff-goal-editor.js +38 -2
  5. package/lib/agent/extensions/handoff-goal-editor.js.map +1 -1
  6. package/lib/agent/interactive/interactive-mode.d.ts.map +1 -1
  7. package/lib/agent/interactive/interactive-mode.js +11 -2
  8. package/lib/agent/interactive/interactive-mode.js.map +1 -1
  9. package/lib/agent/interactive/prompt-history-search.d.ts +26 -0
  10. package/lib/agent/interactive/prompt-history-search.d.ts.map +1 -0
  11. package/lib/agent/interactive/prompt-history-search.js +139 -0
  12. package/lib/agent/interactive/prompt-history-search.js.map +1 -0
  13. package/lib/agent/interactive/prompt-history-store.d.ts +38 -0
  14. package/lib/agent/interactive/prompt-history-store.d.ts.map +1 -0
  15. package/lib/agent/interactive/prompt-history-store.js +156 -0
  16. package/lib/agent/interactive/prompt-history-store.js.map +1 -0
  17. package/lib/agent/interactive/session-keybindings.d.ts +1 -1
  18. package/lib/agent/interactive/session-keybindings.d.ts.map +1 -1
  19. package/lib/agent/interactive/session-keybindings.js +10 -1
  20. package/lib/agent/interactive/session-keybindings.js.map +1 -1
  21. package/lib/docs/apps/app-listing.md +1 -0
  22. package/lib/docs/apps/architecture.md +2 -0
  23. package/lib/docs/apps/context-menu.md +2 -0
  24. package/lib/docs/apps/quality.md +86 -0
  25. package/lib/docs/apps/security.md +1 -0
  26. package/lib/docs/cli/app-management.md +2 -0
  27. package/lib/docs/index.md +3 -0
  28. package/package.json +1 -1
package/README.md CHANGED
@@ -194,6 +194,8 @@ When the selected model cannot read images, the agent briefly uses Bkper's defau
194
194
 
195
195
  Use `/handoff <goal>` to continue long-running work in a new focused session. If you omit the goal, the agent opens an empty goal editor. Pressing `Ctrl+H` opens that editor with your current input text as the goal. The new session is linked to the original, with the relevant context drafted in the input editor for you to adjust or submit.
196
196
 
197
+ Press `Ctrl+R` in the standard or handoff input to fuzzy-search recently submitted inputs. Search history starts with inputs submitted after this feature is installed; it does not scan existing sessions. The handoff search omits Bash commands. Press `Ctrl+Alt+R` to open the session tree.
198
+
197
199
  Auto-handoff is enabled by default and offers a handoff shortly before context compaction. Auto-handoff and Auto-compact are independent and can each be turned on or off from `/settings`.
198
200
 
199
201
  ---
@@ -1,4 +1,5 @@
1
1
  import { type AutocompleteProvider } from '@earendil-works/pi-tui';
2
+ import type { PromptHistoryRepository } from '../interactive/prompt-history-store.js';
2
3
  export declare const HANDOFF_GOAL_EDITOR_TITLE = "Next session goal";
3
4
  export interface HandoffPromptTemplate {
4
5
  name: string;
@@ -7,7 +8,16 @@ export interface HandoffPromptTemplate {
7
8
  content: string;
8
9
  }
9
10
  interface HandoffGoalEditor {
11
+ autocompleteProvider?: AutocompleteProvider;
10
12
  setAutocompleteProvider(provider: AutocompleteProvider): void;
13
+ requestAutocomplete?(options: {
14
+ force: boolean;
15
+ explicitTab: boolean;
16
+ }): void;
17
+ isShowingAutocomplete?(): boolean;
18
+ getText?(): string;
19
+ setText?(text: string): void;
20
+ handleInput?(data: string): void;
11
21
  }
12
22
  export interface HandoffGoalEditorHost {
13
23
  showExtensionEditor(title: string, prefill?: string): Promise<string | undefined>;
@@ -22,6 +32,7 @@ export interface HandoffGoalEditorHost {
22
32
  };
23
33
  }
24
34
  export declare function expandHandoffGoalTemplate(goal: string, templates: ReadonlyArray<HandoffPromptTemplate>): string;
35
+ export declare function installHandoffGoalEditorPromptHistory(host: HandoffGoalEditorHost, history: PromptHistoryRepository): void;
25
36
  export declare function installHandoffGoalEditorAutocomplete(host: HandoffGoalEditorHost): void;
26
37
  export {};
27
38
  //# sourceMappingURL=handoff-goal-editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handoff-goal-editor.d.ts","sourceRoot":"","sources":["../../../src/agent/extensions/handoff-goal-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,oBAAoB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,iBAAiB;IACvB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,qBAAqB;IAClC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClF,eAAe,CAAC,EAAE;QACd,MAAM,CAAC,EAAE,iBAAiB,CAAC;KAC9B,CAAC;IACF,OAAO,CAAC,EAAE;QACN,eAAe,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;KACzD,CAAC;IACF,cAAc,CAAC,EAAE;QACb,MAAM,IAAI,MAAM,CAAC;KACpB,CAAC;CACL;AA+DD,wBAAgB,yBAAyB,CACrC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,qBAAqB,CAAC,GAChD,MAAM,CAYR;AAgCD,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAuBtF"}
1
+ {"version":3,"file":"handoff-goal-editor.d.ts","sourceRoot":"","sources":["../../../src/agent/extensions/handoff-goal-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,oBAAoB,EAC5B,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,wCAAwC,CAAC;AAEpF,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAE7D,MAAM,WAAW,qB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}
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { CombinedAutocompleteProvider, } from '@earendil-works/pi-tui';
11
+ import { installPromptHistorySearch, } from '../interactive/prompt-history-search.js';
11
12
  export const HANDOFF_GOAL_EDITOR_TITLE = 'Next session goal';
12
13
  function parseCommandArgs(argsString) {
13
14
  const args = [];
@@ -86,13 +87,48 @@ function createPromptTemplateAutocompleteProvider(templates, cwd) {
86
87
  if (cursorLine !== 0 || !/^\/[^\s]*$/.test(textBeforeCursor)) {
87
88
  return null;
88
89
  }
89
- return provider.getSuggestions(lines, cursorLine, cursorCol, Object.assign(Object.assign({}, options), { force: false }));
90
+ const suggestions = yield provider.getSuggestions(lines, cursorLine, cursorCol, Object.assign(Object.assign({}, options), { force: false }));
91
+ return suggestions ? Object.assign(Object.assign({}, suggestions), { prefix: '' }) : null;
90
92
  });
91
93
  },
92
- applyCompletion: (lines, cursorLine, cursorCol, item, prefix) => provider.applyCompletion(lines, cursorLine, cursorCol, item, prefix),
94
+ applyCompletion(lines, cursorLine, cursorCol, item) {
95
+ var _a, _b;
96
+ const template = templates.find(candidate => candidate.name === item.value);
97
+ if (!template) {
98
+ return { lines, cursorLine, cursorCol };
99
+ }
100
+ const expandedLines = substituteArgs(template.content, []).split('\n');
101
+ const expandedCursorLine = Math.max(0, expandedLines.length - 1);
102
+ return {
103
+ lines: expandedLines,
104
+ cursorLine: expandedCursorLine,
105
+ cursorCol: (_b = (_a = expandedLines[expandedCursorLine]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
106
+ };
107
+ },
93
108
  shouldTriggerFileCompletion: () => false,
94
109
  };
95
110
  }
111
+ export function installHandoffGoalEditorPromptHistory(host, history) {
112
+ const showExtensionEditor = host.showExtensionEditor.bind(host);
113
+ host.showExtensionEditor = (title, prefill) => __awaiter(this, void 0, void 0, function* () {
114
+ if (title !== HANDOFF_GOAL_EDITOR_TITLE) {
115
+ return showExtensionEditor(title, prefill);
116
+ }
117
+ const result = showExtensionEditor(title, prefill);
118
+ queueMicrotask(() => {
119
+ var _a;
120
+ const editor = (_a = host.extensionEditor) === null || _a === void 0 ? void 0 : _a.editor;
121
+ if ((editor === null || editor === void 0 ? void 0 : editor.getText) && editor.setText && editor.handleInput) {
122
+ installPromptHistorySearch(editor, history, false);
123
+ }
124
+ });
125
+ const goal = yield result;
126
+ if (goal === null || goal === void 0 ? void 0 : goal.trim()) {
127
+ history.record(goal, 'handoff');
128
+ }
129
+ return goal;
130
+ });
131
+ }
96
132
  export function installHandoffGoalEditorAutocomplete(host) {
97
133
  const showExtensionEditor = host.showExtensionEditor.bind(host);
98
134
  host.showExtensionEditor = (title, prefill) => __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"handoff-goal-editor.js","sourceRoot":"","sources":["../../../src/agent/extensions/handoff-goal-editor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,4BAA4B,GAE/B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;AA0B7D,SAAS,gBAAgB,CAAC,UAAkB;IACxC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,OAA2B,CAAC;IAEhC,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACnB,OAAO,GAAG,SAAS,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACJ,OAAO,IAAI,IAAI,CAAC;YACpB,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACtC,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,C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,EAAE,EAAE;;QAChD,IAAI,KAAK,KAAK,yBAAyB,EAAE,CAAC;YACtC,OAAO,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,eAAe,mCAAI,EAAE,CAAC,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,eAAe,0CAAE,MAAM,CAAC;QAC5C,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,uBAAuB,CAC1B,wCAAwC,CACpC,SAAS,EACT,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,MAAM,EAAE,mCAAI,OAAO,CAAC,GAAG,EAAE,CACjD,CACJ,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC;QAC1B,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvF,CAAC,CAAA,CAAC;AACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,eAAe,EAElB,MAAM,iCAAiC,CAAC;AAiBzC,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAStF,wBAAgB,0BAA0B,IAAI,MAAM,IAAI,CAmBvD;AAED,qBAAa,oBAAqB,SAAQ,eAAe;IAC/C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA2DrB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
1
+ {"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,eAAe,EAElB,MAAM,iCAAiC,CAAC;AA0BzC,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAStF,wBAAgB,0BAA0B,IAAI,MAAM,IAAI,CAmBvD;AAED,qBAAa,oBAAqB,SAAQ,eAAe;IAC/C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsErB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
@@ -9,8 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { getAgentDir, InteractiveMode, } from '@earendil-works/pi-coding-agent';
11
11
  import { installBkperAuthCommandRouting } from '../extensions/auth-commands.js';
12
- import { installHandoffGoalEditorAutocomplete, } from '../extensions/handoff-goal-editor.js';
12
+ import { installHandoffGoalEditorAutocomplete, installHandoffGoalEditorPromptHistory, } from '../extensions/handoff-goal-editor.js';
13
13
  import { FileAutoHandoffSettings, getAutoHandoffSettingsPath, installAutoHandoffSettingsIntegration, } from '../extensions/handoff.js';
14
+ import { installPromptHistoryEditor, } from './prompt-history-search.js';
15
+ import { FilePromptHistory, getPromptHistoryPath, } from './prompt-history-store.js';
14
16
  import { installBkperSessionKeybindings, } from './session-keybindings.js';
15
17
  const PI_RESUME_HINT_TEXT = 'To resume this session:';
16
18
  const ANSI_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/g;
@@ -46,9 +48,12 @@ export class BkperInteractiveMode extends InteractiveMode {
46
48
  if (authRoutingMode.editorContainer && authRoutingMode.showSettingsSelector) {
47
49
  installAutoHandoffSettingsIntegration(authRoutingMode, new FileAutoHandoffSettings(getAutoHandoffSettingsPath(getAgentDir())));
48
50
  }
51
+ const promptHistory = new FilePromptHistory(getPromptHistoryPath(getAgentDir()));
49
52
  const handoffGoalMode = this;
50
53
  if (handoffGoalMode.showExtensionEditor) {
51
- installHandoffGoalEditorAutocomplete(handoffGoalMode);
54
+ const handoffGoalHost = handoffGoalMode;
55
+ installHandoffGoalEditorPromptHistory(handoffGoalHost, promptHistory);
56
+ installHandoffGoalEditorAutocomplete(handoffGoalHost);
52
57
  }
53
58
  const providerRegistry = (_a = authRoutingMode.session) === null || _a === void 0 ? void 0 : _a.modelRuntime;
54
59
  if (providerRegistry) {
@@ -57,6 +62,10 @@ export class BkperInteractiveMode extends InteractiveMode {
57
62
  installBkperAuthCommandRouting(editor, providerRegistry);
58
63
  }
59
64
  }
65
+ const editors = new Set([authRoutingMode.defaultEditor, authRoutingMode.editor].filter(editor => editor !== undefined));
66
+ for (const editor of editors) {
67
+ installPromptHistoryEditor(editor, promptHistory);
68
+ }
60
69
  });
61
70
  }
62
71
  run() {
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-mode.js","sourceRoot":"","sources":["../../../src/agent/interactive/interactive-mode.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,WAAW,EACX,eAAe,GAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAC,8BAA8B,EAAC,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EACH,oCAAoC,GAEvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,uBAAuB,EACvB,0BAA0B,EAC1B,qCAAqC,GAExC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,8BAA8B,GAEjC,MAAM,0BAA0B,CAAC;AAIlC,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AACtD,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,SAAS,oBAAoB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,0BAA0B;IACtC,MAAM,aAAa,GAAG,OAAO,CA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GAAG,IAAI,GAAG,CACnB,CAAC,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAC1D,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,SAAS,CACjC,CACJ,CAAC;gBACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;oBAC3B,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;gBAC7D,CAAC;YACL,CAAC;QACL,CAAC;KAAA;IAEK,GAAG;;;;;YACL,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC;YAE7D,IAAI,CAAC;gBACD,MAAM,OAAM,GAAG,WAAE,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACP,uBAAuB,EAAE,CAAC;YAC9B,CAAC;QACL,CAAC;KAAA;CACJ"}
1
+ {"version":3,"file":"interactive-mode.js","sourceRoot":"","sources":["../../../src/agent/interactive/interactive-mode.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,WAAW,EACX,eAAe,GAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAC,8BAA8B,EAAC,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EACH,oCAAoC,EACpC,qCAAqC,GAExC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,uBAAuB,EACvB,0BAA0B,EAC1B,qCAAqC,GAExC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,0BAA0B,GAE7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,8BAA8B,GAEjC,MAAM,0BAA0B,CAAC;AAIlC,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AACtD,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,SAAS,oBAAoB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE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AC,mBAAmB,EAAE,CAAC;gBACtC,MAAM,eAAe,GAAG,eAAwC,CAAC;gBACjE,qCAAqC,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;gBACtE,oCAAoC,CAAC,eAAe,CAAC,CAAC;YAC1D,CAAC;YAED,MAAM,gBAAgB,GAAG,MAAA,eAAe,CAAC,OAAO,0CAAE,YAAY,CAAC;YAC/D,IAAI,gBAAgB,EAAE,CAAC;gBACnB,MAAM,OAAO,GAAG,IAAI,GAAG,CACnB,CAAC,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAC1D,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,SAAS,CACjC,CACJ,CAAC;gBACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;oBAC3B,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;gBAC7D,CAAC;YACL,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,GAAG,CACnB,CAAC,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAC1D,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,SAAS,CACjC,CACJ,CAAC;YACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC3B,0BAA0B,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;KAAA;IAEK,GAAG;;;;;YACL,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC;YAE7D,IAAI,CAAC;gBACD,MAAM,OAAM,GAAG,WAAE,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACP,uBAAuB,EAAE,CAAC;YAC9B,CAAC;QACL,CAAC;KAAA;CACJ"}
@@ -0,0 +1,26 @@
1
+ import type { AutocompleteItem, AutocompleteProvider, AutocompleteSuggestions } from '@earendil-works/pi-tui';
2
+ import { type PromptHistoryEntry, type PromptHistoryRepository } from './prompt-history-store.js';
3
+ export interface PromptHistoryEditor {
4
+ getText(): string;
5
+ getExpandedText?(): string;
6
+ setText(text: string): void;
7
+ handleInput(data: string): void;
8
+ onSubmit?: (text: string) => void | Promise<void>;
9
+ }
10
+ export declare class PromptHistoryAutocompleteProvider implements AutocompleteProvider {
11
+ private readonly entries;
12
+ private readonly includeBash;
13
+ constructor(entries: readonly PromptHistoryEntry[], includeBash: boolean);
14
+ getSuggestions(lines: string[], _cursorLine: number, _cursorCol: number, _options: {
15
+ signal: AbortSignal;
16
+ force?: boolean;
17
+ }): Promise<AutocompleteSuggestions | null>;
18
+ applyCompletion(_lines: string[], _cursorLine: number, _cursorCol: number, item: AutocompleteItem, _prefix: string): {
19
+ lines: string[];
20
+ cursorLine: number;
21
+ cursorCol: number;
22
+ };
23
+ }
24
+ export declare function installPromptHistorySearch(editor: PromptHistoryEditor, history: Pick<PromptHistoryRepository, 'getEntries'>, includeBash: boolean): void;
25
+ export declare function installPromptHistoryEditor(editor: PromptHistoryEditor, history: PromptHistoryRepository): void;
26
+ //# sourceMappingURL=prompt-history-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history-search.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/prompt-history-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC/B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,mBAAmB;IAChC,OAAO,IAAI,MAAM,CAAC;IAClB,eAAe,CAAC,IAAI,MAAM,CAAC;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAyCD,qBAAa,iCAAkC,YAAW,oBAAoB;IAEtE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,WAAW,EAAE,OAAO;IAGnC,cAAc,CAChB,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAC,GACjD,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAkB1C,eAAe,CACX,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,MAAM,GAChB;QAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC;CAS9D;AAED,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,YAAY,CAAC,EACpD,WAAW,EAAE,OAAO,GACrB,IAAI,CA0EN;AAED,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,uBAAuB,GACjC,IAAI,CAkBN"}
@@ -0,0 +1,139 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getKeybindings, matchesKey } from '@earendil-works/pi-tui';
11
+ import { searchPromptHistoryEntries, } from './prompt-history-store.js';
12
+ const searchInstalledEditors = new WeakSet();
13
+ const recordingInstalledEditors = new WeakSet();
14
+ const DOWN_KEY_INPUT = '\x1b[B';
15
+ function collapsePreview(text) {
16
+ return text.replace(/\s+/g, ' ').trim();
17
+ }
18
+ function isBashInput(text) {
19
+ return text.trimStart().startsWith('!');
20
+ }
21
+ function supportsInlineAutocomplete(editor) {
22
+ const candidate = editor;
23
+ return (candidate.autocompleteProvider !== undefined &&
24
+ typeof candidate.setAutocompleteProvider === 'function' &&
25
+ typeof candidate.requestAutocomplete === 'function' &&
26
+ typeof candidate.isShowingAutocomplete === 'function');
27
+ }
28
+ export class PromptHistoryAutocompleteProvider {
29
+ constructor(entries, includeBash) {
30
+ this.entries = entries;
31
+ this.includeBash = includeBash;
32
+ }
33
+ getSuggestions(lines, _cursorLine, _cursorCol, _options) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const results = searchPromptHistoryEntries(this.entries, lines.join('\n'), { includeBash: this.includeBash });
36
+ if (results.length === 0) {
37
+ return null;
38
+ }
39
+ return {
40
+ items: results.map(entry => ({
41
+ value: entry.text,
42
+ label: collapsePreview(entry.text),
43
+ })),
44
+ prefix: '',
45
+ };
46
+ });
47
+ }
48
+ applyCompletion(_lines, _cursorLine, _cursorCol, item, _prefix) {
49
+ var _a, _b;
50
+ const lines = item.value.split('\n');
51
+ const cursorLine = Math.max(0, lines.length - 1);
52
+ return {
53
+ lines,
54
+ cursorLine,
55
+ cursorCol: (_b = (_a = lines[cursorLine]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
56
+ };
57
+ }
58
+ }
59
+ export function installPromptHistorySearch(editor, history, includeBash) {
60
+ if (searchInstalledEditors.has(editor) || !supportsInlineAutocomplete(editor)) {
61
+ return;
62
+ }
63
+ searchInstalledEditors.add(editor);
64
+ const handleInput = editor.handleInput.bind(editor);
65
+ let originalProvider;
66
+ let searching = false;
67
+ const restoreProvider = () => {
68
+ if (!searching || !originalProvider) {
69
+ return;
70
+ }
71
+ editor.setAutocompleteProvider(originalProvider);
72
+ originalProvider = undefined;
73
+ searching = false;
74
+ };
75
+ const requestSuggestions = () => {
76
+ editor.requestAutocomplete({ force: false, explicitTab: true });
77
+ };
78
+ editor.handleInput = (data) => {
79
+ const keybindings = getKeybindings();
80
+ if (matchesKey(data, 'ctrl+r')) {
81
+ if (searching) {
82
+ if (editor.isShowingAutocomplete()) {
83
+ handleInput(DOWN_KEY_INPUT);
84
+ }
85
+ else {
86
+ requestSuggestions();
87
+ }
88
+ return;
89
+ }
90
+ originalProvider = editor.autocompleteProvider;
91
+ searching = true;
92
+ editor.setAutocompleteProvider(new PromptHistoryAutocompleteProvider(history.getEntries(), includeBash));
93
+ requestSuggestions();
94
+ return;
95
+ }
96
+ if (!searching) {
97
+ handleInput(data);
98
+ return;
99
+ }
100
+ if (keybindings.matches(data, 'tui.select.cancel')) {
101
+ if (editor.isShowingAutocomplete()) {
102
+ handleInput(data);
103
+ }
104
+ restoreProvider();
105
+ return;
106
+ }
107
+ if (keybindings.matches(data, 'tui.select.confirm') ||
108
+ keybindings.matches(data, 'tui.input.submit') ||
109
+ keybindings.matches(data, 'tui.input.tab')) {
110
+ if (editor.isShowingAutocomplete()) {
111
+ handleInput(data);
112
+ restoreProvider();
113
+ }
114
+ return;
115
+ }
116
+ handleInput(data);
117
+ if (!editor.isShowingAutocomplete()) {
118
+ requestSuggestions();
119
+ }
120
+ };
121
+ }
122
+ export function installPromptHistoryEditor(editor, history) {
123
+ installPromptHistorySearch(editor, history, true);
124
+ if (recordingInstalledEditors.has(editor)) {
125
+ return;
126
+ }
127
+ recordingInstalledEditors.add(editor);
128
+ const submit = editor.onSubmit;
129
+ if (submit) {
130
+ editor.onSubmit = (text) => __awaiter(this, void 0, void 0, function* () {
131
+ const normalized = text.trim();
132
+ if (normalized) {
133
+ history.record(normalized, isBashInput(normalized) ? 'bash' : 'standard');
134
+ }
135
+ yield submit(text);
136
+ });
137
+ }
138
+ }
139
+ //# sourceMappingURL=prompt-history-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history-search.js","sourceRoot":"","sources":["../../../src/agent/interactive/prompt-history-search.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAClE,OAAO,EACH,0BAA0B,GAG7B,MAAM,2BAA2B,CAAC;AAiBnC,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAuB,CAAC;AAClE,MAAM,yBAAyB,GAAG,IAAI,OAAO,EAAuB,CAAC;AACrE,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC,SAAS,eAAe,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,0BAA0B,CAC/B,MAA2B;IAE3B,MAAM,SAAS,GAAG,MAQjB,CAAC;IACF,OAAO,CACH,SAAS,CAAC,oBAAoB,KAAK,SAAS;QAC5C,OAAO,SAAS,CAAC,uBAAuB,KAAK,UAAU;QACvD,OAAO,SAAS,CAAC,mBAAmB,KAAK,UAAU;QACnD,OAAO,SAAS,CAAC,qBAAqB,KAAK,UAAU,CACxD,CAAC;AACN,CAAC;AAED,MAAM,OAAO,iCAAiC;IAC1C,YACqB,OAAsC,EACtC,WAAoB;QADpB,YAAO,GAAP,OAAO,CAA+B;QACtC,gBAAW,GAAX,WAAW,CAAS;IACtC,CAAC;IAEE,cAAc,CAChB,KAAe,EACf,WAAmB,EACnB,UAAkB,EAClB,QAA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;YAC9E,CAAC;YACD,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAA,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,38 @@
1
+ export type PromptHistoryKind = 'standard' | 'handoff' | 'bash';
2
+ export interface PromptHistoryEntry {
3
+ text: string;
4
+ kind: PromptHistoryKind;
5
+ timestamp: number;
6
+ }
7
+ export interface PromptHistoryRecorder {
8
+ record(text: string, kind: PromptHistoryKind, timestamp?: number): void;
9
+ }
10
+ export interface PromptHistoryRepository extends PromptHistoryRecorder {
11
+ getEntries(): readonly PromptHistoryEntry[];
12
+ }
13
+ export interface PromptHistorySearchOptions {
14
+ includeBash: boolean;
15
+ limit?: number;
16
+ }
17
+ export interface FilePromptHistoryOptions {
18
+ maxEntries?: number;
19
+ trimRecordCount?: number;
20
+ maxFileBytes?: number;
21
+ }
22
+ export declare function searchPromptHistoryEntries(entries: readonly PromptHistoryEntry[], query: string, options: PromptHistorySearchOptions): PromptHistoryEntry[];
23
+ export declare class FilePromptHistory implements PromptHistoryRepository {
24
+ private readonly filePath;
25
+ private readonly maxEntries;
26
+ private readonly trimRecordCount;
27
+ private readonly maxFileBytes;
28
+ private entries;
29
+ private recordCount;
30
+ private fileBytes;
31
+ constructor(filePath: string, options?: FilePromptHistoryOptions);
32
+ getEntries(): readonly PromptHistoryEntry[];
33
+ record(text: string, kind: PromptHistoryKind, timestamp?: number): void;
34
+ private load;
35
+ private rotate;
36
+ }
37
+ export declare function getPromptHistoryPath(agentDir: string): string;
38
+ //# sourceMappingURL=prompt-history-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history-store.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/prompt-history-store.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,E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oB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,156 @@
1
+ import { appendFileSync, chmodSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fuzzyFilter } from '@earendil-works/pi-tui';
4
+ const DEFAULT_MAX_ENTRIES = 10000;
5
+ const DEFAULT_TRIM_RECORD_COUNT = 20000;
6
+ const DEFAULT_MAX_FILE_BYTES = 16 * 1024 * 1024;
7
+ const DEFAULT_SEARCH_LIMIT = 10;
8
+ function isPromptHistoryKind(value) {
9
+ return value === 'standard' || value === 'handoff' || value === 'bash';
10
+ }
11
+ function parseEntry(line) {
12
+ try {
13
+ const value = JSON.parse(line);
14
+ if (typeof value !== 'object' || value === null) {
15
+ return undefined;
16
+ }
17
+ const record = value;
18
+ if (typeof record.text !== 'string' ||
19
+ !record.text.trim() ||
20
+ !isPromptHistoryKind(record.kind) ||
21
+ typeof record.timestamp !== 'number' ||
22
+ !Number.isFinite(record.timestamp)) {
23
+ return undefined;
24
+ }
25
+ return {
26
+ text: record.text,
27
+ kind: record.kind,
28
+ timestamp: record.timestamp,
29
+ };
30
+ }
31
+ catch (_a) {
32
+ return undefined;
33
+ }
34
+ }
35
+ function serializeEntry(entry) {
36
+ return `${JSON.stringify(entry)}\n`;
37
+ }
38
+ function positiveInteger(value, fallback) {
39
+ return value !== undefined && Number.isInteger(value) && value > 0 ? value : fallback;
40
+ }
41
+ export function searchPromptHistoryEntries(entries, query, options) {
42
+ var _a;
43
+ const uniqueEntries = [];
44
+ const seen = new Set();
45
+ for (const entry of entries) {
46
+ if ((!options.includeBash && entry.kind === 'bash') || seen.has(entry.text)) {
47
+ continue;
48
+ }
49
+ seen.add(entry.text);
50
+ uniqueEntries.push(entry);
51
+ }
52
+ return fuzzyFilter(uniqueEntries, query, entry => entry.text).slice(0, (_a = options.limit) !== null && _a !== void 0 ? _a : DEFAULT_SEARCH_LIMIT);
53
+ }
54
+ export class FilePromptHistory {
55
+ constructor(filePath, options = {}) {
56
+ this.filePath = filePath;
57
+ this.entries = [];
58
+ this.recordCount = 0;
59
+ this.fileBytes = 0;
60
+ this.maxEntries = positiveInteger(options.maxEntries, DEFAULT_MAX_ENTRIES);
61
+ this.trimRecordCount = Math.max(this.maxEntries, positiveInteger(options.trimRecordCount, DEFAULT_TRIM_RECORD_COUNT));
62
+ this.maxFileBytes = positiveInteger(options.maxFileBytes, DEFAULT_MAX_FILE_BYTES);
63
+ this.load();
64
+ }
65
+ getEntries() {
66
+ return this.entries;
67
+ }
68
+ record(text, kind, timestamp = Date.now()) {
69
+ const normalized = text.trim();
70
+ if (!normalized) {
71
+ return;
72
+ }
73
+ const entry = { text: normalized, kind, timestamp };
74
+ const serialized = serializeEntry(entry);
75
+ this.entries.unshift(entry);
76
+ if (this.entries.length > this.maxEntries) {
77
+ this.entries.pop();
78
+ }
79
+ try {
80
+ mkdirSync(path.dirname(this.filePath), { recursive: true });
81
+ appendFileSync(this.filePath, serialized, { encoding: 'utf8', mode: 0o600 });
82
+ this.recordCount++;
83
+ this.fileBytes += Buffer.byteLength(serialized);
84
+ if (this.recordCount >= this.trimRecordCount ||
85
+ this.fileBytes >= this.maxFileBytes) {
86
+ this.rotate();
87
+ }
88
+ }
89
+ catch (_a) {
90
+ // Prompt history is a best-effort convenience cache.
91
+ }
92
+ }
93
+ load() {
94
+ let content;
95
+ try {
96
+ content = readFileSync(this.filePath, 'utf8');
97
+ chmodSync(this.filePath, 0o600);
98
+ this.fileBytes = statSync(this.filePath).size;
99
+ }
100
+ catch (_a) {
101
+ return;
102
+ }
103
+ const lines = content.split('\n').filter(line => line.trim().length > 0);
104
+ this.recordCount = lines.length;
105
+ this.entries = lines
106
+ .map(parseEntry)
107
+ .filter((entry) => entry !== undefined)
108
+ .slice(-this.maxEntries)
109
+ .reverse();
110
+ if (this.recordCount >= this.trimRecordCount ||
111
+ this.fileBytes >= this.maxFileBytes) {
112
+ this.rotate();
113
+ }
114
+ }
115
+ rotate() {
116
+ const retainedNewest = [];
117
+ let retainedBytes = 0;
118
+ for (const entry of this.entries) {
119
+ if (retainedNewest.length >= this.maxEntries) {
120
+ break;
121
+ }
122
+ const bytes = Buffer.byteLength(serializeEntry(entry));
123
+ if (retainedBytes + bytes > this.maxFileBytes) {
124
+ break;
125
+ }
126
+ retainedNewest.push(entry);
127
+ retainedBytes += bytes;
128
+ }
129
+ const content = retainedNewest
130
+ .slice()
131
+ .reverse()
132
+ .map(serializeEntry)
133
+ .join('');
134
+ const temporaryPath = `${this.filePath}.${process.pid}.${Date.now()}.tmp`;
135
+ try {
136
+ mkdirSync(path.dirname(this.filePath), { recursive: true });
137
+ writeFileSync(temporaryPath, content, { encoding: 'utf8', mode: 0o600 });
138
+ renameSync(temporaryPath, this.filePath);
139
+ this.entries = retainedNewest;
140
+ this.recordCount = retainedNewest.length;
141
+ this.fileBytes = Buffer.byteLength(content);
142
+ }
143
+ catch (_a) {
144
+ try {
145
+ unlinkSync(temporaryPath);
146
+ }
147
+ catch (_b) {
148
+ // Ignore cleanup failures for the best-effort cache.
149
+ }
150
+ }
151
+ }
152
+ }
153
+ export function getPromptHistoryPath(agentDir) {
154
+ return path.join(agentDir, 'bkper-input-history.jsonl');
155
+ }
156
+ //# sourceMappingURL=prompt-history-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history-store.js","sourceRoot":"","sources":["../../../src/agent/interactive/prompt-history-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AA6BnD,MAAM,mBAAmB,GAAG,KAAM,CAAC;AACnC,MAAM,yBAAyB,GAAG,KAAM,CAAC;AACzC,MAAM,sBA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-7,7 +7,7 @@ export type BkperKeybindingsManager = {
7
7
  };
8
8
  declare const BKPER_SESSION_KEYBINDINGS: {
9
9
  readonly 'app.session.resume': "ctrl+s";
10
- readonly 'app.session.tree': "ctrl+r";
10
+ readonly 'app.session.tree': "ctrl+alt+r";
11
11
  readonly 'app.session.fork': "ctrl+x";
12
12
  };
13
13
  export declare function applyBkperSessionKeybindings(keybindings: Pick<BkperKeybindingsManager, 'getUserBindings' | 'setUserBindings'>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"session-keybindings.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/session-keybindings.ts"],"names":[],"mappings":"AAEA,KAAK,sBAAsB,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAC5D,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE3E,MAAM,MAAM,uBAAuB,GAAG;IAClC,eAAe,IAAI,qBAAqB,CAAC;IACzC,eAAe,CAAC,YAAY,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC3D,MAAM,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,yBAAyB;;;;CAIrB,CAAC;AA8BX,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,GAClF,IAAI,CAoBN;AAED,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI,CAWzF;AAED,wBAAgB,iCAAiC,CAC7C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,OAAO,yBAAyB,GACnD,MAAM,CAGR"}
1
+ {"version":3,"file":"session-keybindings.d.ts","sourceRoot":"","sources":["../../../src/agent/interactive/session-keybindings.ts"],"names":[],"mappings":"AAEA,KAAK,sBAAsB,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAC5D,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE3E,MAAM,MAAM,uBAAuB,GAAG;IAClC,eAAe,IAAI,qBAAqB,CAAC;IACzC,eAAe,CAAC,YAAY,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC3D,MAAM,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,yBAAyB;;;;CAIrB,CAAC;AAgCX,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,GAClF,IAAI,CA+BN;AAED,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI,CAWzF;AAED,wBAAgB,iCAAiC,CAC7C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,OAAO,yBAAyB,GACnD,MAAM,CAGR"}
@@ -1,9 +1,10 @@
1
1
  import { keyText } from '@earendil-works/pi-coding-agent';
2
2
  const BKPER_SESSION_KEYBINDINGS = {
3
3
  'app.session.resume': 'ctrl+s',
4
- 'app.session.tree': 'ctrl+r',
4
+ 'app.session.tree': 'ctrl+alt+r',
5
5
  'app.session.fork': 'ctrl+x',
6
6
  };
7
+ const LEGACY_BKPER_TREE_SHORTCUT = 'ctrl+r';
7
8
  const installedBkperKeybindingsManagers = new WeakSet();
8
9
  function keybindingConfigIncludesShortcut(configuredBinding, shortcut) {
9
10
  const normalizedShortcut = shortcut.toLowerCase();
@@ -21,6 +22,14 @@ export function applyBkperSessionKeybindings(keybindings) {
21
22
  const nextBindings = Object.assign({}, userBindings);
22
23
  let changed = false;
23
24
  for (const [keybinding, shortcut] of Object.entries(BKPER_SESSION_KEYBINDINGS)) {
25
+ if (keybinding === 'app.session.tree' &&
26
+ typeof nextBindings[keybinding] === 'string' &&
27
+ nextBindings[keybinding].toLowerCase() === LEGACY_BKPER_TREE_SHORTCUT &&
28
+ !isShortcutClaimedByUserBinding(userBindings, keybinding, shortcut)) {
29
+ nextBindings[keybinding] = shortcut;
30
+ changed = true;
31
+ continue;
32
+ }
24
33
  if (nextBindings[keybinding] !== undefined ||
25
34
  isShortcutClaimedByUserBinding(userBindings, keybinding, shortcut)) {
26
35
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"session-keybindings.js","sourceRoot":"","sources":["../../../src/agent/interactive/session-keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,iCAAiC,CAAC;AAWxD,MAAM,yBAAyB,GAAG;IAC9B,oBAAoB,EAAE,QAAQ;IAC9B,kBAAkB,EAAE,QAAQ;IAC5B,kBAAkB,EAAE,QAAQ;CACtB,CAAC;AAEX,MAAM,iCAAiC,GAAG,IAAI,OAAO,EAA2B,CAAC;AAEjF,SAAS,gCAAgC,CACrC,iBAAyC,EACzC,QAAgB;IAEhB,MAAM,kBAAkB,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAClD,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACxD,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAE1B,OAAO,mBAAmB,CAAC,IAAI,CAC3B,kBAAkB,CAAC,EAAE,CAAC,CAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,WAAW,EAAE,MAAK,kBAAkB,CACjF,CAAC;AACN,CAAC;AAED,SAAS,8BAA8B,CACnC,YAAmC,EACnC,gBAAwB,EACxB,QAAgB;IAEhB,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CACpC,CAAC,CAAC,UAAU,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAChC,UAAU,KAAK,gBAAgB;QAC/B,gCAAgC,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CACpE,CAAC;AACN,CAAC;AAED,MAAM,UAAU,4BAA4B,CACxC,WAAiF;IAEjF,MAAM,YAAY,GAAG,WAAW,CAAC,eA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AAC,CAAC,CAAC,GAAG,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3D,CAAC"}
@@ -49,6 +49,7 @@ To make your app available to all Bkper users, contact us at [support@bkper.com]
49
49
  ### What the review involves
50
50
 
51
51
  - **Functionality check** — The app works correctly and handles errors gracefully
52
+ - **Quality review** — The implementation follows the [App Quality Guidelines](https://bkper.com/docs/build/apps/quality.md)
52
53
  - **Security review** — Event handlers are idempotent and include loop prevention
53
54
  - **Listing quality** — The app has a clear name, description, logo, and user-facing documentation
54
55
 
@@ -4,6 +4,8 @@ Bkper platform apps use one Worker bundle per app and environment. The same Work
4
4
 
5
5
  Treat `/api/*` as the reusable surface for app behavior. The bundled web client is one consumer; scripts, external clients, and agents can call the same routes with bearer authentication.
6
6
 
7
+ Follow the [App Quality Guidelines](https://bkper.com/docs/build/apps/quality.md) when implementing, changing, or reviewing an app.
8
+
7
9
  ## Structure
8
10
 
9
11
  ```txt
@@ -2,6 +2,8 @@
2
2
 
3
3
  Apps can add context menu items on the Transactions page **More** menu in your Books. This lets you open dynamically built URLs with reference to the current Book's context — the active query, selected account, date range, and more.
4
4
 
5
+ Embedded interfaces should follow the [App Quality Guidelines](https://bkper.com/docs/build/apps/quality.md) for visual consistency, startup behavior, and Book-context verification.
6
+
5
7
  ## How it works
6
8
 
7
9
  Once you install an App with a menu configuration, a new menu item appears in your Book:
@@ -0,0 +1,86 @@
1
+ # App Quality Guidelines
2
+
3
+ Use these guidelines when building, changing, or reviewing a Bkper app. They complement the detailed architecture, security, and feature documentation.
4
+
5
+ After implementation, review the changed code against these guidelines before considering the work complete. Automated checks support this review but do not replace it.
6
+
7
+ ## Bkper behavior
8
+
9
+ Always:
10
+
11
+ - Model financial activity as balanced resource movements between Accounts.
12
+ - Keep calculations deterministic and cover financial behavior with focused unit tests.
13
+ - Use canonical Bkper SDK and API types instead of recreating Bkper data structures.
14
+ - Add meaning with properties before introducing new structural complexity.
15
+
16
+ ## User interface
17
+
18
+ Always:
19
+
20
+ - Use Web Awesome as the primary component library.
21
+ - Style with Bkper design tokens instead of ad-hoc design constants.
22
+ - Support the active Bkper light or dark theme.
23
+ - Keep interactions accessible and provide clear loading, empty, and error states.
24
+
25
+ Apps opened from a Book context menu should feel like part of the Book. Keep their layout focused, make them work in the configured sidebar or expanded width, and preserve context when the Book URL changes.
26
+
27
+ ## Startup
28
+
29
+ Always render the app shell or a meaningful loading state before waiting for authentication, API calls, or other initialization. Start asynchronous work after the first render and update the interface as results arrive.
30
+
31
+ Prefer loading only the client code and Web Awesome components needed for the initial experience.
32
+
33
+ ## API contracts
34
+
35
+ When an app exposes its own HTTP API:
36
+
37
+ - Define and publish its OpenAPI contract at `/openapi.json`.
38
+ - Generate client types from that contract.
39
+ - Call the API through the generated typed boundary rather than duplicating request or response types.
40
+ - Validate untrusted request data at the server boundary.
41
+ - Keep published routes backward compatible or introduce a new API version for breaking changes.
42
+
43
+ UI-only and event-only apps without an app-owned HTTP API do not need to add one. Direct calls to Bkper should use the canonical Bkper SDK and API types.
44
+
45
+ ## Focused modules
46
+
47
+ Prefer modules with one clear responsibility, high cohesion, and few dependencies.
48
+
49
+ - Components render state and communicate user intent. They should delegate API and Bkper operations to client API or service modules.
50
+ - HTTP routes and event handlers adapt transport concerns and delegate app behavior.
51
+ - Business modules contain domain decisions without depending on UI, HTTP, storage, or external-service details.
52
+ - Connectors isolate external APIs and storage concerns from business behavior.
53
+ - Add a repository or another layer when connection or storage complexity justifies it, not by default.
54
+ - Avoid layers that only forward calls without creating a useful boundary.
55
+
56
+ Split a module when unrelated behavior changes for different reasons or when mixed responsibilities make it difficult to understand or test.
57
+
58
+ ## Security
59
+
60
+ Keep the security boundary simple and explicit:
61
+
62
+ - Authorize sensitive app operations on the server.
63
+ - Validate untrusted requests, events, and browser messages at their boundaries.
64
+ - Keep application secrets and privileged credentials out of client bundles.
65
+ - Access only the Book data needed for the operation.
66
+ - Make event handling safe to retry and prevent event loops.
67
+
68
+ See [App Security](https://bkper.com/docs/build/apps/security.md) and [Event Handlers](https://bkper.com/docs/build/apps/event-handlers.md) for implementation details.
69
+
70
+ ## Verification
71
+
72
+ After implementation:
73
+
74
+ 1. Review the changed code against these guidelines.
75
+ 2. Run the app's deterministic checks, including unit tests, typechecking, and production builds.
76
+ 3. Confirm generated API types and contract snapshots are current when the API changed.
77
+ 4. Verify user interfaces in their intended Book context, including first rendering, loading, errors, theme, and configured width.
78
+
79
+ App reviews should report concrete findings with file locations and suggested fixes. If no issues are found, a short confirmation is enough.
80
+
81
+ ## Next Steps
82
+
83
+ - [App Architecture](https://bkper.com/docs/build/apps/architecture.md) — Client, server, API, and event structure.
84
+ - [App Security](https://bkper.com/docs/build/apps/security.md) — Authentication and authorization boundaries.
85
+ - [Context Menu](https://bkper.com/docs/build/apps/context-menu.md) — Embedded Book context and open modes.
86
+ - [Development Experience](https://bkper.com/docs/build/apps/development.md) — Local development and deterministic checks.
@@ -68,6 +68,7 @@ if (!isInstalled) {
68
68
 
69
69
  ## Next Steps
70
70
 
71
+ - [App Quality Guidelines](https://bkper.com/docs/build/apps/quality.md) — Review cross-cutting app quality and security expectations.
71
72
  - [App Architecture](https://bkper.com/docs/build/apps/architecture.md) — Understand client and server authentication flows.
72
73
  - [Building & Deploying](https://bkper.com/docs/build/apps/deploying.md#setting-secrets) — Store production and preview secrets.
73
74
  - [Event Handlers](https://bkper.com/docs/build/apps/event-handlers.md#authentication) — Understand authentication for platform and self-hosted events.
@@ -46,6 +46,8 @@ Sync preserves the existing App identity, activates managed source, configures i
46
46
 
47
47
  When scaffolding, developing, or deploying an app, verify each step before proceeding. This prevents broken deployments and silent failures.
48
48
 
49
+ For app implementation, refactoring, or code review, first read the [App Quality Guidelines](https://bkper.com/docs/build/apps/quality.md). After implementation, review the changed code against the guidelines and run the project's deterministic checks. A successful build does not replace this quality review.
50
+
49
51
  ### 1. Init
50
52
 
51
53
  ```bash
package/lib/docs/index.md CHANGED
@@ -4,6 +4,8 @@ Reference docs for Bkper tasks. Load only the specific doc(s) relevant to the ta
4
4
 
5
5
  For Bkper data, accounting, reporting, tax, or financial-flow tasks, read `core/core-concepts.md` first.
6
6
 
7
+ For Bkper app implementation, refactoring, or code review, always read `apps/quality.md` alongside the task-specific references. After implementation, review the changed code against the guidelines before considering the work complete.
8
+
7
9
  - `core/core-concepts.md` — canonical Bkper data model: resources, movements, balances, accounts, groups, books, transactions, properties, and the zero-sum invariant.
8
10
  - `cli/data-management.md` — CLI reference for managing financial data and files: books, accounts, groups, files, transactions, per-account balance queries, query operators (on:, after:, before:, account:, group:), output formats (table/json/csv), human-review Bkper UI links, batch operations via stdin/piping, collections.
9
11
  - `cli/app-management.md` — CLI reference for building and deploying Bkper apps: init/git clone/credential helpers, dev/build/deploy workflow, app install/uninstall, secrets management, app logs, bkper.yaml configuration reference (identity, branding, events, menu integration, deployment).
@@ -11,6 +13,7 @@ For Bkper data, accounting, reporting, tax, or financial-flow tasks, read `core/
11
13
  - `apps/ai.md` — Bkper AI integration for Platform apps: authenticated `/api/*` request flow, outbound authorization and app attribution, live model discovery, strict structured output, response validation, error preservation, data minimization, and unit-test boundaries.
12
14
  - `apps/first-app.md` — First-app walkthrough: scaffold, install, run locally, trigger an event, customize the listing, establish shared source, check, and deploy.
13
15
  - `apps/architecture.md` — App and template architecture: npm workspace structure, Lit/Vite client, Hono Worker, typed `/api/*` contracts, authentication, `/events`, static assets, and supported app shapes.
16
+ - `apps/quality.md` — Cross-cutting quality guidance for Bkper apps: UI consistency, immediate first rendering, typed API contracts, cohesive low-coupling modules, separation of business behavior from connectors and storage, security, and final implementation review. Load for app implementation, refactoring, or review tasks.
14
17
  - `apps/security.md` — App security responsibilities and server-side authorization: platform authentication boundaries, user-domain restrictions, Book permission allowlists, and app installation checks.
15
18
  - `apps/configuration.md` — Complete `bkper.yaml` reference: identity, branding, ownership, access, context menus, event subscriptions, property schemas, and single-Worker deployment settings.
16
19
  - `apps/development.md` — Local development: Vite and Worker processes, ports, API proxy, local authentication, secrets, KV, generated environment types, development loop, and debugging.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "4.28.1",
3
+ "version": "4.29.0",
4
4
  "description": "Official Bkper CLI for accounting data, automation, apps, and AI agents",
5
5
  "bin": {
6
6
  "bkper": "./lib/cli.js"