dsh-taskbridge 0.0.0-stage → 1.3.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/CHANGELOG.md +754 -0
- package/LICENSE +21 -0
- package/README.md +624 -3
- package/bin/dsh-delegate-codex-agent.js +115 -0
- package/bin/dsh-delegate-control.d.ts +90 -0
- package/bin/dsh-delegate-control.js +450 -0
- package/bin/dsh-delegate-mcp.d.ts +121 -0
- package/bin/dsh-delegate-mcp.js +273 -0
- package/codex/dsh-delegate.toml +245 -0
- package/cordis.patch.yml +6 -0
- package/docs/INTRODUCTION.md +15 -0
- package/docs/INTRODUCTION.zh.md +32 -0
- package/docs/auth-contract.md +138 -0
- package/docs/claude-code.md +31 -0
- package/docs/codex-integration.md +922 -0
- package/docs/contracts-stage-b.md +443 -0
- package/docs/conversation-placement.md +293 -0
- package/docs/plugin-market.md +30 -0
- package/docs/redaction-contract.md +127 -0
- package/docs/runtime-compatibility.md +220 -0
- package/docs/silent-wait.md +191 -0
- package/docs/taskbridge-upgrade.md +28 -0
- package/docs/taskdispatch-upgrade.md +25 -0
- package/docs/worker-permissions.md +347 -0
- package/docs/workspace-contract.md +538 -0
- package/icon.svg +1 -0
- package/lib/client.d.ts +118 -0
- package/lib/client.js +3232 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +135 -4
- package/src/auth/fence.js +361 -0
- package/src/auth/grants.js +789 -0
- package/src/client/api.js +2322 -0
- package/src/client/index.jsx +2333 -0
- package/src/client/styles.js +251 -0
- package/src/codex/installer.js +3260 -0
- package/src/codex/seam.js +429 -0
- package/src/codex/toml.js +784 -0
- package/src/config/defaults.js +164 -0
- package/src/config/redact.js +184 -0
- package/src/config/settings.js +629 -0
- package/src/config/store.js +186 -0
- package/src/config/validate.js +763 -0
- package/src/credentials/seam.js +202 -0
- package/src/http/execution-plane.js +454 -0
- package/src/http/respond.js +175 -0
- package/src/http/user-plane.js +1122 -0
- package/src/index.d.ts +332 -0
- package/src/index.js +657 -0
- package/src/jobs/activity.js +1008 -0
- package/src/jobs/engine.js +3609 -0
- package/src/jobs/history.js +1467 -0
- package/src/mcp/server.js +1820 -0
- package/src/mcp/wait.js +536 -0
- package/src/model/connectivity.js +371 -0
- package/src/model/discovery.js +582 -0
- package/src/model/native-catalog.js +68 -0
- package/src/model/openai-adapter.js +671 -0
- package/src/model/probe.js +264 -0
- package/src/model/providers.js +756 -0
- package/src/model/routing.js +321 -0
- package/src/review/preset.js +868 -0
- package/src/review/prompts.js +126 -0
- package/src/review/reviewer.js +933 -0
- package/src/runtime/agent-runner.js +1738 -0
- package/src/runtime/endpoint-discovery.js +118 -0
- package/src/runtime/permissions.js +1429 -0
- package/src/runtime/sandbox.js +358 -0
- package/src/runtime/session-placement.js +1103 -0
- package/src/workspace/audit.js +775 -0
- package/src/workspace/locks.js +167 -0
- package/src/workspace/preflight.js +424 -0
- package/src/workspace/worktrees.js +613 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Plugin-owned configuration constants and defaults.
|
|
2
|
+
//
|
|
3
|
+
// dsh-delegate owns exactly one namespace and one document. Delegation is
|
|
4
|
+
// disabled on a fresh install; the operator controls it with one persisted
|
|
5
|
+
// switch in the authenticated DSH settings page.
|
|
6
|
+
|
|
7
|
+
/** Persisted document format version. Unknown versions are refused, never migrated silently. */
|
|
8
|
+
export const SCHEMA_VERSION = 1;
|
|
9
|
+
|
|
10
|
+
/** Settings document file name inside the plugin data directory. */
|
|
11
|
+
export const SETTINGS_FILE = 'settings.json';
|
|
12
|
+
|
|
13
|
+
/** Bounded job history file name inside the plugin data directory. */
|
|
14
|
+
export const HISTORY_FILE = 'jobs.json';
|
|
15
|
+
|
|
16
|
+
/** Provider wire protocols this stage actually supports. */
|
|
17
|
+
export const SUPPORTED_PROTOCOLS = Object.freeze(['openai-chat']);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Workspace isolation modes, strongest first.
|
|
21
|
+
*
|
|
22
|
+
* `worktree` is the default: a mutation runs in a disposable git worktree so the
|
|
23
|
+
* operator's checkout is untouched. It requires a committed repository, and this
|
|
24
|
+
* stage refuses it rather than downgrading (see `src/jobs/engine.js`). `shared`
|
|
25
|
+
* therefore has to be *chosen* by the operator — it is never a silent fallback.
|
|
26
|
+
*/
|
|
27
|
+
export const ISOLATION_MODES = Object.freeze(['worktree', 'shared']);
|
|
28
|
+
|
|
29
|
+
/** Isolation mode stored when a document does not name one. */
|
|
30
|
+
export const DEFAULT_ISOLATION = 'worktree';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The retired directory-level conversation mode, kept only as accepted input.
|
|
34
|
+
*
|
|
35
|
+
* A stored settings document may still say `conversation.mode: "reuse"` from an
|
|
36
|
+
* earlier build that let an operator make every run in a directory continue the
|
|
37
|
+
* previous one. That setting is GONE: a new submission always starts a new DSH
|
|
38
|
+
* conversation, and a follow-up continues only the task thread named by
|
|
39
|
+
* `continueFromTaskId`. The value is still tolerated on read so an existing
|
|
40
|
+
* document keeps loading, and it is incapable of causing a reuse because no code
|
|
41
|
+
* path consults it. {@link LEGACY_CONVERSATION_MODES} is the complete set of
|
|
42
|
+
* values a document may still carry.
|
|
43
|
+
*/
|
|
44
|
+
export const LEGACY_CONVERSATION_MODE = 'reuse';
|
|
45
|
+
|
|
46
|
+
/** Every conversation-mode value a stored document may still carry. */
|
|
47
|
+
export const LEGACY_CONVERSATION_MODES = Object.freeze(['new', LEGACY_CONVERSATION_MODE]);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Session/task-thread identity map file name inside the plugin data directory.
|
|
51
|
+
*
|
|
52
|
+
* Holds only `task id -> { source/execution path, DSH Workspace id, DSH Session id,
|
|
53
|
+
* isolation, worktree ownership facts }`, so an explicit `continueFromTaskId`
|
|
54
|
+
* follow-up can ask the harness to resume THAT task's conversation in the same
|
|
55
|
+
* execution path it ran in. No transcript, prompt, output, credential or usage
|
|
56
|
+
* figure is stored here: the native session log remains the single owner of
|
|
57
|
+
* conversation content.
|
|
58
|
+
*/
|
|
59
|
+
export const SESSIONS_FILE = 'sessions.json';
|
|
60
|
+
|
|
61
|
+
/** Hard bounds. Exceeding any of these is a validation error, not a clamp. */
|
|
62
|
+
export const LIMITS = Object.freeze({
|
|
63
|
+
providers: 32,
|
|
64
|
+
manualModelsPerProvider: 128,
|
|
65
|
+
presets: 32,
|
|
66
|
+
timeoutSecondsMin: 30,
|
|
67
|
+
timeoutSecondsMax: 2 * 60 * 60,
|
|
68
|
+
maxParallelismMin: 1,
|
|
69
|
+
maxParallelismMax: 8,
|
|
70
|
+
taskGrantTtlSecondsMin: 30,
|
|
71
|
+
taskGrantTtlSecondsMax: 60 * 60,
|
|
72
|
+
sessionGrantTtlSecondsMin: 60,
|
|
73
|
+
sessionGrantTtlSecondsMax: 12 * 60 * 60,
|
|
74
|
+
// Monitoring. The two thresholds are bounded, and the second one must stay
|
|
75
|
+
// strictly greater than the first: two identical thresholds would deliver a
|
|
76
|
+
// self-check and an attention alert for the same instant, which is exactly the
|
|
77
|
+
// noisy behaviour the whole feature exists to remove.
|
|
78
|
+
selfCheckSecondsMin: 30,
|
|
79
|
+
selfCheckSecondsMax: 60 * 60,
|
|
80
|
+
attentionSecondsMin: 31,
|
|
81
|
+
attentionSecondsMax: 2 * 60 * 60,
|
|
82
|
+
promptChars: 200_000,
|
|
83
|
+
reviewPromptChars: 400_000,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Default activity-monitoring thresholds, in seconds of *inactivity*.
|
|
88
|
+
*
|
|
89
|
+
* A run that keeps producing events never reaches either threshold, so these are
|
|
90
|
+
* not poll intervals: nothing is scheduled until the executor has actually been
|
|
91
|
+
* silent for the first one.
|
|
92
|
+
*/
|
|
93
|
+
export const MONITORING_DEFAULTS = Object.freeze({
|
|
94
|
+
/** Idle span after which one read-only local self-check is performed. */
|
|
95
|
+
selfCheckSeconds: 300,
|
|
96
|
+
/** Idle span after which the wait reports `attention` instead of `heartbeat`. */
|
|
97
|
+
attentionSeconds: 600,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The complete set of native reasoning-effort ids this build understands, in
|
|
102
|
+
* canonical order (weakest first).
|
|
103
|
+
*
|
|
104
|
+
* These are *ids the wire protocol accepts*, not a claim that any model supports
|
|
105
|
+
* them. Whether a given model can take one is declared per model in
|
|
106
|
+
* `provider.models[].efforts`, and both validation and routing refuse anything a
|
|
107
|
+
* model has not declared. `off` is a real id meaning "no reasoning", not an
|
|
108
|
+
* absence of a value: a model must declare it explicitly.
|
|
109
|
+
*/
|
|
110
|
+
export const KNOWN_EFFORTS = Object.freeze(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
111
|
+
|
|
112
|
+
/** Canonical sort index for declared effort ids. */
|
|
113
|
+
export const EFFORT_ORDER = Object.freeze(new Map(KNOWN_EFFORTS.map((id, index) => [id, index])));
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Default settings document. Delegation is off until the operator enables it.
|
|
117
|
+
*/
|
|
118
|
+
export function defaultSettings() {
|
|
119
|
+
return {
|
|
120
|
+
schemaVersion: SCHEMA_VERSION,
|
|
121
|
+
delegationEnabled: false,
|
|
122
|
+
providers: [],
|
|
123
|
+
worker: {
|
|
124
|
+
providerId: null,
|
|
125
|
+
model: null,
|
|
126
|
+
reasoningEffort: null,
|
|
127
|
+
timeoutSeconds: 1800,
|
|
128
|
+
maxParallelism: 1,
|
|
129
|
+
isolation: DEFAULT_ISOLATION,
|
|
130
|
+
},
|
|
131
|
+
review: {
|
|
132
|
+
enabled: false,
|
|
133
|
+
providerId: null,
|
|
134
|
+
model: null,
|
|
135
|
+
reasoningEffort: null,
|
|
136
|
+
},
|
|
137
|
+
// Kept separate from the legacy in-memory connection/grant compatibility
|
|
138
|
+
// layer. New installations use this one switch for MCP dispatch.
|
|
139
|
+
authorization: {
|
|
140
|
+
taskGrantTtlSeconds: 900,
|
|
141
|
+
sessionGrantTtlSeconds: 4 * 60 * 60,
|
|
142
|
+
},
|
|
143
|
+
// Silence thresholds for a running task. Absent in documents written before
|
|
144
|
+
// this block existed; validation fills in the defaults, so schema version 1
|
|
145
|
+
// stays readable both ways and an upgraded document needs no migration step.
|
|
146
|
+
monitoring: {
|
|
147
|
+
selfCheckSeconds: MONITORING_DEFAULTS.selfCheckSeconds,
|
|
148
|
+
attentionSeconds: MONITORING_DEFAULTS.attentionSeconds,
|
|
149
|
+
},
|
|
150
|
+
projectOverrides: {},
|
|
151
|
+
// Named, non-secret worker/review combinations. Empty by default, and absent
|
|
152
|
+
// in documents written before presets existed — validation fills it in, so
|
|
153
|
+
// schema version 1 stays readable both ways.
|
|
154
|
+
presets: [],
|
|
155
|
+
// Deprecated and inert. A document that carries `conversation.mode: "reuse"`
|
|
156
|
+
// from an earlier build still loads, but the value is never consulted: a new
|
|
157
|
+
// submission starts a new DSH conversation and a follow-up continues the task
|
|
158
|
+
// thread named by `continueFromTaskId`. It is written as `new` so an upgraded
|
|
159
|
+
// document stops advertising a capability the plugin no longer has.
|
|
160
|
+
conversation: {
|
|
161
|
+
mode: LEGACY_CONVERSATION_MODES[0],
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Secret masking and structural redaction.
|
|
2
|
+
//
|
|
3
|
+
// One rule governs every public surface: a stored secret value never leaves the
|
|
4
|
+
// module that read it. Configuration surfaces, job history, MCP results and
|
|
5
|
+
// logs carry a masked marker at most.
|
|
6
|
+
|
|
7
|
+
/** Masked placeholder returned wherever a credential would otherwise appear. */
|
|
8
|
+
export const MASK = '••••••••';
|
|
9
|
+
|
|
10
|
+
const SECRET_KEY_PATTERN = /(api[_-]?key|apikey|secret|token|password|passwd|credential[_-]?value|authorization)/i;
|
|
11
|
+
const BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi;
|
|
12
|
+
const KEYLIKE_PATTERN = /\b(sk|pk|ak)-[A-Za-z0-9_-]{16,}\b/g;
|
|
13
|
+
const ASSIGNMENT_PATTERN = /\b([A-Za-z0-9_]*(?:API_?KEY|SECRET|TOKEN|PASSWORD)[A-Za-z0-9_]*)\s*=\s*("[^"]*"|'[^']*'|\S+)/gi;
|
|
14
|
+
/**
|
|
15
|
+
* A profile key embedded in a *directory* name, the shape this repository's own
|
|
16
|
+
* workspace has (`…/Local/Temp/dsh-SoexNz/…`, which held the local user id). It is
|
|
17
|
+
* masked because it identifies an account; only a path-shaped key is matched, so
|
|
18
|
+
* an ordinary hyphenated word in prose is untouched.
|
|
19
|
+
*
|
|
20
|
+
* The preceding separator is captured and re-emitted so a Windows path keeps its
|
|
21
|
+
* backslash. A single combined character class would normalise `\` to `/` and
|
|
22
|
+
* change a path an operator is trying to recognise.
|
|
23
|
+
*/
|
|
24
|
+
const PATH_KEY_PATTERN = /([\\/])(?:dsh|profile)-[A-Za-z0-9]{6,}(?=[\\/]|$)/g;
|
|
25
|
+
|
|
26
|
+
/** What {@link PATH_KEY_PATTERN} replaces the identifying segment with. */
|
|
27
|
+
const PATH_KEY_SEGMENT = 'masks-user-profile-segment';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Exact names of model usage counters. These keys contain the substring `token`,
|
|
31
|
+
* so the secret-key pattern alone would mask every prompt/completion count and
|
|
32
|
+
* publish nothing about what a run actually consumed.
|
|
33
|
+
*
|
|
34
|
+
* The exemption is deliberately an allow-list of exact names, not a `*Tokens`
|
|
35
|
+
* suffix rule: a suffix rule would exempt `refreshTokens` and every future
|
|
36
|
+
* credential field that happens to end in the same letters. The listed keys are
|
|
37
|
+
* also only exempt for a finite non-negative number (see {@link isUsageCounter});
|
|
38
|
+
* a string, object or array behind one of these names is still masked.
|
|
39
|
+
*/
|
|
40
|
+
const USAGE_COUNTER_KEYS = new Set([
|
|
41
|
+
'inputTokens',
|
|
42
|
+
'outputTokens',
|
|
43
|
+
'totalTokens',
|
|
44
|
+
'reasoningTokens',
|
|
45
|
+
'cacheTokens',
|
|
46
|
+
'cacheReadTokens',
|
|
47
|
+
'cacheWriteTokens',
|
|
48
|
+
'input_tokens',
|
|
49
|
+
'output_tokens',
|
|
50
|
+
'total_tokens',
|
|
51
|
+
'reasoning_tokens',
|
|
52
|
+
'cache_tokens',
|
|
53
|
+
'cache_read_tokens',
|
|
54
|
+
'cache_write_tokens',
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether a settings key names a secret that must be masked on the way out.
|
|
59
|
+
* @param {string} key - object key.
|
|
60
|
+
* @returns {boolean} true when the value behind this key is a secret.
|
|
61
|
+
*/
|
|
62
|
+
export function isSecretKey(key) {
|
|
63
|
+
return typeof key === 'string' && SECRET_KEY_PATTERN.test(key);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether a key/value pair is a usage counter that may be published as a number.
|
|
68
|
+
* Requires both an exact counter name and a finite, non-negative number, so a
|
|
69
|
+
* credential stored under a counter-shaped name is still masked.
|
|
70
|
+
* @param {string} key - object key.
|
|
71
|
+
* @param {unknown} value - value behind that key.
|
|
72
|
+
* @returns {boolean} true when the value is a plain usage count.
|
|
73
|
+
*/
|
|
74
|
+
export function isUsageCounter(key, value) {
|
|
75
|
+
if (typeof key !== 'string' || !USAGE_COUNTER_KEYS.has(key)) return false;
|
|
76
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Mask a secret for display. Short values are fully masked so a mask never
|
|
81
|
+
* leaks length or a prefix of a real credential.
|
|
82
|
+
* @param {string} value - secret value.
|
|
83
|
+
* @returns {string} masked marker.
|
|
84
|
+
*/
|
|
85
|
+
export function maskSecret(value) {
|
|
86
|
+
if (typeof value !== 'string' || value === '') return '';
|
|
87
|
+
return MASK;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Replace credential-looking text inside free-form output (diff, model text,
|
|
92
|
+
* diagnostics). This is a safety net for values we never intended to see, not a
|
|
93
|
+
* substitute for not reading them.
|
|
94
|
+
* @param {string} text - untrusted text.
|
|
95
|
+
* @returns {string} text with credential-shaped substrings replaced.
|
|
96
|
+
*/
|
|
97
|
+
export function redactText(text) {
|
|
98
|
+
if (typeof text !== 'string' || text === '') return '';
|
|
99
|
+
return text
|
|
100
|
+
.replace(BEARER_PATTERN, `Bearer ${MASK}`)
|
|
101
|
+
.replace(KEYLIKE_PATTERN, MASK)
|
|
102
|
+
.replace(ASSIGNMENT_PATTERN, (_match, name) => `${name}=${MASK}`)
|
|
103
|
+
// Last, and path-anchored: a workspace path reported by a preflight is shown
|
|
104
|
+
// so an operator can recognise the repository, but the per-profile segment of
|
|
105
|
+
// the platform temp path is not theirs to see.
|
|
106
|
+
.replace(PATH_KEY_PATTERN, (_match, separator) => `${separator}${PATH_KEY_SEGMENT}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Deep-redact a JSON-compatible value: secret-named keys become the mask and
|
|
111
|
+
* every string is passed through {@link redactText}.
|
|
112
|
+
*
|
|
113
|
+
* The one exemption is a genuine model usage counter (exact known name plus a
|
|
114
|
+
* finite non-negative number), so a job record can report what it consumed
|
|
115
|
+
* instead of a wall of masks.
|
|
116
|
+
* @param {unknown} value - value to project.
|
|
117
|
+
* @param {number} [depth] - remaining recursion depth.
|
|
118
|
+
* @returns {unknown} redacted copy.
|
|
119
|
+
*/
|
|
120
|
+
export function redactDeep(value, depth = 0) {
|
|
121
|
+
if (depth > 12) return '[depth-limit]';
|
|
122
|
+
if (value === null || value === undefined) return value ?? null;
|
|
123
|
+
if (typeof value === 'string') return redactText(value);
|
|
124
|
+
if (typeof value === 'number' || typeof value === 'boolean') return value;
|
|
125
|
+
if (Array.isArray(value)) return value.map((item) => redactDeep(item, depth + 1));
|
|
126
|
+
if (typeof value === 'object') {
|
|
127
|
+
const out = {};
|
|
128
|
+
for (const [key, item] of Object.entries(value)) {
|
|
129
|
+
if (isUsageCounter(key, item)) {
|
|
130
|
+
out[key] = item;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (isSecretKey(key) && item !== null && item !== undefined && item !== '') {
|
|
134
|
+
out[key] = typeof item === 'string' ? maskSecret(item) : MASK;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
out[key] = redactDeep(item, depth + 1);
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
return String(value);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Truncate and redact a diagnostic string for durable storage.
|
|
146
|
+
*
|
|
147
|
+
* This lives here, beside {@link redactText}, rather than in the agent runner
|
|
148
|
+
* that first needed it: it is a pure string transform with no harness
|
|
149
|
+
* dependency, and the stdio MCP executable imports it too. Leaving it in
|
|
150
|
+
* `runtime/agent-runner.js` forced that standalone process to statically import
|
|
151
|
+
* `@deepseek-ai/dsh-llm` and `@deepseek-ai/dsh-agent` — packages only the DSH
|
|
152
|
+
* runtime provides — so the executable died with `ERR_MODULE_NOT_FOUND` before
|
|
153
|
+
* it could even report a missing token.
|
|
154
|
+
* @param {unknown} value - raw error text.
|
|
155
|
+
* @param {number} [max] - character bound.
|
|
156
|
+
* @returns {string | null} redacted text, or null.
|
|
157
|
+
*/
|
|
158
|
+
export function diagnostic(value, max = 800) {
|
|
159
|
+
if (value === null || value === undefined) return null;
|
|
160
|
+
const text = typeof value === 'string' ? value : String(value);
|
|
161
|
+
if (text === '') return null;
|
|
162
|
+
return redactText(text.slice(0, max));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const SENSITIVE_SUFFIXES = ['.pem', '.key', '.pfx', '.p12'];
|
|
166
|
+
const SENSITIVE_PREFIXES = ['credentials', 'secret', 'id_rsa', 'id_ed25519'];
|
|
167
|
+
const ENV_BASENAME = '.env';
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Whether a workspace path names credential material whose content must never
|
|
171
|
+
* be captured into a diff or evidence bundle. The path itself stays visible as
|
|
172
|
+
* a changed file; only its content is withheld.
|
|
173
|
+
* @param {string} relPath - workspace-relative path.
|
|
174
|
+
* @returns {boolean} true when content must be withheld.
|
|
175
|
+
*/
|
|
176
|
+
export function isSensitivePath(relPath) {
|
|
177
|
+
const segments = String(relPath ?? '').replace(/\\/g, '/').split('/');
|
|
178
|
+
return segments.some((raw) => {
|
|
179
|
+
const seg = raw.toLowerCase();
|
|
180
|
+
if (seg === ENV_BASENAME || seg.startsWith(`${ENV_BASENAME}.`)) return true;
|
|
181
|
+
if (SENSITIVE_PREFIXES.some((prefix) => seg.startsWith(prefix))) return true;
|
|
182
|
+
return SENSITIVE_SUFFIXES.some((suffix) => seg.endsWith(suffix));
|
|
183
|
+
});
|
|
184
|
+
}
|