@agentfare/loader 0.1.0

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 ADDED
@@ -0,0 +1,14 @@
1
+ # agentfare/loader
2
+
3
+ Node.js `--require` 预加载器,自动初始化 AgentFare hook。
4
+
5
+ ## 使用
6
+
7
+ ```bash
8
+ NODE_OPTIONS="--require agentfare/loader" claude
9
+ NODE_OPTIONS="--require agentfare/loader" codex
10
+ ```
11
+
12
+ ## License
13
+
14
+ MIT
@@ -0,0 +1,2 @@
1
+ export declare function ensureLoaderScript(): string;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,wBAAgB,kBAAkB,IAAI,MAAM,CAiB3C"}
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ // @agentfare/loader — --require entry point
3
+ // Generates ~/.agentfare/loader.js (user-editable), then loads it
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.ensureLoaderScript = ensureLoaderScript;
39
+ const fs = __importStar(require("node:fs"));
40
+ const path = __importStar(require("node:path"));
41
+ const os = __importStar(require("node:os"));
42
+ const LOADER_DIR = path.join(os.homedir(), ".agentfare");
43
+ const LOADER_FILE = path.join(LOADER_DIR, "loader.js");
44
+ function ensureLoaderScript() {
45
+ if (!fs.existsSync(LOADER_DIR)) {
46
+ fs.mkdirSync(LOADER_DIR, { recursive: true });
47
+ }
48
+ if (!fs.existsSync(LOADER_FILE)) {
49
+ const content = `// AgentFare Loader — editable
50
+ // Add other hook requires to this array:
51
+ const hooks = [
52
+ require("@agentfare/hook"),
53
+ ];
54
+ hooks.forEach(h => { if (typeof h === 'function') h(); });
55
+ `;
56
+ fs.writeFileSync(LOADER_FILE, content);
57
+ }
58
+ return LOADER_FILE;
59
+ }
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,kEAAkE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASlE,gDAiBC;AAxBD,4CAA8B;AAC9B,gDAAkC;AAClC,4CAA8B;AAE9B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AACzD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAEvD,SAAgB,kBAAkB;IAChC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG;;;;;;CAMnB,CAAC;QACE,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@agentfare/loader",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "dependencies": {
14
+ "@agentfare/hook": "workspace:*"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^22.0.0",
18
+ "typescript": "^5.8",
19
+ "vitest": "^3.2"
20
+ }
21
+ }