@solaqua/gji 0.12.4 → 0.13.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 +12 -0
- package/dist/application/worktree/catalog.d.ts +31 -0
- package/dist/application/worktree/catalog.js +88 -0
- package/dist/application/worktree/context-card.d.ts +14 -0
- package/dist/application/worktree/context-card.js +12 -0
- package/dist/{go-resolver.d.ts → application/worktree/go-resolution.d.ts} +12 -4
- package/dist/{go-resolver.js → application/worktree/go-resolution.js} +46 -44
- package/dist/application/worktree/read-models.d.ts +31 -0
- package/dist/application/worktree/sources.d.ts +7 -0
- package/dist/{worktree-sources.js → application/worktree/sources.js} +12 -24
- package/dist/{back.d.ts → cli/commands/back.d.ts} +3 -1
- package/dist/{back.js → cli/commands/back.js} +8 -6
- package/dist/{clean.d.ts → cli/commands/clean.d.ts} +4 -2
- package/dist/{clean.js → cli/commands/clean.js} +32 -24
- package/dist/{completion.js → cli/commands/completion.js} +2 -2
- package/dist/{config-command.d.ts → cli/commands/config-command.d.ts} +2 -0
- package/dist/{config-command.js → cli/commands/config-command.js} +7 -5
- package/dist/{doctor.d.ts → cli/commands/doctor.d.ts} +2 -0
- package/dist/{doctor.js → cli/commands/doctor.js} +23 -25
- package/dist/{done.d.ts → cli/commands/done.d.ts} +2 -0
- package/dist/{done.js → cli/commands/done.js} +26 -23
- package/dist/{go.d.ts → cli/commands/go.d.ts} +6 -1
- package/dist/{go.js → cli/commands/go.js} +57 -41
- package/dist/{history-command.d.ts → cli/commands/history-command.d.ts} +2 -0
- package/dist/{history-command.js → cli/commands/history-command.js} +3 -1
- package/dist/{hub.d.ts → cli/commands/hub.d.ts} +7 -3
- package/dist/{hub.js → cli/commands/hub.js} +23 -33
- package/dist/{init.d.ts → cli/commands/init.d.ts} +3 -1
- package/dist/{init.js → cli/commands/init.js} +37 -34
- package/dist/{ls.d.ts → cli/commands/ls.d.ts} +4 -2
- package/dist/{ls.js → cli/commands/ls.js} +8 -5
- package/dist/{new.d.ts → cli/commands/new.d.ts} +6 -2
- package/dist/{new.js → cli/commands/new.js} +237 -109
- package/dist/{open.d.ts → cli/commands/open.d.ts} +4 -2
- package/dist/{open.js → cli/commands/open.js} +19 -12
- package/dist/{pr-open.d.ts → cli/commands/pr-open.d.ts} +4 -2
- package/dist/{pr-open.js → cli/commands/pr-open.js} +20 -18
- package/dist/{pr.d.ts → cli/commands/pr.d.ts} +5 -3
- package/dist/{pr.js → cli/commands/pr.js} +34 -41
- package/dist/{remove.d.ts → cli/commands/remove.d.ts} +4 -2
- package/dist/{remove.js → cli/commands/remove.js} +23 -17
- package/dist/{root.d.ts → cli/commands/root.d.ts} +2 -0
- package/dist/{root.js → cli/commands/root.js} +4 -2
- package/dist/{run-hook.d.ts → cli/commands/run-hook.d.ts} +2 -0
- package/dist/{run-hook.js → cli/commands/run-hook.js} +7 -4
- package/dist/{status.d.ts → cli/commands/status.d.ts} +2 -0
- package/dist/{status.js → cli/commands/status.js} +10 -7
- package/dist/{sync-files-command.d.ts → cli/commands/sync-files-command.d.ts} +2 -0
- package/dist/{sync-files-command.js → cli/commands/sync-files-command.js} +11 -9
- package/dist/{sync.d.ts → cli/commands/sync.d.ts} +2 -0
- package/dist/{sync.js → cli/commands/sync.js} +7 -4
- package/dist/{task-command.d.ts → cli/commands/task-command.d.ts} +2 -0
- package/dist/{task-command.js → cli/commands/task-command.js} +4 -2
- package/dist/{undo.d.ts → cli/commands/undo.d.ts} +8 -6
- package/dist/{undo.js → cli/commands/undo.js} +44 -34
- package/dist/{warp.d.ts → cli/commands/warp.d.ts} +5 -2
- package/dist/{warp.js → cli/commands/warp.js} +20 -10
- package/dist/cli/dependencies.d.ts +114 -0
- package/dist/cli/dependencies.js +118 -0
- package/dist/{cli.d.ts → cli/program.d.ts} +4 -2
- package/dist/{cli.js → cli/program.js} +108 -124
- package/dist/domain/repository/context.d.ts +6 -0
- package/dist/domain/repository/context.js +1 -0
- package/dist/domain/repository/registry.d.ts +5 -0
- package/dist/domain/repository/registry.js +1 -0
- package/dist/domain/shared/concurrency.d.ts +1 -0
- package/dist/domain/shared/concurrency.js +15 -0
- package/dist/domain/worktree/matching.d.ts +4 -0
- package/dist/domain/worktree/matching.js +79 -0
- package/dist/domain/worktree/policy.d.ts +2 -0
- package/dist/domain/worktree/policy.js +58 -0
- package/dist/domain/worktree/pr-reference.d.ts +1 -0
- package/dist/domain/worktree/pr-reference.js +9 -0
- package/dist/{worktree-source.d.ts → domain/worktree/source.d.ts} +1 -1
- package/dist/domain/worktree/source.js +1 -0
- package/dist/domain/worktree/types.d.ts +5 -0
- package/dist/domain/worktree/types.js +1 -0
- package/dist/gji-bundle.mjs +7100 -6265
- package/dist/index.js +3 -3
- package/dist/{dependency-bootstrap.d.ts → infrastructure/bootstrap/dependency-bootstrap.d.ts} +3 -30
- package/dist/{dependency-bootstrap.js → infrastructure/bootstrap/dependency-bootstrap.js} +4 -4
- package/dist/infrastructure/git/health.d.ts +9 -0
- package/dist/infrastructure/git/health.js +44 -0
- package/dist/infrastructure/git/refs.d.ts +6 -0
- package/dist/{git.js → infrastructure/git/refs.js} +1 -51
- package/dist/infrastructure/git/runner.d.ts +2 -0
- package/dist/infrastructure/git/runner.js +16 -0
- package/dist/{editor.d.ts → infrastructure/integrations/editor.d.ts} +2 -6
- package/dist/{pull-requests.d.ts → infrastructure/integrations/pull-requests.d.ts} +3 -11
- package/dist/{config.d.ts → infrastructure/persistence/config.d.ts} +3 -17
- package/dist/{config.js → infrastructure/persistence/config.js} +2 -17
- package/dist/{history.d.ts → infrastructure/persistence/history.d.ts} +2 -5
- package/dist/{task.js → infrastructure/persistence/task.js} +1 -1
- package/dist/infrastructure/process/command-runner.d.ts +3 -0
- package/dist/{hooks.d.ts → infrastructure/process/hooks.d.ts} +2 -12
- package/dist/infrastructure/repository/adapters.d.ts +7 -0
- package/dist/infrastructure/repository/adapters.js +23 -0
- package/dist/infrastructure/repository/context.d.ts +3 -0
- package/dist/infrastructure/repository/context.js +20 -0
- package/dist/infrastructure/repository/refs.d.ts +3 -0
- package/dist/infrastructure/repository/refs.js +37 -0
- package/dist/{repo-registry.d.ts → infrastructure/repository/registry.d.ts} +1 -5
- package/dist/{repo-registry.js → infrastructure/repository/registry.js} +1 -1
- package/dist/infrastructure/repository/worktrees.d.ts +2 -0
- package/dist/infrastructure/repository/worktrees.js +48 -0
- package/dist/{uv-validation.d.ts → infrastructure/validation/uv.d.ts} +1 -1
- package/dist/{uv-validation.js → infrastructure/validation/uv.js} +1 -1
- package/dist/infrastructure/worktree/bootstrap.d.ts +3 -0
- package/dist/{worktree-bootstrap.js → infrastructure/worktree/bootstrap.js} +7 -10
- package/dist/infrastructure/worktree/info.d.ts +6 -0
- package/dist/infrastructure/worktree/info.js +61 -0
- package/dist/{worktree-management.d.ts → infrastructure/worktree/lifecycle.d.ts} +0 -6
- package/dist/{worktree-management.js → infrastructure/worktree/lifecycle.js} +1 -9
- package/dist/ports/bootstrap.d.ts +61 -0
- package/dist/ports/bootstrap.js +1 -0
- package/dist/ports/config.d.ts +21 -0
- package/dist/ports/config.js +17 -0
- package/dist/ports/editor.d.ts +6 -0
- package/dist/ports/editor.js +1 -0
- package/dist/ports/git.d.ts +8 -0
- package/dist/ports/git.js +1 -0
- package/dist/ports/history.d.ts +5 -0
- package/dist/ports/history.js +1 -0
- package/dist/ports/hooks.d.ts +12 -0
- package/dist/ports/hooks.js +1 -0
- package/dist/{command-runner.d.ts → ports/process.d.ts} +0 -1
- package/dist/ports/process.js +1 -0
- package/dist/ports/pull-requests.d.ts +11 -0
- package/dist/ports/pull-requests.js +1 -0
- package/dist/ports/repository.d.ts +17 -0
- package/dist/ports/repository.js +1 -0
- package/dist/{bootstrap-output.d.ts → presentation/bootstrap/output.d.ts} +1 -1
- package/dist/presentation/bootstrap/preview.d.ts +2 -0
- package/dist/{bootstrap-preview.js → presentation/bootstrap/preview.js} +0 -4
- package/dist/{shell-completion.js → presentation/shell/completion.js} +5 -4
- package/dist/presentation/terminal/context-card.d.ts +2 -0
- package/dist/{context-card.js → presentation/terminal/context-card.js} +3 -12
- package/dist/presentation/worktree/format.d.ts +4 -0
- package/dist/presentation/worktree/format.js +41 -0
- package/dist/{worktree-picker.d.ts → presentation/worktree/picker.d.ts} +7 -11
- package/dist/{worktree-picker.js → presentation/worktree/picker.js} +36 -191
- package/man/man1/gji-back.1 +1 -1
- package/man/man1/gji-clean.1 +1 -1
- package/man/man1/gji-completion.1 +1 -1
- package/man/man1/gji-config.1 +1 -1
- package/man/man1/gji-doctor.1 +1 -1
- package/man/man1/gji-done.1 +1 -1
- package/man/man1/gji-go.1 +1 -1
- package/man/man1/gji-history.1 +1 -1
- package/man/man1/gji-init.1 +1 -1
- package/man/man1/gji-ls.1 +1 -1
- package/man/man1/gji-new.1 +6 -3
- package/man/man1/gji-open.1 +1 -1
- package/man/man1/gji-pr.1 +1 -1
- package/man/man1/gji-remove.1 +1 -1
- package/man/man1/gji-root.1 +1 -1
- package/man/man1/gji-run-hook.1 +1 -1
- package/man/man1/gji-status.1 +1 -1
- package/man/man1/gji-sync-files.1 +1 -1
- package/man/man1/gji-sync.1 +1 -1
- package/man/man1/gji-task.1 +1 -1
- package/man/man1/gji-undo.1 +1 -1
- package/man/man1/gji-warp.1 +1 -1
- package/man/man1/gji.1 +2 -2
- package/package.json +1 -1
- package/dist/bootstrap-preview.d.ts +0 -9
- package/dist/context-card.d.ts +0 -1
- package/dist/format-bytes.d.ts +0 -1
- package/dist/format-bytes.js +0 -14
- package/dist/git.d.ts +0 -18
- package/dist/repo.d.ts +0 -20
- package/dist/repo.js +0 -161
- package/dist/worktree-bootstrap.d.ts +0 -24
- package/dist/worktree-info.d.ts +0 -37
- package/dist/worktree-info.js +0 -123
- package/dist/worktree-sources.d.ts +0 -4
- /package/dist/{worktree-source.js → application/worktree/read-models.js} +0 -0
- /package/dist/{completion.d.ts → cli/commands/completion.d.ts} +0 -0
- /package/dist/{headless.d.ts → cli/runtime/headless.d.ts} +0 -0
- /package/dist/{headless.js → cli/runtime/headless.js} +0 -0
- /package/dist/{paths.d.ts → domain/shared/paths.d.ts} +0 -0
- /package/dist/{paths.js → domain/shared/paths.js} +0 -0
- /package/dist/{file-sync.d.ts → infrastructure/filesystem/file-sync.d.ts} +0 -0
- /package/dist/{file-sync.js → infrastructure/filesystem/file-sync.js} +0 -0
- /package/dist/{fs-utils.d.ts → infrastructure/filesystem/fs-utils.d.ts} +0 -0
- /package/dist/{fs-utils.js → infrastructure/filesystem/fs-utils.js} +0 -0
- /package/dist/{safe-destination.d.ts → infrastructure/filesystem/safe-destination.d.ts} +0 -0
- /package/dist/{safe-destination.js → infrastructure/filesystem/safe-destination.js} +0 -0
- /package/dist/{browser.d.ts → infrastructure/integrations/browser.d.ts} +0 -0
- /package/dist/{browser.js → infrastructure/integrations/browser.js} +0 -0
- /package/dist/{editor.js → infrastructure/integrations/editor.js} +0 -0
- /package/dist/{pull-requests.js → infrastructure/integrations/pull-requests.js} +0 -0
- /package/dist/{history.js → infrastructure/persistence/history.js} +0 -0
- /package/dist/{slots.d.ts → infrastructure/persistence/slots.d.ts} +0 -0
- /package/dist/{slots.js → infrastructure/persistence/slots.js} +0 -0
- /package/dist/{task.d.ts → infrastructure/persistence/task.d.ts} +0 -0
- /package/dist/{command-runner.js → infrastructure/process/command-runner.js} +0 -0
- /package/dist/{hooks.js → infrastructure/process/hooks.js} +0 -0
- /package/dist/{bootstrap-output.js → presentation/bootstrap/output.js} +0 -0
- /package/dist/{conflict.d.ts → presentation/prompts/path-conflict.d.ts} +0 -0
- /package/dist/{conflict.js → presentation/prompts/path-conflict.js} +0 -0
- /package/dist/{shell-completion.d.ts → presentation/shell/completion.d.ts} +0 -0
- /package/dist/{shell-handoff.d.ts → presentation/shell/handoff.d.ts} +0 -0
- /package/dist/{shell-handoff.js → presentation/shell/handoff.js} +0 -0
- /package/dist/{shell-setup.d.ts → presentation/shell/setup.d.ts} +0 -0
- /package/dist/{shell-setup.js → presentation/shell/setup.js} +0 -0
- /package/dist/{shell.d.ts → presentation/shell/shell.d.ts} +0 -0
- /package/dist/{shell.js → presentation/shell/shell.js} +0 -0
- /package/dist/{navigation-output.d.ts → presentation/terminal/navigation.d.ts} +0 -0
- /package/dist/{navigation-output.js → presentation/terminal/navigation.js} +0 -0
- /package/dist/{terminal-text.d.ts → presentation/terminal/text.d.ts} +0 -0
- /package/dist/{terminal-text.js → presentation/terminal/text.js} +0 -0
- /package/dist/{worktree-prompts.d.ts → presentation/worktree/prompts.d.ts} +0 -0
- /package/dist/{worktree-prompts.js → presentation/worktree/prompts.js} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export function resolveWorktreeQuery(sources, query) {
|
|
2
|
+
return resolveWorktreeQueryMatches(sources, query)[0] ?? null;
|
|
3
|
+
}
|
|
4
|
+
export function resolveWorktreeQueryMatches(sources, query) {
|
|
5
|
+
const normalizedQuery = normalizeQuery(query);
|
|
6
|
+
if (normalizedQuery === null)
|
|
7
|
+
return [];
|
|
8
|
+
const matches = findWorktreeSourceMatches(sources, normalizedQuery);
|
|
9
|
+
if (isAmbiguousRepoOnlyQuery(matches, normalizedQuery))
|
|
10
|
+
return [];
|
|
11
|
+
const bestScore = matches[0]?.matchScore;
|
|
12
|
+
return matches
|
|
13
|
+
.filter((match) => match.matchScore === bestScore)
|
|
14
|
+
.map((match) => match.source);
|
|
15
|
+
}
|
|
16
|
+
export function resolveExactWorktreeQueryMatches(sources, query) {
|
|
17
|
+
const normalizedQuery = normalizeQuery(query);
|
|
18
|
+
if (normalizedQuery === null)
|
|
19
|
+
return [];
|
|
20
|
+
return sources.filter((source) => scoreWorktreeMatch({
|
|
21
|
+
...source.worktree,
|
|
22
|
+
repoName: source.repoName,
|
|
23
|
+
}, normalizedQuery) === 1000);
|
|
24
|
+
}
|
|
25
|
+
function findWorktreeSourceMatches(sources, normalizedQuery) {
|
|
26
|
+
return sources
|
|
27
|
+
.flatMap((source) => {
|
|
28
|
+
const matchScore = scoreWorktreeMatch({
|
|
29
|
+
...source.worktree,
|
|
30
|
+
repoName: source.repoName,
|
|
31
|
+
}, normalizedQuery);
|
|
32
|
+
return matchScore === null ? [] : [{ matchScore, source }];
|
|
33
|
+
})
|
|
34
|
+
.sort(compareQueryMatches);
|
|
35
|
+
}
|
|
36
|
+
function isAmbiguousRepoOnlyQuery(matches, query) {
|
|
37
|
+
if (matches[0]?.matchScore === 1000)
|
|
38
|
+
return false;
|
|
39
|
+
return (matches.filter((match) => match.source.repoName.toLowerCase() === query)
|
|
40
|
+
.length > 1);
|
|
41
|
+
}
|
|
42
|
+
function compareQueryMatches(a, b) {
|
|
43
|
+
if (a.matchScore !== b.matchScore) {
|
|
44
|
+
return b.matchScore - a.matchScore;
|
|
45
|
+
}
|
|
46
|
+
if (a.source.worktree.isCurrent && !b.source.worktree.isCurrent)
|
|
47
|
+
return -1;
|
|
48
|
+
if (!a.source.worktree.isCurrent && b.source.worktree.isCurrent)
|
|
49
|
+
return 1;
|
|
50
|
+
return (a.source.repoName.localeCompare(b.source.repoName) ||
|
|
51
|
+
(a.source.worktree.branch ?? "").localeCompare(b.source.worktree.branch ?? "") ||
|
|
52
|
+
a.source.worktree.path.localeCompare(b.source.worktree.path));
|
|
53
|
+
}
|
|
54
|
+
function normalizeQuery(query) {
|
|
55
|
+
const normalized = query?.trim().toLowerCase();
|
|
56
|
+
return normalized && normalized.length > 0 ? normalized : null;
|
|
57
|
+
}
|
|
58
|
+
function scoreWorktreeMatch(entry, query) {
|
|
59
|
+
const branch = entry.branch ?? "detached";
|
|
60
|
+
const exactCandidates = [
|
|
61
|
+
branch,
|
|
62
|
+
entry.path,
|
|
63
|
+
`${entry.repoName}/${branch}`,
|
|
64
|
+
].map((candidate) => candidate.toLowerCase());
|
|
65
|
+
if (exactCandidates.includes(query)) {
|
|
66
|
+
return 1000;
|
|
67
|
+
}
|
|
68
|
+
return buildSearchText(entry.repoName, entry).includes(query) ? 1 : null;
|
|
69
|
+
}
|
|
70
|
+
function buildSearchText(repoName, worktree) {
|
|
71
|
+
return [
|
|
72
|
+
repoName,
|
|
73
|
+
worktree.branch ?? "detached",
|
|
74
|
+
worktree.path,
|
|
75
|
+
`${repoName}/${worktree.branch ?? "detached"}`,
|
|
76
|
+
]
|
|
77
|
+
.join(" ")
|
|
78
|
+
.toLowerCase();
|
|
79
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
export function resolveWorktreePath(repoRoot, branch, basePath) {
|
|
4
|
+
const segments = branch.split("/").filter(Boolean);
|
|
5
|
+
if (segments.length === 0) {
|
|
6
|
+
throw new Error("Branch name must not be empty.");
|
|
7
|
+
}
|
|
8
|
+
if (segments.some((segment) => segment === "." || segment === "..")) {
|
|
9
|
+
throw new Error(`Branch name '${branch}' contains an invalid path segment.`);
|
|
10
|
+
}
|
|
11
|
+
const base = basePath
|
|
12
|
+
? expandTildeInPath(basePath)
|
|
13
|
+
: join(dirname(repoRoot), "worktrees", basename(repoRoot));
|
|
14
|
+
return join(base, ...segments);
|
|
15
|
+
}
|
|
16
|
+
export function validateBranchName(name) {
|
|
17
|
+
if (name.length === 0) {
|
|
18
|
+
return "Branch name must not be empty.";
|
|
19
|
+
}
|
|
20
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: intentional control chars to reject in git branch names
|
|
21
|
+
if (/[\x00-\x1f\x7f ~^:?*[\\\s]/.test(name)) {
|
|
22
|
+
return `Branch name '${name}' contains an invalid character.`;
|
|
23
|
+
}
|
|
24
|
+
if (name.startsWith("-")) {
|
|
25
|
+
return `Branch name '${name}' must not start with a dash.`;
|
|
26
|
+
}
|
|
27
|
+
if (name.startsWith("/") || name.endsWith("/") || name.includes("//")) {
|
|
28
|
+
return `Branch name '${name}' has invalid slash placement.`;
|
|
29
|
+
}
|
|
30
|
+
if (name.includes("..")) {
|
|
31
|
+
return `Branch name '${name}' must not contain '..'.`;
|
|
32
|
+
}
|
|
33
|
+
if (name.endsWith(".")) {
|
|
34
|
+
return `Branch name '${name}' must not end with '.'.`;
|
|
35
|
+
}
|
|
36
|
+
if (name.includes("@{")) {
|
|
37
|
+
return `Branch name '${name}' must not contain '@{'.`;
|
|
38
|
+
}
|
|
39
|
+
if (name === "@") {
|
|
40
|
+
return "Branch name cannot be '@'.";
|
|
41
|
+
}
|
|
42
|
+
for (const segment of name.split("/")) {
|
|
43
|
+
if (segment.startsWith(".")) {
|
|
44
|
+
return `Branch name '${name}' contains a path component starting with '.'.`;
|
|
45
|
+
}
|
|
46
|
+
if (segment.endsWith(".lock")) {
|
|
47
|
+
return `Branch name '${name}' contains a path component ending with '.lock'.`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function expandTildeInPath(path) {
|
|
53
|
+
if (path === "~")
|
|
54
|
+
return homedir();
|
|
55
|
+
if (path.startsWith("~/"))
|
|
56
|
+
return join(homedir(), path.slice(2));
|
|
57
|
+
return path;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parsePrInput(input: string): string | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function parsePrInput(input) {
|
|
2
|
+
if (/^\d+$/.test(input))
|
|
3
|
+
return input;
|
|
4
|
+
const hashMatch = input.match(/^#(\d+)$/);
|
|
5
|
+
if (hashMatch)
|
|
6
|
+
return hashMatch[1];
|
|
7
|
+
const urlMatch = input.match(/(?:\/pull|\/pull-requests|\/merge_requests)\/(\d+)/);
|
|
8
|
+
return urlMatch?.[1] ?? null;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|