@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,115 +0,0 @@
1
- /**
2
- * Custom Compaction Extension
3
- *
4
- * Replaces the default compaction behavior with a full summary of the entire context.
5
- * Instead of keeping the last 20k tokens of conversation turns, this extension:
6
- * 1. Summarizes ALL messages (messagesToSummarize + turnPrefixMessages)
7
- * 2. Discards all old turns completely, keeping only the summary
8
- *
9
- * This example also demonstrates using a different model (Gemini Flash) for summarization,
10
- * which can be cheaper/faster than the main conversation model.
11
- *
12
- * Usage:
13
- * pi --extension examples/extensions/custom-compaction.ts
14
- */
15
-
16
- import { complete } from "@apholdings/jensen-ai";
17
- import type { ExtensionAPI } from "@apholdings/jensen-code";
18
- import { convertToLlm, serializeConversation } from "@apholdings/jensen-code";
19
-
20
- export default function (pi: ExtensionAPI) {
21
- pi.on("session_before_compact", async (event, ctx) => {
22
- ctx.ui.notify("Custom compaction extension triggered", "info");
23
-
24
- const { preparation, branchEntries: _, signal } = event;
25
- const { messagesToSummarize, turnPrefixMessages, tokensBefore, firstKeptEntryId, previousSummary } = preparation;
26
-
27
- // Use Gemini Flash for summarization (cheaper/faster than most conversation models)
28
- const model = ctx.modelRegistry.find("google", "gemini-2.5-flash");
29
- if (!model) {
30
- ctx.ui.notify(`Could not find Gemini Flash model, using default compaction`, "warning");
31
- return;
32
- }
33
-
34
- // Resolve API key for the summarization model
35
- const apiKey = await ctx.modelRegistry.getApiKey(model);
36
- if (!apiKey) {
37
- ctx.ui.notify(`No API key for ${model.provider}, using default compaction`, "warning");
38
- return;
39
- }
40
-
41
- // Combine all messages for full summary
42
- const allMessages = [...messagesToSummarize, ...turnPrefixMessages];
43
-
44
- ctx.ui.notify(
45
- `Custom compaction: summarizing ${allMessages.length} messages (${tokensBefore.toLocaleString()} tokens) with ${model.id}...`,
46
- "info",
47
- );
48
-
49
- // Convert messages to readable text format
50
- const conversationText = serializeConversation(convertToLlm(allMessages));
51
-
52
- // Include previous summary context if available
53
- const previousContext = previousSummary ? `\n\nPrevious session summary for context:\n${previousSummary}` : "";
54
-
55
- // Build messages that ask for a comprehensive summary
56
- const summaryMessages = [
57
- {
58
- role: "user" as const,
59
- content: [
60
- {
61
- type: "text" as const,
62
- text: `You are a conversation summarizer. Create a comprehensive summary of this conversation that captures:${previousContext}
63
-
64
- 1. The main goals and objectives discussed
65
- 2. Key decisions made and their rationale
66
- 3. Important code changes, file modifications, or technical details
67
- 4. Current state of any ongoing work
68
- 5. Any blockers, issues, or open questions
69
- 6. Next steps that were planned or suggested
70
-
71
- Be thorough but concise. The summary will replace the ENTIRE conversation history, so include all information needed to continue the work effectively.
72
-
73
- Format the summary as structured markdown with clear sections.
74
-
75
- <conversation>
76
- ${conversationText}
77
- </conversation>`,
78
- },
79
- ],
80
- timestamp: Date.now(),
81
- },
82
- ];
83
-
84
- try {
85
- // Pass signal to honor abort requests (e.g., user cancels compaction)
86
- const response = await complete(model, { messages: summaryMessages }, { apiKey, maxTokens: 8192, signal });
87
-
88
- const summary = response.content
89
- .filter((c): c is { type: "text"; text: string } => c.type === "text")
90
- .map((c) => c.text)
91
- .join("\n");
92
-
93
- if (!summary.trim()) {
94
- if (!signal.aborted) ctx.ui.notify("Compaction summary was empty, using default compaction", "warning");
95
- return;
96
- }
97
-
98
- // Return compaction content - SessionManager adds id/parentId
99
- // Use firstKeptEntryId from preparation to keep recent messages
100
- return {
101
- compaction: {
102
- summary,
103
- firstKeptEntryId,
104
- tokensBefore,
105
- },
106
- };
107
- } catch (error) {
108
- const message = error instanceof Error ? error.message : String(error);
109
- ctx.ui.notify(`Compaction failed: ${message}`, "error");
110
- // Fall back to default compaction on error
111
- return;
112
- }
113
- });
114
- }
115
-
@@ -1,65 +0,0 @@
1
- /**
2
- * Custom Footer Extension - demonstrates ctx.ui.setFooter()
3
- *
4
- * footerData exposes data not otherwise accessible:
5
- * - getGitBranch(): current git branch
6
- * - getExtensionStatuses(): texts from ctx.ui.setStatus()
7
- *
8
- * Token stats come from ctx.sessionManager/ctx.model (already accessible).
9
- */
10
-
11
- import type { AssistantMessage } from "@apholdings/jensen-ai";
12
- import type { ExtensionAPI } from "@apholdings/jensen-code";
13
- import { truncateToWidth, visibleWidth } from "@apholdings/jensen-tui";
14
-
15
- export default function (pi: ExtensionAPI) {
16
- let enabled = false;
17
-
18
- pi.registerCommand("footer", {
19
- description: "Toggle custom footer",
20
- handler: async (_args, ctx) => {
21
- enabled = !enabled;
22
-
23
- if (enabled) {
24
- ctx.ui.setFooter((tui, theme, footerData) => {
25
- const unsub = footerData.onBranchChange(() => tui.requestRender());
26
-
27
- return {
28
- dispose: unsub,
29
- invalidate() {},
30
- render(width: number): string[] {
31
- // Compute tokens from ctx (already accessible to extensions)
32
- let input = 0,
33
- output = 0,
34
- cost = 0;
35
- for (const e of ctx.sessionManager.getBranch()) {
36
- if (e.type === "message" && e.message.role === "assistant") {
37
- const m = e.message as AssistantMessage;
38
- input += m.usage.input;
39
- output += m.usage.output;
40
- cost += m.usage.cost.total;
41
- }
42
- }
43
-
44
- // Get git branch (not otherwise accessible)
45
- const branch = footerData.getGitBranch();
46
- const fmt = (n: number) => (n < 1000 ? `${n}` : `${(n / 1000).toFixed(1)}k`);
47
-
48
- const left = theme.fg("dim", `↑${fmt(input)} ↓${fmt(output)} $${cost.toFixed(3)}`);
49
- const branchStr = branch ? ` (${branch})` : "";
50
- const right = theme.fg("dim", `${ctx.model?.id || "no-model"}${branchStr}`);
51
-
52
- const pad = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(right)));
53
- return [truncateToWidth(left + pad + right, width)];
54
- },
55
- };
56
- });
57
- ctx.ui.notify("Custom footer enabled", "info");
58
- } else {
59
- ctx.ui.setFooter(undefined);
60
- ctx.ui.notify("Default footer restored", "info");
61
- }
62
- },
63
- });
64
- }
65
-
@@ -1,74 +0,0 @@
1
- /**
2
- * Custom Header Extension
3
- *
4
- * Demonstrates ctx.ui.setHeader() for replacing the built-in header
5
- * (logo + keybinding hints) with a custom component showing the pi mascot.
6
- */
7
-
8
- import type { ExtensionAPI, Theme } from "@apholdings/jensen-code";
9
- import { VERSION } from "@apholdings/jensen-code";
10
-
11
- // --- PI MASCOT ---
12
- // Based on pi_mascot.ts - the pi agent character
13
- function getPiMascot(theme: Theme): string[] {
14
- // --- COLORS ---
15
- // 3b1b Blue: R=80, G=180, B=230
16
- const piBlue = (text: string) => theme.fg("accent", text);
17
- const white = (text: string) => text; // Use plain white (or theme.fg("text", text))
18
- const black = (text: string) => theme.fg("dim", text); // Use dim for contrast
19
-
20
- // --- GLYPHS ---
21
- const BLOCK = "█";
22
- const PUPIL = "▌"; // Vertical half-block for the pupil
23
-
24
- // --- CONSTRUCTION ---
25
-
26
- // 1. The Eye Unit: [White Full Block][Black Vertical Sliver]
27
- // This creates the "looking sideways" effect
28
- const eye = `${white(BLOCK)}${black(PUPIL)}`;
29
-
30
- // 2. Line 1: The Eyes
31
- // 5 spaces indent aligns them with the start of the legs
32
- const lineEyes = ` ${eye} ${eye}`;
33
-
34
- // 3. Line 2: The Wide Top Bar (The "Overhang")
35
- // 14 blocks wide for that serif-style roof
36
- const lineBar = ` ${piBlue(BLOCK.repeat(14))}`;
37
-
38
- // 4. Lines 3-6: The Legs
39
- // Indented 5 spaces relative to the very left edge
40
- // Leg width: 2 blocks | Gap: 4 blocks
41
- const lineLeg = ` ${piBlue(BLOCK.repeat(2))} ${piBlue(BLOCK.repeat(2))}`;
42
-
43
- // --- ASSEMBLY ---
44
- return ["", lineEyes, lineBar, lineLeg, lineLeg, lineLeg, lineLeg, ""];
45
- }
46
-
47
- export default function (pi: ExtensionAPI) {
48
- // Set custom header immediately on load (if UI is available)
49
- pi.on("session_start", async (_event, ctx) => {
50
- if (ctx.hasUI) {
51
- ctx.ui.setHeader((_tui, theme) => {
52
- return {
53
- render(_width: number): string[] {
54
- const mascotLines = getPiMascot(theme);
55
- // Add a subtitle with hint
56
- const subtitle = `${theme.fg("muted", " shitty coding agent")}${theme.fg("dim", ` v${VERSION}`)}`;
57
- return [...mascotLines, subtitle];
58
- },
59
- invalidate() {},
60
- };
61
- });
62
- }
63
- });
64
-
65
- // Command to restore built-in header
66
- pi.registerCommand("builtin-header", {
67
- description: "Restore built-in header with keybinding hints",
68
- handler: async (_args, ctx) => {
69
- ctx.ui.setHeader(undefined);
70
- ctx.ui.notify("Built-in header restored", "info");
71
- },
72
- });
73
- }
74
-