modelstat 0.10.3 → 0.11.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/dist/cli.mjs +34 -82
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -99,8 +99,7 @@ async function resolveGitContext(cwd) {
|
|
|
99
99
|
remote_url: null,
|
|
100
100
|
remote_host: null,
|
|
101
101
|
remote_slug: null,
|
|
102
|
-
branch: null
|
|
103
|
-
commit_sha: null
|
|
102
|
+
branch: null
|
|
104
103
|
};
|
|
105
104
|
cache.set(target, empty);
|
|
106
105
|
return empty;
|
|
@@ -115,14 +114,12 @@ async function resolveGitContext(cwd) {
|
|
|
115
114
|
};
|
|
116
115
|
const remoteUrl = await ran(["config", "--get", "remote.origin.url"]);
|
|
117
116
|
const branch = await ran(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
118
|
-
const sha = await ran(["rev-parse", "HEAD"]);
|
|
119
117
|
const parsed = remoteUrl ? parseRemote(remoteUrl) : { host: null, slug: null };
|
|
120
118
|
const ctx = {
|
|
121
119
|
remote_url: remoteUrl,
|
|
122
120
|
remote_host: parsed.host,
|
|
123
121
|
remote_slug: parsed.slug,
|
|
124
|
-
branch
|
|
125
|
-
commit_sha: sha
|
|
122
|
+
branch
|
|
126
123
|
};
|
|
127
124
|
cache.set(target, ctx);
|
|
128
125
|
return ctx;
|
|
@@ -4740,7 +4737,7 @@ var init_redact = __esm({
|
|
|
4740
4737
|
|
|
4741
4738
|
// ../../packages/core/src/session-metadata.ts
|
|
4742
4739
|
function emptyDetectedRefs() {
|
|
4743
|
-
return { repos: [], pull_requests: [],
|
|
4740
|
+
return { repos: [], pull_requests: [], issues: [] };
|
|
4744
4741
|
}
|
|
4745
4742
|
function repoFrom(host, slug, source) {
|
|
4746
4743
|
return { host, slug, branches: [], source };
|
|
@@ -4826,31 +4823,29 @@ function detectReferences(text, source = "content") {
|
|
|
4826
4823
|
confidence: 0.9
|
|
4827
4824
|
});
|
|
4828
4825
|
}
|
|
4829
|
-
for (const m of text.matchAll(GITHUB_COMMIT)) {
|
|
4830
|
-
const slug = `${m[1]}/${m[2]}`;
|
|
4831
|
-
out.commits.push({ sha: m[3] ?? "", slug, url: m[0], source, confidence: 0.95 });
|
|
4832
|
-
out.repos.push(repoFrom("github.com", slug, source));
|
|
4833
|
-
}
|
|
4834
|
-
for (const m of text.matchAll(GITLAB_COMMIT)) {
|
|
4835
|
-
out.commits.push({
|
|
4836
|
-
sha: m[2] ?? "",
|
|
4837
|
-
slug: m[1] ?? null,
|
|
4838
|
-
url: m[0],
|
|
4839
|
-
source,
|
|
4840
|
-
confidence: 0.95
|
|
4841
|
-
});
|
|
4842
|
-
if (m[1]) out.repos.push(repoFrom("gitlab.com", m[1], source));
|
|
4843
|
-
}
|
|
4844
4826
|
for (const m of text.matchAll(SLUG_HASH)) {
|
|
4845
4827
|
const slug = m[1] ?? "";
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4828
|
+
const lead = text.slice(Math.max(0, (m.index ?? 0) - 20), m.index ?? 0).toLowerCase();
|
|
4829
|
+
if (/\b(pr|pull[ -]?request|merge[ -]?request|mr|merged)\s*$/.test(lead)) {
|
|
4830
|
+
out.pull_requests.push({
|
|
4831
|
+
host: "github.com",
|
|
4832
|
+
slug,
|
|
4833
|
+
number: Number(m[2] ?? ""),
|
|
4834
|
+
url: null,
|
|
4835
|
+
source,
|
|
4836
|
+
confidence: 0.6
|
|
4837
|
+
});
|
|
4838
|
+
out.repos.push(repoFrom("github.com", slug, source));
|
|
4839
|
+
} else {
|
|
4840
|
+
out.issues.push({
|
|
4841
|
+
provider: "github",
|
|
4842
|
+
key: m[2] ?? "",
|
|
4843
|
+
slug,
|
|
4844
|
+
url: null,
|
|
4845
|
+
source,
|
|
4846
|
+
confidence: 0.55
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4854
4849
|
}
|
|
4855
4850
|
if (source === "model") {
|
|
4856
4851
|
for (const m of text.matchAll(BARE_TICKET)) {
|
|
@@ -4898,7 +4893,6 @@ function dedupeSessionMetadata(parts) {
|
|
|
4898
4893
|
for (const p of parts) {
|
|
4899
4894
|
all.repos.push(...p.repos);
|
|
4900
4895
|
all.pull_requests.push(...p.pull_requests);
|
|
4901
|
-
all.commits.push(...p.commits);
|
|
4902
4896
|
all.issues.push(...p.issues);
|
|
4903
4897
|
}
|
|
4904
4898
|
const repos = dedupe(
|
|
@@ -4927,22 +4921,6 @@ function dedupeSessionMetadata(parts) {
|
|
|
4927
4921
|
};
|
|
4928
4922
|
}
|
|
4929
4923
|
);
|
|
4930
|
-
const commits = dedupe(
|
|
4931
|
-
all.commits,
|
|
4932
|
-
// Key on slug + sha: two different commits in two repos can share a short
|
|
4933
|
-
// 7-hex prefix, and must not collapse into one.
|
|
4934
|
-
(c) => `${(c.slug ?? "").toLowerCase()}@${c.sha.toLowerCase()}`,
|
|
4935
|
-
(a, b) => {
|
|
4936
|
-
const [win, lose] = score(a) >= score(b) ? [a, b] : [b, a];
|
|
4937
|
-
return {
|
|
4938
|
-
sha: win.sha,
|
|
4939
|
-
slug: win.slug ?? lose.slug,
|
|
4940
|
-
url: win.url ?? lose.url,
|
|
4941
|
-
source: win.source,
|
|
4942
|
-
confidence: Math.max(win.confidence, lose.confidence)
|
|
4943
|
-
};
|
|
4944
|
-
}
|
|
4945
|
-
);
|
|
4946
4924
|
const issues = dedupe(
|
|
4947
4925
|
all.issues,
|
|
4948
4926
|
(i) => `${i.provider}:${(i.slug ?? "").toLowerCase()}#${i.key.toLowerCase()}`,
|
|
@@ -4966,12 +4944,11 @@ function dedupeSessionMetadata(parts) {
|
|
|
4966
4944
|
return {
|
|
4967
4945
|
repos: keepValid(RepoRef, repos).slice(0, 50),
|
|
4968
4946
|
pull_requests: keepValid(PullRequestRef, pull_requests).slice(0, 100),
|
|
4969
|
-
commits: keepValid(CommitRef, commits).slice(0, 200),
|
|
4970
4947
|
issues: keepValid(IssueRef, reconciledIssues).slice(0, 100)
|
|
4971
4948
|
};
|
|
4972
4949
|
}
|
|
4973
4950
|
function isEmptySessionMetadata(m) {
|
|
4974
|
-
return m.repos.length === 0 && m.pull_requests.length === 0 && m.
|
|
4951
|
+
return m.repos.length === 0 && m.pull_requests.length === 0 && m.issues.length === 0;
|
|
4975
4952
|
}
|
|
4976
4953
|
function detectEventReferences(text) {
|
|
4977
4954
|
if (!text) return null;
|
|
@@ -4980,11 +4957,10 @@ function detectEventReferences(text) {
|
|
|
4980
4957
|
return {
|
|
4981
4958
|
repos: m.repos.slice(0, 24),
|
|
4982
4959
|
pull_requests: m.pull_requests.slice(0, 24),
|
|
4983
|
-
commits: m.commits.slice(0, 24),
|
|
4984
4960
|
issues: m.issues.slice(0, 24)
|
|
4985
4961
|
};
|
|
4986
4962
|
}
|
|
4987
|
-
var REF_SOURCES, RefSource, SOURCE_RANK, RepoRef, PullRequestRef,
|
|
4963
|
+
var REF_SOURCES, RefSource, SOURCE_RANK, RepoRef, PullRequestRef, ISSUE_PROVIDERS, IssueRef, SessionMetadata, EventReferences, GITHUB_PR, GITLAB_MR, BITBUCKET_PR, GITHUB_ISSUE, GITLAB_ISSUE, LINEAR_ISSUE, JIRA_ISSUE, SLUG_HASH, BARE_TICKET;
|
|
4988
4964
|
var init_session_metadata = __esm({
|
|
4989
4965
|
"../../packages/core/src/session-metadata.ts"() {
|
|
4990
4966
|
"use strict";
|
|
@@ -5018,14 +4994,6 @@ var init_session_metadata = __esm({
|
|
|
5018
4994
|
hotfixed: external_exports.boolean().nullable().optional(),
|
|
5019
4995
|
reopened: external_exports.boolean().nullable().optional()
|
|
5020
4996
|
});
|
|
5021
|
-
CommitRef = external_exports.object({
|
|
5022
|
-
/** 7–40 char hex SHA. */
|
|
5023
|
-
sha: external_exports.string().max(64),
|
|
5024
|
-
slug: external_exports.string().max(200).nullable().default(null),
|
|
5025
|
-
url: external_exports.string().max(400).nullable().default(null),
|
|
5026
|
-
source: RefSource.default("content"),
|
|
5027
|
-
confidence: external_exports.number().min(0).max(1).default(0.8)
|
|
5028
|
-
});
|
|
5029
4997
|
ISSUE_PROVIDERS = [
|
|
5030
4998
|
"github",
|
|
5031
4999
|
"gitlab",
|
|
@@ -5045,13 +5013,11 @@ var init_session_metadata = __esm({
|
|
|
5045
5013
|
SessionMetadata = external_exports.object({
|
|
5046
5014
|
repos: external_exports.array(RepoRef).max(50).default([]),
|
|
5047
5015
|
pull_requests: external_exports.array(PullRequestRef).max(100).default([]),
|
|
5048
|
-
commits: external_exports.array(CommitRef).max(200).default([]),
|
|
5049
5016
|
issues: external_exports.array(IssueRef).max(100).default([])
|
|
5050
5017
|
});
|
|
5051
5018
|
EventReferences = external_exports.object({
|
|
5052
5019
|
repos: external_exports.array(RepoRef).max(24).default([]),
|
|
5053
5020
|
pull_requests: external_exports.array(PullRequestRef).max(24).default([]),
|
|
5054
|
-
commits: external_exports.array(CommitRef).max(24).default([]),
|
|
5055
5021
|
issues: external_exports.array(IssueRef).max(24).default([])
|
|
5056
5022
|
});
|
|
5057
5023
|
GITHUB_PR = /https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/gi;
|
|
@@ -5059,8 +5025,6 @@ var init_session_metadata = __esm({
|
|
|
5059
5025
|
BITBUCKET_PR = /https?:\/\/bitbucket\.org\/([\w.-]+)\/([\w.-]+)\/pull-requests\/(\d+)/gi;
|
|
5060
5026
|
GITHUB_ISSUE = /https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/issues\/(\d+)/gi;
|
|
5061
5027
|
GITLAB_ISSUE = /https?:\/\/gitlab\.com\/([\w./-]+?)\/-\/issues\/(\d+)/gi;
|
|
5062
|
-
GITHUB_COMMIT = /https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/commit\/([0-9a-f]{7,40})/gi;
|
|
5063
|
-
GITLAB_COMMIT = /https?:\/\/gitlab\.com\/([\w./-]+?)\/-\/commit\/([0-9a-f]{7,40})/gi;
|
|
5064
5028
|
LINEAR_ISSUE = /https?:\/\/linear\.app\/[\w.-]+\/issue\/([A-Z][A-Z0-9]*-\d+)/gi;
|
|
5065
5029
|
JIRA_ISSUE = /https?:\/\/[\w.-]+\/browse\/([A-Z][A-Z0-9]+-\d+)/gi;
|
|
5066
5030
|
SLUG_HASH = /(?:^|[\s([{<])([\w.-]+\/[\w.-]+)#(\d+)\b/g;
|
|
@@ -5090,8 +5054,7 @@ var init_schemas = __esm({
|
|
|
5090
5054
|
// "github.com"
|
|
5091
5055
|
remote_slug: external_exports.string().nullable(),
|
|
5092
5056
|
// "org/repo"
|
|
5093
|
-
branch: external_exports.string().nullable()
|
|
5094
|
-
commit_sha: external_exports.string().nullable()
|
|
5057
|
+
branch: external_exports.string().nullable()
|
|
5095
5058
|
});
|
|
5096
5059
|
RawEvent = external_exports.object({
|
|
5097
5060
|
source_event_id: external_exports.string(),
|
|
@@ -5128,7 +5091,7 @@ var init_schemas = __esm({
|
|
|
5128
5091
|
// summarize prompt; it never gets stored long-term server-side, only
|
|
5129
5092
|
// used to construct the summarize input.
|
|
5130
5093
|
content_excerpt: external_exports.string().max(320).optional(),
|
|
5131
|
-
// Public code references (PRs, issues,
|
|
5094
|
+
// Public code references (PRs, issues, repos) detected on-device
|
|
5132
5095
|
// from this turn's FULL text — the high-recall feed the server rolls up into
|
|
5133
5096
|
// SessionMetadata. Only public reference shapes (forge URLs, slugs, numbers,
|
|
5134
5097
|
// ticket keys) ride here, never raw text — so it is derived pre-redaction
|
|
@@ -5286,7 +5249,7 @@ var init_schemas = __esm({
|
|
|
5286
5249
|
* no-op browser summariser). */
|
|
5287
5250
|
session_titles: external_exports.record(external_exports.string(), external_exports.string().max(120)).optional(),
|
|
5288
5251
|
/** Optional per-session deterministic metadata — session_id →
|
|
5289
|
-
* {@link SessionMetadata}: the repos, pull requests,
|
|
5252
|
+
* {@link SessionMetadata}: the repos, pull requests, and issues the
|
|
5290
5253
|
* session touched, detected on-device across git context, tool calls,
|
|
5291
5254
|
* redacted content, and the local model (so it works for any provider).
|
|
5292
5255
|
* Additive — old daemons omit it, old servers ignore it (the wire has no
|
|
@@ -6030,8 +5993,7 @@ async function parseClaudeCodeJsonl(ctx) {
|
|
|
6030
5993
|
remote_url: null,
|
|
6031
5994
|
remote_host: slug?.includes("/") ? "github.com" : null,
|
|
6032
5995
|
remote_slug: slug,
|
|
6033
|
-
branch: gitBranch
|
|
6034
|
-
commit_sha: null
|
|
5996
|
+
branch: gitBranch
|
|
6035
5997
|
} : null,
|
|
6036
5998
|
tokens: {
|
|
6037
5999
|
input: usage.input_tokens ?? 0,
|
|
@@ -6408,8 +6370,7 @@ async function parseCodexRollout(ctx) {
|
|
|
6408
6370
|
remote_url: null,
|
|
6409
6371
|
remote_host: slug.includes("/") ? "github.com" : null,
|
|
6410
6372
|
remote_slug: slug,
|
|
6411
|
-
branch: null
|
|
6412
|
-
commit_sha: null
|
|
6373
|
+
branch: null
|
|
6413
6374
|
} : null,
|
|
6414
6375
|
tokens: {
|
|
6415
6376
|
input: tk.input_tokens ?? 0,
|
|
@@ -35525,15 +35486,6 @@ async function buildSessionMetadata(segments, events, opts = {}) {
|
|
|
35525
35486
|
});
|
|
35526
35487
|
}
|
|
35527
35488
|
if (e.git.branch) refs.issues.push(...detectBranchTickets(e.git.branch));
|
|
35528
|
-
if (e.git.commit_sha) {
|
|
35529
|
-
refs.commits.push({
|
|
35530
|
-
sha: e.git.commit_sha,
|
|
35531
|
-
slug: e.git.remote_slug ?? null,
|
|
35532
|
-
url: null,
|
|
35533
|
-
source: "git",
|
|
35534
|
-
confidence: 0.6
|
|
35535
|
-
});
|
|
35536
|
-
}
|
|
35537
35489
|
parts.push(refs);
|
|
35538
35490
|
}
|
|
35539
35491
|
if (opts.resolveGit) {
|
|
@@ -37315,7 +37267,7 @@ var init_scan = __esm({
|
|
|
37315
37267
|
init_api();
|
|
37316
37268
|
init_config2();
|
|
37317
37269
|
init_pipeline2();
|
|
37318
|
-
DAEMON_VERSION = true ? "daemon-0.
|
|
37270
|
+
DAEMON_VERSION = true ? "daemon-0.11.1" : "daemon-dev";
|
|
37319
37271
|
BATCH_MAX_EVENTS = INGEST_BATCH_MAX_EVENTS;
|
|
37320
37272
|
BATCH_MAX_TOOL_CALLS = 2e4;
|
|
37321
37273
|
BATCH_BUFFER_HARD_CAP = BATCH_MAX_EVENTS * 2;
|
|
@@ -40262,7 +40214,7 @@ var init_daemon = __esm({
|
|
|
40262
40214
|
init_scan();
|
|
40263
40215
|
init_single_flight();
|
|
40264
40216
|
init_update();
|
|
40265
|
-
DAEMON_VERSION2 = true ? "daemon-0.
|
|
40217
|
+
DAEMON_VERSION2 = true ? "daemon-0.11.1" : "daemon-dev";
|
|
40266
40218
|
HEARTBEAT_INTERVAL_MS = 1e4;
|
|
40267
40219
|
SCAN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
40268
40220
|
DISCOVERY_INTERVAL_MS = 6e4;
|
|
@@ -40894,7 +40846,7 @@ function tryOpenBrowser(url) {
|
|
|
40894
40846
|
return false;
|
|
40895
40847
|
}
|
|
40896
40848
|
}
|
|
40897
|
-
var DAEMON_VERSION3 = true ? "daemon-0.
|
|
40849
|
+
var DAEMON_VERSION3 = true ? "daemon-0.11.1" : "daemon-dev";
|
|
40898
40850
|
function osFamily() {
|
|
40899
40851
|
const p = platform6();
|
|
40900
40852
|
if (p === "darwin") return "macos";
|