clawlet 0.2.0 → 0.2.1
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 +10 -2
- package/package.json +1 -1
- package/src/agent.ts +12 -3
package/README.md
CHANGED
|
@@ -32,8 +32,16 @@ TELEGRAM_BOT_TOKEN=
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
3. Install and run clawlet cli
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
If you want to use the published release use:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
$ npx clawlet
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Development Version
|
|
43
|
+
|
|
44
|
+
If you cloned this repository run:
|
|
37
45
|
|
|
38
46
|
```
|
|
39
47
|
$ pnpm install
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -14,8 +14,14 @@ import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
|
14
14
|
import 'dotenv/config';
|
|
15
15
|
import { hermesToolMiddleware } from '@ai-sdk-tool/parser';
|
|
16
16
|
import { AgentMemory } from './memory.js';
|
|
17
|
-
import { readFile, writeFile, copyFile, access } from 'node:fs/promises';
|
|
17
|
+
import { readFile, writeFile, copyFile, access, mkdir } from 'node:fs/promises';
|
|
18
18
|
import path from 'path';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
|
|
21
|
+
// Resolve the package root directory (where template/ lives), independent of cwd
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = path.dirname(__filename);
|
|
24
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
19
25
|
|
|
20
26
|
// --- ADAPTER INTERFACES ---
|
|
21
27
|
|
|
@@ -1121,15 +1127,18 @@ export class Agent {
|
|
|
1121
1127
|
this.initialized = true;
|
|
1122
1128
|
|
|
1123
1129
|
// Bootstrap: copy AGENTS.template -> workspace/AGENTS.md if missing
|
|
1130
|
+
// Templates are resolved from the package install directory (PACKAGE_ROOT),
|
|
1131
|
+
// NOT from process.cwd(), so this works correctly via npx/global install.
|
|
1124
1132
|
const workspaceDir = path.join(process.cwd(), 'workspace');
|
|
1125
1133
|
const agentsMdPath = path.join(workspaceDir, 'AGENTS.md');
|
|
1126
|
-
const templatePath = path.join(
|
|
1134
|
+
const templatePath = path.join(PACKAGE_ROOT, 'template', 'AGENTS.template');
|
|
1127
1135
|
|
|
1128
1136
|
try {
|
|
1129
1137
|
await access(agentsMdPath);
|
|
1130
1138
|
} catch {
|
|
1131
1139
|
// AGENTS.md does not exist, copy from template
|
|
1132
1140
|
try {
|
|
1141
|
+
await mkdir(workspaceDir, { recursive: true });
|
|
1133
1142
|
await copyFile(templatePath, agentsMdPath);
|
|
1134
1143
|
console.log(` 📋 Copied AGENTS.template -> workspace/AGENTS.md`);
|
|
1135
1144
|
} catch (e: any) {
|
|
@@ -1151,7 +1160,7 @@ export class Agent {
|
|
|
1151
1160
|
|
|
1152
1161
|
if (needsBootstrap) {
|
|
1153
1162
|
try {
|
|
1154
|
-
const bootstrapPath = path.join(
|
|
1163
|
+
const bootstrapPath = path.join(PACKAGE_ROOT, 'template', 'BOOTSTRAP.md');
|
|
1155
1164
|
this.bootstrapPrompt = await readFile(bootstrapPath, 'utf-8');
|
|
1156
1165
|
console.log(` 🚀 Bootstrap mode: SOUL.md, IDENTITY.md, or USER.md missing. Running BOOTSTRAP.md first.`);
|
|
1157
1166
|
} catch (e: any) {
|