@harbinger-ai/harbinger 0.1.5 → 0.1.6

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 (2) hide show
  1. package/lib/agents.js +20 -3
  2. package/package.json +1 -1
package/lib/agents.js CHANGED
@@ -1,9 +1,24 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { fileURLToPath } from 'url';
3
4
  import { agentsDir } from './paths.js';
4
5
 
5
6
  const SKIP_DIRS = ['shared', '_template', 'node_modules'];
6
7
 
8
+ // Package-level agents directory (fallback when project doesn't have its own agents/)
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const packageAgentsDir = path.join(__dirname, '..', 'agents');
11
+
12
+ /**
13
+ * Resolve the effective agents directory.
14
+ * Prefers the project-level agents/ dir, falls back to the package's bundled agents/.
15
+ */
16
+ function resolveAgentsDir() {
17
+ if (fs.existsSync(agentsDir)) return agentsDir;
18
+ if (fs.existsSync(packageAgentsDir)) return packageAgentsDir;
19
+ return agentsDir; // return default even if missing — callers handle non-existence
20
+ }
21
+
7
22
  /**
8
23
  * Parse flat YAML (key: value per line, simple arrays with [a, b]).
9
24
  * No external yaml dependency needed — CONFIG.yaml files are flat key-value.
@@ -81,7 +96,8 @@ function parseIdentity(content) {
81
96
  * Returns null if the directory doesn't exist or is invalid.
82
97
  */
83
98
  export function loadAgentProfile(agentDirName) {
84
- const agentPath = path.join(agentsDir, agentDirName);
99
+ const effectiveDir = resolveAgentsDir();
100
+ const agentPath = path.join(effectiveDir, agentDirName);
85
101
 
86
102
  if (!fs.existsSync(agentPath)) return null;
87
103
  const stat = fs.statSync(agentPath);
@@ -135,9 +151,10 @@ export function loadAgentProfile(agentDirName) {
135
151
  * Returns array of profile objects with id, name, codename, role, etc.
136
152
  */
137
153
  export function discoverAgents() {
138
- if (!fs.existsSync(agentsDir)) return [];
154
+ const effectiveDir = resolveAgentsDir();
155
+ if (!fs.existsSync(effectiveDir)) return [];
139
156
 
140
- const entries = fs.readdirSync(agentsDir, { withFileTypes: true });
157
+ const entries = fs.readdirSync(effectiveDir, { withFileTypes: true });
141
158
  const agents = [];
142
159
 
143
160
  for (const entry of entries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbinger-ai/harbinger",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Create autonomous AI agents with a two-layer architecture: Next.js Event Handler + Docker Agent.",
6
6
  "bin": {