agentel 0.2.8 → 0.3.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 +222 -68
- package/docs/code-reference.md +121 -37
- package/docs/history-source-handling.md +555 -124
- package/docs/release.md +35 -8
- package/npm-shrinkwrap.json +478 -0
- package/package.json +18 -5
- package/scripts/postinstall.js +156 -0
- package/src/archive.js +1174 -65
- package/src/canonical-events.js +346 -35
- package/src/cli.js +7121 -819
- package/src/collector.js +42 -4
- package/src/config.js +15 -4
- package/src/diffs.js +156 -0
- package/src/doctor.js +48 -5
- package/src/importers/claude.js +51 -4
- package/src/importers/copilot.js +385 -0
- package/src/importers/cursor-recovery.js +22 -0
- package/src/importers/factory.js +396 -0
- package/src/importers/gemini.js +39 -0
- package/src/importers/grok.js +367 -0
- package/src/importers/pi.js +422 -0
- package/src/importers/providers.js +64 -5
- package/src/importers.js +4524 -383
- package/src/mcp.js +1 -0
- package/src/memory-sources.js +671 -0
- package/src/memory-store.js +0 -0
- package/src/parser-versions.js +13 -0
- package/src/pricing.js +84 -0
- package/src/search.js +256 -70
- package/src/session-store.js +405 -0
- package/src/source-watch.js +293 -0
- package/src/sources.js +60 -11
- package/src/supervisor.js +197 -9
- package/src/sync.js +6 -0
- package/src/unavailable-sources.js +358 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const readline = require("readline");
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
8
|
+
const { paths } = require("../src/paths");
|
|
9
|
+
|
|
10
|
+
const PACKAGE_NAMES = new Set(["agentel", "agentlog"]);
|
|
11
|
+
|
|
12
|
+
async function main(env = process.env, io = process) {
|
|
13
|
+
const plan = buildPostinstallPlan(env, {
|
|
14
|
+
stdinIsTTY: Boolean(io.stdin?.isTTY),
|
|
15
|
+
stdoutIsTTY: Boolean(io.stdout?.isTTY)
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (plan.skip) return;
|
|
19
|
+
|
|
20
|
+
if (!plan.interactive) {
|
|
21
|
+
printPostinstallHint(plan);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const answer = await ask(plan.prompt, io);
|
|
26
|
+
if (!isYes(answer)) {
|
|
27
|
+
console.log(`Skipped. Run \`${plan.displayCommand}\` when you are ready.`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = spawnSync(process.execPath, [agentlogBin(), plan.command], {
|
|
32
|
+
stdio: "inherit",
|
|
33
|
+
env
|
|
34
|
+
});
|
|
35
|
+
if (result.error) throw result.error;
|
|
36
|
+
if (result.status !== 0) process.exitCode = result.status || 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function buildPostinstallPlan(env = process.env, options = {}) {
|
|
40
|
+
if (isTruthy(env.AGENTLOG_SKIP_POSTINSTALL)) return skipped("AGENTLOG_SKIP_POSTINSTALL is set");
|
|
41
|
+
if (isTruthy(env.CI)) return skipped("CI is set");
|
|
42
|
+
if (env.npm_command === "exec") return skipped("npm exec/npx install");
|
|
43
|
+
if (env.npm_lifecycle_event && env.npm_lifecycle_event !== "postinstall") {
|
|
44
|
+
return skipped("not a postinstall lifecycle");
|
|
45
|
+
}
|
|
46
|
+
if (!isUserRequestedInstall(env)) return skipped("not a direct agentlog install");
|
|
47
|
+
|
|
48
|
+
const configured = fs.existsSync(paths(env).config);
|
|
49
|
+
const command = configured ? "update" : "init";
|
|
50
|
+
const displayCommand = `agentlog ${command}`;
|
|
51
|
+
const commandOnPath = findCommandOnPath("agentlog", env);
|
|
52
|
+
const pathNote = commandOnPath
|
|
53
|
+
? ""
|
|
54
|
+
: "The installed command is not on PATH in this shell yet, so this prompt will run the packaged CLI directly.";
|
|
55
|
+
const intro = configured
|
|
56
|
+
? `Found an existing agentlog config. Run \`${displayCommand}\` now to refresh this archive for the installed version?`
|
|
57
|
+
: `No agentlog config found. Run \`${displayCommand}\` now to set up local archiving?`;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
skip: false,
|
|
61
|
+
command,
|
|
62
|
+
configured,
|
|
63
|
+
displayCommand,
|
|
64
|
+
commandOnPath,
|
|
65
|
+
interactive: Boolean(options.stdinIsTTY && options.stdoutIsTTY),
|
|
66
|
+
prompt: `${intro}${pathNote ? `\n${pathNote}` : ""}\nRun now? [y/N] `
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isUserRequestedInstall(env) {
|
|
71
|
+
if (isTruthy(env.AGENTLOG_POSTINSTALL_FORCE)) return true;
|
|
72
|
+
if (env.npm_config_global === "true" || env.npm_config_location === "global") return true;
|
|
73
|
+
const initCwd = env.INIT_CWD ? path.resolve(env.INIT_CWD) : "";
|
|
74
|
+
const packageRoot = path.resolve(__dirname, "..");
|
|
75
|
+
if (!initCwd || initCwd === packageRoot) return false;
|
|
76
|
+
return projectDependsOnAgentlog(initCwd);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function projectDependsOnAgentlog(projectDir) {
|
|
80
|
+
const packageJson = readJson(path.join(projectDir, "package.json"));
|
|
81
|
+
if (!packageJson) return false;
|
|
82
|
+
for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
83
|
+
const deps = packageJson[section] || {};
|
|
84
|
+
for (const name of PACKAGE_NAMES) {
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(deps, name)) return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function printPostinstallHint(plan) {
|
|
92
|
+
console.log(`agentlog installed. Run \`${plan.displayCommand}\` to ${plan.configured ? "refresh your archive" : "set up local archiving"}.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function ask(prompt, io = process) {
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
const rl = readline.createInterface({ input: io.stdin, output: io.stdout });
|
|
98
|
+
rl.question(prompt, (answer) => {
|
|
99
|
+
rl.close();
|
|
100
|
+
resolve(answer);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function findCommandOnPath(command, env = process.env) {
|
|
106
|
+
const pathValue = env.PATH || env.Path || env.path || "";
|
|
107
|
+
const pathExt = process.platform === "win32"
|
|
108
|
+
? String(env.PATHEXT || ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean)
|
|
109
|
+
: [""];
|
|
110
|
+
for (const dir of pathValue.split(path.delimiter).filter(Boolean)) {
|
|
111
|
+
for (const ext of pathExt) {
|
|
112
|
+
const candidate = path.join(dir, `${command}${ext}`);
|
|
113
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function agentlogBin() {
|
|
120
|
+
return path.resolve(__dirname, "..", "bin", "agentlog.js");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isYes(value) {
|
|
124
|
+
return /^(y|yes)$/i.test(String(value || "").trim());
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function isTruthy(value) {
|
|
128
|
+
return ["1", "true", "yes", "on"].includes(String(value || "").trim().toLowerCase());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function readJson(file) {
|
|
132
|
+
try {
|
|
133
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (error.code === "ENOENT") return null;
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function skipped(reason) {
|
|
141
|
+
return { skip: true, reason };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (require.main === module) {
|
|
145
|
+
main().catch((error) => {
|
|
146
|
+
console.error(error?.message || String(error));
|
|
147
|
+
process.exitCode = 1;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = {
|
|
152
|
+
buildPostinstallPlan,
|
|
153
|
+
isYes,
|
|
154
|
+
isUserRequestedInstall,
|
|
155
|
+
projectDependsOnAgentlog
|
|
156
|
+
};
|