sideby 0.40.1 → 0.41.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/build.json +1 -1
- package/dist/src/cli/commands.d.ts +7 -0
- package/dist/src/cli/commands.js +145 -0
- package/dist/src/cli/json-schemas.js +75 -2
- package/dist/src/cli/main.js +32 -2
- package/dist/src/core/claude-trust.d.ts +198 -0
- package/dist/src/core/claude-trust.js +559 -0
- package/dist/src/core/cli-commands.js +14 -2
- package/dist/src/core/config.d.ts +7 -3
- package/dist/src/core/config.js +12 -5
- package/dist/src/core/network.d.ts +9 -7
- package/dist/src/core/network.js +10 -13
- package/dist/src/core/search-catalog.js +23 -0
- package/dist/src/panel/handler.d.ts +14 -0
- package/dist/src/panel/handler.js +55 -0
- package/dist/src/panel/i18n.d.ts +22 -0
- package/dist/src/panel/i18n.js +46 -2
- package/dist/src/panel/page-script.js +80 -2
- package/dist/src/runtime.d.ts +32 -0
- package/dist/src/runtime.js +74 -1
- package/package.json +1 -1
- package/schemas/config.json +5 -1
- package/schemas/network.json +5 -1
- package/schemas/trust-set.json +117 -0
- package/schemas/trust-undo.json +155 -0
- package/schemas/trust.json +183 -0
- package/skills/sideby/SKILL.md +2 -1
- package/skills/sideby/references/network.md +1 -1
- package/skills/sideby/references/trust.md +28 -0
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261118T151638-9b7801"}
|
|
@@ -191,6 +191,13 @@ export declare function cmdNetwork(a: ParsedArgs, io: Io): Promise<number>;
|
|
|
191
191
|
* is no preview) and print the undo.
|
|
192
192
|
*/
|
|
193
193
|
export declare function cmdProgress(a: ParsedArgs, io: Io): Promise<number>;
|
|
194
|
+
/**
|
|
195
|
+
* `sideby trust` (spec §3.43, ADR-0078): carried folder trust between Claude accounts. Without a subcommand shows config
|
|
196
|
+
* `claude.carryTrust`, the carries sideby recorded and, while it is on, each Claude account's trust of the folder
|
|
197
|
+
* (`--dir`, default the current one): booleans only. `on` and `off` change the config, `undo` takes the copied marks
|
|
198
|
+
* back; each shows the change first and exits 10 until `--yes`.
|
|
199
|
+
*/
|
|
200
|
+
export declare function cmdTrust(a: ParsedArgs, io: Io): Promise<number>;
|
|
194
201
|
/** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
|
|
195
202
|
export declare function cmdUnattended(a: ParsedArgs, io: Io): Promise<number>;
|
|
196
203
|
export declare function cmdCommands(a: ParsedArgs, io: Io): number;
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -4675,6 +4675,7 @@ export async function cmdNetwork(a, io) {
|
|
|
4675
4675
|
const why = {
|
|
4676
4676
|
'third-party': 'third-party endpoint, not checked',
|
|
4677
4677
|
'at-launch': 'API account, checked when it starts',
|
|
4678
|
+
api: 'API account, not checked',
|
|
4678
4679
|
'not-covered': 'not covered',
|
|
4679
4680
|
};
|
|
4680
4681
|
for (const x of skipped)
|
|
@@ -4832,6 +4833,150 @@ export async function cmdProgress(a, io) {
|
|
|
4832
4833
|
io.out(c.dim(`Undo: ${undo}`));
|
|
4833
4834
|
return 0;
|
|
4834
4835
|
}
|
|
4836
|
+
/**
|
|
4837
|
+
* `sideby trust` (spec §3.43, ADR-0078): carried folder trust between Claude accounts. Without a subcommand shows config
|
|
4838
|
+
* `claude.carryTrust`, the carries sideby recorded and, while it is on, each Claude account's trust of the folder
|
|
4839
|
+
* (`--dir`, default the current one): booleans only. `on` and `off` change the config, `undo` takes the copied marks
|
|
4840
|
+
* back; each shows the change first and exits 10 until `--yes`.
|
|
4841
|
+
*/
|
|
4842
|
+
export async function cmdTrust(a, io) {
|
|
4843
|
+
const [sub, ...rest] = a.positionals;
|
|
4844
|
+
const asJson = a.flags.has('json');
|
|
4845
|
+
const usage = 'usage: sideby trust [--dir <path>] | sideby trust on|off [--yes] | sideby trust undo [--yes]';
|
|
4846
|
+
if (rest.length || a.rest.length || (sub !== undefined && !['status', 'on', 'off', 'undo'].includes(sub)))
|
|
4847
|
+
throw new UsageError(usage);
|
|
4848
|
+
const status = sub === undefined || sub === 'status';
|
|
4849
|
+
for (const k of a.flags.keys())
|
|
4850
|
+
if (k !== 'json' && !(k === 'dir' && status) && !(k === 'yes' && !status))
|
|
4851
|
+
throw new UsageError(`--${k} does not go with \`sideby trust ${sub ?? ''}\`; ${usage}`);
|
|
4852
|
+
const rt = await createRuntime();
|
|
4853
|
+
const home = rt.paths.home;
|
|
4854
|
+
// Inside text too: a reason names a path in the middle of a sentence.
|
|
4855
|
+
const show = (p) => tilde(p, home);
|
|
4856
|
+
const what = 'Before sideby starts a Claude session in a folder one of your Claude accounts has not trusted yet, it copies the trust another of your Claude accounts already gave that folder, so Claude Code does not ask "Is this a project you created or one you trust?" again. It never trusts a folder none of your accounts trusted.';
|
|
4857
|
+
if (sub === 'on' || sub === 'off') {
|
|
4858
|
+
const r = await rt.trustSet(sub === 'on', { apply: a.flags.has('yes') });
|
|
4859
|
+
const turnedOffNote = 'Turning it off keeps the trust sideby already copied; `sideby trust undo` takes it back.';
|
|
4860
|
+
if (asJson) {
|
|
4861
|
+
json(io, {
|
|
4862
|
+
action: sub,
|
|
4863
|
+
on: r.applied ? r.after : r.before,
|
|
4864
|
+
changed: r.changed,
|
|
4865
|
+
applied: r.applied,
|
|
4866
|
+
before: r.before,
|
|
4867
|
+
after: r.after,
|
|
4868
|
+
file: show(r.file),
|
|
4869
|
+
});
|
|
4870
|
+
}
|
|
4871
|
+
else if (!r.changed)
|
|
4872
|
+
io.out(`Carrying folder trust was already ${sub}.`);
|
|
4873
|
+
else if (!r.applied) {
|
|
4874
|
+
io.out(`Change to ${show(r.file)}: claude.carryTrust ${r.before} → ${r.after}`);
|
|
4875
|
+
io.out(c.dim(sub === 'on' ? what : turnedOffNote));
|
|
4876
|
+
io.out(c.cyan(`Apply it with \`sideby trust ${sub} --yes\`.`));
|
|
4877
|
+
}
|
|
4878
|
+
else {
|
|
4879
|
+
io.out(`${c.green('✓')} Carrying folder trust is ${sub}.`);
|
|
4880
|
+
io.out(c.dim(sub === 'on'
|
|
4881
|
+
? `${what} Each copy prints one line; \`sideby trust undo\` takes them back.`
|
|
4882
|
+
: turnedOffNote));
|
|
4883
|
+
}
|
|
4884
|
+
return r.changed && !r.applied ? 10 : 0;
|
|
4885
|
+
}
|
|
4886
|
+
if (sub === 'undo') {
|
|
4887
|
+
const apply = a.flags.has('yes');
|
|
4888
|
+
const items = await rt.trustUndo({ apply });
|
|
4889
|
+
const out = items.map((x) => ({
|
|
4890
|
+
id: x.id,
|
|
4891
|
+
account: x.account,
|
|
4892
|
+
path: show(x.key),
|
|
4893
|
+
from: x.from,
|
|
4894
|
+
at: x.at,
|
|
4895
|
+
status: x.status,
|
|
4896
|
+
...(x.why ? { why: show(x.why) } : {}),
|
|
4897
|
+
}));
|
|
4898
|
+
const todo = out.filter((x) => x.status === 'undo');
|
|
4899
|
+
const stuck = out.filter((x) => x.status === 'blocked' || x.status === 'busy');
|
|
4900
|
+
if (asJson)
|
|
4901
|
+
json(io, { action: 'undo', applied: apply, items: out });
|
|
4902
|
+
else if (!out.length)
|
|
4903
|
+
io.out('sideby has not copied any folder trust, so there is nothing to undo.');
|
|
4904
|
+
else {
|
|
4905
|
+
const word = {
|
|
4906
|
+
undo: 'will no longer trust',
|
|
4907
|
+
undone: c.green('no longer trusts'),
|
|
4908
|
+
changed: c.dim('left alone (changed since sideby copied it):'),
|
|
4909
|
+
gone: c.dim('left alone (its .claude.json is gone):'),
|
|
4910
|
+
blocked: c.yellow('not changed:'),
|
|
4911
|
+
busy: c.yellow('not changed:'),
|
|
4912
|
+
};
|
|
4913
|
+
for (const x of out)
|
|
4914
|
+
io.out(` ${x.account} ${word[x.status]} ${x.path}${c.dim(` (copied from ${x.from})`)}${x.why ? ` ${c.dim(x.why)}` : ''}`);
|
|
4915
|
+
if (!apply && todo.length)
|
|
4916
|
+
io.out(c.cyan('Take it back with `sideby trust undo --yes`.'));
|
|
4917
|
+
else if (!apply)
|
|
4918
|
+
io.out('Nothing to undo: each mark changed since sideby copied it.');
|
|
4919
|
+
if (apply && stuck.length)
|
|
4920
|
+
io.out(c.cyan('Fix what is named above, then run `sideby trust undo --yes` again.'));
|
|
4921
|
+
}
|
|
4922
|
+
if (!apply)
|
|
4923
|
+
return todo.length ? 10 : 0;
|
|
4924
|
+
return stuck.length ? 1 : 0;
|
|
4925
|
+
}
|
|
4926
|
+
const dirFlag = a.flags.get('dir');
|
|
4927
|
+
if (dirFlag === true)
|
|
4928
|
+
throw new UsageError(`--dir takes a folder; ${usage}`);
|
|
4929
|
+
const dir = typeof dirFlag === 'string' ? resolve(dirFlag) : process.cwd();
|
|
4930
|
+
const st = await rt.trustStatus(dir);
|
|
4931
|
+
if (asJson) {
|
|
4932
|
+
json(io, {
|
|
4933
|
+
action: 'status',
|
|
4934
|
+
on: st.on,
|
|
4935
|
+
carried: st.carried.map(({ key, ...x }) => ({ ...x, path: show(key) })),
|
|
4936
|
+
...(st.dir ? { dir: show(st.dir) } : {}),
|
|
4937
|
+
...(st.root
|
|
4938
|
+
? {
|
|
4939
|
+
root: {
|
|
4940
|
+
kind: st.root.kind,
|
|
4941
|
+
...(st.root.path ? { path: show(st.root.path) } : {}),
|
|
4942
|
+
...(st.root.why ? { why: show(st.root.why) } : {}),
|
|
4943
|
+
},
|
|
4944
|
+
}
|
|
4945
|
+
: {}),
|
|
4946
|
+
...(st.accounts
|
|
4947
|
+
? { accounts: st.accounts.map((x) => (x.problem ? { ...x, problem: show(x.problem) } : x)) }
|
|
4948
|
+
: {}),
|
|
4949
|
+
});
|
|
4950
|
+
return 0;
|
|
4951
|
+
}
|
|
4952
|
+
io.out(`Carry folder trust between Claude accounts: ${st.on ? c.green('on') : c.dim('off')}`);
|
|
4953
|
+
if (!st.on) {
|
|
4954
|
+
io.out(c.dim(what));
|
|
4955
|
+
io.out(c.cyan('Turn it on with `sideby trust on`.'));
|
|
4956
|
+
}
|
|
4957
|
+
else if (st.root) {
|
|
4958
|
+
const where = st.root.kind === 'git'
|
|
4959
|
+
? `git repository; trust is kept for ${show(st.root.path)}`
|
|
4960
|
+
: st.root.kind === 'folder'
|
|
4961
|
+
? 'not in a git repository; trust of this folder or a parent folder counts'
|
|
4962
|
+
: `sideby cannot tell (${show(st.root.why)}), so it copies nothing here`;
|
|
4963
|
+
io.out(`Folder: ${show(st.dir)} (${where})`);
|
|
4964
|
+
const width = Math.max(0, ...(st.accounts ?? []).map((x) => x.ref.length));
|
|
4965
|
+
for (const x of st.accounts ?? []) {
|
|
4966
|
+
const state = x.trusts === true
|
|
4967
|
+
? c.green('trusts it')
|
|
4968
|
+
: x.trusts === false
|
|
4969
|
+
? `asks${x.carryFrom ? c.dim(` · gets ${x.carryFrom}'s trust when sideby starts it here`) : ''}`
|
|
4970
|
+
: c.dim(`cannot tell${x.problem ? `: ${show(x.problem)}` : ''}`);
|
|
4971
|
+
io.out(` ${x.ref.padEnd(width)} ${state}`);
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
if (st.carried.length)
|
|
4975
|
+
io.out(`Copied by sideby: ${st.carried.length} ${st.carried.length === 1 ? 'mark' : 'marks'}${c.dim(' (see or take back with `sideby trust undo`)')}`);
|
|
4976
|
+
if (st.on)
|
|
4977
|
+
io.out(c.dim('Turning it off keeps what was copied; `sideby trust undo` takes it back.'));
|
|
4978
|
+
return 0;
|
|
4979
|
+
}
|
|
4835
4980
|
/** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
|
|
4836
4981
|
export async function cmdUnattended(a, io) {
|
|
4837
4982
|
const [sub, ...rest] = a.positionals;
|
|
@@ -1425,8 +1425,13 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1425
1425
|
accounts: Type.Array(Type.Object({
|
|
1426
1426
|
ref: Str,
|
|
1427
1427
|
url: Type.Optional(Type.String({ description: 'The address this account is checked at.' })),
|
|
1428
|
-
skip: Type.Optional(Type.Union([
|
|
1429
|
-
|
|
1428
|
+
skip: Type.Optional(Type.Union([
|
|
1429
|
+
Type.Literal('not-covered'),
|
|
1430
|
+
Type.Literal('third-party'),
|
|
1431
|
+
Type.Literal('at-launch'),
|
|
1432
|
+
Type.Literal('api'),
|
|
1433
|
+
], {
|
|
1434
|
+
description: 'api: an API account, never checked; third-party: an endpoint set to a third party, not checked; at-launch: no longer given.',
|
|
1430
1435
|
})),
|
|
1431
1436
|
})),
|
|
1432
1437
|
}, { title: 'sideby network [check] --json' }),
|
|
@@ -1534,6 +1539,74 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1534
1539
|
undo: Type.Optional(Type.String({ description: 'on and off: the command that puts back what was there.' })),
|
|
1535
1540
|
message: Type.Optional(Type.String({ description: 'on and off: one line for the user.' })),
|
|
1536
1541
|
}, { title: 'sideby progress [on|off] --json' }),
|
|
1542
|
+
trust: Type.Object({
|
|
1543
|
+
schemaVersion: Version,
|
|
1544
|
+
action: Type.Literal('status'),
|
|
1545
|
+
on: Type.Boolean({
|
|
1546
|
+
description: 'Config `claude.carryTrust` (spec §3.43): before sideby starts an interactive Claude session, an account that does not trust the folder gets the trust another Claude account already gave it.',
|
|
1547
|
+
}),
|
|
1548
|
+
carried: Type.Array(Type.Object({
|
|
1549
|
+
account: Type.String({ description: 'The account that got the trust mark.' }),
|
|
1550
|
+
path: Type.String({ description: 'The folder the mark is for, as sideby wrote it.' }),
|
|
1551
|
+
from: Type.String({ description: 'The account whose trust was copied.' }),
|
|
1552
|
+
at: Type.String({ description: 'When (ISO time).' }),
|
|
1553
|
+
}), { description: 'The marks sideby copied and `sideby trust undo` can take back, oldest first.' }),
|
|
1554
|
+
dir: Type.Optional(Type.String({
|
|
1555
|
+
description: 'The folder asked about (its real path); only while on. Nothing is read while off.',
|
|
1556
|
+
})),
|
|
1557
|
+
root: Type.Optional(Type.Object({
|
|
1558
|
+
kind: Type.Union([Type.Literal('git'), Type.Literal('folder'), Type.Literal('unclear')], {
|
|
1559
|
+
description: '`git`: trust is kept for the main checkout `path`; `folder`: the folder or a parent counts; `unclear`: sideby cannot tell from the files and copies nothing.',
|
|
1560
|
+
}),
|
|
1561
|
+
path: Type.Optional(Type.String()),
|
|
1562
|
+
why: Type.Optional(Type.String({ description: 'With `unclear`: why.' })),
|
|
1563
|
+
}, { description: 'Where Claude Code looks trust up for the folder; only while on.' })),
|
|
1564
|
+
accounts: Type.Optional(Type.Array(Type.Object({
|
|
1565
|
+
ref: Str,
|
|
1566
|
+
trusts: Type.Optional(Type.Boolean({
|
|
1567
|
+
description: 'Whether this account trusts the folder; absent when sideby cannot tell (`problem`).',
|
|
1568
|
+
})),
|
|
1569
|
+
problem: Type.Optional(Type.String({ description: 'Why its .claude.json cannot be read; names the path only.' })),
|
|
1570
|
+
carryFrom: Type.Optional(Type.String({ description: 'Starting this account here copies the trust of this account.' })),
|
|
1571
|
+
}), { description: 'Each Claude account and its trust of the folder (booleans only); only while on.' })),
|
|
1572
|
+
}, { title: 'sideby trust [--dir <path>] --json' }),
|
|
1573
|
+
'trust-set': Type.Object({
|
|
1574
|
+
schemaVersion: Version,
|
|
1575
|
+
action: Type.Union([Type.Literal('on'), Type.Literal('off')]),
|
|
1576
|
+
on: Type.Boolean({ description: 'Whether config `claude.carryTrust` is on now.' }),
|
|
1577
|
+
changed: Type.Boolean(),
|
|
1578
|
+
applied: Type.Boolean({
|
|
1579
|
+
description: 'False when only the change was shown; run again with --yes (exit 10).',
|
|
1580
|
+
}),
|
|
1581
|
+
before: Type.Boolean(),
|
|
1582
|
+
after: Type.Boolean(),
|
|
1583
|
+
file: Type.String({ description: 'The config file changed.' }),
|
|
1584
|
+
}, { title: 'sideby trust on|off --json' }),
|
|
1585
|
+
'trust-undo': Type.Object({
|
|
1586
|
+
schemaVersion: Version,
|
|
1587
|
+
action: Type.Literal('undo'),
|
|
1588
|
+
applied: Type.Boolean({
|
|
1589
|
+
description: 'False when only shown (exit 10 when something would be taken back); true with --yes.',
|
|
1590
|
+
}),
|
|
1591
|
+
items: Type.Array(Type.Object({
|
|
1592
|
+
id: Type.String({ description: 'The carry record; the Panel confirms only the ids it showed.' }),
|
|
1593
|
+
account: Str,
|
|
1594
|
+
path: Type.String({ description: 'The folder the mark is for.' }),
|
|
1595
|
+
from: Type.String({ description: 'The account whose trust was copied.' }),
|
|
1596
|
+
at: Type.String({ description: 'When it was copied (ISO time).' }),
|
|
1597
|
+
status: Type.Union([
|
|
1598
|
+
Type.Literal('undo'),
|
|
1599
|
+
Type.Literal('undone'),
|
|
1600
|
+
Type.Literal('changed'),
|
|
1601
|
+
Type.Literal('gone'),
|
|
1602
|
+
Type.Literal('blocked'),
|
|
1603
|
+
Type.Literal('busy'),
|
|
1604
|
+
], {
|
|
1605
|
+
description: '`undo`: would be taken back; `undone`: taken back; `changed`: the mark changed since sideby wrote it, left alone; `gone`: the file is gone; `blocked`/`busy`: not changed (`why`), kept for another try.',
|
|
1606
|
+
}),
|
|
1607
|
+
why: Type.Optional(Type.String()),
|
|
1608
|
+
})),
|
|
1609
|
+
}, { title: 'sideby trust undo --json' }),
|
|
1537
1610
|
browser: Type.Object({
|
|
1538
1611
|
schemaVersion: Version,
|
|
1539
1612
|
enabled: Type.Boolean({
|
package/dist/src/cli/main.js
CHANGED
|
@@ -324,10 +324,10 @@ it started, check the country the requests leave from. When it is not one you al
|
|
|
324
324
|
seconds (the proxy is off, the network is down), stop and say what to do. It guards against a proxy that stopped
|
|
325
325
|
or a node in the wrong country; it does not make use from an unsupported region allowed.
|
|
326
326
|
|
|
327
|
-
sideby asks the vendor's own https://api.anthropic.com
|
|
327
|
+
sideby asks the vendor's own https://api.anthropic.com or chatgpt.com /cdn-cgi/trace, through the
|
|
328
328
|
account's proxy settings, with no credential, account or identity, and keeps only the country and a hash of the
|
|
329
329
|
address. Results are reused for 60 seconds. Off by default; off in CI. Sessions started without sideby (running
|
|
330
|
-
claude or codex directly) are not checked. API accounts
|
|
330
|
+
claude or codex directly) are not checked. API accounts are never checked.
|
|
331
331
|
|
|
332
332
|
network shows the setting and the newest result per address (no request)
|
|
333
333
|
network check asks every address now
|
|
@@ -406,6 +406,33 @@ Examples:
|
|
|
406
406
|
sideby progress on --every 15
|
|
407
407
|
sideby progress off
|
|
408
408
|
Exit: 0 shown or done (also when nothing changed); 2 an interval or option it does not take.`,
|
|
409
|
+
trust: `sideby trust [--dir <path>] [--json]
|
|
410
|
+
sideby trust on|off [--yes] [--json]
|
|
411
|
+
sideby trust undo [--yes] [--json]
|
|
412
|
+
|
|
413
|
+
Carry folder trust between Claude accounts. Claude Code asks "Is this a project you created or one you trust?" in
|
|
414
|
+
every account that has not trusted a folder yet, and its default answer ends the session. With this on, before
|
|
415
|
+
sideby starts an interactive Claude session (sideby run, short commands, pick commands, next, Auto Handoff, AI Tasks,
|
|
416
|
+
Unattended Mode), when that account does not trust the folder and another of your Claude accounts does, sideby
|
|
417
|
+
copies that one trust mark into the account's .claude.json, so Claude Code does not ask again. It reuses only trust
|
|
418
|
+
you already gave; it never trusts a folder none of your accounts trusted. Each copy prints one line.
|
|
419
|
+
|
|
420
|
+
Which trust counts, by Claude Code's own rules: in a git repository, the trust of the repository's main checkout (a
|
|
421
|
+
linked worktree uses its main checkout's); elsewhere, the trust of the folder or a parent folder (never your home
|
|
422
|
+
folder or /). When sideby cannot tell from the files (a submodule, a separate git folder), it copies nothing. It never
|
|
423
|
+
runs git in the folder. A headless run (-p) and \`sideby login\` copy nothing.
|
|
424
|
+
|
|
425
|
+
Without a subcommand: whether it is on, the marks sideby copied, and, while on, whether each Claude account trusts
|
|
426
|
+
the folder (--dir, default the current one); nothing of .claude.json is read while it is off. \`on\` and \`off\`
|
|
427
|
+
change config claude.carryTrust; turning it off keeps what was copied. \`undo\` takes the copied marks back, each
|
|
428
|
+
only while it still holds what sideby wrote. Each shows the change first and makes it with --yes.
|
|
429
|
+
|
|
430
|
+
Examples:
|
|
431
|
+
sideby trust on --yes
|
|
432
|
+
sideby trust --dir ~/code/app
|
|
433
|
+
sideby trust undo
|
|
434
|
+
Exit: 0 shown or done; 10 a change was shown and waits for --yes; 1 undo left a mark it could not change (the line
|
|
435
|
+
says why); 2 malformed command line.`,
|
|
409
436
|
browser: `sideby browser [--enable|--disable] [--yes] [--json]
|
|
410
437
|
sideby browser open <account> [--profile <folder|name>] [--json]
|
|
411
438
|
sideby browser set <account> <folder|name> [--json]
|
|
@@ -506,6 +533,7 @@ const COMMANDS = {
|
|
|
506
533
|
valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at'],
|
|
507
534
|
},
|
|
508
535
|
progress: { flags: ['json'], valued: ['every'] },
|
|
536
|
+
trust: { flags: ['json', 'yes'], valued: ['dir'] },
|
|
509
537
|
new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
|
|
510
538
|
alias: { flags: ['json', 'yes'], valued: ['pick'] },
|
|
511
539
|
doctor: { flags: ['fix', 'force', 'json'] },
|
|
@@ -841,6 +869,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
841
869
|
return await cmds.cmdUnattended(parsed, io);
|
|
842
870
|
case 'progress':
|
|
843
871
|
return await cmds.cmdProgress(parsed, io);
|
|
872
|
+
case 'trust':
|
|
873
|
+
return await cmds.cmdTrust(parsed, io);
|
|
844
874
|
case 'shell-init':
|
|
845
875
|
return await cmds.cmdShellInit(parsed, io);
|
|
846
876
|
case 'plugins':
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { Account } from '../types.ts';
|
|
2
|
+
/** The one field of a `projects` entry sideby reads or writes. */
|
|
3
|
+
export declare const TRUST_FIELD = "hasTrustDialogAccepted";
|
|
4
|
+
/**
|
|
5
|
+
* The key a Claude Account's trust is looked up by for one folder, by Claude Code's documented rules
|
|
6
|
+
* (https://code.claude.com/docs/en/permissions): inside a git checkout the main checkout's root (`git`, a linked
|
|
7
|
+
* worktree uses its main checkout's), elsewhere the folder or any parent folder (`folder`). `unclear` when sideby
|
|
8
|
+
* cannot tell from the files alone; then nothing counts as trusted and nothing is written.
|
|
9
|
+
*/
|
|
10
|
+
export type TrustRoot = {
|
|
11
|
+
kind: 'git';
|
|
12
|
+
folder: string;
|
|
13
|
+
path: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'folder';
|
|
16
|
+
folder: string;
|
|
17
|
+
path: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'unclear';
|
|
20
|
+
folder: string;
|
|
21
|
+
why: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Where trust is looked up for `cwd`, from the files alone: walks up from its real path to the first `.git`. A `.git`
|
|
25
|
+
* folder makes that folder the root; a `.git` file must describe a linked worktree exactly (`worktreeMain`). Anything
|
|
26
|
+
* else (a submodule, a separate git folder, a link, a file sideby cannot read) is `unclear`. Without any `.git`, the
|
|
27
|
+
* folder and its parents count.
|
|
28
|
+
*/
|
|
29
|
+
export declare function trustRoot(cwd: string): Promise<TrustRoot>;
|
|
30
|
+
/**
|
|
31
|
+
* The keys that make an Account trust the folder, narrowest first: the main checkout root in a git checkout, else the
|
|
32
|
+
* folder and every parent. HOME and a filesystem root never count, as Claude Code does not keep trust for them.
|
|
33
|
+
*/
|
|
34
|
+
export declare function trustCandidates(root: TrustRoot, home: string): Promise<string[]>;
|
|
35
|
+
/** What one Account's `.claude.json` says about trust: the keys it trusts, or why it cannot be read. */
|
|
36
|
+
export type TrustRead = {
|
|
37
|
+
status: 'ok';
|
|
38
|
+
keys: Set<string>;
|
|
39
|
+
} | {
|
|
40
|
+
status: 'missing';
|
|
41
|
+
} | {
|
|
42
|
+
status: 'problem';
|
|
43
|
+
why: string;
|
|
44
|
+
};
|
|
45
|
+
/** The keys of `.claude.json` whose `hasTrustDialogAccepted` is `true`; nothing else of the file is kept. */
|
|
46
|
+
export declare function readTrustKeys(file: string): Promise<TrustRead>;
|
|
47
|
+
/** The narrowest key of `candidates` that `read` trusts, or null. Keys compare as written (a real path). */
|
|
48
|
+
export declare function trustedKey(read: TrustRead, candidates: readonly string[]): string | null;
|
|
49
|
+
/** What the field held before sideby set it: no entry for the key, an entry without it, or `false`. */
|
|
50
|
+
export type TrustBefore = 'no-entry' | 'no-field' | 'false';
|
|
51
|
+
/** Internal, for tests: runs between reading the file and writing it, to change it in between. */
|
|
52
|
+
export interface WriteHooks {
|
|
53
|
+
afterRead?: () => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sets `projects[key].hasTrustDialogAccepted` to true in `file`, under the rules of Share Mode `json-key`: never
|
|
57
|
+
* through a link, never in a file that is not a JSON object, a `projects` or an entry that is not an object, or a field
|
|
58
|
+
* that is neither absent nor `false`; only that one field (a new entry is `{ "hasTrustDialogAccepted": true }`), every
|
|
59
|
+
* other key and its order and the file's indentation kept; written atomically (mode 600) only while the file still
|
|
60
|
+
* has the hash it was read with. Never creates the file.
|
|
61
|
+
*/
|
|
62
|
+
export declare function writeTrust(file: string, key: string, hooks?: WriteHooks): Promise<{
|
|
63
|
+
ok: true;
|
|
64
|
+
before: TrustBefore;
|
|
65
|
+
} | {
|
|
66
|
+
ok: true;
|
|
67
|
+
already: true;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
why: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** One carry sideby made, as its record keeps it (sideby's state folder; never a value of `.claude.json`). */
|
|
73
|
+
export interface TrustCarry {
|
|
74
|
+
version: 1;
|
|
75
|
+
/** The Account that got the mark. */
|
|
76
|
+
account: string;
|
|
77
|
+
/** Its `.claude.json`. */
|
|
78
|
+
file: string;
|
|
79
|
+
/** Where that file really was when sideby wrote it: an undo leaves the mark alone once the path leads elsewhere. */
|
|
80
|
+
real: string;
|
|
81
|
+
/** The `projects` key sideby set the field under (a folder path). */
|
|
82
|
+
key: string;
|
|
83
|
+
before: TrustBefore;
|
|
84
|
+
/** The Account whose trust was copied. */
|
|
85
|
+
from: string;
|
|
86
|
+
at: string;
|
|
87
|
+
}
|
|
88
|
+
/** Every carry sideby recorded, oldest first; a record that cannot be read is left out. */
|
|
89
|
+
export declare function readCarries(stateDir: string): Promise<(TrustCarry & {
|
|
90
|
+
record: string;
|
|
91
|
+
parked?: true;
|
|
92
|
+
})[]>;
|
|
93
|
+
/** How long a carry waits for another sideby change of the same `.claude.json`; mutable for tests only. */
|
|
94
|
+
export declare const trustLockWait: {
|
|
95
|
+
timeoutMs: number;
|
|
96
|
+
pollMs: number;
|
|
97
|
+
};
|
|
98
|
+
export interface TrustContext {
|
|
99
|
+
/** Every Claude Account sideby knows (the Main Account included). */
|
|
100
|
+
accounts: readonly Account[];
|
|
101
|
+
/** Where each Account keeps `.claude.json` (the Family's own rule). */
|
|
102
|
+
jsonOf: (account: Account) => string;
|
|
103
|
+
home: string;
|
|
104
|
+
stateDir: string;
|
|
105
|
+
}
|
|
106
|
+
export type CarryResult =
|
|
107
|
+
/** The folder has no key trust could be carried by (HOME, a root, or sideby cannot tell). */
|
|
108
|
+
{
|
|
109
|
+
status: 'no-root';
|
|
110
|
+
} | {
|
|
111
|
+
status: 'already';
|
|
112
|
+
}
|
|
113
|
+
/** No other Account trusts the folder: nothing to copy, and nothing is created. */
|
|
114
|
+
| {
|
|
115
|
+
status: 'none';
|
|
116
|
+
} | {
|
|
117
|
+
status: 'carried';
|
|
118
|
+
key: string;
|
|
119
|
+
from: string;
|
|
120
|
+
recordProblem?: boolean;
|
|
121
|
+
} | {
|
|
122
|
+
status: 'skipped';
|
|
123
|
+
key: string;
|
|
124
|
+
from: string;
|
|
125
|
+
why: string;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Before `target` starts in `cwd`: when it does not trust the folder and another Claude Account does, copies that
|
|
129
|
+
* Account's matching key into `target`'s `.claude.json` and records the carry. Reads the other Accounts only when the
|
|
130
|
+
* target lacks trust. Never throws for a file it cannot read or write: the answer says why.
|
|
131
|
+
*/
|
|
132
|
+
export declare function carryTrust(ctx: TrustContext, target: Account, cwd: string, opts: {
|
|
133
|
+
now: Date;
|
|
134
|
+
hooks?: WriteHooks;
|
|
135
|
+
}): Promise<CarryResult>;
|
|
136
|
+
/** The one line a Launch prints for a carry, or null when there is nothing to say. `show` shortens a path. */
|
|
137
|
+
export declare function carryLine(r: CarryResult, target: string, show: (p: string) => string): string | null;
|
|
138
|
+
/** Each Claude Account's trust of one folder, for `sideby trust`: booleans only, never another `projects` key. */
|
|
139
|
+
export interface TrustAccountState {
|
|
140
|
+
ref: string;
|
|
141
|
+
/** Absent when sideby cannot tell (the folder is unclear, or the file cannot be read: `problem`). */
|
|
142
|
+
trusts?: boolean;
|
|
143
|
+
problem?: string;
|
|
144
|
+
/** With the setting on, the next Launch of this Account here copies this Account's trust. */
|
|
145
|
+
carryFrom?: string;
|
|
146
|
+
}
|
|
147
|
+
export declare function trustStates(ctx: TrustContext, cwd: string): Promise<{
|
|
148
|
+
root: TrustRoot;
|
|
149
|
+
accounts: TrustAccountState[];
|
|
150
|
+
}>;
|
|
151
|
+
export type UndoStatus = 'undo' | 'undone' | 'changed' | 'gone' | 'blocked' | 'busy';
|
|
152
|
+
export interface UndoItem {
|
|
153
|
+
/** The carry's record (its file name without `.json`): what a confirmation names to undo only what it showed. */
|
|
154
|
+
id: string;
|
|
155
|
+
account: string;
|
|
156
|
+
key: string;
|
|
157
|
+
from: string;
|
|
158
|
+
at: string;
|
|
159
|
+
status: UndoStatus;
|
|
160
|
+
why?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* `sideby trust undo`: every recorded carry, with what undoing it does (`apply` false) or did. A carry that was undone,
|
|
164
|
+
* or whose field the user changed since or whose file is gone, loses its record; one that is blocked or busy keeps it.
|
|
165
|
+
*/
|
|
166
|
+
export declare function undoCarries(stateDir: string, opts: {
|
|
167
|
+
apply: boolean;
|
|
168
|
+
hooks?: WriteHooks;
|
|
169
|
+
/** Only these carries, each as shown (`id` and `at`): one made or carried again since is left for another look. */
|
|
170
|
+
only?: readonly {
|
|
171
|
+
id: string;
|
|
172
|
+
at: string;
|
|
173
|
+
}[];
|
|
174
|
+
}): Promise<UndoItem[]>;
|
|
175
|
+
/** What `sideby trust` and the Panel show (spec §3.43). */
|
|
176
|
+
export interface TrustStatus {
|
|
177
|
+
/** Config `claude.carryTrust`. */
|
|
178
|
+
on: boolean;
|
|
179
|
+
/** The carries sideby recorded and can undo, oldest first. */
|
|
180
|
+
carried: {
|
|
181
|
+
account: string;
|
|
182
|
+
key: string;
|
|
183
|
+
from: string;
|
|
184
|
+
at: string;
|
|
185
|
+
}[];
|
|
186
|
+
/** The folder asked about (its real path), only while on. */
|
|
187
|
+
dir?: string;
|
|
188
|
+
/** Where trust is looked up for it, only while on. */
|
|
189
|
+
root?: {
|
|
190
|
+
kind: TrustRoot['kind'];
|
|
191
|
+
path?: string;
|
|
192
|
+
why?: string;
|
|
193
|
+
};
|
|
194
|
+
/** Each Claude Account's trust of that folder, only while on. */
|
|
195
|
+
accounts?: TrustAccountState[];
|
|
196
|
+
}
|
|
197
|
+
/** `sideby trust` (spec §3.43): never reads a `.claude.json` while the setting is off. */
|
|
198
|
+
export declare function trustStatus(ctx: TrustContext, on: boolean, cwd?: string): Promise<TrustStatus>;
|