@super-one/cli 0.68.0-alpha → 0.68.0-alpha.2
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/MANIFEST.json +2 -2
- package/lib/cli.mjs +403 -10
- package/package.json +10 -10
package/MANIFEST.json
CHANGED
package/lib/cli.mjs
CHANGED
|
@@ -11741,11 +11741,11 @@ var init_harness_capabilities = __esm({
|
|
|
11741
11741
|
// Host intercepts `/compact` → `x.ai/compact_conversation`.
|
|
11742
11742
|
supportsCompact: true,
|
|
11743
11743
|
supportsStreamingToolInput: false,
|
|
11744
|
-
// Mid-turn send queues
|
|
11745
|
-
//
|
|
11746
|
-
//
|
|
11744
|
+
// Mid-turn send queues. Steer (`now`) is a new `session/prompt` with
|
|
11745
|
+
// `_meta.sendNow`, which cancels the live turn and runs the message next.
|
|
11746
|
+
// Steer soon is `x.ai/interject`: next safe point, the tool in flight stays.
|
|
11747
11747
|
supportsQueuedSteer: true,
|
|
11748
|
-
supportsQueuedSteerSoon:
|
|
11748
|
+
supportsQueuedSteerSoon: true,
|
|
11749
11749
|
// session/new additionalDirectories, gated per agent capability.
|
|
11750
11750
|
supportsAdditionalDirs: true,
|
|
11751
11751
|
// Cold `x.ai/session/fork` copies Grok session files; SuperOne then resumes the child.
|
|
@@ -13271,7 +13271,9 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
|
|
|
13271
13271
|
...opts.resumeSessionAt ? { resumeSessionAt: opts.resumeSessionAt } : {},
|
|
13272
13272
|
...opts.resumeDropsTurn ? { resumeDropsTurn: opts.resumeDropsTurn } : {},
|
|
13273
13273
|
...env ? { env } : {},
|
|
13274
|
-
|
|
13274
|
+
// Constant: the CLI only defaults the Bash working-tree diff on in auto /
|
|
13275
|
+
// bypassPermissions mode, and the chat renders those edits as file rows.
|
|
13276
|
+
settings: { ...settingsEnv ? { env: settingsEnv } : {}, bashEditDiffEnabled: true }
|
|
13275
13277
|
};
|
|
13276
13278
|
return {
|
|
13277
13279
|
...base,
|
|
@@ -14752,10 +14754,126 @@ var init_capability_prompt_tags = __esm({
|
|
|
14752
14754
|
}
|
|
14753
14755
|
});
|
|
14754
14756
|
|
|
14757
|
+
// ../../packages/shared/src/fuzzy-match.ts
|
|
14758
|
+
function forwardMatchFrom(queryLower, textLower, start) {
|
|
14759
|
+
const indices = [];
|
|
14760
|
+
let qi2 = 0;
|
|
14761
|
+
for (let pi2 = start; pi2 < textLower.length && qi2 < queryLower.length; pi2++) {
|
|
14762
|
+
if (textLower[pi2] === queryLower[qi2]) {
|
|
14763
|
+
indices.push(pi2);
|
|
14764
|
+
qi2++;
|
|
14765
|
+
}
|
|
14766
|
+
}
|
|
14767
|
+
return indices;
|
|
14768
|
+
}
|
|
14769
|
+
function scoreIndices(indices, query, text2) {
|
|
14770
|
+
let score = 0;
|
|
14771
|
+
for (let i = 0; i < indices.length; i++) {
|
|
14772
|
+
const idx = indices[i];
|
|
14773
|
+
if (i > 0 && idx === indices[i - 1] + 1) score += 5;
|
|
14774
|
+
if (text2[idx] === query[i]) score += 1;
|
|
14775
|
+
}
|
|
14776
|
+
if (indices.length > 0 && indices[0] === 0) score += 10;
|
|
14777
|
+
score -= text2.length * 0.1;
|
|
14778
|
+
return score;
|
|
14779
|
+
}
|
|
14780
|
+
function fuzzyMatch(query, text2) {
|
|
14781
|
+
if (!query) return { match: true, score: 0, indices: [] };
|
|
14782
|
+
const queryLower = query.toLowerCase();
|
|
14783
|
+
const textLower = text2.toLowerCase();
|
|
14784
|
+
const fwd = forwardMatchFrom(queryLower, textLower, 0);
|
|
14785
|
+
if (fwd.length < queryLower.length) return { match: false, score: 0, indices: [] };
|
|
14786
|
+
let bestIndices = fwd;
|
|
14787
|
+
let bestScore = scoreIndices(fwd, query, text2);
|
|
14788
|
+
const startPositions = /* @__PURE__ */ new Set();
|
|
14789
|
+
for (let pi2 = 1; pi2 < textLower.length; pi2++) {
|
|
14790
|
+
if (textLower[pi2] === queryLower[0]) startPositions.add(pi2);
|
|
14791
|
+
}
|
|
14792
|
+
for (const start of startPositions) {
|
|
14793
|
+
const candidate = forwardMatchFrom(queryLower, textLower, start);
|
|
14794
|
+
if (candidate.length < queryLower.length) continue;
|
|
14795
|
+
const s4 = scoreIndices(candidate, query, text2);
|
|
14796
|
+
if (s4 > bestScore) {
|
|
14797
|
+
bestScore = s4;
|
|
14798
|
+
bestIndices = candidate;
|
|
14799
|
+
}
|
|
14800
|
+
}
|
|
14801
|
+
return { match: true, score: bestScore, indices: bestIndices };
|
|
14802
|
+
}
|
|
14803
|
+
var init_fuzzy_match = __esm({
|
|
14804
|
+
"../../packages/shared/src/fuzzy-match.ts"() {
|
|
14805
|
+
"use strict";
|
|
14806
|
+
}
|
|
14807
|
+
});
|
|
14808
|
+
|
|
14809
|
+
// ../../packages/shared/src/git-mention-query.ts
|
|
14810
|
+
function gitMentionPortalOf(kind) {
|
|
14811
|
+
return GIT_MENTION_PORTALS.gh.includes(kind) ? "gh" : "git";
|
|
14812
|
+
}
|
|
14813
|
+
function isGitHubRefKind(kind) {
|
|
14814
|
+
return gitMentionPortalOf(kind) === "gh";
|
|
14815
|
+
}
|
|
14816
|
+
function isGitMentionRefKind(value) {
|
|
14817
|
+
return typeof value === "string" && GIT_MENTION_REF_KINDS.includes(value);
|
|
14818
|
+
}
|
|
14819
|
+
function gitRefNameMatches(text2, query) {
|
|
14820
|
+
const q2 = query.trim();
|
|
14821
|
+
if (!q2) return true;
|
|
14822
|
+
return fuzzyMatch(q2, text2).match;
|
|
14823
|
+
}
|
|
14824
|
+
function titledKind(kind) {
|
|
14825
|
+
return kind === "commit" || isGitHubRefKind(kind);
|
|
14826
|
+
}
|
|
14827
|
+
function gitRefMatches(ref, query) {
|
|
14828
|
+
return gitRefNameMatches(titledKind(ref.kind) ? ref.detail : ref.label, query);
|
|
14829
|
+
}
|
|
14830
|
+
var GIT_MENTION_REF_KINDS, GIT_MENTION_PORTALS, GIT_MENTION_KEYWORD, GH_MENTION_KEYWORD, GIT_MENTION_NAV_PREFIX, GH_MENTION_NAV_PREFIX, GIT_HOST_PROVIDERS, GIT_MENTION_REF_LIMIT;
|
|
14831
|
+
var init_git_mention_query = __esm({
|
|
14832
|
+
"../../packages/shared/src/git-mention-query.ts"() {
|
|
14833
|
+
"use strict";
|
|
14834
|
+
init_fuzzy_match();
|
|
14835
|
+
GIT_MENTION_REF_KINDS = ["branch", "commit", "worktree", "tag", "issue", "pr"];
|
|
14836
|
+
GIT_MENTION_PORTALS = {
|
|
14837
|
+
git: ["branch", "commit", "worktree", "tag"],
|
|
14838
|
+
gh: ["issue", "pr"]
|
|
14839
|
+
};
|
|
14840
|
+
GIT_MENTION_KEYWORD = "git";
|
|
14841
|
+
GH_MENTION_KEYWORD = "gh";
|
|
14842
|
+
GIT_MENTION_NAV_PREFIX = `${GIT_MENTION_KEYWORD} `;
|
|
14843
|
+
GH_MENTION_NAV_PREFIX = `${GH_MENTION_KEYWORD} `;
|
|
14844
|
+
GIT_HOST_PROVIDERS = ["github"];
|
|
14845
|
+
GIT_MENTION_REF_LIMIT = 50;
|
|
14846
|
+
}
|
|
14847
|
+
});
|
|
14848
|
+
|
|
14849
|
+
// ../../packages/shared/src/git-mention-tags.ts
|
|
14850
|
+
function unescapeGitTagText(value) {
|
|
14851
|
+
return value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
14852
|
+
}
|
|
14853
|
+
function gitTagDisplayName(name) {
|
|
14854
|
+
return unescapeGitTagText(name).trim();
|
|
14855
|
+
}
|
|
14856
|
+
function replaceGitTagsWithMention(text2) {
|
|
14857
|
+
return text2.replace(GIT_TAG_REGEX, (_full, _kind, name) => `@${gitTagDisplayName(String(name))}`).replace(GIT_HOST_TAG_REGEX, (_full, _host, _kind, name) => `@${gitTagDisplayName(String(name))}`);
|
|
14858
|
+
}
|
|
14859
|
+
var INNER, GIT_TAG_REGEX, GIT_HOST_TAG_REGEX;
|
|
14860
|
+
var init_git_mention_tags = __esm({
|
|
14861
|
+
"../../packages/shared/src/git-mention-tags.ts"() {
|
|
14862
|
+
"use strict";
|
|
14863
|
+
init_git_mention_query();
|
|
14864
|
+
INNER = "\\s*<kind>([\\s\\S]*?)<\\/kind>\\s*<name>([\\s\\S]*?)<\\/name>\\s*<id>([\\s\\S]*?)<\\/id>\\s*";
|
|
14865
|
+
GIT_TAG_REGEX = new RegExp(`<superone-git>${INNER}<\\/superone-git>`, "g");
|
|
14866
|
+
GIT_HOST_TAG_REGEX = new RegExp(
|
|
14867
|
+
`<superone-(${GIT_HOST_PROVIDERS.join("|")})>${INNER}<\\/superone-\\1>`,
|
|
14868
|
+
"g"
|
|
14869
|
+
);
|
|
14870
|
+
}
|
|
14871
|
+
});
|
|
14872
|
+
|
|
14755
14873
|
// ../../packages/shared/src/miniapp-prompt-tags.ts
|
|
14756
14874
|
function stripMiniAppMarkup(text2) {
|
|
14757
14875
|
return stripCapabilityMarkup(
|
|
14758
|
-
text2.replace(MINIAPP_REMINDER_REGEX, "").replace(SESSION_REMINDER_REGEX, "").replace(DESKTOP_APP_REMINDER_REGEX, "").replace(MINIAPP_TAG_REGEX, (_3, appName) => `@${String(appName).trim()}`).replace(SESSION_TAG_REGEX, (_3, title) => `@${String(title).trim()}`).replace(DESKTOP_APP_TAG_REGEX, (_3, name) => `@${String(name).trim()}`).replace(PATH_REF_TAG_REGEX, (_full, _kind, name, value) => {
|
|
14876
|
+
replaceGitTagsWithMention(text2).replace(MINIAPP_REMINDER_REGEX, "").replace(SESSION_REMINDER_REGEX, "").replace(DESKTOP_APP_REMINDER_REGEX, "").replace(MINIAPP_TAG_REGEX, (_3, appName) => `@${String(appName).trim()}`).replace(SESSION_TAG_REGEX, (_3, title) => `@${String(title).trim()}`).replace(DESKTOP_APP_TAG_REGEX, (_3, name) => `@${String(name).trim()}`).replace(PATH_REF_TAG_REGEX, (_full, _kind, name, value) => {
|
|
14759
14877
|
const n = String(name).trim();
|
|
14760
14878
|
const v3 = String(value).trim();
|
|
14761
14879
|
return `@${n || v3}`;
|
|
@@ -14768,6 +14886,7 @@ var init_miniapp_prompt_tags = __esm({
|
|
|
14768
14886
|
"use strict";
|
|
14769
14887
|
init_miniapp_mention_marker();
|
|
14770
14888
|
init_capability_prompt_tags();
|
|
14889
|
+
init_git_mention_tags();
|
|
14771
14890
|
MINIAPP_TAG_REGEX = /<superone-miniapp>\s*<appname>([\s\S]*?)<\/appname>\s*<appid>([\s\S]*?)<\/appid>\s*<\/superone-miniapp>/g;
|
|
14772
14891
|
MINIAPP_REMINDER_REGEX = /\n*<superone-miniapp-reminder>[\s\S]*?<\/superone-miniapp-reminder>\n*/g;
|
|
14773
14892
|
SESSION_TAG_REGEX = /<superone-session>\s*<title>([\s\S]*?)<\/title>\s*<sessionId>([\s\S]*?)<\/sessionId>\s*<\/superone-session>/g;
|
|
@@ -73284,8 +73403,8 @@ import { fileURLToPath } from "node:url";
|
|
|
73284
73403
|
function resolveCliReleaseVersion() {
|
|
73285
73404
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
73286
73405
|
if (fromEnv) return fromEnv;
|
|
73287
|
-
if ("0.68.0-alpha".trim()) {
|
|
73288
|
-
return "0.68.0-alpha".trim();
|
|
73406
|
+
if ("0.68.0-alpha.2".trim()) {
|
|
73407
|
+
return "0.68.0-alpha.2".trim();
|
|
73289
73408
|
}
|
|
73290
73409
|
const fromDist = readDistManifestVersion();
|
|
73291
73410
|
if (fromDist) return fromDist;
|
|
@@ -75384,6 +75503,7 @@ async function cloneRepository(input) {
|
|
|
75384
75503
|
}
|
|
75385
75504
|
|
|
75386
75505
|
// src/rpc/handlers.ts
|
|
75506
|
+
init_git_mention_query();
|
|
75387
75507
|
import { existsSync as existsSync26, mkdirSync as mkdirSync15, readdirSync as readdirSync9, statSync as statSync6 } from "node:fs";
|
|
75388
75508
|
import { join as pathJoin, resolve as pathResolve } from "node:path";
|
|
75389
75509
|
import { arch, cpus, freemem, homedir as homedir7, hostname as hostname4, platform, totalmem, uptime } from "node:os";
|
|
@@ -77802,6 +77922,10 @@ async function dispatchRpcInner(method, payload, ctx) {
|
|
|
77802
77922
|
return handleGitCreateBranch(payload, ctx);
|
|
77803
77923
|
case "git.worktrees":
|
|
77804
77924
|
return handleGitWorktrees(payload, ctx);
|
|
77925
|
+
case "git.mentionRefs":
|
|
77926
|
+
return handleGitMentionRefs(payload, ctx);
|
|
77927
|
+
case "git.mentionCapabilities":
|
|
77928
|
+
return handleGitMentionCapabilities(payload, ctx);
|
|
77805
77929
|
case "git.worktreeActivate":
|
|
77806
77930
|
return handleGitWorktreeActivate(payload, ctx);
|
|
77807
77931
|
case "git.worktreeCheckedOutBranches":
|
|
@@ -78855,6 +78979,41 @@ function handleGitCreateBranch(payload, ctx) {
|
|
|
78855
78979
|
return mapThrown8(err);
|
|
78856
78980
|
}
|
|
78857
78981
|
}
|
|
78982
|
+
async function handleGitMentionCapabilities(payload, ctx) {
|
|
78983
|
+
const denied = requireScopes8(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
78984
|
+
if (denied) return denied;
|
|
78985
|
+
const p3 = asRecord24(payload);
|
|
78986
|
+
try {
|
|
78987
|
+
return {
|
|
78988
|
+
result: await ctx.workspaceGit.mentionCapabilities(
|
|
78989
|
+
String(p3.projectId ?? ""),
|
|
78990
|
+
typeof p3.cwd === "string" ? p3.cwd : null
|
|
78991
|
+
)
|
|
78992
|
+
};
|
|
78993
|
+
} catch (err) {
|
|
78994
|
+
return mapThrown8(err);
|
|
78995
|
+
}
|
|
78996
|
+
}
|
|
78997
|
+
async function handleGitMentionRefs(payload, ctx) {
|
|
78998
|
+
const denied = requireScopes8(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
78999
|
+
if (denied) return denied;
|
|
79000
|
+
const p3 = asRecord24(payload);
|
|
79001
|
+
if (!isGitMentionRefKind(p3.kind)) {
|
|
79002
|
+
return { error: { code: "invalid_argument", message: "kind must be branch | commit | worktree | tag | issue | pr" } };
|
|
79003
|
+
}
|
|
79004
|
+
try {
|
|
79005
|
+
return {
|
|
79006
|
+
result: await ctx.workspaceGit.mentionRefs(
|
|
79007
|
+
String(p3.projectId ?? ""),
|
|
79008
|
+
p3.kind,
|
|
79009
|
+
typeof p3.query === "string" ? p3.query : "",
|
|
79010
|
+
typeof p3.cwd === "string" ? p3.cwd : null
|
|
79011
|
+
)
|
|
79012
|
+
};
|
|
79013
|
+
} catch (err) {
|
|
79014
|
+
return mapThrown8(err);
|
|
79015
|
+
}
|
|
79016
|
+
}
|
|
78858
79017
|
function handleGitWorktrees(payload, ctx) {
|
|
78859
79018
|
const denied = requireScopes8(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
78860
79019
|
if (denied) return denied;
|
|
@@ -80778,8 +80937,8 @@ function requiredRuntimeVersion(harnessId, manifest) {
|
|
|
80778
80937
|
import { existsSync as existsSync29, mkdirSync as mkdirSync18, readFileSync as readFileSync17, readdirSync as readdirSync11, statSync as statSync9, writeFileSync as writeFileSync13 } from "node:fs";
|
|
80779
80938
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
80780
80939
|
import { join as join29, resolve as resolve8 } from "node:path";
|
|
80781
|
-
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.
|
|
80782
|
-
var OFFICIAL_CODEX_NPM_VERSION = "0.
|
|
80940
|
+
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.280";
|
|
80941
|
+
var OFFICIAL_CODEX_NPM_VERSION = "0.155.1";
|
|
80783
80942
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
80784
80943
|
function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
80785
80944
|
const platform2 = process.platform;
|
|
@@ -85970,6 +86129,10 @@ function gitErrorMessage(err) {
|
|
|
85970
86129
|
if (stderr) return stderr;
|
|
85971
86130
|
return err?.message ?? "Unknown git error";
|
|
85972
86131
|
}
|
|
86132
|
+
var NOT_A_REPO_RE = /not a git repository/i;
|
|
86133
|
+
function isNotGitRepoError(err) {
|
|
86134
|
+
return NOT_A_REPO_RE.test(gitErrorMessage(err));
|
|
86135
|
+
}
|
|
85973
86136
|
|
|
85974
86137
|
// ../../packages/runtime/src/git/shortstat.ts
|
|
85975
86138
|
function parseShortstat(shortstat) {
|
|
@@ -86028,6 +86191,220 @@ function gitRunSync(folderPath, args, env) {
|
|
|
86028
86191
|
}
|
|
86029
86192
|
}
|
|
86030
86193
|
|
|
86194
|
+
// ../../packages/runtime/src/git/mention-refs.ts
|
|
86195
|
+
init_git_mention_query();
|
|
86196
|
+
|
|
86197
|
+
// ../../packages/runtime/src/git/gh-run.ts
|
|
86198
|
+
init_spawn_env();
|
|
86199
|
+
import { execFile as execFile4 } from "child_process";
|
|
86200
|
+
var GH_MAX_BUFFER = 16 * 1024 * 1024;
|
|
86201
|
+
function isGhMissingError(err) {
|
|
86202
|
+
return err?.code === "ENOENT";
|
|
86203
|
+
}
|
|
86204
|
+
function ghRun(folderPath, args, timeoutMs, env) {
|
|
86205
|
+
return new Promise((resolve17, reject) => {
|
|
86206
|
+
execFile4(
|
|
86207
|
+
"gh",
|
|
86208
|
+
args,
|
|
86209
|
+
{
|
|
86210
|
+
cwd: folderPath,
|
|
86211
|
+
env: { ...env ? buildSafeEnv(env) : process.env, GH_PROMPT_DISABLED: "1", GH_NO_UPDATE_NOTIFIER: "1" },
|
|
86212
|
+
maxBuffer: GH_MAX_BUFFER,
|
|
86213
|
+
timeout: timeoutMs
|
|
86214
|
+
},
|
|
86215
|
+
(err, stdout, stderr) => {
|
|
86216
|
+
if (err) {
|
|
86217
|
+
const annotated = err;
|
|
86218
|
+
if (stderr && !annotated.stderr) annotated.stderr = String(stderr);
|
|
86219
|
+
annotated.ghArgs = args;
|
|
86220
|
+
reject(annotated);
|
|
86221
|
+
} else {
|
|
86222
|
+
resolve17(stdout.trimEnd());
|
|
86223
|
+
}
|
|
86224
|
+
}
|
|
86225
|
+
);
|
|
86226
|
+
});
|
|
86227
|
+
}
|
|
86228
|
+
|
|
86229
|
+
// ../../packages/runtime/src/git/mention-refs.ts
|
|
86230
|
+
var REF_SCAN_LIMIT = 500;
|
|
86231
|
+
var COMMIT_SCAN_LIMIT = 500;
|
|
86232
|
+
var REF_FORMAT = ["%(refname:short)", "%(objectname)", "%(subject)", "%(committerdate:iso-strict)", "%(HEAD)"].join("%00");
|
|
86233
|
+
var TAG_FORMAT = ["%(refname:short)", "%(objectname)", "%(subject)", "%(creatordate:iso-strict)"].join("%00");
|
|
86234
|
+
var LOG_FORMAT = ["%H", "%s", "%an", "%aI"].join("%x00");
|
|
86235
|
+
var HEX_PREFIX_RE = /^[0-9a-f]{4,40}$/i;
|
|
86236
|
+
var ISSUE_NUMBER_RE = /^#?(\d+)$/;
|
|
86237
|
+
var GH_ITEM_FIELDS = "number,title,state,author,updatedAt";
|
|
86238
|
+
var GH_PR_FIELDS = `${GH_ITEM_FIELDS},isDraft`;
|
|
86239
|
+
async function listGitMentionRefs(kind, query, runners, limit = GIT_MENTION_REF_LIMIT) {
|
|
86240
|
+
const { git: git2, gh } = typeof runners === "function" ? { git: runners } : runners;
|
|
86241
|
+
const needle = query.trim();
|
|
86242
|
+
if (isGitHubRefKind(kind)) {
|
|
86243
|
+
if (!gh) return { ok: false, reason: "gh-unavailable" };
|
|
86244
|
+
try {
|
|
86245
|
+
return { ok: true, refs: (await listGitHubItems(kind, needle, gh)).slice(0, limit) };
|
|
86246
|
+
} catch (err) {
|
|
86247
|
+
if (isGhMissingError(err)) return { ok: false, reason: "gh-unavailable" };
|
|
86248
|
+
return { ok: false, reason: "error", error: ghErrorMessage(err) };
|
|
86249
|
+
}
|
|
86250
|
+
}
|
|
86251
|
+
try {
|
|
86252
|
+
const refs = await listRefs(kind, needle, git2);
|
|
86253
|
+
return { ok: true, refs: refs.slice(0, limit) };
|
|
86254
|
+
} catch (err) {
|
|
86255
|
+
if (isNotGitRepoError(err)) return { ok: false, reason: "not-repo" };
|
|
86256
|
+
return { ok: false, reason: "error", error: err.message };
|
|
86257
|
+
}
|
|
86258
|
+
}
|
|
86259
|
+
async function probeGitMentionCapabilities(runners) {
|
|
86260
|
+
let repo = "ready";
|
|
86261
|
+
try {
|
|
86262
|
+
await runners.git(["rev-parse", "--git-dir"]);
|
|
86263
|
+
} catch {
|
|
86264
|
+
repo = "not-repo";
|
|
86265
|
+
}
|
|
86266
|
+
if (repo !== "ready" || !runners.gh) return { repo, github: false };
|
|
86267
|
+
try {
|
|
86268
|
+
await runners.gh(["repo", "view", "--json", "nameWithOwner"]);
|
|
86269
|
+
return { repo, github: true };
|
|
86270
|
+
} catch {
|
|
86271
|
+
return { repo, github: false };
|
|
86272
|
+
}
|
|
86273
|
+
}
|
|
86274
|
+
function ghErrorMessage(err) {
|
|
86275
|
+
const e = err;
|
|
86276
|
+
const stderr = e.stderr?.trim();
|
|
86277
|
+
return stderr ? stderr.split("\n")[0] : e.message ?? "gh failed";
|
|
86278
|
+
}
|
|
86279
|
+
async function listRefs(kind, needle, run) {
|
|
86280
|
+
switch (kind) {
|
|
86281
|
+
case "branch":
|
|
86282
|
+
return listBranches(needle, run);
|
|
86283
|
+
case "tag":
|
|
86284
|
+
return listTags(needle, run);
|
|
86285
|
+
case "commit":
|
|
86286
|
+
return listCommits(needle, run);
|
|
86287
|
+
case "worktree":
|
|
86288
|
+
return listWorktrees(needle, run);
|
|
86289
|
+
case "issue":
|
|
86290
|
+
case "pr":
|
|
86291
|
+
throw new Error(`${kind} is a GitHub kind`);
|
|
86292
|
+
}
|
|
86293
|
+
}
|
|
86294
|
+
function ghItemState(item) {
|
|
86295
|
+
if (item.isDraft) return "draft";
|
|
86296
|
+
const s4 = item.state.toLowerCase();
|
|
86297
|
+
return s4 === "merged" ? "merged" : s4 === "closed" ? "closed" : "open";
|
|
86298
|
+
}
|
|
86299
|
+
function parseGhItems(kind, raw) {
|
|
86300
|
+
const items = JSON.parse(raw || "[]");
|
|
86301
|
+
return (Array.isArray(items) ? items : [items]).map((item) => ({
|
|
86302
|
+
kind,
|
|
86303
|
+
id: String(item.number),
|
|
86304
|
+
label: `#${item.number}`,
|
|
86305
|
+
detail: item.title ?? "",
|
|
86306
|
+
date: item.updatedAt,
|
|
86307
|
+
author: item.author?.login,
|
|
86308
|
+
state: ghItemState(item),
|
|
86309
|
+
host: "github"
|
|
86310
|
+
}));
|
|
86311
|
+
}
|
|
86312
|
+
async function listGitHubItems(kind, needle, gh) {
|
|
86313
|
+
const fields = kind === "pr" ? GH_PR_FIELDS : GH_ITEM_FIELDS;
|
|
86314
|
+
const list = (extra) => gh([kind, "list", "--limit", String(GIT_MENTION_REF_LIMIT), "--json", fields, ...extra]);
|
|
86315
|
+
if (!needle) return parseGhItems(kind, await list(["--state", "open"]));
|
|
86316
|
+
const searched = parseGhItems(kind, await list(["--state", "all", "--search", needle]));
|
|
86317
|
+
const number4 = ISSUE_NUMBER_RE.exec(needle)?.[1];
|
|
86318
|
+
if (!number4) return searched;
|
|
86319
|
+
let exact = [];
|
|
86320
|
+
try {
|
|
86321
|
+
exact = parseGhItems(kind, await gh([kind, "view", number4, "--json", fields]));
|
|
86322
|
+
} catch {
|
|
86323
|
+
}
|
|
86324
|
+
const seen = new Set(exact.map((r) => r.id));
|
|
86325
|
+
return [...exact, ...searched.filter((r) => !seen.has(r.id))];
|
|
86326
|
+
}
|
|
86327
|
+
async function listBranches(needle, run) {
|
|
86328
|
+
const raw = await run([
|
|
86329
|
+
"for-each-ref",
|
|
86330
|
+
"refs/heads",
|
|
86331
|
+
"--sort=-committerdate",
|
|
86332
|
+
`--count=${REF_SCAN_LIMIT}`,
|
|
86333
|
+
`--format=${REF_FORMAT}`
|
|
86334
|
+
]);
|
|
86335
|
+
const refs = [];
|
|
86336
|
+
for (const line of raw.split("\n")) {
|
|
86337
|
+
if (!line) continue;
|
|
86338
|
+
const [name = "", , subject = "", date5 = "", head = ""] = line.split("\0");
|
|
86339
|
+
const ref = { kind: "branch", id: name, label: name, detail: subject, date: date5, current: head === "*" };
|
|
86340
|
+
if (gitRefMatches(ref, needle)) refs.push(ref);
|
|
86341
|
+
}
|
|
86342
|
+
refs.sort((a, b3) => Number(b3.current === true) - Number(a.current === true));
|
|
86343
|
+
return refs;
|
|
86344
|
+
}
|
|
86345
|
+
async function listTags(needle, run) {
|
|
86346
|
+
const raw = await run([
|
|
86347
|
+
"for-each-ref",
|
|
86348
|
+
"refs/tags",
|
|
86349
|
+
"--sort=-creatordate",
|
|
86350
|
+
`--count=${REF_SCAN_LIMIT}`,
|
|
86351
|
+
`--format=${TAG_FORMAT}`
|
|
86352
|
+
]);
|
|
86353
|
+
const refs = [];
|
|
86354
|
+
for (const line of raw.split("\n")) {
|
|
86355
|
+
if (!line) continue;
|
|
86356
|
+
const [name = "", , subject = "", date5 = ""] = line.split("\0");
|
|
86357
|
+
const ref = { kind: "tag", id: name, label: name, detail: subject, date: date5 };
|
|
86358
|
+
if (gitRefMatches(ref, needle)) refs.push(ref);
|
|
86359
|
+
}
|
|
86360
|
+
return refs;
|
|
86361
|
+
}
|
|
86362
|
+
function parseLog(raw) {
|
|
86363
|
+
const refs = [];
|
|
86364
|
+
for (const line of raw.split("\n")) {
|
|
86365
|
+
if (!line) continue;
|
|
86366
|
+
const [sha = "", subject = "", author = "", date5 = ""] = line.split("\0");
|
|
86367
|
+
if (!sha) continue;
|
|
86368
|
+
refs.push({ kind: "commit", id: sha, label: sha.slice(0, 7), detail: subject, date: date5, author });
|
|
86369
|
+
}
|
|
86370
|
+
return refs;
|
|
86371
|
+
}
|
|
86372
|
+
async function listCommits(needle, run) {
|
|
86373
|
+
if (!needle) return parseLog(await run(["log", `-n${GIT_MENTION_REF_LIMIT}`, `--format=${LOG_FORMAT}`]));
|
|
86374
|
+
const recent = parseLog(await run(["log", `-n${COMMIT_SCAN_LIMIT}`, `--format=${LOG_FORMAT}`]));
|
|
86375
|
+
const byMessage = recent.filter((r) => gitRefMatches(r, needle)).slice(0, GIT_MENTION_REF_LIMIT);
|
|
86376
|
+
if (!HEX_PREFIX_RE.test(needle)) return byMessage;
|
|
86377
|
+
let bySha = [];
|
|
86378
|
+
try {
|
|
86379
|
+
bySha = parseLog(await run(["log", "-n1", `--format=${LOG_FORMAT}`, needle, "--"]));
|
|
86380
|
+
} catch {
|
|
86381
|
+
}
|
|
86382
|
+
const seen = new Set(bySha.map((r) => r.id));
|
|
86383
|
+
return [...bySha, ...byMessage.filter((r) => !seen.has(r.id))];
|
|
86384
|
+
}
|
|
86385
|
+
async function listWorktrees(needle, run) {
|
|
86386
|
+
const [raw, toplevel] = await Promise.all([
|
|
86387
|
+
run(["worktree", "list", "--porcelain"]),
|
|
86388
|
+
run(["rev-parse", "--show-toplevel"]).catch(() => "")
|
|
86389
|
+
]);
|
|
86390
|
+
const here = toplevel.trim().replace(/[\\/]+$/, "");
|
|
86391
|
+
const refs = [];
|
|
86392
|
+
for (const wt2 of parseWorktreePorcelain(raw)) {
|
|
86393
|
+
if (wt2.bare) continue;
|
|
86394
|
+
const label = wt2.branch ?? (wt2.head ? `detached @ ${wt2.head.slice(0, 7)}` : wt2.path);
|
|
86395
|
+
const ref = {
|
|
86396
|
+
kind: "worktree",
|
|
86397
|
+
id: wt2.path,
|
|
86398
|
+
label,
|
|
86399
|
+
detail: wt2.path,
|
|
86400
|
+
current: !!here && wt2.path.replace(/[\\/]+$/, "") === here
|
|
86401
|
+
};
|
|
86402
|
+
if (gitRefMatches(ref, needle)) refs.push(ref);
|
|
86403
|
+
}
|
|
86404
|
+
refs.sort((a, b3) => Number(b3.current === true) - Number(a.current === true));
|
|
86405
|
+
return refs;
|
|
86406
|
+
}
|
|
86407
|
+
|
|
86031
86408
|
// ../../packages/runtime/src/git/worktree-plan.ts
|
|
86032
86409
|
import { basename as basename3, dirname as dirname17, join as join32, resolve as resolve12, sep as sep4 } from "node:path";
|
|
86033
86410
|
import { homedir as homedir8 } from "node:os";
|
|
@@ -86074,6 +86451,7 @@ function parseNumstat(numstat) {
|
|
|
86074
86451
|
}
|
|
86075
86452
|
|
|
86076
86453
|
// src/workspace/git-service.ts
|
|
86454
|
+
var GH_TIMEOUT_MS = 15e3;
|
|
86077
86455
|
function git(cwd, args, env) {
|
|
86078
86456
|
return gitRunSync(cwd, args, env);
|
|
86079
86457
|
}
|
|
@@ -86216,6 +86594,21 @@ var WorkspaceGitService = class {
|
|
|
86216
86594
|
return { ok: false, error: gitErrorMessage(err) };
|
|
86217
86595
|
}
|
|
86218
86596
|
}
|
|
86597
|
+
/** `@git` / `@gh` popup rows; `absolutePath` narrows to a linked worktree of the project. */
|
|
86598
|
+
mentionRefs(projectId, kind, query, absolutePath) {
|
|
86599
|
+
return listGitMentionRefs(kind, query, this.mentionRunners(projectId, absolutePath));
|
|
86600
|
+
}
|
|
86601
|
+
/** What the `@git` / `@gh` portals may offer for the project (or one of its worktrees). */
|
|
86602
|
+
mentionCapabilities(projectId, absolutePath) {
|
|
86603
|
+
return probeGitMentionCapabilities(this.mentionRunners(projectId, absolutePath));
|
|
86604
|
+
}
|
|
86605
|
+
mentionRunners(projectId, absolutePath) {
|
|
86606
|
+
const cwd = absolutePath ? this.assertRepoWorktreePath(projectId, absolutePath) : this.root(projectId);
|
|
86607
|
+
return {
|
|
86608
|
+
git: async (args) => gitRunSync(cwd, args),
|
|
86609
|
+
gh: (args) => ghRun(cwd, args, GH_TIMEOUT_MS)
|
|
86610
|
+
};
|
|
86611
|
+
}
|
|
86219
86612
|
worktrees(projectId) {
|
|
86220
86613
|
const cwd = this.root(projectId);
|
|
86221
86614
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-one/cli",
|
|
3
|
-
"version": "0.68.0-alpha",
|
|
3
|
+
"version": "0.68.0-alpha.2",
|
|
4
4
|
"description": "SuperOne headless node CLI — remote execution environment (RPC, workspaces, sessions).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"directory": "apps/cli"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
28
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.280",
|
|
29
29
|
"@cursor/sdk": "1.0.30",
|
|
30
30
|
"better-sqlite3": "^13.0.1",
|
|
31
31
|
"node-pty": "^1.0.0"
|
|
32
32
|
},
|
|
33
33
|
"optionalDependencies": {
|
|
34
|
-
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.
|
|
35
|
-
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.
|
|
36
|
-
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.
|
|
37
|
-
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.
|
|
38
|
-
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.
|
|
39
|
-
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.
|
|
40
|
-
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.
|
|
41
|
-
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.
|
|
34
|
+
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.280",
|
|
35
|
+
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.280",
|
|
36
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.280",
|
|
37
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.280",
|
|
38
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.280",
|
|
39
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.280",
|
|
40
|
+
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.280",
|
|
41
|
+
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.280",
|
|
42
42
|
"@cursor/sdk-darwin-arm64": "1.0.30",
|
|
43
43
|
"@cursor/sdk-darwin-x64": "1.0.30",
|
|
44
44
|
"@cursor/sdk-linux-arm64": "1.0.30",
|