@apholdings/jensen-code 0.0.3 → 0.0.5

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 (166) hide show
  1. package/dist/cli/args.d.ts.map +1 -1
  2. package/dist/cli/args.js +6 -6
  3. package/dist/cli/args.js.map +1 -1
  4. package/dist/config.d.ts +6 -5
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +32 -25
  7. package/dist/config.js.map +1 -1
  8. package/dist/core/agent-session.d.ts +1 -0
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +25 -0
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/extensions/loader.d.ts.map +1 -1
  13. package/dist/core/extensions/loader.js +1 -1
  14. package/dist/core/extensions/loader.js.map +1 -1
  15. package/dist/core/footer-data-provider.d.ts +4 -1
  16. package/dist/core/footer-data-provider.d.ts.map +1 -1
  17. package/dist/core/footer-data-provider.js +25 -11
  18. package/dist/core/footer-data-provider.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
  24. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  25. package/dist/modes/interactive/components/custom-editor.js +5 -0
  26. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  27. package/dist/modes/interactive/components/footer.d.ts +0 -2
  28. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  29. package/dist/modes/interactive/components/footer.js +8 -146
  30. package/dist/modes/interactive/components/footer.js.map +1 -1
  31. package/dist/modes/interactive/components/header.d.ts +9 -3
  32. package/dist/modes/interactive/components/header.d.ts.map +1 -1
  33. package/dist/modes/interactive/components/header.js +125 -196
  34. package/dist/modes/interactive/components/header.js.map +1 -1
  35. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  36. package/dist/modes/interactive/components/tool-execution.js +1 -2
  37. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  38. package/dist/modes/interactive/interactive-mode.d.ts +23 -4
  39. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  40. package/dist/modes/interactive/interactive-mode.js +657 -243
  41. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  42. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  43. package/dist/modes/interactive/theme/theme.js +2 -0
  44. package/dist/modes/interactive/theme/theme.js.map +1 -1
  45. package/dist/utils/frontmatter.d.ts.map +1 -1
  46. package/dist/utils/frontmatter.js +8 -4
  47. package/dist/utils/frontmatter.js.map +1 -1
  48. package/dist/utils/tools-manager.d.ts.map +1 -1
  49. package/dist/utils/tools-manager.js +2 -2
  50. package/dist/utils/tools-manager.js.map +1 -1
  51. package/examples/extensions/osgrep.ts +643 -0
  52. package/examples/extensions/subagent/agents.ts +150 -38
  53. package/examples/extensions/subagent/index.ts +634 -514
  54. package/package.json +4 -3
  55. package/examples/README.md +0 -25
  56. package/examples/extensions/README.md +0 -206
  57. package/examples/extensions/antigravity-image-gen.ts +0 -416
  58. package/examples/extensions/auto-commit-on-exit.ts +0 -50
  59. package/examples/extensions/bash-spawn-hook.ts +0 -31
  60. package/examples/extensions/bookmark.ts +0 -51
  61. package/examples/extensions/built-in-tool-renderer.ts +0 -247
  62. package/examples/extensions/claude-rules.ts +0 -87
  63. package/examples/extensions/commands.ts +0 -73
  64. package/examples/extensions/confirm-destructive.ts +0 -60
  65. package/examples/extensions/custom-compaction.ts +0 -115
  66. package/examples/extensions/custom-footer.ts +0 -65
  67. package/examples/extensions/custom-header.ts +0 -74
  68. package/examples/extensions/custom-provider-anthropic/index.ts +0 -605
  69. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  70. package/examples/extensions/custom-provider-anthropic/package.json +0 -19
  71. package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -350
  72. package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
  73. package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
  74. package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -346
  75. package/examples/extensions/custom-provider-qwen-cli/package.json +0 -16
  76. package/examples/extensions/dirty-repo-guard.ts +0 -57
  77. package/examples/extensions/doom-overlay/README.md +0 -46
  78. package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
  79. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  80. package/examples/extensions/doom-overlay/doom/build.sh +0 -152
  81. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
  82. package/examples/extensions/doom-overlay/doom-component.ts +0 -132
  83. package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
  84. package/examples/extensions/doom-overlay/doom-keys.ts +0 -104
  85. package/examples/extensions/doom-overlay/index.ts +0 -75
  86. package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
  87. package/examples/extensions/dynamic-resources/SKILL.md +0 -8
  88. package/examples/extensions/dynamic-resources/dynamic.json +0 -79
  89. package/examples/extensions/dynamic-resources/dynamic.md +0 -5
  90. package/examples/extensions/dynamic-resources/index.ts +0 -16
  91. package/examples/extensions/dynamic-tools.ts +0 -75
  92. package/examples/extensions/event-bus.ts +0 -44
  93. package/examples/extensions/file-trigger.ts +0 -42
  94. package/examples/extensions/git-checkpoint.ts +0 -54
  95. package/examples/extensions/handoff.ts +0 -151
  96. package/examples/extensions/hello.ts +0 -26
  97. package/examples/extensions/inline-bash.ts +0 -95
  98. package/examples/extensions/input-transform.ts +0 -44
  99. package/examples/extensions/interactive-shell.ts +0 -197
  100. package/examples/extensions/mac-system-theme.ts +0 -48
  101. package/examples/extensions/message-renderer.ts +0 -60
  102. package/examples/extensions/minimal-mode.ts +0 -427
  103. package/examples/extensions/modal-editor.ts +0 -86
  104. package/examples/extensions/model-status.ts +0 -32
  105. package/examples/extensions/notify.ts +0 -56
  106. package/examples/extensions/overlay-qa-tests.ts +0 -1349
  107. package/examples/extensions/overlay-test.ts +0 -151
  108. package/examples/extensions/permission-gate.ts +0 -35
  109. package/examples/extensions/pirate.ts +0 -48
  110. package/examples/extensions/plan-mode/README.md +0 -65
  111. package/examples/extensions/plan-mode/index.ts +0 -341
  112. package/examples/extensions/plan-mode/utils.ts +0 -168
  113. package/examples/extensions/preset.ts +0 -399
  114. package/examples/extensions/protected-paths.ts +0 -31
  115. package/examples/extensions/provider-payload.ts +0 -15
  116. package/examples/extensions/qna.ts +0 -120
  117. package/examples/extensions/question.ts +0 -265
  118. package/examples/extensions/questionnaire.ts +0 -428
  119. package/examples/extensions/rainbow-editor.ts +0 -89
  120. package/examples/extensions/reload-runtime.ts +0 -38
  121. package/examples/extensions/rpc-demo.ts +0 -125
  122. package/examples/extensions/sandbox/index.ts +0 -319
  123. package/examples/extensions/sandbox/package-lock.json +0 -92
  124. package/examples/extensions/sandbox/package.json +0 -19
  125. package/examples/extensions/send-user-message.ts +0 -98
  126. package/examples/extensions/session-name.ts +0 -28
  127. package/examples/extensions/shutdown-command.ts +0 -64
  128. package/examples/extensions/snake.ts +0 -344
  129. package/examples/extensions/space-invaders.ts +0 -561
  130. package/examples/extensions/ssh.ts +0 -221
  131. package/examples/extensions/status-line.ts +0 -41
  132. package/examples/extensions/subagent/README.md +0 -172
  133. package/examples/extensions/subagent/agents/planner.md +0 -37
  134. package/examples/extensions/subagent/agents/reviewer.md +0 -35
  135. package/examples/extensions/subagent/agents/scout.md +0 -50
  136. package/examples/extensions/subagent/agents/worker.md +0 -24
  137. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  138. package/examples/extensions/subagent/prompts/implement.md +0 -10
  139. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
  140. package/examples/extensions/summarize.ts +0 -196
  141. package/examples/extensions/system-prompt-header.ts +0 -18
  142. package/examples/extensions/timed-confirm.ts +0 -71
  143. package/examples/extensions/titlebar-spinner.ts +0 -59
  144. package/examples/extensions/todo.ts +0 -300
  145. package/examples/extensions/tool-override.ts +0 -144
  146. package/examples/extensions/tools.ts +0 -147
  147. package/examples/extensions/trigger-compact.ts +0 -41
  148. package/examples/extensions/truncated-tool.ts +0 -193
  149. package/examples/extensions/widget-placement.ts +0 -18
  150. package/examples/extensions/with-deps/index.ts +0 -33
  151. package/examples/extensions/with-deps/package-lock.json +0 -31
  152. package/examples/extensions/with-deps/package.json +0 -22
  153. package/examples/rpc-extension-ui.ts +0 -632
  154. package/examples/sdk/01-minimal.ts +0 -23
  155. package/examples/sdk/02-custom-model.ts +0 -50
  156. package/examples/sdk/03-custom-prompt.ts +0 -56
  157. package/examples/sdk/04-skills.ts +0 -47
  158. package/examples/sdk/05-tools.ts +0 -57
  159. package/examples/sdk/06-extensions.ts +0 -89
  160. package/examples/sdk/07-context-files.ts +0 -41
  161. package/examples/sdk/08-prompt-templates.ts +0 -48
  162. package/examples/sdk/09-api-keys-and-oauth.ts +0 -49
  163. package/examples/sdk/10-settings.ts +0 -52
  164. package/examples/sdk/11-sessions.ts +0 -49
  165. package/examples/sdk/12-full-control.ts +0 -83
  166. package/examples/sdk/README.md +0 -145
@@ -1,120 +0,0 @@
1
- /**
2
- * Q&A extraction extension - extracts questions from assistant responses
3
- *
4
- * Demonstrates the "prompt generator" pattern:
5
- * 1. /qna command gets the last assistant message
6
- * 2. Shows a spinner while extracting (hides editor)
7
- * 3. Loads the result into the editor for user to fill in answers
8
- */
9
-
10
- import { complete, type UserMessage } from "@apholdings/jensen-ai";
11
- import type { ExtensionAPI } from "@apholdings/jensen-code";
12
- import { BorderedLoader } from "@apholdings/jensen-code";
13
-
14
- const SYSTEM_PROMPT = `You are a question extractor. Given text from a conversation, extract any questions that need answering and format them for the user to fill in.
15
-
16
- Output format:
17
- - List each question on its own line, prefixed with "Q: "
18
- - After each question, add a blank line for the answer prefixed with "A: "
19
- - If no questions are found, output "No questions found in the last message."
20
-
21
- Example output:
22
- Q: What is your preferred database?
23
- A:
24
-
25
- Q: Should we use TypeScript or JavaScript?
26
- A:
27
-
28
- Keep questions in the order they appeared. Be concise.`;
29
-
30
- export default function (pi: ExtensionAPI) {
31
- pi.registerCommand("qna", {
32
- description: "Extract questions from last assistant message into editor",
33
- handler: async (_args, ctx) => {
34
- if (!ctx.hasUI) {
35
- ctx.ui.notify("qna requires interactive mode", "error");
36
- return;
37
- }
38
-
39
- if (!ctx.model) {
40
- ctx.ui.notify("No model selected", "error");
41
- return;
42
- }
43
-
44
- // Find the last assistant message on the current branch
45
- const branch = ctx.sessionManager.getBranch();
46
- let lastAssistantText: string | undefined;
47
-
48
- for (let i = branch.length - 1; i >= 0; i--) {
49
- const entry = branch[i];
50
- if (entry.type === "message") {
51
- const msg = entry.message;
52
- if ("role" in msg && msg.role === "assistant") {
53
- if (msg.stopReason !== "stop") {
54
- ctx.ui.notify(`Last assistant message incomplete (${msg.stopReason})`, "error");
55
- return;
56
- }
57
- const textParts = msg.content
58
- .filter((c): c is { type: "text"; text: string } => c.type === "text")
59
- .map((c) => c.text);
60
- if (textParts.length > 0) {
61
- lastAssistantText = textParts.join("\n");
62
- break;
63
- }
64
- }
65
- }
66
- }
67
-
68
- if (!lastAssistantText) {
69
- ctx.ui.notify("No assistant messages found", "error");
70
- return;
71
- }
72
-
73
- // Run extraction with loader UI
74
- const result = await ctx.ui.custom<string | null>((tui, theme, _kb, done) => {
75
- const loader = new BorderedLoader(tui, theme, `Extracting questions using ${ctx.model!.id}...`);
76
- loader.onAbort = () => done(null);
77
-
78
- // Do the work
79
- const doExtract = async () => {
80
- const apiKey = await ctx.modelRegistry.getApiKey(ctx.model!);
81
- const userMessage: UserMessage = {
82
- role: "user",
83
- content: [{ type: "text", text: lastAssistantText! }],
84
- timestamp: Date.now(),
85
- };
86
-
87
- const response = await complete(
88
- ctx.model!,
89
- { systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
90
- { apiKey, signal: loader.signal },
91
- );
92
-
93
- if (response.stopReason === "aborted") {
94
- return null;
95
- }
96
-
97
- return response.content
98
- .filter((c): c is { type: "text"; text: string } => c.type === "text")
99
- .map((c) => c.text)
100
- .join("\n");
101
- };
102
-
103
- doExtract()
104
- .then(done)
105
- .catch(() => done(null));
106
-
107
- return loader;
108
- });
109
-
110
- if (result === null) {
111
- ctx.ui.notify("Cancelled", "info");
112
- return;
113
- }
114
-
115
- ctx.ui.setEditorText(result);
116
- ctx.ui.notify("Questions loaded. Edit and submit when ready.", "info");
117
- },
118
- });
119
- }
120
-
@@ -1,265 +0,0 @@
1
- /**
2
- * Question Tool - Single question with options
3
- * Full custom UI: options list + inline editor for "Type something..."
4
- * Escape in editor returns to options, Escape in options cancels
5
- */
6
-
7
- import type { ExtensionAPI } from "@apholdings/jensen-code";
8
- import { Editor, type EditorTheme, Key, matchesKey, Text, truncateToWidth } from "@apholdings/jensen-tui";
9
- import { Type } from "@sinclair/typebox";
10
-
11
- interface OptionWithDesc {
12
- label: string;
13
- description?: string;
14
- }
15
-
16
- type DisplayOption = OptionWithDesc & { isOther?: boolean };
17
-
18
- interface QuestionDetails {
19
- question: string;
20
- options: string[];
21
- answer: string | null;
22
- wasCustom?: boolean;
23
- }
24
-
25
- // Options with labels and optional descriptions
26
- const OptionSchema = Type.Object({
27
- label: Type.String({ description: "Display label for the option" }),
28
- description: Type.Optional(Type.String({ description: "Optional description shown below label" })),
29
- });
30
-
31
- const QuestionParams = Type.Object({
32
- question: Type.String({ description: "The question to ask the user" }),
33
- options: Type.Array(OptionSchema, { description: "Options for the user to choose from" }),
34
- });
35
-
36
- export default function question(pi: ExtensionAPI) {
37
- pi.registerTool({
38
- name: "question",
39
- label: "Question",
40
- description: "Ask the user a question and let them pick from options. Use when you need user input to proceed.",
41
- parameters: QuestionParams,
42
-
43
- async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
44
- if (!ctx.hasUI) {
45
- return {
46
- content: [{ type: "text", text: "Error: UI not available (running in non-interactive mode)" }],
47
- details: {
48
- question: params.question,
49
- options: params.options.map((o) => o.label),
50
- answer: null,
51
- } as QuestionDetails,
52
- };
53
- }
54
-
55
- if (params.options.length === 0) {
56
- return {
57
- content: [{ type: "text", text: "Error: No options provided" }],
58
- details: { question: params.question, options: [], answer: null } as QuestionDetails,
59
- };
60
- }
61
-
62
- const allOptions: DisplayOption[] = [...params.options, { label: "Type something.", isOther: true }];
63
-
64
- const result = await ctx.ui.custom<{ answer: string; wasCustom: boolean; index?: number } | null>(
65
- (tui, theme, _kb, done) => {
66
- let optionIndex = 0;
67
- let editMode = false;
68
- let cachedLines: string[] | undefined;
69
-
70
- const editorTheme: EditorTheme = {
71
- borderColor: (s) => theme.fg("accent", s),
72
- selectList: {
73
- selectedPrefix: (t) => theme.fg("accent", t),
74
- selectedText: (t) => theme.fg("accent", t),
75
- description: (t) => theme.fg("muted", t),
76
- scrollInfo: (t) => theme.fg("dim", t),
77
- noMatch: (t) => theme.fg("warning", t),
78
- },
79
- };
80
- const editor = new Editor(tui, editorTheme);
81
-
82
- editor.onSubmit = (value) => {
83
- const trimmed = value.trim();
84
- if (trimmed) {
85
- done({ answer: trimmed, wasCustom: true });
86
- } else {
87
- editMode = false;
88
- editor.setText("");
89
- refresh();
90
- }
91
- };
92
-
93
- function refresh() {
94
- cachedLines = undefined;
95
- tui.requestRender();
96
- }
97
-
98
- function handleInput(data: string) {
99
- if (editMode) {
100
- if (matchesKey(data, Key.escape)) {
101
- editMode = false;
102
- editor.setText("");
103
- refresh();
104
- return;
105
- }
106
- editor.handleInput(data);
107
- refresh();
108
- return;
109
- }
110
-
111
- if (matchesKey(data, Key.up)) {
112
- optionIndex = Math.max(0, optionIndex - 1);
113
- refresh();
114
- return;
115
- }
116
- if (matchesKey(data, Key.down)) {
117
- optionIndex = Math.min(allOptions.length - 1, optionIndex + 1);
118
- refresh();
119
- return;
120
- }
121
-
122
- if (matchesKey(data, Key.enter)) {
123
- const selected = allOptions[optionIndex];
124
- if (selected.isOther) {
125
- editMode = true;
126
- refresh();
127
- } else {
128
- done({ answer: selected.label, wasCustom: false, index: optionIndex + 1 });
129
- }
130
- return;
131
- }
132
-
133
- if (matchesKey(data, Key.escape)) {
134
- done(null);
135
- }
136
- }
137
-
138
- function render(width: number): string[] {
139
- if (cachedLines) return cachedLines;
140
-
141
- const lines: string[] = [];
142
- const add = (s: string) => lines.push(truncateToWidth(s, width));
143
-
144
- add(theme.fg("accent", "─".repeat(width)));
145
- add(theme.fg("text", ` ${params.question}`));
146
- lines.push("");
147
-
148
- for (let i = 0; i < allOptions.length; i++) {
149
- const opt = allOptions[i];
150
- const selected = i === optionIndex;
151
- const isOther = opt.isOther === true;
152
- const prefix = selected ? theme.fg("accent", "> ") : " ";
153
-
154
- if (isOther && editMode) {
155
- add(prefix + theme.fg("accent", `${i + 1}. ${opt.label} ✎`));
156
- } else if (selected) {
157
- add(prefix + theme.fg("accent", `${i + 1}. ${opt.label}`));
158
- } else {
159
- add(` ${theme.fg("text", `${i + 1}. ${opt.label}`)}`);
160
- }
161
-
162
- // Show description if present
163
- if (opt.description) {
164
- add(` ${theme.fg("muted", opt.description)}`);
165
- }
166
- }
167
-
168
- if (editMode) {
169
- lines.push("");
170
- add(theme.fg("muted", " Your answer:"));
171
- for (const line of editor.render(width - 2)) {
172
- add(` ${line}`);
173
- }
174
- }
175
-
176
- lines.push("");
177
- if (editMode) {
178
- add(theme.fg("dim", " Enter to submit • Esc to go back"));
179
- } else {
180
- add(theme.fg("dim", " ↑↓ navigate • Enter to select • Esc to cancel"));
181
- }
182
- add(theme.fg("accent", "─".repeat(width)));
183
-
184
- cachedLines = lines;
185
- return lines;
186
- }
187
-
188
- return {
189
- render,
190
- invalidate: () => {
191
- cachedLines = undefined;
192
- },
193
- handleInput,
194
- };
195
- },
196
- );
197
-
198
- // Build simple options list for details
199
- const simpleOptions = params.options.map((o) => o.label);
200
-
201
- if (!result) {
202
- return {
203
- content: [{ type: "text", text: "User cancelled the selection" }],
204
- details: { question: params.question, options: simpleOptions, answer: null } as QuestionDetails,
205
- };
206
- }
207
-
208
- if (result.wasCustom) {
209
- return {
210
- content: [{ type: "text", text: `User wrote: ${result.answer}` }],
211
- details: {
212
- question: params.question,
213
- options: simpleOptions,
214
- answer: result.answer,
215
- wasCustom: true,
216
- } as QuestionDetails,
217
- };
218
- }
219
- return {
220
- content: [{ type: "text", text: `User selected: ${result.index}. ${result.answer}` }],
221
- details: {
222
- question: params.question,
223
- options: simpleOptions,
224
- answer: result.answer,
225
- wasCustom: false,
226
- } as QuestionDetails,
227
- };
228
- },
229
-
230
- renderCall(args, theme) {
231
- let text = theme.fg("toolTitle", theme.bold("question ")) + theme.fg("muted", args.question);
232
- const opts = Array.isArray(args.options) ? args.options : [];
233
- if (opts.length) {
234
- const labels = opts.map((o: OptionWithDesc) => o.label);
235
- const numbered = [...labels, "Type something."].map((o, i) => `${i + 1}. ${o}`);
236
- text += `\n${theme.fg("dim", ` Options: ${numbered.join(", ")}`)}`;
237
- }
238
- return new Text(text, 0, 0);
239
- },
240
-
241
- renderResult(result, _options, theme) {
242
- const details = result.details as QuestionDetails | undefined;
243
- if (!details) {
244
- const text = result.content[0];
245
- return new Text(text?.type === "text" ? text.text : "", 0, 0);
246
- }
247
-
248
- if (details.answer === null) {
249
- return new Text(theme.fg("warning", "Cancelled"), 0, 0);
250
- }
251
-
252
- if (details.wasCustom) {
253
- return new Text(
254
- theme.fg("success", "✓ ") + theme.fg("muted", "(wrote) ") + theme.fg("accent", details.answer),
255
- 0,
256
- 0,
257
- );
258
- }
259
- const idx = details.options.indexOf(details.answer) + 1;
260
- const display = idx > 0 ? `${idx}. ${details.answer}` : details.answer;
261
- return new Text(theme.fg("success", "✓ ") + theme.fg("accent", display), 0, 0);
262
- },
263
- });
264
- }
265
-