@cleanslop/cli 0.0.0-stage → 0.1.0-beta.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -2
- package/assets/skill-core.md +62 -0
- package/dist/action.d.ts +5 -0
- package/dist/action.js +22 -0
- package/dist/action.js.map +1 -0
- package/dist/args.d.ts +4 -0
- package/dist/args.js +243 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/credits.d.ts +29 -0
- package/dist/commands/credits.js +267 -0
- package/dist/commands/credits.js.map +1 -0
- package/dist/commands/email.d.ts +3 -0
- package/dist/commands/email.js +51 -0
- package/dist/commands/email.js.map +1 -0
- package/dist/commands/link-identity.d.ts +3 -0
- package/dist/commands/link-identity.js +37 -0
- package/dist/commands/link-identity.js.map +1 -0
- package/dist/commands/link-login.d.ts +3 -0
- package/dist/commands/link-login.js +63 -0
- package/dist/commands/link-login.js.map +1 -0
- package/dist/commands/login.d.ts +6 -0
- package/dist/commands/login.js +198 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +40 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/report.d.ts +8 -0
- package/dist/commands/report.js +55 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/scan-upload.d.ts +3 -0
- package/dist/commands/scan-upload.js +85 -0
- package/dist/commands/scan-upload.js.map +1 -0
- package/dist/commands/scan.d.ts +3 -0
- package/dist/commands/scan.js +81 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/setup.d.ts +19 -0
- package/dist/commands/setup.js +154 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +29 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.js +44 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +64 -0
- package/dist/credentials.js +220 -0
- package/dist/credentials.js.map +1 -0
- package/dist/deps.d.ts +58 -0
- package/dist/deps.js +148 -0
- package/dist/deps.js.map +1 -0
- package/dist/exit.d.ts +24 -0
- package/dist/exit.js +29 -0
- package/dist/exit.js.map +1 -0
- package/dist/git.d.ts +14 -0
- package/dist/git.js +161 -0
- package/dist/git.js.map +1 -0
- package/dist/http.d.ts +16 -0
- package/dist/http.js +210 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/link.d.ts +106 -0
- package/dist/link.js +650 -0
- package/dist/link.js.map +1 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.js +75 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp-config.d.ts +13 -0
- package/dist/mcp-config.js +65 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/output.d.ts +9 -0
- package/dist/output.js +65 -0
- package/dist/output.js.map +1 -0
- package/dist/pack.d.ts +30 -0
- package/dist/pack.js +283 -0
- package/dist/pack.js.map +1 -0
- package/dist/redact.d.ts +2 -0
- package/dist/redact.js +17 -0
- package/dist/redact.js.map +1 -0
- package/dist/skill.d.ts +10 -0
- package/dist/skill.js +110 -0
- package/dist/skill.js.map +1 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ustar.d.ts +7 -0
- package/dist/ustar.js +128 -0
- package/dist/ustar.js.map +1 -0
- package/dist/wait.d.ts +11 -0
- package/dist/wait.js +80 -0
- package/dist/wait.js.map +1 -0
- package/package.json +30 -4
package/dist/deps.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type GitResult = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
code: number;
|
|
6
|
+
};
|
|
7
|
+
export type HttpResult = {
|
|
8
|
+
status: number;
|
|
9
|
+
headers: Headers;
|
|
10
|
+
text: string;
|
|
11
|
+
json: unknown | null;
|
|
12
|
+
};
|
|
13
|
+
export type CliIo = {
|
|
14
|
+
stdout: (text: string) => void;
|
|
15
|
+
stderr: (text: string) => void;
|
|
16
|
+
stdinIsTTY: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ExecFileOpts = {
|
|
19
|
+
cwd?: string;
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
};
|
|
23
|
+
export type CliClock = {
|
|
24
|
+
now: () => number;
|
|
25
|
+
sleep: (ms: number) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
export type CliEnv = {
|
|
28
|
+
get: (name: string) => string | undefined;
|
|
29
|
+
cwd: () => string;
|
|
30
|
+
homeDir: () => string;
|
|
31
|
+
hostname: () => string;
|
|
32
|
+
platform: NodeJS.Platform;
|
|
33
|
+
};
|
|
34
|
+
export type CliFs = {
|
|
35
|
+
exists: (path: string) => boolean;
|
|
36
|
+
read: (path: string) => string;
|
|
37
|
+
write: (path: string, data: string, mode: number) => void;
|
|
38
|
+
mkdir: (path: string, mode: number) => void;
|
|
39
|
+
rm: (path: string) => void;
|
|
40
|
+
chmod: (path: string, mode: number) => void;
|
|
41
|
+
statMode: (path: string) => number;
|
|
42
|
+
};
|
|
43
|
+
export type CliDeps = {
|
|
44
|
+
io: CliIo;
|
|
45
|
+
env: CliEnv;
|
|
46
|
+
fs: CliFs;
|
|
47
|
+
clock: CliClock;
|
|
48
|
+
git: (args: string[], cwd: string) => Promise<GitResult>;
|
|
49
|
+
execFile: (file: string, args: string[], opts?: ExecFileOpts) => Promise<GitResult>;
|
|
50
|
+
confirm: (question: string) => Promise<boolean>;
|
|
51
|
+
request: (url: string, init: RequestInit) => Promise<Response>;
|
|
52
|
+
randomId: () => string;
|
|
53
|
+
minPollMs: number;
|
|
54
|
+
defaultWaitMs: number;
|
|
55
|
+
defaultOrigin: string;
|
|
56
|
+
};
|
|
57
|
+
export declare function createDefaultDeps(): CliDeps;
|
|
58
|
+
export declare function mergeDeps(overrides?: Partial<CliDeps>): CliDeps;
|
package/dist/deps.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { homedir, hostname, platform } from "node:os";
|
|
4
|
+
import { DEFAULT_WAIT_MS, MIN_POLL_MS, defaultOrigin } from "./config.js";
|
|
5
|
+
import { redactSecrets } from "./redact.js";
|
|
6
|
+
function runExecFile(file, args, opts = {}) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
execFile(file, args, {
|
|
9
|
+
cwd: opts.cwd,
|
|
10
|
+
env: opts.env,
|
|
11
|
+
timeout: opts.timeout,
|
|
12
|
+
encoding: "utf8",
|
|
13
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
14
|
+
}, (err, stdout, stderr) => {
|
|
15
|
+
const out = typeof stdout === "string" ? stdout : "";
|
|
16
|
+
const errText = typeof stderr === "string" ? stderr : "";
|
|
17
|
+
if (err && "code" in err && err.code === "ENOENT") {
|
|
18
|
+
resolve({
|
|
19
|
+
ok: false,
|
|
20
|
+
stdout: out,
|
|
21
|
+
stderr: errText || err.message,
|
|
22
|
+
code: 127,
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const code = err && "code" in err && typeof err.code === "number" ? err.code : err ? 1 : 0;
|
|
27
|
+
resolve({
|
|
28
|
+
ok: code === 0,
|
|
29
|
+
stdout: out,
|
|
30
|
+
stderr: errText,
|
|
31
|
+
code,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function defaultConfirm(question) {
|
|
37
|
+
if (!process.stdin.isTTY)
|
|
38
|
+
return false;
|
|
39
|
+
process.stderr.write(redactSecrets(`${question} [y/N] `));
|
|
40
|
+
const line = await new Promise((resolve) => {
|
|
41
|
+
const onData = (buf) => {
|
|
42
|
+
process.stdin.off("data", onData);
|
|
43
|
+
resolve(buf.toString("utf8"));
|
|
44
|
+
};
|
|
45
|
+
process.stdin.once("data", onData);
|
|
46
|
+
});
|
|
47
|
+
return /^\s*y(es)?\s*$/i.test(line);
|
|
48
|
+
}
|
|
49
|
+
function spawnGit(args, cwd) {
|
|
50
|
+
return new Promise((resolve) => {
|
|
51
|
+
const child = spawn("git", args, {
|
|
52
|
+
cwd,
|
|
53
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
54
|
+
});
|
|
55
|
+
const stdout = [];
|
|
56
|
+
const stderr = [];
|
|
57
|
+
child.stdout.on("data", (chunk) => {
|
|
58
|
+
stdout.push(chunk);
|
|
59
|
+
});
|
|
60
|
+
child.stderr.on("data", (chunk) => {
|
|
61
|
+
stderr.push(chunk);
|
|
62
|
+
});
|
|
63
|
+
child.on("error", (err) => {
|
|
64
|
+
resolve({
|
|
65
|
+
ok: false,
|
|
66
|
+
stdout: "",
|
|
67
|
+
stderr: err instanceof Error ? err.message : String(err),
|
|
68
|
+
code: 1,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
child.on("close", (code) => {
|
|
72
|
+
const status = code ?? 1;
|
|
73
|
+
resolve({
|
|
74
|
+
ok: status === 0,
|
|
75
|
+
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
76
|
+
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
77
|
+
code: status,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function createDefaultDeps() {
|
|
83
|
+
return {
|
|
84
|
+
io: {
|
|
85
|
+
stdout: (text) => {
|
|
86
|
+
process.stdout.write(redactSecrets(text));
|
|
87
|
+
},
|
|
88
|
+
stderr: (text) => {
|
|
89
|
+
process.stderr.write(redactSecrets(text));
|
|
90
|
+
},
|
|
91
|
+
stdinIsTTY: Boolean(process.stdin.isTTY),
|
|
92
|
+
},
|
|
93
|
+
env: {
|
|
94
|
+
get: (name) => process.env[name],
|
|
95
|
+
cwd: () => process.cwd(),
|
|
96
|
+
homeDir: () => homedir(),
|
|
97
|
+
hostname: () => hostname(),
|
|
98
|
+
platform: platform(),
|
|
99
|
+
},
|
|
100
|
+
fs: {
|
|
101
|
+
exists: (path) => existsSync(path),
|
|
102
|
+
read: (path) => readFileSync(path, "utf8"),
|
|
103
|
+
write: (path, data, mode) => {
|
|
104
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
105
|
+
writeFileSync(tmp, data, { mode });
|
|
106
|
+
renameSync(tmp, path);
|
|
107
|
+
chmodSync(path, mode);
|
|
108
|
+
},
|
|
109
|
+
mkdir: (path, mode) => {
|
|
110
|
+
mkdirSync(path, { recursive: true, mode });
|
|
111
|
+
chmodSync(path, mode);
|
|
112
|
+
},
|
|
113
|
+
rm: (path) => {
|
|
114
|
+
rmSync(path, { force: true });
|
|
115
|
+
},
|
|
116
|
+
chmod: (path, mode) => {
|
|
117
|
+
chmodSync(path, mode);
|
|
118
|
+
},
|
|
119
|
+
statMode: (path) => statSync(path).mode & 0o777,
|
|
120
|
+
},
|
|
121
|
+
clock: {
|
|
122
|
+
now: () => Date.now(),
|
|
123
|
+
sleep: (ms) => new Promise((resolve) => {
|
|
124
|
+
setTimeout(resolve, ms);
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
git: spawnGit,
|
|
128
|
+
execFile: runExecFile,
|
|
129
|
+
confirm: defaultConfirm,
|
|
130
|
+
request: (url, init) => fetch(url, init),
|
|
131
|
+
randomId: () => crypto.randomUUID(),
|
|
132
|
+
minPollMs: MIN_POLL_MS,
|
|
133
|
+
defaultWaitMs: DEFAULT_WAIT_MS,
|
|
134
|
+
defaultOrigin: defaultOrigin(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export function mergeDeps(overrides = {}) {
|
|
138
|
+
const base = createDefaultDeps();
|
|
139
|
+
return {
|
|
140
|
+
...base,
|
|
141
|
+
...overrides,
|
|
142
|
+
io: { ...base.io, ...overrides.io },
|
|
143
|
+
env: { ...base.env, ...overrides.env },
|
|
144
|
+
fs: { ...base.fs, ...overrides.fs },
|
|
145
|
+
clock: { ...base.clock, ...overrides.clock },
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=deps.js.map
|
package/dist/deps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsE5C,SAAS,WAAW,CAClB,IAAY,EACZ,IAAc,EACd,OAAqB,EAAE;IAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CACN,IAAI,EACJ,IAAI,EACJ;YACE,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;SAC5B,EACD,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACtB,MAAM,GAAG,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAA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E,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC;QACxC,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;QACnC,SAAS,EAAE,WAAW;QACtB,aAAa,EAAE,eAAe;QAC9B,aAAa,EAAE,aAAa,EAAE;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,YAA8B,EAAE;IACxD,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,OAAO;QACL,GAAG,IAAI;QACP,GAAG,SAAS;QACZ,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE;QACnC,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,EAAE;QACtC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE;QACnC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE;KAC7C,CAAC;AACJ,CAAC"}
|
package/dist/exit.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const EXIT_OK = 0;
|
|
2
|
+
export declare const EXIT_UNEXPECTED = 1;
|
|
3
|
+
export declare const EXIT_USAGE = 2;
|
|
4
|
+
export declare const EXIT_ACTION = 10;
|
|
5
|
+
export declare const EXIT_PAYMENT = 11;
|
|
6
|
+
export declare const EXIT_POLICY = 12;
|
|
7
|
+
export declare const EXIT_SOURCE = 13;
|
|
8
|
+
export declare const EXIT_SCAN_FAILED = 20;
|
|
9
|
+
export declare const EXIT_RUNNING = 75;
|
|
10
|
+
export type ActionKind = "approve" | "install" | "top-up" | "beta" | "reauth" | "present_identity" | "link_existing" | "ask_human" | "ask_email" | "wait";
|
|
11
|
+
export type ActionRequired = {
|
|
12
|
+
kind: ActionKind;
|
|
13
|
+
humanPrompt: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
code?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare class CliError extends Error {
|
|
18
|
+
readonly exitCode: number;
|
|
19
|
+
readonly action: ActionRequired | undefined;
|
|
20
|
+
constructor(message: string, exitCode: number, action?: ActionRequired);
|
|
21
|
+
}
|
|
22
|
+
export declare function usageError(message: string): CliError;
|
|
23
|
+
export declare function sourceError(message: string, action?: ActionRequired): CliError;
|
|
24
|
+
export declare function actionError(message: string, action: ActionRequired): CliError;
|
package/dist/exit.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const EXIT_OK = 0;
|
|
2
|
+
export const EXIT_UNEXPECTED = 1;
|
|
3
|
+
export const EXIT_USAGE = 2;
|
|
4
|
+
export const EXIT_ACTION = 10;
|
|
5
|
+
export const EXIT_PAYMENT = 11;
|
|
6
|
+
export const EXIT_POLICY = 12;
|
|
7
|
+
export const EXIT_SOURCE = 13;
|
|
8
|
+
export const EXIT_SCAN_FAILED = 20;
|
|
9
|
+
export const EXIT_RUNNING = 75;
|
|
10
|
+
export class CliError extends Error {
|
|
11
|
+
exitCode;
|
|
12
|
+
action;
|
|
13
|
+
constructor(message, exitCode, action) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "CliError";
|
|
16
|
+
this.exitCode = exitCode;
|
|
17
|
+
this.action = action;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function usageError(message) {
|
|
21
|
+
return new CliError(message, EXIT_USAGE);
|
|
22
|
+
}
|
|
23
|
+
export function sourceError(message, action) {
|
|
24
|
+
return new CliError(message, EXIT_SOURCE, action);
|
|
25
|
+
}
|
|
26
|
+
export function actionError(message, action) {
|
|
27
|
+
return new CliError(message, EXIT_ACTION, action);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=exit.js.map
|
package/dist/exit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../src/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
|
+
import type { GitSnapshot } from "./types.js";
|
|
3
|
+
export type GithubRemote = {
|
|
4
|
+
owner: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
fullName: string;
|
|
7
|
+
};
|
|
8
|
+
/** Accept https, git@, and ssh:// forms on github.com only. */
|
|
9
|
+
export declare function parseGithubRemote(raw: string): GithubRemote | null;
|
|
10
|
+
export declare function isPathInsideWorktree(targetPath: string, worktreeRoot: string): boolean;
|
|
11
|
+
export declare function gitToplevel(deps: CliDeps, cwd: string): Promise<string | null>;
|
|
12
|
+
export declare function inspectGit(deps: CliDeps): Promise<GitSnapshot>;
|
|
13
|
+
export declare function assertGithubReady(git: GitSnapshot): void;
|
|
14
|
+
export declare function detectAgentHint(env: CliDeps["env"]): string;
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { basename, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { sourceError } from "./exit.js";
|
|
4
|
+
const OWNER_REPO_RE = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
|
5
|
+
function stripGitSuffix(name) {
|
|
6
|
+
return name.replace(/\.git$/i, "");
|
|
7
|
+
}
|
|
8
|
+
function ownerRepoFromPath(pathname) {
|
|
9
|
+
const parts = pathname.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
10
|
+
if (parts.length < 2)
|
|
11
|
+
return null;
|
|
12
|
+
const owner = parts[0];
|
|
13
|
+
const repo = stripGitSuffix(parts[1]);
|
|
14
|
+
if (!owner || !repo)
|
|
15
|
+
return null;
|
|
16
|
+
const fullName = `${owner}/${repo}`;
|
|
17
|
+
if (!OWNER_REPO_RE.test(fullName))
|
|
18
|
+
return null;
|
|
19
|
+
return { owner, repo, fullName };
|
|
20
|
+
}
|
|
21
|
+
function hostIsGithub(hostname) {
|
|
22
|
+
return hostname.toLowerCase() === "github.com";
|
|
23
|
+
}
|
|
24
|
+
/** Accept https, git@, and ssh:// forms on github.com only. */
|
|
25
|
+
export function parseGithubRemote(raw) {
|
|
26
|
+
const trimmed = raw.trim();
|
|
27
|
+
if (!trimmed)
|
|
28
|
+
return null;
|
|
29
|
+
const scp = /^git@([^:]+):(.+)$/i.exec(trimmed);
|
|
30
|
+
if (scp) {
|
|
31
|
+
if (!hostIsGithub(scp[1]))
|
|
32
|
+
return null;
|
|
33
|
+
return ownerRepoFromPath(scp[2]);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const withScheme = /^[a-zA-Z][a-zA-Z+.-]*:/.test(trimmed)
|
|
37
|
+
? trimmed
|
|
38
|
+
: `https://${trimmed}`;
|
|
39
|
+
const url = new URL(withScheme);
|
|
40
|
+
const protocol = url.protocol.toLowerCase();
|
|
41
|
+
if (protocol !== "https:" && protocol !== "http:" && protocol !== "ssh:") {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (!hostIsGithub(url.hostname))
|
|
45
|
+
return null;
|
|
46
|
+
return ownerRepoFromPath(url.pathname);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Realpath the nearest existing ancestor and re-append the missing tail.
|
|
54
|
+
* Needed because credentials files usually do not exist yet, and git's
|
|
55
|
+
* `--show-toplevel` is already realpath'd (macOS `/var` → `/private/var`).
|
|
56
|
+
*/
|
|
57
|
+
function resolveThroughExistingAncestor(targetPath) {
|
|
58
|
+
const absolute = resolve(targetPath);
|
|
59
|
+
const missing = [];
|
|
60
|
+
let cursor = absolute;
|
|
61
|
+
while (!existsSync(cursor)) {
|
|
62
|
+
const parent = resolve(cursor, "..");
|
|
63
|
+
if (parent === cursor) {
|
|
64
|
+
throw new Error(`no existing ancestor for ${targetPath}`);
|
|
65
|
+
}
|
|
66
|
+
missing.unshift(basename(cursor));
|
|
67
|
+
cursor = parent;
|
|
68
|
+
}
|
|
69
|
+
const real = realpathSync(cursor);
|
|
70
|
+
return missing.length === 0 ? real : resolve(real, ...missing);
|
|
71
|
+
}
|
|
72
|
+
export function isPathInsideWorktree(targetPath, worktreeRoot) {
|
|
73
|
+
try {
|
|
74
|
+
const root = resolveThroughExistingAncestor(worktreeRoot);
|
|
75
|
+
const target = resolveThroughExistingAncestor(targetPath);
|
|
76
|
+
const rel = relative(root, target);
|
|
77
|
+
return (rel === "" ||
|
|
78
|
+
(rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Cannot resolve — refuse the write (fail closed).
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export async function gitToplevel(deps, cwd) {
|
|
86
|
+
const result = await deps.git(["rev-parse", "--show-toplevel"], cwd);
|
|
87
|
+
if (!result.ok)
|
|
88
|
+
return null;
|
|
89
|
+
const top = result.stdout.trim();
|
|
90
|
+
return top || null;
|
|
91
|
+
}
|
|
92
|
+
async function requireGit(deps, args, cwd, message) {
|
|
93
|
+
const result = await deps.git(args, cwd);
|
|
94
|
+
if (!result.ok) {
|
|
95
|
+
throw sourceError(message);
|
|
96
|
+
}
|
|
97
|
+
return result.stdout.trim();
|
|
98
|
+
}
|
|
99
|
+
export async function inspectGit(deps) {
|
|
100
|
+
const cwd = deps.env.cwd();
|
|
101
|
+
const inside = await deps.git(["rev-parse", "--is-inside-work-tree"], cwd);
|
|
102
|
+
if (!inside.ok || inside.stdout.trim() !== "true") {
|
|
103
|
+
throw sourceError("Not a git work tree. Run this from a GitHub checkout.");
|
|
104
|
+
}
|
|
105
|
+
const toplevel = await requireGit(deps, ["rev-parse", "--show-toplevel"], cwd, "Not a git work tree. Run this from a GitHub checkout.");
|
|
106
|
+
const remote = await requireGit(deps, ["remote", "get-url", "origin"], cwd, "No origin remote. CleanSlop needs a github.com origin.");
|
|
107
|
+
const commitSha = await requireGit(deps, ["rev-parse", "HEAD"], cwd, "Could not read HEAD.");
|
|
108
|
+
const branchResult = await deps.git(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
109
|
+
const branch = branchResult.ok ? branchResult.stdout.trim() : "HEAD";
|
|
110
|
+
const status = await deps.git(["status", "--porcelain"], cwd);
|
|
111
|
+
const dirty = status.ok && status.stdout.trim().length > 0;
|
|
112
|
+
const contains = await deps.git(["branch", "-r", "--contains", "HEAD"], cwd);
|
|
113
|
+
const remotes = contains.ok
|
|
114
|
+
? contains.stdout
|
|
115
|
+
.split("\n")
|
|
116
|
+
.map((line) => line.trim())
|
|
117
|
+
.filter(Boolean)
|
|
118
|
+
: [];
|
|
119
|
+
const unpushed = !remotes.some((line) => line.startsWith("origin/"));
|
|
120
|
+
return {
|
|
121
|
+
toplevel,
|
|
122
|
+
remote,
|
|
123
|
+
commitSha,
|
|
124
|
+
branch,
|
|
125
|
+
dirty,
|
|
126
|
+
unpushed,
|
|
127
|
+
github: parseGithubRemote(remote),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function assertGithubReady(git) {
|
|
131
|
+
if (!git.github) {
|
|
132
|
+
throw sourceError("origin is not a github.com remote. Phase 1 only scans GitHub App repos.", {
|
|
133
|
+
kind: "ask_human",
|
|
134
|
+
humanPrompt: "Point origin at a github.com repository, or wait for upload support.",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (git.dirty || git.unpushed) {
|
|
138
|
+
const why = [
|
|
139
|
+
git.dirty ? "the working tree is dirty" : null,
|
|
140
|
+
git.unpushed ? "HEAD is not on any origin/* ref" : null,
|
|
141
|
+
]
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.join(" and ");
|
|
144
|
+
throw sourceError(`Ask the human before committing or pushing (${why}).`, {
|
|
145
|
+
kind: "ask_human",
|
|
146
|
+
humanPrompt: "This checkout has local changes or an unpushed HEAD. Ask the human to commit and push, then rerun. Do not commit or push yourself.",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function detectAgentHint(env) {
|
|
151
|
+
if (env.get("CLAUDECODE") || env.get("CLAUDE_CODE"))
|
|
152
|
+
return "claude-code";
|
|
153
|
+
if (env.get("CURSOR_TRACE_ID") || env.get("CURSOR_AGENT"))
|
|
154
|
+
return "cursor";
|
|
155
|
+
if (env.get("CODEX_HOME") || env.get("CODEX"))
|
|
156
|
+
return "codex";
|
|
157
|
+
if (env.get("REPL_ID") || env.get("REPLIT_DEV_DOMAIN"))
|
|
158
|
+
return "replit";
|
|
159
|
+
return "other";
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAQ3D,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgB;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IACxB,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IACvC,IAAI,CAAC,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C,YAAY,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9D,IAAI,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAAE,OAAO,QAAQ,CAAC;IACxE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CliDeps, HttpResult } from "./deps.js";
|
|
2
|
+
import type { AgentErrorBody } from "./types.js";
|
|
3
|
+
export declare function hasIdentityPresentationChallenge(result: HttpResult): boolean;
|
|
4
|
+
export declare function asRecord(value: unknown): Record<string, unknown> | null;
|
|
5
|
+
export declare function asErrorBody(value: unknown): AgentErrorBody;
|
|
6
|
+
export declare function httpRequest(deps: CliDeps, origin: string, method: string, path: string, opts?: {
|
|
7
|
+
token?: string;
|
|
8
|
+
body?: unknown;
|
|
9
|
+
rawBody?: Uint8Array;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
accept?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
}): Promise<HttpResult>;
|
|
14
|
+
export declare function throwHttpError(result: HttpResult): never;
|
|
15
|
+
export declare function requireOk(result: HttpResult): HttpResult;
|
|
16
|
+
export declare function retryAfterMs(result: HttpResult, fallback: number): number;
|