tabctl 0.1.0 → 0.2.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/{cli → dist/cli}/lib/commands/index.js +4 -2
- package/dist/cli/lib/commands/meta.js +226 -0
- package/dist/cli/lib/commands/params-groups.js +40 -0
- package/dist/cli/lib/commands/params-move.js +44 -0
- package/{cli → dist/cli}/lib/commands/params.js +61 -125
- package/{cli/lib/commands/meta.js → dist/cli/lib/commands/setup.js} +26 -222
- package/{cli/lib/options.js → dist/cli/lib/options-commands.js} +3 -155
- package/dist/cli/lib/options-groups.js +41 -0
- package/dist/cli/lib/options.js +125 -0
- package/{cli → dist/cli}/lib/output.js +2 -1
- package/dist/cli/lib/policy-filter.js +202 -0
- package/dist/cli/lib/response.js +235 -0
- package/{cli → dist/cli}/lib/scope.js +3 -31
- package/dist/cli/tabctl.js +463 -0
- package/dist/extension/background.js +3398 -0
- package/dist/extension/lib/archive.js +444 -0
- package/dist/extension/lib/content.js +320 -0
- package/dist/extension/lib/deps.js +4 -0
- package/dist/extension/lib/groups.js +443 -0
- package/dist/extension/lib/inspect.js +316 -0
- package/dist/extension/lib/move.js +342 -0
- package/dist/extension/lib/screenshot.js +367 -0
- package/dist/extension/lib/tabs.js +395 -0
- package/dist/extension/lib/undo-handlers.js +439 -0
- package/{extension/manifest.template.json → dist/extension/manifest.json} +3 -2
- package/dist/host/host.js +124 -0
- package/{host/host.js → dist/host/lib/handlers.js} +84 -187
- package/{shared → dist/shared}/version.js +4 -4
- package/package.json +12 -10
- package/cli/tabctl.js +0 -841
- package/extension/background.js +0 -3372
- package/extension/manifest.json +0 -23
- /package/{cli → dist/cli}/lib/args.js +0 -0
- /package/{cli → dist/cli}/lib/client.js +0 -0
- /package/{cli → dist/cli}/lib/commands/list.js +0 -0
- /package/{cli → dist/cli}/lib/commands/profile.js +0 -0
- /package/{cli → dist/cli}/lib/constants.js +0 -0
- /package/{cli → dist/cli}/lib/help.js +0 -0
- /package/{cli → dist/cli}/lib/pagination.js +0 -0
- /package/{cli → dist/cli}/lib/policy.js +0 -0
- /package/{cli → dist/cli}/lib/report.js +0 -0
- /package/{cli → dist/cli}/lib/snapshot.js +0 -0
- /package/{cli → dist/cli}/lib/types.js +0 -0
- /package/{host → dist/host}/host.sh +0 -0
- /package/{host → dist/host}/lib/undo.js +0 -0
- /package/{shared → dist/shared}/config.js +0 -0
- /package/{shared → dist/shared}/extension-sync.js +0 -0
- /package/{shared → dist/shared}/profiles.js +0 -0
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.buildUndoParams = exports.buildHistoryParams = exports.buildScreenshotParams = exports.buildReportParams = exports.buildCloseParams = exports.buildArchiveParams = exports.buildMergeWindowParams = exports.buildMoveGroupParams = exports.buildMoveTabParams = exports.buildGroupAssignParams = exports.buildGroupUngroupParams = exports.buildGroupUpdateParams = exports.buildOpenParams = exports.buildRefreshParams = exports.buildFocusParams = exports.buildInspectParams = exports.buildAnalyzeParams = exports.runProfileRemove = exports.runProfileSwitch = exports.runProfileShow = exports.runProfileList = exports.runGroupList = exports.runList = exports.runPing = exports.runUndo = exports.runHistory = exports.runPolicy = exports.runVersion = exports.runSkillInstall = exports.runSetup = void 0;
|
|
8
|
-
//
|
|
8
|
+
// Setup command
|
|
9
|
+
var setup_1 = require("./setup");
|
|
10
|
+
Object.defineProperty(exports, "runSetup", { enumerable: true, get: function () { return setup_1.runSetup; } });
|
|
11
|
+
// Meta commands (version, ping, skill, policy, history, undo)
|
|
9
12
|
var meta_1 = require("./meta");
|
|
10
|
-
Object.defineProperty(exports, "runSetup", { enumerable: true, get: function () { return meta_1.runSetup; } });
|
|
11
13
|
Object.defineProperty(exports, "runSkillInstall", { enumerable: true, get: function () { return meta_1.runSkillInstall; } });
|
|
12
14
|
Object.defineProperty(exports, "runVersion", { enumerable: true, get: function () { return meta_1.runVersion; } });
|
|
13
15
|
Object.defineProperty(exports, "runPolicy", { enumerable: true, get: function () { return meta_1.runPolicy; } });
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Meta command handlers: version, ping, skill, policy, history, undo
|
|
4
|
+
* These commands don't operate on tab data and are relatively self-contained.
|
|
5
|
+
* Setup command is in ./setup.ts.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.runSetup = void 0;
|
|
12
|
+
exports.runSkillInstall = runSkillInstall;
|
|
13
|
+
exports.runVersion = runVersion;
|
|
14
|
+
exports.runPolicy = runPolicy;
|
|
15
|
+
exports.runHistory = runHistory;
|
|
16
|
+
exports.runUndo = runUndo;
|
|
17
|
+
exports.runPing = runPing;
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const os_1 = __importDefault(require("os"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const node_child_process_1 = require("node:child_process");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
23
|
+
const output_1 = require("../output");
|
|
24
|
+
const client_1 = require("../client");
|
|
25
|
+
const policy_1 = require("../policy");
|
|
26
|
+
const scope_1 = require("../scope");
|
|
27
|
+
var setup_1 = require("./setup");
|
|
28
|
+
Object.defineProperty(exports, "runSetup", { enumerable: true, get: function () { return setup_1.runSetup; } });
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Skill Command
|
|
31
|
+
// ============================================================================
|
|
32
|
+
function resolveProjectRoot() {
|
|
33
|
+
try {
|
|
34
|
+
return fs_1.default.realpathSync(process.cwd());
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return path_1.default.resolve(process.cwd());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function resolveConfigHome() {
|
|
41
|
+
return process.env.XDG_CONFIG_HOME || path_1.default.join(os_1.default.homedir(), ".config");
|
|
42
|
+
}
|
|
43
|
+
function resolveSkillTargetDir(globalInstall) {
|
|
44
|
+
if (globalInstall) {
|
|
45
|
+
return path_1.default.join(resolveConfigHome(), "opencode", "skills", constants_1.SKILL_NAME);
|
|
46
|
+
}
|
|
47
|
+
return path_1.default.join(resolveProjectRoot(), ".opencode", "skills", constants_1.SKILL_NAME);
|
|
48
|
+
}
|
|
49
|
+
function runSkillsCli(args) {
|
|
50
|
+
const result = (0, node_child_process_1.spawnSync)("npx", ["skills", ...args], { stdio: "pipe" });
|
|
51
|
+
if (result.error) {
|
|
52
|
+
(0, output_1.errorOut)(`Failed to run skills CLI: ${result.error.message}`);
|
|
53
|
+
}
|
|
54
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
55
|
+
const stderr = result.stderr ? result.stderr.toString().trim() : "";
|
|
56
|
+
const stdout = result.stdout ? result.stdout.toString().trim() : "";
|
|
57
|
+
const detail = stderr || stdout;
|
|
58
|
+
const message = detail ? `skills CLI failed: ${detail}` : `skills CLI exited with status ${result.status}`;
|
|
59
|
+
(0, output_1.errorOut)(message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function runSkillInstall(options, prettyOutput) {
|
|
63
|
+
const globalInstall = options.global === true;
|
|
64
|
+
const installTarget = resolveSkillTargetDir(globalInstall);
|
|
65
|
+
const agents = Array.isArray(options.agent)
|
|
66
|
+
? options.agent.filter((value) => typeof value === "string" && value.trim())
|
|
67
|
+
: [];
|
|
68
|
+
const args = ["add", constants_1.SKILL_REPO, "--skill", constants_1.SKILL_NAME];
|
|
69
|
+
if (agents.length > 0) {
|
|
70
|
+
for (const agent of agents) {
|
|
71
|
+
args.push("-a", agent);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (globalInstall) {
|
|
75
|
+
args.push("-g");
|
|
76
|
+
}
|
|
77
|
+
const hintAgents = agents.length > 0 ? agents.map((agent) => `-a ${(0, scope_1.formatCliArgValue)(agent)}`).join(" ") : "";
|
|
78
|
+
const installHintParts = ["npx skills add", (0, scope_1.formatCliArgValue)(constants_1.SKILL_REPO), "--skill", constants_1.SKILL_NAME];
|
|
79
|
+
if (hintAgents) {
|
|
80
|
+
installHintParts.push(hintAgents);
|
|
81
|
+
}
|
|
82
|
+
if (globalInstall) {
|
|
83
|
+
installHintParts.push("-g");
|
|
84
|
+
}
|
|
85
|
+
const installHint = installHintParts.join(" ").trim();
|
|
86
|
+
runSkillsCli(args);
|
|
87
|
+
(0, output_1.printJson)({
|
|
88
|
+
ok: true,
|
|
89
|
+
data: {
|
|
90
|
+
name: constants_1.SKILL_NAME,
|
|
91
|
+
targetDir: installTarget,
|
|
92
|
+
scope: globalInstall ? "global" : "project",
|
|
93
|
+
installHint,
|
|
94
|
+
tool: "skills",
|
|
95
|
+
},
|
|
96
|
+
}, prettyOutput);
|
|
97
|
+
}
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Version Command
|
|
100
|
+
// ============================================================================
|
|
101
|
+
function runVersion(prettyOutput) {
|
|
102
|
+
(0, output_1.printJson)({
|
|
103
|
+
ok: true,
|
|
104
|
+
data: {
|
|
105
|
+
version: constants_1.VERSION,
|
|
106
|
+
baseVersion: constants_1.BASE_VERSION,
|
|
107
|
+
gitSha: constants_1.GIT_SHA,
|
|
108
|
+
dirty: constants_1.DIRTY,
|
|
109
|
+
component: "cli",
|
|
110
|
+
},
|
|
111
|
+
}, prettyOutput);
|
|
112
|
+
}
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// Policy Command
|
|
115
|
+
// ============================================================================
|
|
116
|
+
function runPolicy(options, policyContext, prettyOutput) {
|
|
117
|
+
const policyPath = (0, policy_1.defaultPolicyPath)();
|
|
118
|
+
if (options.init) {
|
|
119
|
+
if (fs_1.default.existsSync(policyPath)) {
|
|
120
|
+
(0, output_1.printJson)({
|
|
121
|
+
ok: true,
|
|
122
|
+
data: {
|
|
123
|
+
status: "exists",
|
|
124
|
+
path: policyPath,
|
|
125
|
+
},
|
|
126
|
+
}, prettyOutput);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const dir = path_1.default.dirname(policyPath);
|
|
130
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
131
|
+
fs_1.default.writeFileSync(policyPath, JSON.stringify((0, policy_1.defaultPolicyTemplate)(), null, 2), "utf8");
|
|
132
|
+
(0, output_1.printJson)({
|
|
133
|
+
ok: true,
|
|
134
|
+
data: {
|
|
135
|
+
status: "created",
|
|
136
|
+
path: policyPath,
|
|
137
|
+
},
|
|
138
|
+
}, prettyOutput);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const policySummary = (0, policy_1.summarizePolicy)(policyContext.policy, policyContext.path);
|
|
142
|
+
(0, output_1.printJson)({
|
|
143
|
+
ok: true,
|
|
144
|
+
data: {
|
|
145
|
+
...policySummary,
|
|
146
|
+
path: policyPath,
|
|
147
|
+
},
|
|
148
|
+
}, prettyOutput);
|
|
149
|
+
}
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// History Command
|
|
152
|
+
// ============================================================================
|
|
153
|
+
async function runHistory(options, prettyOutput) {
|
|
154
|
+
const params = {
|
|
155
|
+
limit: options.limit ? Number(options.limit) : undefined,
|
|
156
|
+
};
|
|
157
|
+
const response = await (0, client_1.sendRequest)({
|
|
158
|
+
id: (0, client_1.createRequestId)(),
|
|
159
|
+
action: "history",
|
|
160
|
+
params,
|
|
161
|
+
client: {
|
|
162
|
+
component: "cli",
|
|
163
|
+
version: constants_1.VERSION,
|
|
164
|
+
baseVersion: constants_1.BASE_VERSION,
|
|
165
|
+
gitSha: constants_1.GIT_SHA,
|
|
166
|
+
dirty: constants_1.DIRTY,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
(0, output_1.printJson)(response, prettyOutput);
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// ============================================================================
|
|
175
|
+
// Undo Command
|
|
176
|
+
// ============================================================================
|
|
177
|
+
async function runUndo(options, prettyOutput) {
|
|
178
|
+
const positionalTxid = options._[0];
|
|
179
|
+
const flagTxid = options.txid;
|
|
180
|
+
const useLatest = options.latest === true;
|
|
181
|
+
if (useLatest && (positionalTxid || flagTxid)) {
|
|
182
|
+
(0, output_1.errorOut)("--latest cannot be combined with a txid argument or --txid");
|
|
183
|
+
}
|
|
184
|
+
const txid = positionalTxid || flagTxid;
|
|
185
|
+
const params = {
|
|
186
|
+
txid,
|
|
187
|
+
latest: useLatest,
|
|
188
|
+
};
|
|
189
|
+
const response = await (0, client_1.sendRequest)({
|
|
190
|
+
id: (0, client_1.createRequestId)(),
|
|
191
|
+
action: "undo",
|
|
192
|
+
params,
|
|
193
|
+
client: {
|
|
194
|
+
component: "cli",
|
|
195
|
+
version: constants_1.VERSION,
|
|
196
|
+
baseVersion: constants_1.BASE_VERSION,
|
|
197
|
+
gitSha: constants_1.GIT_SHA,
|
|
198
|
+
dirty: constants_1.DIRTY,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
(0, output_1.printJson)(response, prettyOutput);
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// ============================================================================
|
|
207
|
+
// Ping Command
|
|
208
|
+
// ============================================================================
|
|
209
|
+
async function runPing(prettyOutput) {
|
|
210
|
+
const response = await (0, client_1.sendRequest)({
|
|
211
|
+
id: (0, client_1.createRequestId)(),
|
|
212
|
+
action: "ping",
|
|
213
|
+
params: {},
|
|
214
|
+
client: {
|
|
215
|
+
component: "cli",
|
|
216
|
+
version: constants_1.VERSION,
|
|
217
|
+
baseVersion: constants_1.BASE_VERSION,
|
|
218
|
+
gitSha: constants_1.GIT_SHA,
|
|
219
|
+
dirty: constants_1.DIRTY,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
(0, output_1.printJson)(response, prettyOutput);
|
|
223
|
+
if (!response.ok) {
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Group-related parameter builders.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildGroupUpdateParams = buildGroupUpdateParams;
|
|
7
|
+
exports.buildGroupUngroupParams = buildGroupUngroupParams;
|
|
8
|
+
exports.buildGroupAssignParams = buildGroupAssignParams;
|
|
9
|
+
const params_1 = require("./params");
|
|
10
|
+
function buildGroupUpdateParams(options) {
|
|
11
|
+
const windowValue = (0, params_1.parseWindowScope)(options.window, { allowNew: false });
|
|
12
|
+
return {
|
|
13
|
+
groupTitle: options.group,
|
|
14
|
+
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
15
|
+
windowId: windowValue,
|
|
16
|
+
title: options.title,
|
|
17
|
+
color: options.color,
|
|
18
|
+
collapsed: options.collapsed === true ? true : options.expanded === true ? false : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function buildGroupUngroupParams(options) {
|
|
22
|
+
const windowValue = (0, params_1.parseWindowScope)(options.window, { allowNew: false });
|
|
23
|
+
return {
|
|
24
|
+
groupTitle: options.group,
|
|
25
|
+
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
26
|
+
windowId: windowValue,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function buildGroupAssignParams(options) {
|
|
30
|
+
const windowValue = (0, params_1.parseWindowScope)(options.window, { allowNew: false });
|
|
31
|
+
return {
|
|
32
|
+
tabIds: options.tab ? options.tab.map(Number) : undefined,
|
|
33
|
+
groupTitle: options.group,
|
|
34
|
+
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
35
|
+
windowId: windowValue,
|
|
36
|
+
create: Boolean(options.create),
|
|
37
|
+
color: options.color,
|
|
38
|
+
collapsed: options.collapsed === true ? true : options.expanded === true ? false : undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Movement-related parameter builders.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildMoveTabParams = buildMoveTabParams;
|
|
7
|
+
exports.buildMoveGroupParams = buildMoveGroupParams;
|
|
8
|
+
exports.buildMergeWindowParams = buildMergeWindowParams;
|
|
9
|
+
const params_1 = require("./params");
|
|
10
|
+
function buildMoveTabParams(options) {
|
|
11
|
+
const windowValue = (0, params_1.parseWindowScope)(options.window, { allowNew: false });
|
|
12
|
+
return {
|
|
13
|
+
tabId: options.tab ? Number(options.tab[0]) : undefined,
|
|
14
|
+
tabIds: options.tab ? options.tab.map(Number) : undefined,
|
|
15
|
+
beforeTabId: options["before-tab"] ? Number(options["before-tab"]) : undefined,
|
|
16
|
+
afterTabId: options["after-tab"] ? Number(options["after-tab"]) : undefined,
|
|
17
|
+
beforeGroupTitle: options["before-group"],
|
|
18
|
+
afterGroupTitle: options["after-group"],
|
|
19
|
+
windowId: windowValue,
|
|
20
|
+
newWindow: options["new-window"] === true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function buildMoveGroupParams(options) {
|
|
24
|
+
const windowValue = (0, params_1.parseWindowScope)(options.window, { allowNew: false });
|
|
25
|
+
return {
|
|
26
|
+
groupTitle: options.group,
|
|
27
|
+
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
28
|
+
beforeTabId: options["before-tab"] ? Number(options["before-tab"]) : undefined,
|
|
29
|
+
afterTabId: options["after-tab"] ? Number(options["after-tab"]) : undefined,
|
|
30
|
+
beforeGroupTitle: options["before-group"],
|
|
31
|
+
afterGroupTitle: options["after-group"],
|
|
32
|
+
windowId: windowValue,
|
|
33
|
+
newWindow: options["new-window"] === true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function buildMergeWindowParams(options) {
|
|
37
|
+
return {
|
|
38
|
+
fromWindowId: options.from ? Number(options.from) : undefined,
|
|
39
|
+
toWindowId: options.to ? Number(options.to) : undefined,
|
|
40
|
+
windowId: options.from ? Number(options.from) : undefined,
|
|
41
|
+
closeSource: options["close-source"] === true,
|
|
42
|
+
confirmed: options.confirm === true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -7,42 +7,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildMergeWindowParams = exports.buildMoveGroupParams = exports.buildMoveTabParams = exports.buildGroupUngroupParams = exports.buildGroupAssignParams = exports.buildGroupUpdateParams = void 0;
|
|
10
11
|
exports.buildAnalyzeParams = buildAnalyzeParams;
|
|
11
12
|
exports.buildInspectParams = buildInspectParams;
|
|
12
13
|
exports.buildFocusParams = buildFocusParams;
|
|
13
14
|
exports.buildRefreshParams = buildRefreshParams;
|
|
14
15
|
exports.buildOpenParams = buildOpenParams;
|
|
15
|
-
exports.buildGroupUpdateParams = buildGroupUpdateParams;
|
|
16
|
-
exports.buildGroupUngroupParams = buildGroupUngroupParams;
|
|
17
|
-
exports.buildGroupAssignParams = buildGroupAssignParams;
|
|
18
|
-
exports.buildMoveTabParams = buildMoveTabParams;
|
|
19
|
-
exports.buildMoveGroupParams = buildMoveGroupParams;
|
|
20
|
-
exports.buildMergeWindowParams = buildMergeWindowParams;
|
|
21
16
|
exports.buildArchiveParams = buildArchiveParams;
|
|
22
17
|
exports.buildCloseParams = buildCloseParams;
|
|
23
18
|
exports.buildReportParams = buildReportParams;
|
|
24
19
|
exports.buildScreenshotParams = buildScreenshotParams;
|
|
20
|
+
exports.parseWindowScope = parseWindowScope;
|
|
25
21
|
exports.buildHistoryParams = buildHistoryParams;
|
|
26
22
|
exports.buildUndoParams = buildUndoParams;
|
|
27
23
|
const fs_1 = __importDefault(require("fs"));
|
|
28
24
|
const output_1 = require("../output");
|
|
29
25
|
const args_1 = require("../args");
|
|
30
26
|
// ============================================================================
|
|
31
|
-
//
|
|
27
|
+
// Shared Scope Builder
|
|
32
28
|
// ============================================================================
|
|
33
|
-
function
|
|
29
|
+
function buildScopeFromOptions(options, { allowNew } = { allowNew: false }) {
|
|
34
30
|
if (options.ungrouped && options["group-id"]) {
|
|
35
31
|
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
36
32
|
}
|
|
37
|
-
const
|
|
33
|
+
const windowId = parseWindowScope(options.window, { allowNew });
|
|
38
34
|
return {
|
|
39
|
-
staleDays: options["stale-days"] ? Number(options["stale-days"]) : undefined,
|
|
40
|
-
checkGitHub: Boolean(options.github),
|
|
41
35
|
tabIds: options.tab ? options.tab.map(Number) : undefined,
|
|
42
36
|
groupTitle: options.group,
|
|
43
37
|
groupId: options.ungrouped ? -1 : (options["group-id"] ? Number(options["group-id"]) : undefined),
|
|
44
|
-
windowId
|
|
45
|
-
all: options.all
|
|
38
|
+
windowId,
|
|
39
|
+
all: Boolean(options.all),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Analyze Command Parameters
|
|
44
|
+
// ============================================================================
|
|
45
|
+
function buildAnalyzeParams(options) {
|
|
46
|
+
const { tabIds, groupTitle, groupId, windowId, all } = buildScopeFromOptions(options);
|
|
47
|
+
return {
|
|
48
|
+
staleDays: options["stale-days"] ? Number(options["stale-days"]) : undefined,
|
|
49
|
+
checkGitHub: Boolean(options.github),
|
|
50
|
+
tabIds,
|
|
51
|
+
groupTitle,
|
|
52
|
+
groupId,
|
|
53
|
+
windowId,
|
|
54
|
+
all,
|
|
46
55
|
githubConcurrency: options["github-concurrency"] ? Number(options["github-concurrency"]) : undefined,
|
|
47
56
|
githubTimeoutMs: options["github-timeout-ms"] ? Number(options["github-timeout-ms"]) : undefined,
|
|
48
57
|
progress: Boolean(options.progress),
|
|
@@ -52,10 +61,7 @@ function buildAnalyzeParams(options) {
|
|
|
52
61
|
// Inspect Command Parameters
|
|
53
62
|
// ============================================================================
|
|
54
63
|
function buildInspectParams(options) {
|
|
55
|
-
|
|
56
|
-
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
57
|
-
}
|
|
58
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
64
|
+
const { tabIds, groupTitle, groupId, windowId, all } = buildScopeFromOptions(options);
|
|
59
65
|
const selectorAttr = options["selector-attr"] ? String(options["selector-attr"]).trim() : "";
|
|
60
66
|
const allowedSelectorAttrs = new Set(["text", "href", "src", "href-url", "src-url"]);
|
|
61
67
|
if (options["selector-attr"] && (!selectorAttr || !allowedSelectorAttrs.has(selectorAttr))) {
|
|
@@ -101,11 +107,11 @@ function buildInspectParams(options) {
|
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
return {
|
|
104
|
-
all
|
|
105
|
-
windowId
|
|
106
|
-
groupTitle
|
|
107
|
-
groupId
|
|
108
|
-
tabIds
|
|
110
|
+
all,
|
|
111
|
+
windowId,
|
|
112
|
+
groupTitle,
|
|
113
|
+
groupId,
|
|
114
|
+
tabIds,
|
|
109
115
|
signals: options.signal ? options.signal : undefined,
|
|
110
116
|
selectorSpecs,
|
|
111
117
|
signalConfig,
|
|
@@ -161,98 +167,34 @@ function buildOpenParams(options) {
|
|
|
161
167
|
};
|
|
162
168
|
}
|
|
163
169
|
// ============================================================================
|
|
164
|
-
// Group Command Parameters
|
|
170
|
+
// Group Command Parameters (re-exported from params-groups.ts)
|
|
165
171
|
// ============================================================================
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
171
|
-
windowId: windowValue,
|
|
172
|
-
title: options.title,
|
|
173
|
-
color: options.color,
|
|
174
|
-
collapsed: options.collapsed === true ? true : options.expanded === true ? false : undefined,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function buildGroupUngroupParams(options) {
|
|
178
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
179
|
-
return {
|
|
180
|
-
groupTitle: options.group,
|
|
181
|
-
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
182
|
-
windowId: windowValue,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function buildGroupAssignParams(options) {
|
|
186
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
187
|
-
return {
|
|
188
|
-
tabIds: options.tab ? options.tab.map(Number) : undefined,
|
|
189
|
-
groupTitle: options.group,
|
|
190
|
-
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
191
|
-
windowId: windowValue,
|
|
192
|
-
create: Boolean(options.create),
|
|
193
|
-
color: options.color,
|
|
194
|
-
collapsed: options.collapsed === true ? true : options.expanded === true ? false : undefined,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
172
|
+
var params_groups_1 = require("./params-groups");
|
|
173
|
+
Object.defineProperty(exports, "buildGroupUpdateParams", { enumerable: true, get: function () { return params_groups_1.buildGroupUpdateParams; } });
|
|
174
|
+
Object.defineProperty(exports, "buildGroupAssignParams", { enumerable: true, get: function () { return params_groups_1.buildGroupAssignParams; } });
|
|
175
|
+
Object.defineProperty(exports, "buildGroupUngroupParams", { enumerable: true, get: function () { return params_groups_1.buildGroupUngroupParams; } });
|
|
197
176
|
// ============================================================================
|
|
198
|
-
// Move Command Parameters
|
|
177
|
+
// Move Command Parameters (re-exported from params-move.ts)
|
|
199
178
|
// ============================================================================
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
tabIds: options.tab ? options.tab.map(Number) : undefined,
|
|
205
|
-
beforeTabId: options["before-tab"] ? Number(options["before-tab"]) : undefined,
|
|
206
|
-
afterTabId: options["after-tab"] ? Number(options["after-tab"]) : undefined,
|
|
207
|
-
beforeGroupTitle: options["before-group"],
|
|
208
|
-
afterGroupTitle: options["after-group"],
|
|
209
|
-
windowId: windowValue,
|
|
210
|
-
newWindow: options["new-window"] === true,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function buildMoveGroupParams(options) {
|
|
214
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
215
|
-
return {
|
|
216
|
-
groupTitle: options.group,
|
|
217
|
-
groupId: options["group-id"] ? Number(options["group-id"]) : undefined,
|
|
218
|
-
beforeTabId: options["before-tab"] ? Number(options["before-tab"]) : undefined,
|
|
219
|
-
afterTabId: options["after-tab"] ? Number(options["after-tab"]) : undefined,
|
|
220
|
-
beforeGroupTitle: options["before-group"],
|
|
221
|
-
afterGroupTitle: options["after-group"],
|
|
222
|
-
windowId: windowValue,
|
|
223
|
-
newWindow: options["new-window"] === true,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
function buildMergeWindowParams(options) {
|
|
227
|
-
return {
|
|
228
|
-
fromWindowId: options.from ? Number(options.from) : undefined,
|
|
229
|
-
toWindowId: options.to ? Number(options.to) : undefined,
|
|
230
|
-
windowId: options.from ? Number(options.from) : undefined,
|
|
231
|
-
closeSource: options["close-source"] === true,
|
|
232
|
-
confirmed: options.confirm === true,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
179
|
+
var params_move_1 = require("./params-move");
|
|
180
|
+
Object.defineProperty(exports, "buildMoveTabParams", { enumerable: true, get: function () { return params_move_1.buildMoveTabParams; } });
|
|
181
|
+
Object.defineProperty(exports, "buildMoveGroupParams", { enumerable: true, get: function () { return params_move_1.buildMoveGroupParams; } });
|
|
182
|
+
Object.defineProperty(exports, "buildMergeWindowParams", { enumerable: true, get: function () { return params_move_1.buildMergeWindowParams; } });
|
|
235
183
|
// ============================================================================
|
|
236
184
|
// Archive/Close Command Parameters
|
|
237
185
|
// ============================================================================
|
|
238
186
|
function buildArchiveParams(options) {
|
|
239
|
-
|
|
240
|
-
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
241
|
-
}
|
|
242
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
187
|
+
const { tabIds, groupTitle, groupId, windowId, all } = buildScopeFromOptions(options);
|
|
243
188
|
return {
|
|
244
|
-
all
|
|
245
|
-
windowId
|
|
246
|
-
groupTitle
|
|
247
|
-
groupId
|
|
248
|
-
tabIds
|
|
189
|
+
all,
|
|
190
|
+
windowId,
|
|
191
|
+
groupTitle,
|
|
192
|
+
groupId,
|
|
193
|
+
tabIds,
|
|
249
194
|
};
|
|
250
195
|
}
|
|
251
196
|
function buildCloseParams(options) {
|
|
252
|
-
|
|
253
|
-
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
254
|
-
}
|
|
255
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
197
|
+
const { tabIds, groupTitle, groupId, windowId } = buildScopeFromOptions(options);
|
|
256
198
|
if (options.apply) {
|
|
257
199
|
return { mode: "apply", analysisId: options.apply };
|
|
258
200
|
}
|
|
@@ -262,46 +204,40 @@ function buildCloseParams(options) {
|
|
|
262
204
|
return {
|
|
263
205
|
mode: "direct",
|
|
264
206
|
confirmed: true,
|
|
265
|
-
windowId
|
|
266
|
-
groupTitle
|
|
267
|
-
groupId
|
|
268
|
-
tabIds
|
|
207
|
+
windowId,
|
|
208
|
+
groupTitle,
|
|
209
|
+
groupId,
|
|
210
|
+
tabIds,
|
|
269
211
|
};
|
|
270
212
|
}
|
|
271
213
|
// ============================================================================
|
|
272
214
|
// Report Command Parameters
|
|
273
215
|
// ============================================================================
|
|
274
216
|
function buildReportParams(options) {
|
|
275
|
-
|
|
276
|
-
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
277
|
-
}
|
|
278
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
217
|
+
const { tabIds, groupTitle, groupId, windowId, all } = buildScopeFromOptions(options);
|
|
279
218
|
return {
|
|
280
|
-
all
|
|
281
|
-
windowId
|
|
282
|
-
groupTitle
|
|
283
|
-
groupId
|
|
284
|
-
tabIds
|
|
219
|
+
all,
|
|
220
|
+
windowId,
|
|
221
|
+
groupTitle,
|
|
222
|
+
groupId,
|
|
223
|
+
tabIds,
|
|
285
224
|
};
|
|
286
225
|
}
|
|
287
226
|
// ============================================================================
|
|
288
227
|
// Screenshot Command Parameters
|
|
289
228
|
// ============================================================================
|
|
290
229
|
function buildScreenshotParams(options) {
|
|
291
|
-
|
|
292
|
-
(0, output_1.errorOut)("--ungrouped cannot be combined with --group-id");
|
|
293
|
-
}
|
|
294
|
-
const windowValue = parseWindowScope(options.window, { allowNew: false });
|
|
230
|
+
const { tabIds, groupTitle, groupId, windowId, all } = buildScopeFromOptions(options);
|
|
295
231
|
const outDir = options.out != null ? String(options.out).trim() : "";
|
|
296
232
|
if (options.out && !outDir) {
|
|
297
233
|
(0, output_1.errorOut)("--out requires a directory path");
|
|
298
234
|
}
|
|
299
235
|
return {
|
|
300
|
-
all
|
|
301
|
-
windowId
|
|
302
|
-
groupTitle
|
|
303
|
-
groupId
|
|
304
|
-
tabIds
|
|
236
|
+
all,
|
|
237
|
+
windowId,
|
|
238
|
+
groupTitle,
|
|
239
|
+
groupId,
|
|
240
|
+
tabIds,
|
|
305
241
|
mode: options.mode,
|
|
306
242
|
format: options.format,
|
|
307
243
|
quality: options.quality != null ? Number(options.quality) : undefined,
|