@hasna/oldpal 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -6,10 +6,10 @@ Your personal AI assistant - terminal first, voice enabled, connector powered.
6
6
 
7
7
  ```bash
8
8
  # Install globally with bun
9
- bun install -g @hasnaxyz/oldpal
9
+ bun install -g @hasna/oldpal
10
10
 
11
11
  # Or with npm
12
- npm install -g @hasnaxyz/oldpal
12
+ npm install -g @hasna/oldpal
13
13
 
14
14
  # Run
15
15
  oldpal
@@ -100,7 +100,7 @@ Hooks run at specific lifecycle points:
100
100
 
101
101
  ```bash
102
102
  # Clone the repo
103
- git clone https://github.com/hasnaxyz/oldpal.git
103
+ git clone https://github.com/hasna/oldpal.git
104
104
  cd oldpal
105
105
 
106
106
  # Install dependencies
package/dist/index.js CHANGED
@@ -20450,15 +20450,35 @@ var exports_anthropic = {};
20450
20450
  __export(exports_anthropic, {
20451
20451
  AnthropicClient: () => AnthropicClient
20452
20452
  });
20453
+ import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
20454
+ import { homedir as homedir3 } from "os";
20455
+ import { join as join4 } from "path";
20456
+ function loadApiKeyFromSecrets() {
20457
+ const secretsPath = join4(homedir3(), ".secrets");
20458
+ if (existsSync2(secretsPath)) {
20459
+ try {
20460
+ const content = readFileSync2(secretsPath, "utf-8");
20461
+ const match = content.match(/export\s+ANTHROPIC_API_KEY\s*=\s*["']?([^"'\n]+)["']?/);
20462
+ if (match) {
20463
+ return match[1];
20464
+ }
20465
+ } catch {}
20466
+ }
20467
+ return;
20468
+ }
20453
20469
 
20454
20470
  class AnthropicClient {
20455
20471
  client;
20456
20472
  model;
20457
20473
  maxTokens;
20458
20474
  constructor(config) {
20459
- this.client = new sdk_default({
20460
- apiKey: config.apiKey || process.env.ANTHROPIC_API_KEY
20461
- });
20475
+ const apiKey = config.apiKey || process.env.ANTHROPIC_API_KEY || loadApiKeyFromSecrets();
20476
+ if (!apiKey) {
20477
+ throw new Error(`ANTHROPIC_API_KEY not found. Please either:
20478
+ ` + ` 1. Set the ANTHROPIC_API_KEY environment variable, or
20479
+ ` + ' 2. Add it to ~/.secrets: export ANTHROPIC_API_KEY="your-key"');
20480
+ }
20481
+ this.client = new sdk_default({ apiKey });
20462
20482
  this.model = config.model;
20463
20483
  this.maxTokens = config.maxTokens || 8192;
20464
20484
  }
@@ -20571,17 +20591,17 @@ class AnthropicClient {
20571
20591
  }));
20572
20592
  }
20573
20593
  getDefaultSystemPrompt() {
20574
- return `You are Oldpal, a helpful personal AI assistant running in the terminal.
20594
+ return `You are a helpful personal AI assistant running in the terminal.
20575
20595
 
20576
- You have access to various tools and connectors to help the user with their tasks:
20577
- - Connectors for services like Notion, Google Drive, Gmail, Calendar, Linear, Slack
20596
+ You have access to various tools and connectors:
20597
+ - Connectors for Notion, Google Drive, Gmail, Calendar, Linear, Slack
20578
20598
  - Filesystem operations (read, write, search files)
20579
20599
  - Shell command execution
20580
20600
 
20581
20601
  Guidelines:
20582
- - Be concise and direct in your responses
20602
+ - Be concise and direct
20603
+ - Don't introduce yourself or say your name
20583
20604
  - Use tools proactively to accomplish tasks
20584
- - When using connectors, explain what you're doing
20585
20605
  - Format output nicely for the terminal (use markdown)
20586
20606
  - If a task requires multiple steps, break it down clearly
20587
20607
 
@@ -23370,7 +23390,7 @@ var require_core = __commonJS((exports, module) => {
23370
23390
  return match && match.index === 0;
23371
23391
  }
23372
23392
  var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
23373
- function join5(regexps, separator = "|") {
23393
+ function join6(regexps, separator = "|") {
23374
23394
  let numCaptures = 0;
23375
23395
  return regexps.map((regex2) => {
23376
23396
  numCaptures += 1;
@@ -23653,7 +23673,7 @@ var require_core = __commonJS((exports, module) => {
23653
23673
  this.exec = () => null;
23654
23674
  }
23655
23675
  const terminators = this.regexes.map((el) => el[1]);
23656
- this.matcherRe = langRe(join5(terminators), true);
23676
+ this.matcherRe = langRe(join6(terminators), true);
23657
23677
  this.lastIndex = 0;
23658
23678
  }
23659
23679
  exec(s) {
@@ -84046,8 +84066,8 @@ async function createLLMClient(config) {
84046
84066
  }
84047
84067
 
84048
84068
  // packages/core/src/config.ts
84049
- import { join as join4 } from "path";
84050
- import { homedir as homedir3 } from "os";
84069
+ import { join as join5 } from "path";
84070
+ import { homedir as homedir4 } from "os";
84051
84071
  var DEFAULT_CONFIG = {
84052
84072
  llm: {
84053
84073
  provider: "anthropic",
@@ -84077,13 +84097,13 @@ var DEFAULT_CONFIG = {
84077
84097
  ]
84078
84098
  };
84079
84099
  function getConfigDir() {
84080
- return join4(homedir3(), ".oldpal");
84100
+ return join5(homedir4(), ".oldpal");
84081
84101
  }
84082
84102
  function getConfigPath(filename) {
84083
- return join4(getConfigDir(), filename);
84103
+ return join5(getConfigDir(), filename);
84084
84104
  }
84085
84105
  function getProjectConfigDir(cwd2 = process.cwd()) {
84086
- return join4(cwd2, ".oldpal");
84106
+ return join5(cwd2, ".oldpal");
84087
84107
  }
84088
84108
  async function loadConfig(cwd2 = process.cwd()) {
84089
84109
  const config = { ...DEFAULT_CONFIG };
@@ -84096,7 +84116,7 @@ async function loadConfig(cwd2 = process.cwd()) {
84096
84116
  if (userConfig.voice)
84097
84117
  config.voice = { ...config.voice, ...userConfig.voice };
84098
84118
  }
84099
- const projectConfigPath = join4(getProjectConfigDir(cwd2), "settings.json");
84119
+ const projectConfigPath = join5(getProjectConfigDir(cwd2), "settings.json");
84100
84120
  const projectConfig = await loadJsonFile(projectConfigPath);
84101
84121
  if (projectConfig) {
84102
84122
  Object.assign(config, projectConfig);
@@ -84105,7 +84125,7 @@ async function loadConfig(cwd2 = process.cwd()) {
84105
84125
  if (projectConfig.voice)
84106
84126
  config.voice = { ...config.voice, ...projectConfig.voice };
84107
84127
  }
84108
- const localConfigPath = join4(getProjectConfigDir(cwd2), "settings.local.json");
84128
+ const localConfigPath = join5(getProjectConfigDir(cwd2), "settings.local.json");
84109
84129
  const localConfig = await loadJsonFile(localConfigPath);
84110
84130
  if (localConfig) {
84111
84131
  Object.assign(config, localConfig);
@@ -84123,7 +84143,7 @@ async function loadHooksConfig(cwd2 = process.cwd()) {
84123
84143
  if (userHooks?.hooks) {
84124
84144
  mergeHooks(hooks, userHooks.hooks);
84125
84145
  }
84126
- const projectHooksPath = join4(getProjectConfigDir(cwd2), "hooks.json");
84146
+ const projectHooksPath = join5(getProjectConfigDir(cwd2), "hooks.json");
84127
84147
  const projectHooks = await loadJsonFile(projectHooksPath);
84128
84148
  if (projectHooks?.hooks) {
84129
84149
  mergeHooks(hooks, projectHooks.hooks);
@@ -87211,20 +87231,13 @@ function Messages4({ messages, currentResponse }) {
87211
87231
  }, message.id, false, undefined, this)),
87212
87232
  currentResponse && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87213
87233
  marginY: 1,
87214
- flexDirection: "column",
87215
87234
  children: [
87216
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87217
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87218
- color: "magenta",
87219
- bold: true,
87220
- children: [
87221
- "assistant:",
87222
- " "
87223
- ]
87224
- }, undefined, true, undefined, this)
87235
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87236
+ color: "white",
87237
+ children: "\u25CF "
87225
87238
  }, undefined, false, undefined, this),
87226
87239
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87227
- marginLeft: 2,
87240
+ flexGrow: 1,
87228
87241
  children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Markdown, {
87229
87242
  content: currentResponse
87230
87243
  }, undefined, false, undefined, this)
@@ -87238,38 +87251,34 @@ function MessageBubble({ message }) {
87238
87251
  const isUser = message.role === "user";
87239
87252
  const isSystem = message.role === "system";
87240
87253
  if (isSystem) {
87254
+ return null;
87255
+ }
87256
+ if (isUser) {
87241
87257
  return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87242
87258
  marginY: 1,
87243
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87244
- color: "gray",
87245
- dimColor: true,
87246
- children: [
87247
- "[system] ",
87248
- message.content
87249
- ]
87250
- }, undefined, true, undefined, this)
87251
- }, undefined, false, undefined, this);
87259
+ children: [
87260
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87261
+ color: "gray",
87262
+ children: "\u276F "
87263
+ }, undefined, false, undefined, this),
87264
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87265
+ color: "white",
87266
+ backgroundColor: "gray",
87267
+ children: message.content
87268
+ }, undefined, false, undefined, this)
87269
+ ]
87270
+ }, undefined, true, undefined, this);
87252
87271
  }
87253
87272
  return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87254
87273
  marginY: 1,
87255
- flexDirection: "column",
87256
87274
  children: [
87257
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87258
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87259
- color: isUser ? "blue" : "magenta",
87260
- bold: true,
87261
- children: [
87262
- isUser ? "you" : "assistant",
87263
- ":",
87264
- " "
87265
- ]
87266
- }, undefined, true, undefined, this)
87275
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87276
+ color: "white",
87277
+ children: "\u25CF "
87267
87278
  }, undefined, false, undefined, this),
87268
87279
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
87269
- marginLeft: 2,
87270
- children: isUser ? /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
87271
- children: message.content
87272
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Markdown, {
87280
+ flexGrow: 1,
87281
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Markdown, {
87273
87282
  content: message.content
87274
87283
  }, undefined, false, undefined, this)
87275
87284
  }, undefined, false, undefined, this)
@@ -87483,20 +87492,6 @@ function App2({ cwd: cwd2 }) {
87483
87492
  flexDirection: "column",
87484
87493
  padding: 1,
87485
87494
  children: [
87486
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
87487
- marginBottom: 1,
87488
- children: [
87489
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
87490
- bold: true,
87491
- color: "cyan",
87492
- children: "oldpal"
87493
- }, undefined, false, undefined, this),
87494
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
87495
- color: "gray",
87496
- children: " - Your personal AI assistant"
87497
- }, undefined, false, undefined, this)
87498
- ]
87499
- }, undefined, true, undefined, this),
87500
87495
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Messages4, {
87501
87496
  messages,
87502
87497
  currentResponse
@@ -87575,4 +87570,4 @@ waitUntilExit().then(() => {
87575
87570
  process.exit(0);
87576
87571
  });
87577
87572
 
87578
- //# debugId=3F6DA8414A2A00FA64756E2164756E21
87573
+ //# debugId=C49F23935734477464756E2164756E21