@yhong91/vibetime 0.1.14 → 0.1.15
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/bin/vibetime.mjs +105 -29
- package/package.json +1 -1
package/bin/vibetime.mjs
CHANGED
|
@@ -158,7 +158,7 @@ var init_fs = __esm({
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
// src/cli.ts
|
|
161
|
-
import { spawn } from "node:child_process";
|
|
161
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
162
162
|
import { mkdir as mkdir4, rename as rename2, rm, stat as stat11, writeFile as writeFile3 } from "node:fs/promises";
|
|
163
163
|
import os8 from "node:os";
|
|
164
164
|
import path19 from "node:path";
|
|
@@ -1195,7 +1195,7 @@ function countTextLines(text) {
|
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
1197
|
// src/lib/constants.ts
|
|
1198
|
-
var PACKAGE_VERSION = true ? "0.1.
|
|
1198
|
+
var PACKAGE_VERSION = true ? "0.1.15" : "0.1.1";
|
|
1199
1199
|
var DEFAULT_API_URL = "http://121.196.224.82:3001";
|
|
1200
1200
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
1201
1201
|
var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
|
|
@@ -5096,34 +5096,43 @@ export const AgentTime = async ({ $, directory }) => {
|
|
|
5096
5096
|
}
|
|
5097
5097
|
|
|
5098
5098
|
return {
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
session_id: ctx?.id,
|
|
5103
|
-
cwd: directory
|
|
5104
|
-
})
|
|
5105
|
-
},
|
|
5106
|
-
"session.idle": async (ctx) => {
|
|
5107
|
-
await report({
|
|
5108
|
-
hook_event_name: "SessionEnd",
|
|
5109
|
-
session_id: ctx?.id,
|
|
5110
|
-
cwd: directory
|
|
5111
|
-
})
|
|
5112
|
-
},
|
|
5113
|
-
"tool.execute.after": async (input) => {
|
|
5114
|
-
const toolName = input?.tool || "unknown"
|
|
5115
|
-
const toolCallId = input?.toolCallId
|
|
5116
|
-
const toolInput = input?.args || input?.input || {}
|
|
5117
|
-
const command = toolInput?.command
|
|
5118
|
-
const filePath = toolInput?.file_path || toolInput?.filePath
|
|
5099
|
+
event: async ({ event }) => {
|
|
5100
|
+
const type = event?.type
|
|
5101
|
+
const props = event?.properties || {}
|
|
5119
5102
|
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5103
|
+
if (type === "session.created") {
|
|
5104
|
+
await report({
|
|
5105
|
+
hook_event_name: "SessionStart",
|
|
5106
|
+
session_id: event?.sessionID || event?.sessionId || props?.session?.id || event?.id,
|
|
5107
|
+
cwd: directory
|
|
5108
|
+
})
|
|
5109
|
+
return
|
|
5110
|
+
}
|
|
5111
|
+
|
|
5112
|
+
if (type === "session.idle") {
|
|
5113
|
+
await report({
|
|
5114
|
+
hook_event_name: "SessionEnd",
|
|
5115
|
+
session_id: event?.sessionID || event?.sessionId || props?.session?.id || event?.id,
|
|
5116
|
+
cwd: directory
|
|
5117
|
+
})
|
|
5118
|
+
return
|
|
5119
|
+
}
|
|
5120
|
+
|
|
5121
|
+
if (type === "tool.execute.after") {
|
|
5122
|
+
const toolName = props?.tool || event?.tool || "unknown"
|
|
5123
|
+
const toolCallId = props?.toolCallId || event?.toolCallId
|
|
5124
|
+
const toolInput = props?.args || props?.input || {}
|
|
5125
|
+
const command = toolInput?.command
|
|
5126
|
+
const filePath = toolInput?.file_path || toolInput?.filePath
|
|
5127
|
+
|
|
5128
|
+
await report({
|
|
5129
|
+
hook_event_name: "PostToolUse",
|
|
5130
|
+
tool_name: toolName,
|
|
5131
|
+
tool_use_id: toolCallId,
|
|
5132
|
+
cwd: directory,
|
|
5133
|
+
tool_input: { command, file_path: filePath }
|
|
5134
|
+
})
|
|
5135
|
+
}
|
|
5127
5136
|
}
|
|
5128
5137
|
}
|
|
5129
5138
|
}
|
|
@@ -8755,6 +8764,7 @@ function createCli(ctx, registry) {
|
|
|
8755
8764
|
});
|
|
8756
8765
|
cli.command("detect", "Show supported local targets and install status").action((options) => detectCommand(normalizeOptions(options), ctx, registry).then(() => 0));
|
|
8757
8766
|
cli.command("install", "Install integration files into detected or requested targets").option("--target <targets>", "Target integrations, comma-separated").option("--targets <targets>", "Target integrations, comma-separated").option("--all", "Install all supported integrations").option("--force", "Overwrite existing non-generated files when needed").action((options) => installCommand(normalizeOptions(options), ctx, registry));
|
|
8767
|
+
cli.command("upgrade", "Check for updates and upgrade to the latest version").option("--check", "Only check for updates, do not install").action((options) => upgradeCommand(normalizeOptions(options), ctx, registry));
|
|
8758
8768
|
cli.command("hook", "Read agent hook JSON from stdin and report a throttled event").option("--agent <name>", "Agent name").option("--project <name>", "Project name").option("--min-interval <seconds>", "Minimum seconds between similar hook reports").action((options) => hookCommand(normalizeOptions(options), ctx));
|
|
8759
8769
|
cli.command("sync-local-trigger", "Trigger one background local sync with throttle and locking").option("--min-interval <seconds>", "Minimum seconds between sync triggers").action((options) => syncLocalTriggerCommand(normalizeOptions(options), ctx, registry));
|
|
8760
8770
|
cli.command("sync-local-runner", "Internal background local sync runner").option("--lock-file <path>", "Lock file for the active sync").option("--state-file <path>", "State file for trigger metadata").action((options) => syncLocalRunnerCommand(normalizeOptions(options), ctx, registry));
|
|
@@ -8849,6 +8859,70 @@ async function installCommand(options, ctx, registry) {
|
|
|
8849
8859
|
}
|
|
8850
8860
|
return 0;
|
|
8851
8861
|
}
|
|
8862
|
+
var NPM_PACKAGE = "@yhong91/vibetime";
|
|
8863
|
+
async function fetchLatestVersion() {
|
|
8864
|
+
try {
|
|
8865
|
+
const response = await fetch(`https://registry.npmjs.org/${NPM_PACKAGE}/latest`, {
|
|
8866
|
+
headers: { Accept: "application/json" },
|
|
8867
|
+
signal: AbortSignal.timeout(1e4)
|
|
8868
|
+
});
|
|
8869
|
+
if (!response.ok) return null;
|
|
8870
|
+
const data = await response.json();
|
|
8871
|
+
return typeof data.version === "string" ? data.version : null;
|
|
8872
|
+
} catch {
|
|
8873
|
+
return null;
|
|
8874
|
+
}
|
|
8875
|
+
}
|
|
8876
|
+
function compareVersions(a, b) {
|
|
8877
|
+
const pa = a.split(".").map(Number);
|
|
8878
|
+
const pb = b.split(".").map(Number);
|
|
8879
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
8880
|
+
const na = pa[i] ?? 0;
|
|
8881
|
+
const nb = pb[i] ?? 0;
|
|
8882
|
+
if (na > nb) return 1;
|
|
8883
|
+
if (na < nb) return -1;
|
|
8884
|
+
}
|
|
8885
|
+
return 0;
|
|
8886
|
+
}
|
|
8887
|
+
async function upgradeCommand(options, ctx, registry) {
|
|
8888
|
+
const current = PACKAGE_VERSION;
|
|
8889
|
+
write(ctx.stdout, `Current version: ${current}
|
|
8890
|
+
`);
|
|
8891
|
+
write(ctx.stdout, "Checking npm registry...\n");
|
|
8892
|
+
const latest = await fetchLatestVersion();
|
|
8893
|
+
if (!latest) {
|
|
8894
|
+
write(ctx.stderr, "Could not fetch latest version from npm. Check your network connection.\n");
|
|
8895
|
+
return 1;
|
|
8896
|
+
}
|
|
8897
|
+
if (compareVersions(current, latest) >= 0) {
|
|
8898
|
+
write(ctx.stdout, `Already up to date (${current}).
|
|
8899
|
+
`);
|
|
8900
|
+
return 0;
|
|
8901
|
+
}
|
|
8902
|
+
write(ctx.stdout, `New version available: ${latest}
|
|
8903
|
+
`);
|
|
8904
|
+
if (options.check) {
|
|
8905
|
+
write(ctx.stdout, `Run \`vibetime upgrade\` to install.
|
|
8906
|
+
`);
|
|
8907
|
+
return 0;
|
|
8908
|
+
}
|
|
8909
|
+
write(ctx.stdout, `Installing ${NPM_PACKAGE}@${latest}...
|
|
8910
|
+
|
|
8911
|
+
`);
|
|
8912
|
+
const result = spawnSync("npm", ["install", "-g", `${NPM_PACKAGE}@latest`], {
|
|
8913
|
+
stdio: "inherit"
|
|
8914
|
+
});
|
|
8915
|
+
if (result.status !== 0) {
|
|
8916
|
+
write(ctx.stderr, "\nFailed to install update. Try manually: npm install -g @yhong91/vibetime@latest\n");
|
|
8917
|
+
return 1;
|
|
8918
|
+
}
|
|
8919
|
+
write(ctx.stdout, "\nRefreshing integration hooks...\n");
|
|
8920
|
+
await installCommand({ ...options, all: true, _: [] }, ctx, registry);
|
|
8921
|
+
write(ctx.stdout, `
|
|
8922
|
+
Upgraded ${current} \u2192 ${latest}
|
|
8923
|
+
`);
|
|
8924
|
+
return 0;
|
|
8925
|
+
}
|
|
8852
8926
|
async function hookCommand(options, ctx) {
|
|
8853
8927
|
const home = resolveHome2(options, ctx);
|
|
8854
8928
|
try {
|
|
@@ -9803,6 +9877,7 @@ function helpText() {
|
|
|
9803
9877
|
Usage:
|
|
9804
9878
|
vibetime detect [--json] [--home <path>]
|
|
9805
9879
|
vibetime install [--target codex,claude,opencode,pi] [--all] [--dry-run] [--force] [--home <path>]
|
|
9880
|
+
vibetime upgrade [--check]
|
|
9806
9881
|
vibetime hook --agent <name>
|
|
9807
9882
|
vibetime backfill discover|plan|import|verify --source codex|claude-code|opencode|pi|all --dry-run [--json] [--batch-size <count>]
|
|
9808
9883
|
vibetime token set <token>
|
|
@@ -9816,6 +9891,7 @@ Setup:
|
|
|
9816
9891
|
Commands:
|
|
9817
9892
|
detect Show supported local targets and install status.
|
|
9818
9893
|
install Install integration files into detected or requested targets.
|
|
9894
|
+
upgrade Check for updates and upgrade to the latest version.
|
|
9819
9895
|
hook Read agent hook JSON from stdin and report a throttled event.
|
|
9820
9896
|
backfill Discover local history and create metadata-only import plans.
|
|
9821
9897
|
token Set, show, or clear the persisted API token.
|
package/package.json
CHANGED