@testsprite/testsprite-cli 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/secret-file.js
CHANGED
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
import { closeSync, constants, fstatSync, openSync, readFileSync, statSync } from 'node:fs';
|
|
28
28
|
import { isAbsolute, resolve } from 'node:path';
|
|
29
29
|
import { localValidationError } from './errors.js';
|
|
30
|
+
import { decodeWithBom } from './text-file.js';
|
|
30
31
|
/**
|
|
31
32
|
* Read a secret from `path`, surfacing every filesystem failure as a typed
|
|
32
33
|
* `VALIDATION_ERROR` (exit 5) attributed to `flag`.
|
|
33
34
|
*
|
|
34
|
-
*
|
|
35
|
+
* Most flags trim the returned value. A credential file preserves spaces in a raw Basic pair.
|
|
35
36
|
* Trimming also drops a leading UTF-8 BOM: `U+FEFF` is ECMAScript whitespace,
|
|
36
37
|
* so a file written by PowerShell 5.1's default `Set-Content -Encoding utf8`
|
|
37
38
|
* no longer smuggles an invisible character into the secret.
|
|
@@ -95,8 +96,16 @@ export function readSecretFileGuarded(flag, path) {
|
|
|
95
96
|
throw localValidationError(flag, `not a regular file: ${path}`);
|
|
96
97
|
}
|
|
97
98
|
try {
|
|
99
|
+
// Decoded through decodeWithBom so a UTF-16LE/BE secret file (PowerShell
|
|
100
|
+
// 5.1 `Set-Content -Encoding unicode`) yields the real secret instead of
|
|
101
|
+
// mojibake; decodeWithBom also strips a UTF-8 BOM.
|
|
98
102
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- `fd` is the open file descriptor from openSync() above, not a path string; the rule's non-literal-argument check does not distinguish the two, but there is no path re-resolution here for anything to race against.
|
|
99
|
-
|
|
103
|
+
const value = decodeWithBom(readFileSync(fd));
|
|
104
|
+
// A Basic username or password can start or end in a space. Drop only
|
|
105
|
+
// the file's BOM and one terminating line ending for static credentials.
|
|
106
|
+
return flag === 'credential-file'
|
|
107
|
+
? value.replace(/^\uFEFF/, '').replace(/\r?\n$/, '')
|
|
108
|
+
: value.trim();
|
|
100
109
|
}
|
|
101
110
|
catch (err) {
|
|
102
111
|
throw secretFileError(flag, path, err, 'read');
|
|
@@ -2,19 +2,16 @@ import { type AgentTarget } from './agent-targets.js';
|
|
|
2
2
|
import type { OutputMode } from './output.js';
|
|
3
3
|
/**
|
|
4
4
|
* Full command paths (group + leaf) that signal the caller is actively driving
|
|
5
|
-
* the verification loop — running
|
|
6
|
-
*
|
|
5
|
+
* the verification loop — running tests, or checking auth in preflight. The
|
|
6
|
+
* skill nudge fires ONLY for these.
|
|
7
7
|
*
|
|
8
8
|
* Deliberately excluded:
|
|
9
|
-
* - `setup` / `
|
|
10
|
-
* - read-only inspection (`test list/get
|
|
9
|
+
* - `setup` / `agent install` — they ARE the fix; nudging is circular.
|
|
10
|
+
* - read-only inspection (`test list/get`, `result list/get`, `project list/get`) —
|
|
11
11
|
* keeps an agent that is merely browsing from being nagged.
|
|
12
|
-
* - `auth
|
|
13
|
-
* credential management, not the loop.
|
|
12
|
+
* - `auth remove` — credential management, not the loop.
|
|
14
13
|
*
|
|
15
|
-
* Match the strings emitted by `commandPathOf` in `src/index.ts`.
|
|
16
|
-
* is the primary identity command; `auth whoami` is its deprecated alias and is
|
|
17
|
-
* listed too so the warning fires regardless of which name the caller uses.
|
|
14
|
+
* Match the strings emitted by `commandPathOf` in `src/index.ts`.
|
|
18
15
|
*/
|
|
19
16
|
export declare const SKILL_NUDGE_COMMANDS: ReadonlySet<string>;
|
|
20
17
|
/**
|
|
@@ -22,23 +19,6 @@ export declare const SKILL_NUDGE_COMMANDS: ReadonlySet<string>;
|
|
|
22
19
|
* the CLI by hand without wiring a coding agent.
|
|
23
20
|
*/
|
|
24
21
|
export declare const SKILL_NUDGE_OPT_OUT_ENV = "TESTSPRITE_NO_SKILL_WARNING";
|
|
25
|
-
/**
|
|
26
|
-
* True when this invocation is `test create --plan-template`, a
|
|
27
|
-
* pure-local/informational flag (prints the plan-file skeleton and exits)
|
|
28
|
-
* that must be treated like `setup` / `agent install`: exempt from BOTH the
|
|
29
|
-
* missing-skill nudge above AND the update-registry check
|
|
30
|
-
* (`src/lib/update-check.ts`'s `maybeNotifyUpdate`, which hits the network
|
|
31
|
-
* and writes `~/.testsprite/update-check.json` — both contradict "no
|
|
32
|
-
* network" for this flag). Neither allowlist (`SKILL_NUDGE_COMMANDS` here,
|
|
33
|
-
* the unconditional call site in `src/index.ts`) tracks individual flags,
|
|
34
|
-
* only whole commands, so `src/index.ts`'s `preAction` hook filters this one
|
|
35
|
-
* case via this pure, independently-testable helper instead of teaching
|
|
36
|
-
* either module about flags. Exported from `skill-nudge.ts` (rather than
|
|
37
|
-
* `src/index.ts`, which executes `program.parse()` at import time and so
|
|
38
|
-
* cannot be safely imported by a unit test) purely so it has a home that
|
|
39
|
-
* supports direct unit testing.
|
|
40
|
-
*/
|
|
41
|
-
export declare function isPlanTemplateInvocation(commandPath: string, planTemplate: boolean | undefined): boolean;
|
|
42
22
|
export interface SkillPresenceDeps {
|
|
43
23
|
existsSync?: (p: string) => boolean;
|
|
44
24
|
readFileSync?: (p: string) => string;
|
|
@@ -65,7 +45,7 @@ export interface SkillPresenceDeps {
|
|
|
65
45
|
*/
|
|
66
46
|
export declare function isVerifySkillInstalled(dir: string, deps?: SkillPresenceDeps): boolean;
|
|
67
47
|
export interface SkillNudgeContext {
|
|
68
|
-
/** Full command path, e.g. "
|
|
48
|
+
/** Full command path, e.g. "run" / "auth status". */
|
|
69
49
|
commandPath: string;
|
|
70
50
|
output: OutputMode;
|
|
71
51
|
dryRun: boolean;
|
package/dist/lib/skill-nudge.js
CHANGED
|
@@ -3,54 +3,26 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, TARGETS, } from './agent-targets.js';
|
|
4
4
|
import { detectCallerFromEnv } from './agent-detect.js';
|
|
5
5
|
import { defaultCredentialsPath, readProfile } from './credentials.js';
|
|
6
|
+
import { terminalSafeWriter } from './terminal-text.js';
|
|
6
7
|
/**
|
|
7
8
|
* Full command paths (group + leaf) that signal the caller is actively driving
|
|
8
|
-
* the verification loop — running
|
|
9
|
-
*
|
|
9
|
+
* the verification loop — running tests, or checking auth in preflight. The
|
|
10
|
+
* skill nudge fires ONLY for these.
|
|
10
11
|
*
|
|
11
12
|
* Deliberately excluded:
|
|
12
|
-
* - `setup` / `
|
|
13
|
-
* - read-only inspection (`test list/get
|
|
13
|
+
* - `setup` / `agent install` — they ARE the fix; nudging is circular.
|
|
14
|
+
* - read-only inspection (`test list/get`, `result list/get`, `project list/get`) —
|
|
14
15
|
* keeps an agent that is merely browsing from being nagged.
|
|
15
|
-
* - `auth
|
|
16
|
-
* credential management, not the loop.
|
|
16
|
+
* - `auth remove` — credential management, not the loop.
|
|
17
17
|
*
|
|
18
|
-
* Match the strings emitted by `commandPathOf` in `src/index.ts`.
|
|
19
|
-
* is the primary identity command; `auth whoami` is its deprecated alias and is
|
|
20
|
-
* listed too so the warning fires regardless of which name the caller uses.
|
|
18
|
+
* Match the strings emitted by `commandPathOf` in `src/index.ts`.
|
|
21
19
|
*/
|
|
22
|
-
export const SKILL_NUDGE_COMMANDS = new Set([
|
|
23
|
-
'test run',
|
|
24
|
-
'test rerun',
|
|
25
|
-
'test create',
|
|
26
|
-
'test create-batch',
|
|
27
|
-
'auth status',
|
|
28
|
-
'auth whoami',
|
|
29
|
-
]);
|
|
20
|
+
export const SKILL_NUDGE_COMMANDS = new Set(['run', 'auth status']);
|
|
30
21
|
/**
|
|
31
22
|
* Env var that silences the warning. For CI, or users who deliberately drive
|
|
32
23
|
* the CLI by hand without wiring a coding agent.
|
|
33
24
|
*/
|
|
34
25
|
export const SKILL_NUDGE_OPT_OUT_ENV = 'TESTSPRITE_NO_SKILL_WARNING';
|
|
35
|
-
/**
|
|
36
|
-
* True when this invocation is `test create --plan-template`, a
|
|
37
|
-
* pure-local/informational flag (prints the plan-file skeleton and exits)
|
|
38
|
-
* that must be treated like `setup` / `agent install`: exempt from BOTH the
|
|
39
|
-
* missing-skill nudge above AND the update-registry check
|
|
40
|
-
* (`src/lib/update-check.ts`'s `maybeNotifyUpdate`, which hits the network
|
|
41
|
-
* and writes `~/.testsprite/update-check.json` — both contradict "no
|
|
42
|
-
* network" for this flag). Neither allowlist (`SKILL_NUDGE_COMMANDS` here,
|
|
43
|
-
* the unconditional call site in `src/index.ts`) tracks individual flags,
|
|
44
|
-
* only whole commands, so `src/index.ts`'s `preAction` hook filters this one
|
|
45
|
-
* case via this pure, independently-testable helper instead of teaching
|
|
46
|
-
* either module about flags. Exported from `skill-nudge.ts` (rather than
|
|
47
|
-
* `src/index.ts`, which executes `program.parse()` at import time and so
|
|
48
|
-
* cannot be safely imported by a unit test) purely so it has a home that
|
|
49
|
-
* supports direct unit testing.
|
|
50
|
-
*/
|
|
51
|
-
export function isPlanTemplateInvocation(commandPath, planTemplate) {
|
|
52
|
-
return commandPath === 'test create' && planTemplate === true;
|
|
53
|
-
}
|
|
54
26
|
/**
|
|
55
27
|
* True if the `testsprite-verify` skill is installed in `dir` — for any
|
|
56
28
|
* supported agent, or only for `deps.requiredTargets` when given. own-file
|
|
@@ -117,7 +89,7 @@ function hasCompleteManagedSection(content) {
|
|
|
117
89
|
* `--debug` callers receive the swallowed reason on stderr.
|
|
118
90
|
*/
|
|
119
91
|
export function maybeEmitSkillNudge(ctx) {
|
|
120
|
-
const write = ctx.stderr
|
|
92
|
+
const write = terminalSafeWriter(ctx.stderr);
|
|
121
93
|
try {
|
|
122
94
|
if (ctx.output !== 'text')
|
|
123
95
|
return;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TargetPathFs {
|
|
2
|
+
lstat(p: string): Promise<{
|
|
3
|
+
isFile: boolean;
|
|
4
|
+
isSymbolicLink: boolean;
|
|
5
|
+
} | null>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Inspect existing components before creating a target. Symlinks are refused
|
|
9
|
+
* unless the caller supplies a policy that validates their destination.
|
|
10
|
+
* Returns null at the first missing component. A race between inspection and
|
|
11
|
+
* writing remains, as with the agent installer's original path guard.
|
|
12
|
+
*/
|
|
13
|
+
export declare function inspectTargetPath(agentFs: TargetPathFs, root: string, relPath: string, allowSymlink?: (target: string) => Promise<void>): Promise<{
|
|
14
|
+
isFile: boolean;
|
|
15
|
+
} | null>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { CLIError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Inspect existing components before creating a target. Symlinks are refused
|
|
5
|
+
* unless the caller supplies a policy that validates their destination.
|
|
6
|
+
* Returns null at the first missing component. A race between inspection and
|
|
7
|
+
* writing remains, as with the agent installer's original path guard.
|
|
8
|
+
*/
|
|
9
|
+
export async function inspectTargetPath(agentFs, root, relPath, allowSymlink) {
|
|
10
|
+
const segments = relPath.split(process.platform === 'win32' ? /[/\\]+/ : /\/+/).filter(Boolean);
|
|
11
|
+
let current = root;
|
|
12
|
+
let finalIsFile = false;
|
|
13
|
+
for (const [i, seg] of segments.entries()) {
|
|
14
|
+
current = path.join(current, seg);
|
|
15
|
+
const ls = await agentFs.lstat(current);
|
|
16
|
+
if (ls === null) {
|
|
17
|
+
// This component and everything below it does not exist yet.
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (ls.isSymbolicLink && allowSymlink) {
|
|
21
|
+
await allowSymlink(current);
|
|
22
|
+
}
|
|
23
|
+
else if (ls.isSymbolicLink) {
|
|
24
|
+
const shown = segments.slice(0, i + 1).join('/');
|
|
25
|
+
throw new CLIError(`refusing to write through a symlink: "${shown}" — installing here could place files outside --dir. Remove the symlink or choose a different --dir.`, 5);
|
|
26
|
+
}
|
|
27
|
+
if (i < segments.length - 1 && ls.isFile) {
|
|
28
|
+
const shown = segments.slice(0, i + 1).join('/');
|
|
29
|
+
throw new CLIError(`cannot create ${relPath}: "${shown}" exists and is not a directory.`, 5);
|
|
30
|
+
}
|
|
31
|
+
finalIsFile = ls.isFile;
|
|
32
|
+
}
|
|
33
|
+
return { isFile: finalIsFile };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=target-path.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Point-of-use advisory for `run --target-url`. Response-driven: it
|
|
3
|
+
* compares what the caller asked for against the target the trigger response
|
|
4
|
+
* reports, and speaks up only when they differ — the backend is the ground
|
|
5
|
+
* truth for which origin a run used, so the CLI never infers it.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately cause-agnostic in its wording: a mismatch is reported purely
|
|
8
|
+
* from the observed response, regardless of why the backend didn't apply the
|
|
9
|
+
* override.
|
|
10
|
+
*/
|
|
11
|
+
export declare function targetUrlAdvisoryText(requested: string, applied: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Compare the requested `--target-url` against what the trigger response
|
|
14
|
+
* reports and write the advisory when they differ. No-op when they match
|
|
15
|
+
* (the override was applied, or the caller didn't supply one — callers are
|
|
16
|
+
* expected to gate the `requested` argument on `opts.targetUrl !== undefined`
|
|
17
|
+
* themselves so this stays a pure comparison).
|
|
18
|
+
*/
|
|
19
|
+
export declare function emitTargetUrlMismatchAdvisory(stderr: (line: string) => void, requested: string, applied: string): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { terminalSafeLine } from './terminal-text.js';
|
|
2
|
+
/**
|
|
3
|
+
* Point-of-use advisory for `run --target-url`. Response-driven: it
|
|
4
|
+
* compares what the caller asked for against the target the trigger response
|
|
5
|
+
* reports, and speaks up only when they differ — the backend is the ground
|
|
6
|
+
* truth for which origin a run used, so the CLI never infers it.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately cause-agnostic in its wording: a mismatch is reported purely
|
|
9
|
+
* from the observed response, regardless of why the backend didn't apply the
|
|
10
|
+
* override.
|
|
11
|
+
*/
|
|
12
|
+
export function targetUrlAdvisoryText(requested, applied) {
|
|
13
|
+
const appliedClause = applied.length > 0
|
|
14
|
+
? `the run will use ${terminalSafeLine(applied)} instead`
|
|
15
|
+
: 'the run reports no target URL for it';
|
|
16
|
+
return (`[advisory] --target-url ${terminalSafeLine(requested)} was not applied to this run — ${appliedClause}. ` +
|
|
17
|
+
`The run used its own configured environment.`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compare the requested `--target-url` against what the trigger response
|
|
21
|
+
* reports and write the advisory when they differ. No-op when they match
|
|
22
|
+
* (the override was applied, or the caller didn't supply one — callers are
|
|
23
|
+
* expected to gate the `requested` argument on `opts.targetUrl !== undefined`
|
|
24
|
+
* themselves so this stays a pure comparison).
|
|
25
|
+
*/
|
|
26
|
+
export function emitTargetUrlMismatchAdvisory(stderr, requested, applied) {
|
|
27
|
+
if (applied === requested)
|
|
28
|
+
return;
|
|
29
|
+
stderr(targetUrlAdvisoryText(requested, applied));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=target-url-advisory.js.map
|
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
* string; the resolved-address check only covers *this* URL's host),
|
|
42
42
|
* so following it would hand an attacker-controlled Location header a
|
|
43
43
|
* live SSRF primitive running on the caller's machine or CI runner.
|
|
44
|
+
*
|
|
45
|
+
* One redirect is refused: Vercel Deployment Protection's login wall. Its
|
|
46
|
+
* Location is parsed as a string and never fetched, so the guarantee above
|
|
47
|
+
* holds. Unlike the app's own login page, no test credential gets past
|
|
48
|
+
* Vercel's wall. The honest limitation above (the probe runs here, not on
|
|
49
|
+
* the Lambda) does not apply either: Vercel sends every visitor without a
|
|
50
|
+
* Vercel session there, the Lambda included.
|
|
44
51
|
*/
|
|
45
52
|
import { type ShutdownHandle } from './interrupt.js';
|
|
46
53
|
export interface TargetUrlPreflightDeps {
|
|
@@ -63,6 +70,7 @@ export interface TargetUrlPreflightDeps {
|
|
|
63
70
|
*/
|
|
64
71
|
proxyActive?: boolean;
|
|
65
72
|
}
|
|
73
|
+
/** A `refuse` verdict's `refusal` names why; it becomes `details.reason` on the thrown error. */
|
|
66
74
|
export type TargetUrlPreflightOutcome = {
|
|
67
75
|
verdict: 'ok';
|
|
68
76
|
} | {
|
|
@@ -70,6 +78,7 @@ export type TargetUrlPreflightOutcome = {
|
|
|
70
78
|
reason: string;
|
|
71
79
|
} | {
|
|
72
80
|
verdict: 'refuse';
|
|
81
|
+
refusal: 'target-unreachable' | 'target-protected';
|
|
73
82
|
reason: string;
|
|
74
83
|
};
|
|
75
84
|
/**
|