passport-bridge 0.31.0 → 0.31.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/README.md +1 -1
- package/dist/cliGuardState.d.ts +2 -0
- package/dist/cliGuardState.js +1 -1
- package/dist/cliHookAfter.d.ts +4 -1
- package/dist/cliHookAfter.js +24 -3
- package/dist/cliHookDeliver.d.ts +6 -0
- package/dist/cliHookDeliver.js +14 -0
- package/dist/cliHookLocal.d.ts +6 -0
- package/dist/cliHookLocal.js +10 -4
- package/dist/cliHookPushed.d.ts +18 -0
- package/dist/cliHookPushed.js +32 -0
- package/dist/cliStatus.js +10 -5
- package/dist/localGit.d.ts +7 -0
- package/dist/localGit.js +44 -16
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -278,7 +278,7 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
278
278
|
|
|
279
279
|
**Guard health** (`src/cliGuardHealth.ts`, states and fixes in `src/cliGuardState.ts`, a checked copy of `shared/guardContract.ts`). `passport hook status` and `passport status` show each agent's guard in the web's words, **On**, **Off**, **Outdated**, **Not trusted**, or **Locked**, and each problem's fix (on a terminal the command goes on its own `Run:` line): `passport hook install --agent <agent> --guard --apply`, `npx passport-bridge@latest init`, or `Open Codex → /hooks and trust Passport's hooks.` At most once a day (`$PASSPORT_HOME/guard/.<profile>.heartbeat`) the CLI sends `POST /api/my/guard-health` with `{cliVersion, launcherTarget?, clients: [{client, present, mode, guard, plugin, codexTrust?, locked?, disabledEnv?}]}`: flags only, never a command, path, or value. It goes from a guard run with at least 300 ms of its budget left (a hook's first one waits a day), from `passport exec`, and from `passport status`. Codex trust (`src/cliCodexTrust.ts`) compares `trusted_hash` in `~/.codex/config.toml` `[hooks.state."<hooks.json>:pre_tool_use:<group>:<handler>"]` with Codex's own hash of Passport's guard entry: SHA-256 of the sorted-key JSON of `{event_name, matcher?, hooks: [{type, command, timeout (600 when unset), async, statusMessage?, additionalContextLimit? (when not 2500)}]}`, as in openai/codex `hook_hash`/`version_for_toml`, checked against codex-cli 0.146.0's `hooks/list`. Missing is **Not trusted**, a different hash is **Not trusted** (modified), `enabled = false` is **Off**. **Locked** means managed settings hold Passport's guard: `/Library/Application Support/ClaudeCode/managed-settings.json` (and `managed-settings.d/`), `/etc/claude-code/…`, `/etc/codex/requirements.toml`, `/Library/Application Support/Cursor/hooks.json`, or `/etc/cursor/hooks.json` (`PASSPORT_MANAGED_ROOT` points tests elsewhere).
|
|
280
280
|
|
|
281
|
-
**Coverage** (`src/cliSeen.ts`). The guard counts every command it saw, per agent per day, one character per command in `$PASSPORT_HOME/seen/<profile>.<agent>.<day>.log` (an app's action, not checked, or neither), and Cursor's imported copy of Claude Code's hook doesn't count twice. Counts go in their own batches, at most every five minutes, as `seen: {batch, day, count, governed, opaque}` on `POST /api/my/cli-activity`, never inside a report that can expire. `passport status` prints `
|
|
281
|
+
**Coverage** (`src/cliSeen.ts`). The guard counts every command it saw, per agent per day, one character per command in `$PASSPORT_HOME/seen/<profile>.<agent>.<day>.log` (an app's action, not checked, or neither), and Cursor's imported copy of Claude Code's hook doesn't count twice. Counts go in their own batches, at most every five minutes, as `seen: {batch, day, count, governed, opaque}` on `POST /api/my/cli-activity`, never inside a report that can expire. `passport status` prints `Rules could decide 82% of commands Passport saw this week · 1,204 not checked` and a link to those commands on Work (from a server before the buckets: `Checked 94% of commands Passport saw this week`).
|
|
282
282
|
|
|
283
283
|
**When Passport can't be reached.** A local run, block, or attended ask stands as decided. When the guard needs Passport (an unattended ask, Codex, or a Production action someone else approves) and it doesn't answer within the budget, the environment's `offline` setting from cli-policy v2 decides: ask, block, or allow (ask everywhere by default). An ask nobody can answer (unattended, or Codex) blocks, a second-person action is always blocked, and allow never covers an irreversible action or an ask from a team floor, team or workspace rule, approver rule, or approved exception. A policy synced more than 7 days ago uses the default. The reason ends with one line saying why, such as `Nobody is here to approve it and Passport couldn't be reached, so it's blocked.`
|
|
284
284
|
|
package/dist/cliGuardState.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export type ProblemFix = {
|
|
|
38
38
|
link: string;
|
|
39
39
|
docs: string;
|
|
40
40
|
};
|
|
41
|
+
/** Work's Actions view, the commands Passport couldn't check. */
|
|
42
|
+
export declare const UNCHECKED_LINK = "#work?view=actions&outcome=unchecked";
|
|
41
43
|
export declare function versionBelow(version: string, minimum: string): boolean;
|
|
42
44
|
/** The state this computer can see on its own: no history (Removed) and no
|
|
43
45
|
* staleness, which only Passport knows. */
|
package/dist/cliGuardState.js
CHANGED
|
@@ -25,7 +25,7 @@ export const GUARD_MIN_CLI_VERSION = "0.16.0";
|
|
|
25
25
|
export const GUARD_HEARTBEAT_MS = 24 * 60 * 60_000;
|
|
26
26
|
export const DOCS_BASE = "https://docs.passportmcp.com";
|
|
27
27
|
/** Work's Actions view, the commands Passport couldn't check. */
|
|
28
|
-
const UNCHECKED_LINK = "#work?view=actions&outcome=unchecked";
|
|
28
|
+
export const UNCHECKED_LINK = "#work?view=actions&outcome=unchecked";
|
|
29
29
|
function versionParts(version) {
|
|
30
30
|
const [major, minor, patch] = version.split(".").map((part) => Number.parseInt(part, 10));
|
|
31
31
|
return [major || 0, minor || 0, patch || 0];
|
package/dist/cliHookAfter.d.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* - a vendor sign-in that expired here (`signInFailure.ts`, from the last
|
|
7
7
|
* 4 KB of output, read locally and never sent);
|
|
8
8
|
* - what it created or removed that keeps running (`cliHookCreates.ts`);
|
|
9
|
-
* - how many times in a row the same command failed (`cliHookSessionState.ts`)
|
|
9
|
+
* - how many times in a row the same command failed (`cliHookSessionState.ts`);
|
|
10
|
+
* - the non-default branch a `git push` that succeeded sent (`cliHookPushed.ts`),
|
|
11
|
+
* for the session's title, to any server (an older one refuses it and the
|
|
12
|
+
* report goes again without it).
|
|
10
13
|
*
|
|
11
14
|
* The report carries only the vendor, kinds, names, and counts, and only to
|
|
12
15
|
* a server that keeps them (cli-policy v2 `afterFacts`). The agent hears
|
package/dist/cliHookAfter.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* - a vendor sign-in that expired here (`signInFailure.ts`, from the last
|
|
7
7
|
* 4 KB of output, read locally and never sent);
|
|
8
8
|
* - what it created or removed that keeps running (`cliHookCreates.ts`);
|
|
9
|
-
* - how many times in a row the same command failed (`cliHookSessionState.ts`)
|
|
9
|
+
* - how many times in a row the same command failed (`cliHookSessionState.ts`);
|
|
10
|
+
* - the non-default branch a `git push` that succeeded sent (`cliHookPushed.ts`),
|
|
11
|
+
* for the session's title, to any server (an older one refuses it and the
|
|
12
|
+
* report goes again without it).
|
|
10
13
|
*
|
|
11
14
|
* The report carries only the vendor, kinds, names, and counts, and only to
|
|
12
15
|
* a server that keeps them (cli-policy v2 `afterFacts`). The agent hears
|
|
@@ -22,6 +25,7 @@ import { EXEC_VENDOR_NAMES, vendorCommand } from "./execVendors.js";
|
|
|
22
25
|
import { readKeysChoices } from "./keysKept.js";
|
|
23
26
|
import { outputTail, signInFailureOf } from "./signInFailure.js";
|
|
24
27
|
import { outcomeOfInput } from "./cliHookOutcome.js";
|
|
28
|
+
import { pushedOf } from "./cliHookPushed.js";
|
|
25
29
|
import { RETRY_ASK_AT } from "./cliHookStuck.js";
|
|
26
30
|
/** The agent hears about a retry loop from this many failures in a row. */
|
|
27
31
|
export const RETRY_TELL_AT = 3;
|
|
@@ -55,7 +59,24 @@ function learn(context, state) {
|
|
|
55
59
|
const resources = failed ? { creates: [], removes: [] } : resourcesOf(context.findings);
|
|
56
60
|
const retry = nextRetry(state, context.command, exitCode, context.now);
|
|
57
61
|
const program = retry.state.retry?.program;
|
|
58
|
-
|
|
62
|
+
const pushed = failed ? undefined : pushedOf(context.findings);
|
|
63
|
+
return {
|
|
64
|
+
learned: {
|
|
65
|
+
signIn,
|
|
66
|
+
resources,
|
|
67
|
+
streak: retry.streak,
|
|
68
|
+
...(program ? { program } : {}),
|
|
69
|
+
...(pushed ? { pushed } : {})
|
|
70
|
+
},
|
|
71
|
+
state: retry.state
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** The branch a push sent, on the report (built for it when there was none). Sessions only. */
|
|
75
|
+
function withPushed(context, report, pushed) {
|
|
76
|
+
if (!pushed)
|
|
77
|
+
return report;
|
|
78
|
+
const base = report ?? { ...context.base(), findings: [], opaque: false };
|
|
79
|
+
return base.sessionId ? { ...base, pushed } : report;
|
|
59
80
|
}
|
|
60
81
|
/** The report's new facts, only for a server that keeps them. */
|
|
61
82
|
function withFacts(context, learned) {
|
|
@@ -92,7 +113,7 @@ export function afterCommand(context) {
|
|
|
92
113
|
: state;
|
|
93
114
|
if (JSON.stringify(next) !== JSON.stringify(before))
|
|
94
115
|
writeSessionState(context.runtimeName, sessionId, next);
|
|
95
|
-
const report = withFacts(context, learned);
|
|
116
|
+
const report = withPushed(context, withFacts(context, learned), learned.pushed);
|
|
96
117
|
if (!claude)
|
|
97
118
|
return { report, output: null };
|
|
98
119
|
const asksNext = context.policy?.version === 2 && context.policy.autopilot.retryLoops === true;
|
package/dist/cliHookDeliver.d.ts
CHANGED
|
@@ -106,6 +106,12 @@ export type CliHookReport = {
|
|
|
106
106
|
};
|
|
107
107
|
/** It waited for another session's deploy lease, or didn't run because of one. Names only. */
|
|
108
108
|
lease?: LeaseNote;
|
|
109
|
+
/** A `git push` that succeeded sent this non-default branch, from a folder
|
|
110
|
+
* in this repository (`cliHookPushed.ts`). The two names only. */
|
|
111
|
+
pushed?: {
|
|
112
|
+
branch: string;
|
|
113
|
+
project?: string;
|
|
114
|
+
};
|
|
109
115
|
};
|
|
110
116
|
/** One governed command as reported: never its arguments. v2 adds the
|
|
111
117
|
* environment: a short name the flags gave, or a kind. */
|
package/dist/cliHookDeliver.js
CHANGED
|
@@ -90,6 +90,11 @@ function hasAutopilotFields(report) {
|
|
|
90
90
|
finding.from !== undefined ||
|
|
91
91
|
finding.projectAction !== undefined));
|
|
92
92
|
}
|
|
93
|
+
/** Whether a report still says something once a field an older server refuses is gone. */
|
|
94
|
+
function worthSending(report) {
|
|
95
|
+
const facts = report.signIn ?? report.creates ?? report.removes ?? report.retry ?? report.lease;
|
|
96
|
+
return report.findings.length > 0 || report.opaque || Boolean(report.sessionStarted || report.sessionEnded || facts);
|
|
97
|
+
}
|
|
93
98
|
async function postWith(api, initial, signal) {
|
|
94
99
|
const post = (body) => api(CLI_ACTIVITY_PATH, {
|
|
95
100
|
method: "POST",
|
|
@@ -100,6 +105,15 @@ async function postWith(api, initial, signal) {
|
|
|
100
105
|
let report = initial;
|
|
101
106
|
let response = await post(report);
|
|
102
107
|
await response.body?.cancel().catch(() => undefined);
|
|
108
|
+
// A server from before pushed branches (bridge 0.31.1) refuses the field.
|
|
109
|
+
if (response.status === 400 && report.pushed !== undefined) {
|
|
110
|
+
const { pushed: _pushed, ...rest } = report;
|
|
111
|
+
report = rest;
|
|
112
|
+
if (!worthSending(report))
|
|
113
|
+
return;
|
|
114
|
+
response = await post(report);
|
|
115
|
+
await response.body?.cancel().catch(() => undefined);
|
|
116
|
+
}
|
|
103
117
|
// A server from before unchecked names and repo rules (bridge 0.31.0) refuses them.
|
|
104
118
|
if (response.status === 400 && (report.opaqueNames !== undefined || report.repoRules !== undefined)) {
|
|
105
119
|
const { opaqueNames: _names, repoRules: _rules, ...rest } = report;
|
package/dist/cliHookLocal.d.ts
CHANGED
|
@@ -71,6 +71,12 @@ export declare function gitBranches(dir: string, fs: LocalFs): {
|
|
|
71
71
|
* `.git` file points at its own). Only for a push, and at most a few tiny reads.
|
|
72
72
|
*/
|
|
73
73
|
export declare function folderPushPlace(args: readonly string[], cwd: string | null, machine: Pick<LocalMachine, "fs">): ReturnType<typeof pushPlace>;
|
|
74
|
+
/** The folder a `git … push` runs in (`-C` moves it; null when unknown) and
|
|
75
|
+
* the arguments after `push`. Undefined for any other git command. */
|
|
76
|
+
export declare function pushFolder(args: readonly string[], cwd: string | null): {
|
|
77
|
+
folder: string | null;
|
|
78
|
+
args: string[];
|
|
79
|
+
} | undefined;
|
|
74
80
|
export type LineResult = {
|
|
75
81
|
findings: CliFinding[];
|
|
76
82
|
/** Every part understood: the only lines Passport may allow. */
|
package/dist/cliHookLocal.js
CHANGED
|
@@ -291,6 +291,15 @@ export function gitBranches(dir, fs) {
|
|
|
291
291
|
* `.git` file points at its own). Only for a push, and at most a few tiny reads.
|
|
292
292
|
*/
|
|
293
293
|
export function folderPushPlace(args, cwd, machine) {
|
|
294
|
+
const push = pushFolder(args, cwd);
|
|
295
|
+
if (!push)
|
|
296
|
+
return undefined;
|
|
297
|
+
const branches = push.folder ? gitBranches(push.folder, machine.fs) : { current: null, defaultBranch: null };
|
|
298
|
+
return pushPlace(push.args, { currentBranch: branches.current, defaultBranch: branches.defaultBranch });
|
|
299
|
+
}
|
|
300
|
+
/** The folder a `git … push` runs in (`-C` moves it; null when unknown) and
|
|
301
|
+
* the arguments after `push`. Undefined for any other git command. */
|
|
302
|
+
export function pushFolder(args, cwd) {
|
|
294
303
|
let index = 0;
|
|
295
304
|
let folder = cwd;
|
|
296
305
|
while (index < args.length && args[index].startsWith("-")) {
|
|
@@ -303,10 +312,7 @@ export function folderPushPlace(args, cwd, machine) {
|
|
|
303
312
|
else
|
|
304
313
|
index++;
|
|
305
314
|
}
|
|
306
|
-
|
|
307
|
-
return undefined;
|
|
308
|
-
const branches = folder ? gitBranches(folder, machine.fs) : { current: null, defaultBranch: null };
|
|
309
|
-
return pushPlace(args.slice(index + 1), { currentBranch: branches.current, defaultBranch: branches.defaultBranch });
|
|
315
|
+
return args[index] === "push" ? { folder, args: args.slice(index + 1) } : undefined;
|
|
310
316
|
}
|
|
311
317
|
const RISK_OF_CLASS = { read: "read", change: "write", delete: "destructive", irreversible: "destructive" };
|
|
312
318
|
/** A local action as a finding the guard and reports understand. */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The branch a `git push` sent, for the session's title (bridge 0.31.1).
|
|
3
|
+
*
|
|
4
|
+
* Agents often stay in one folder (the main checkout) and push from other
|
|
5
|
+
* worktrees (`cd ../wt/x && git push -u origin claude/x`), so the folder's
|
|
6
|
+
* own branch never says what they worked on. After a push that succeeded,
|
|
7
|
+
* the report carries the one non-default branch it sent and the name of the
|
|
8
|
+
* repository it ran in (`cliHookProject.ts`), read from the files git writes.
|
|
9
|
+
* Never an argument, a remote, or a URL.
|
|
10
|
+
*/
|
|
11
|
+
import type { CliFinding } from "./cliHookClassify.js";
|
|
12
|
+
import { type LocalFs } from "./cliHookLocal.js";
|
|
13
|
+
export type PushedBranch = {
|
|
14
|
+
branch: string;
|
|
15
|
+
project?: string;
|
|
16
|
+
};
|
|
17
|
+
/** The last non-default branch this command line pushed, or undefined. */
|
|
18
|
+
export declare function pushedOf(findings: readonly CliFinding[], fs?: LocalFs): PushedBranch | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The branch a `git push` sent, for the session's title (bridge 0.31.1).
|
|
3
|
+
*
|
|
4
|
+
* Agents often stay in one folder (the main checkout) and push from other
|
|
5
|
+
* worktrees (`cd ../wt/x && git push -u origin claude/x`), so the folder's
|
|
6
|
+
* own branch never says what they worked on. After a push that succeeded,
|
|
7
|
+
* the report carries the one non-default branch it sent and the name of the
|
|
8
|
+
* repository it ran in (`cliHookProject.ts`), read from the files git writes.
|
|
9
|
+
* Never an argument, a remote, or a URL.
|
|
10
|
+
*/
|
|
11
|
+
import { gitBranches, NODE_FS, pushFolder } from "./cliHookLocal.js";
|
|
12
|
+
import { detectProject, MAX_BRANCH, projectOf } from "./cliHookProject.js";
|
|
13
|
+
import { pushedBranch } from "./localGit.js";
|
|
14
|
+
const CONTROL = /[\u0000-\u001f\u007f-\u009f\s]/;
|
|
15
|
+
/** The last non-default branch this command line pushed, or undefined. */
|
|
16
|
+
export function pushedOf(findings, fs = NODE_FS) {
|
|
17
|
+
let found;
|
|
18
|
+
for (const finding of findings) {
|
|
19
|
+
if (finding.vendor !== "git" || finding.verb !== "push" || finding.pushEnvironment !== "development")
|
|
20
|
+
continue;
|
|
21
|
+
const push = pushFolder(finding.args ?? [], finding.at?.cwd ?? null);
|
|
22
|
+
if (!push?.folder)
|
|
23
|
+
continue;
|
|
24
|
+
const { current, defaultBranch } = gitBranches(push.folder, fs);
|
|
25
|
+
const branch = pushedBranch(push.args, { currentBranch: current, defaultBranch });
|
|
26
|
+
if (!branch || branch.length > MAX_BRANCH || CONTROL.test(branch))
|
|
27
|
+
continue;
|
|
28
|
+
const { project } = fs === NODE_FS ? projectOf(push.folder) : detectProject(push.folder, fs);
|
|
29
|
+
found = { branch, ...(project ? { project } : {}) };
|
|
30
|
+
}
|
|
31
|
+
return found;
|
|
32
|
+
}
|
package/dist/cliStatus.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { managePayload } from "./cliConnect.js";
|
|
2
2
|
import { linksHere, envRows } from "./cliEnv.js";
|
|
3
|
-
import { fixLines } from "./cliGuardState.js";
|
|
3
|
+
import { fixLines, UNCHECKED_LINK } from "./cliGuardState.js";
|
|
4
4
|
import { computerName, keyUse, KEYS_PATH } from "./cliKeys.js";
|
|
5
5
|
import { PRESET_ROWS, PRESET_STANCE_LABEL, rowLabel } from "./cliAutopilotPolicy.js";
|
|
6
6
|
import { ENV_LABEL } from "./cliHookEnvironment.js";
|
|
@@ -8,7 +8,7 @@ import { readBoundedJson, sanitize, timeoutMs } from "./cliSupport.js";
|
|
|
8
8
|
import { ago, mark, paint, table, termOf, visibleLength, wrap } from "./term.js";
|
|
9
9
|
export { ago };
|
|
10
10
|
import { localStatus } from "./cliStatusLocal.js";
|
|
11
|
-
import { ruleLink } from "./webLinks.js";
|
|
11
|
+
import { hashLink, ruleLink } from "./webLinks.js";
|
|
12
12
|
import { agree, countOf } from "./plural.js";
|
|
13
13
|
import { listOf } from "./initUi.js";
|
|
14
14
|
import { VERSION } from "./version.js";
|
|
@@ -119,7 +119,7 @@ function youRows(view, term) {
|
|
|
119
119
|
];
|
|
120
120
|
}
|
|
121
121
|
/** Each agent's guard here and its fix, coverage, time added, and prompts answered. */
|
|
122
|
-
function guardRow(autopilot, term) {
|
|
122
|
+
function guardRow(autopilot, endpoint, term) {
|
|
123
123
|
const guard = autopilot?.guard;
|
|
124
124
|
if (!guard && !autopilot?.answered && !autopilot?.speed)
|
|
125
125
|
return undefined;
|
|
@@ -137,10 +137,15 @@ function guardRow(autopilot, term) {
|
|
|
137
137
|
const days = guard.coverage.days;
|
|
138
138
|
const window = days === 7 ? "this week" : `in the last ${countOf(days, "day")}`;
|
|
139
139
|
const { decides, blind } = guard.coverage;
|
|
140
|
+
// "Not checked", as Work says it: the command ran, but Passport couldn't read it.
|
|
141
|
+
const unchecked = decides !== undefined && blind ? ` · ${blind.toLocaleString("en-US")} not checked` : "";
|
|
140
142
|
const line = decides === undefined
|
|
141
143
|
? `Checked ${guard.coverage.percent}% of commands Passport saw ${window}`
|
|
142
|
-
: `Rules could decide ${decides}% of commands Passport saw ${window}${
|
|
144
|
+
: `Rules could decide ${decides}% of commands Passport saw ${window}${unchecked}`;
|
|
143
145
|
lines.push(...wrap(line, width));
|
|
146
|
+
const link = unchecked ? hashLink(endpoint, UNCHECKED_LINK) : null;
|
|
147
|
+
if (link)
|
|
148
|
+
lines.push(...wrap(`See them: ${link}`, width));
|
|
144
149
|
}
|
|
145
150
|
const speed = autopilot?.speed;
|
|
146
151
|
if (speed)
|
|
@@ -301,7 +306,7 @@ function cliRow(autopilot) {
|
|
|
301
306
|
export function statusLines(view, term) {
|
|
302
307
|
const rows = [
|
|
303
308
|
...youRows(view, term),
|
|
304
|
-
guardRow(view.autopilot, term),
|
|
309
|
+
guardRow(view.autopilot, view.auth.endpoint, term),
|
|
305
310
|
autopilotRow(view.autopilot, view.auth.endpoint, term),
|
|
306
311
|
appRow(view, term),
|
|
307
312
|
keysRow(view, term),
|
package/dist/localGit.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export declare function localBackupVerb(vendor: string, verb: string): boolean;
|
|
|
39
39
|
* (`regenerable.ts`): `rm -r` there, and `git clean`. The guard decides; the
|
|
40
40
|
* server keeps its word only for these. */
|
|
41
41
|
export declare function regenerableVerb(vendor: string, verb: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The one branch a `git push` sends when it is a single, non-default branch
|
|
44
|
+
* (`git push -u origin claude/x`, `git push` on a checked-out branch): the
|
|
45
|
+
* branch a session worked on. Undefined for the default branch, tags,
|
|
46
|
+
* deletes, several refs, or anything Passport can't tell.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pushedBranch(args: string[], ctx: Pick<CommandContext, "currentBranch" | "defaultBranch">): string | undefined;
|
|
42
49
|
/**
|
|
43
50
|
* Where `git push` lands: the default branch is Production, any other branch
|
|
44
51
|
* is Development. Undefined when Passport can't tell (the vendor map's
|
package/dist/localGit.js
CHANGED
|
@@ -304,20 +304,15 @@ export function regenerableVerb(vendor, verb) {
|
|
|
304
304
|
return (vendor === "rm" && verb === "-r project") || (vendor === "git" && verb === "clean");
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
307
|
+
* What a `git push` sends: its flags, the refs after the remote, and the
|
|
308
|
+
* branch (or tag) names they land on. Null when Passport can't tell (a ref
|
|
309
|
+
* that ends empty, `HEAD` or nothing with no branch checked out).
|
|
310
310
|
*/
|
|
311
|
-
|
|
311
|
+
function pushTargets(args, ctx) {
|
|
312
312
|
const flags = args.filter((arg) => arg.startsWith("-"));
|
|
313
313
|
const positional = args.filter((arg, index) => !arg.startsWith("-") &&
|
|
314
314
|
!["-o", "--push-option", "--repo", "--receive-pack", "--exec"].includes(args[index - 1] ?? ""));
|
|
315
|
-
if (flags.some((flag) => flag === "--all" || flag === "--mirror" || flag === "--branches"))
|
|
316
|
-
return "production";
|
|
317
|
-
if (flags.some((flag) => flag === "--tags") && positional.length < 2)
|
|
318
|
-
return "production";
|
|
319
315
|
const refs = positional.slice(1);
|
|
320
|
-
const isDefault = (branch) => (ctx.defaultBranch ? branch === ctx.defaultBranch : false) || PRODUCTION_BRANCHES.has(branch);
|
|
321
316
|
const names = [];
|
|
322
317
|
for (const ref of refs) {
|
|
323
318
|
const target = ref
|
|
@@ -326,25 +321,58 @@ export function pushPlace(args, ctx) {
|
|
|
326
321
|
.at(-1)
|
|
327
322
|
.replace(/^refs\/heads\//, "");
|
|
328
323
|
if (!target)
|
|
329
|
-
return
|
|
324
|
+
return null;
|
|
330
325
|
if (target === "HEAD") {
|
|
331
326
|
if (!ctx.currentBranch)
|
|
332
|
-
return
|
|
327
|
+
return null;
|
|
333
328
|
names.push(ctx.currentBranch);
|
|
334
329
|
}
|
|
335
|
-
else if (target.startsWith("refs/tags/"))
|
|
336
|
-
names.push(target);
|
|
337
330
|
else
|
|
338
331
|
names.push(target);
|
|
339
332
|
}
|
|
340
333
|
if (!names.length) {
|
|
341
334
|
if (!ctx.currentBranch)
|
|
342
|
-
return
|
|
335
|
+
return null;
|
|
343
336
|
names.push(ctx.currentBranch);
|
|
344
337
|
}
|
|
345
|
-
|
|
338
|
+
return { flags, positional, refs, names };
|
|
339
|
+
}
|
|
340
|
+
const WHOLE_PUSH = new Set(["--all", "--mirror", "--branches", "--tags", "--delete", "-d"]);
|
|
341
|
+
/**
|
|
342
|
+
* The one branch a `git push` sends when it is a single, non-default branch
|
|
343
|
+
* (`git push -u origin claude/x`, `git push` on a checked-out branch): the
|
|
344
|
+
* branch a session worked on. Undefined for the default branch, tags,
|
|
345
|
+
* deletes, several refs, or anything Passport can't tell.
|
|
346
|
+
*/
|
|
347
|
+
export function pushedBranch(args, ctx) {
|
|
348
|
+
const sent = pushTargets(args, ctx);
|
|
349
|
+
if (!sent || sent.flags.some((flag) => WHOLE_PUSH.has(flag)) || sent.names.length !== 1)
|
|
350
|
+
return undefined;
|
|
351
|
+
if (sent.refs.some((ref) => ref.startsWith(":")))
|
|
352
|
+
return undefined;
|
|
353
|
+
const name = sent.names[0];
|
|
354
|
+
if (name.startsWith("refs/") || name === ctx.defaultBranch || PRODUCTION_BRANCHES.has(name))
|
|
355
|
+
return undefined;
|
|
356
|
+
return name;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Where `git push` lands: the default branch is Production, any other branch
|
|
360
|
+
* is Development. Undefined when Passport can't tell (the vendor map's
|
|
361
|
+
* "unknown means Production" applies).
|
|
362
|
+
*/
|
|
363
|
+
export function pushPlace(args, ctx) {
|
|
364
|
+
const flags = args.filter((arg) => arg.startsWith("-"));
|
|
365
|
+
if (flags.some((flag) => flag === "--all" || flag === "--mirror" || flag === "--branches"))
|
|
366
|
+
return "production";
|
|
367
|
+
const sent = pushTargets(args, ctx);
|
|
368
|
+
if (flags.some((flag) => flag === "--tags") && (sent?.positional.length ?? 0) < 2)
|
|
369
|
+
return "production";
|
|
370
|
+
if (!sent)
|
|
371
|
+
return undefined;
|
|
372
|
+
const isDefault = (branch) => (ctx.defaultBranch ? branch === ctx.defaultBranch : false) || PRODUCTION_BRANCHES.has(branch);
|
|
373
|
+
if (sent.names.some(isDefault))
|
|
346
374
|
return "production";
|
|
347
375
|
// Deleting a shared branch affects teammates: a Delete in Other apps.
|
|
348
|
-
const deletes = flags.some((flag) => flag === "--delete" || flag === "-d") || refs.some((ref) => ref.startsWith(":"));
|
|
376
|
+
const deletes = flags.some((flag) => flag === "--delete" || flag === "-d") || sent.refs.some((ref) => ref.startsWith(":"));
|
|
349
377
|
return deletes ? "other" : "development";
|
|
350
378
|
}
|
package/dist/pluginPin.d.ts
CHANGED
package/dist/pluginPin.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.31.
|
|
1
|
+
export declare const VERSION = "0.31.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Keep in lockstep with bridge/package.json.
|
|
2
|
-
export const VERSION = "0.31.
|
|
2
|
+
export const VERSION = "0.31.1";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.31.
|
|
9
|
+
"version": "0.31.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.1"
|