opencode-swarm 7.148.4 → 7.148.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/{config-doctor-ycf9ws4p.js → config-doctor-6z7x0jnz.js} +2 -2
- package/dist/cli/{core-a1bhs3xa.js → core-0ph6pb2y.js} +1 -1
- package/dist/cli/{curator-llm-factory-rj4vw5fd.js → curator-llm-factory-mbsn281q.js} +17 -17
- package/dist/cli/{curator-8y57gq1g.js → curator-pffqw3br.js} +17 -17
- package/dist/cli/{evidence-summary-service-wkp0gfpd.js → evidence-summary-service-9ajw5tpc.js} +6 -6
- package/dist/cli/{gate-evidence-qty15skw.js → gate-evidence-wc8wzwaw.js} +2 -2
- package/dist/cli/{guardrail-explain-2n3ahs0m.js → guardrail-explain-a8706sq1.js} +18 -18
- package/dist/cli/{guardrail-log-bmxrb3r2.js → guardrail-log-wx43bj32.js} +3 -3
- package/dist/cli/{guardrail-reset-be3sx0am.js → guardrail-reset-sy0vztrd.js} +17 -17
- package/dist/cli/{hive-promoter-te5d78yt.js → hive-promoter-jvyzykgx.js} +17 -17
- package/dist/cli/{index-qpewzk0q.js → index-0yzt06r5.js} +2 -2
- package/dist/cli/{index-sxtz2d26.js → index-1w5nnyew.js} +4 -4
- package/dist/cli/{index-hj1xd3pg.js → index-3aev3a0c.js} +1093 -63
- package/dist/cli/{index-qbvq3xt2.js → index-579qg534.js} +1 -1
- package/dist/cli/{index-7rerkeg8.js → index-59wqcatm.js} +1 -1
- package/dist/cli/{index-1vbmra32.js → index-5r2mcgpa.js} +1 -1
- package/dist/cli/{index-8kzrgjt6.js → index-5zq3892p.js} +1 -1
- package/dist/cli/{index-rzzwem6x.js → index-ag9bv589.js} +19 -19
- package/dist/cli/{index-b94487xm.js → index-arjq717j.js} +1 -1
- package/dist/cli/{index-0045n7qe.js → index-c6jqkx9d.js} +2 -2
- package/dist/cli/{index-622phhp5.js → index-haf092ak.js} +1 -1
- package/dist/cli/{index-bccfz7br.js → index-jzz52as5.js} +3 -3
- package/dist/cli/{index-gswx08pr.js → index-kj6m9ry3.js} +1 -1
- package/dist/cli/{index-skgeytf6.js → index-ne45ew6z.js} +3 -3
- package/dist/cli/{index-6kw1a3bk.js → index-q7ke7kwd.js} +2 -2
- package/dist/cli/{index-9qzkcmry.js → index-qbsc2btq.js} +3 -3
- package/dist/cli/{index-ye7kpzrk.js → index-vyg5b8ee.js} +5 -5
- package/dist/cli/{index-9m8jy3av.js → index-x3d9asnz.js} +1 -1
- package/dist/cli/{index-yq89bgnz.js → index-yezd5ks6.js} +1 -1
- package/dist/cli/{index-w00hn0dd.js → index-zf2vwa7y.js} +1 -1
- package/dist/cli/{index-b1c83zf9.js → index-zhn0q7nf.js} +3 -3
- package/dist/cli/index.js +17 -17
- package/dist/cli/{knowledge-escalator-9w53tx55.js → knowledge-escalator-bvrtfdyb.js} +6 -6
- package/dist/cli/{knowledge-events-my31zepa.js → knowledge-events-rpvkevbm.js} +4 -4
- package/dist/cli/{knowledge-store-yf59mxp5.js → knowledge-store-wjy2kshh.js} +1 -1
- package/dist/cli/{knowledge-validator-8n569fp4.js → knowledge-validator-cq2cgfcx.js} +2 -2
- package/dist/cli/{scan-cursor-www6dbn8.js → scan-cursor-7n0zs72g.js} +2 -2
- package/dist/cli/{schema-vyg0k7rh.js → schema-e59spg93.js} +1 -1
- package/dist/cli/{scope-persistence-3qbr019s.js → scope-persistence-d75p900m.js} +4 -4
- package/dist/cli/{skill-generator-fh8emssb.js → skill-generator-c65y1h6a.js} +7 -7
- package/dist/cli/{worktree-isolation-sbsdx1yj.js → worktree-isolation-ay9d58w4.js} +17 -17
- package/dist/index.js +9 -6
- package/dist/sast/rules/javascript-call-classifier.d.ts +4 -0
- package/package.json +1 -1
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
normalizeToolNameLowerCase,
|
|
12
12
|
stableCanonicalStringify
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-arjq717j.js";
|
|
14
14
|
import {
|
|
15
15
|
detectStraySwarmDirs,
|
|
16
16
|
readDoctorArtifact,
|
|
17
17
|
removeStraySwarmDir,
|
|
18
18
|
runConfigDoctor
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-5r2mcgpa.js";
|
|
20
20
|
import {
|
|
21
21
|
MAX_TRANSIENT_RETRIES,
|
|
22
22
|
archiveEvidence,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
updateTaskStatus,
|
|
63
63
|
validateProjectRoot,
|
|
64
64
|
validateSymlinkBoundary
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-zhn0q7nf.js";
|
|
66
66
|
import {
|
|
67
67
|
EvaluationTaskV1Schema,
|
|
68
68
|
GateAuditManifestV1Schema,
|
|
@@ -105,12 +105,12 @@ import {
|
|
|
105
105
|
} from "./index-y8552snf.js";
|
|
106
106
|
import {
|
|
107
107
|
readRecentEscalations
|
|
108
|
-
} from "./index-
|
|
108
|
+
} from "./index-vyg5b8ee.js";
|
|
109
109
|
import {
|
|
110
110
|
alreadyCuratedThisGeneration,
|
|
111
111
|
claimNextScanBatch,
|
|
112
112
|
resolveCohortId
|
|
113
|
-
} from "./index-
|
|
113
|
+
} from "./index-zf2vwa7y.js";
|
|
114
114
|
import {
|
|
115
115
|
CURATOR_INIT_PROMPT,
|
|
116
116
|
CURATOR_PHASE_PROMPT,
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
retireSkill,
|
|
181
181
|
selectCandidateEntries,
|
|
182
182
|
syncBundledProjectSkillsIfMissingAsync
|
|
183
|
-
} from "./index-
|
|
183
|
+
} from "./index-jzz52as5.js";
|
|
184
184
|
import {
|
|
185
185
|
appendUnactionable,
|
|
186
186
|
quarantineEntry,
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
validateActionableFields,
|
|
192
192
|
validateLesson,
|
|
193
193
|
validateSkillPath
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-kj6m9ry3.js";
|
|
195
195
|
import {
|
|
196
196
|
authorizeCuration,
|
|
197
197
|
buildConfigFingerprintInput
|
|
@@ -252,18 +252,18 @@ import {
|
|
|
252
252
|
transitionTaskWorkflowEvidence,
|
|
253
253
|
withTaskEvidenceTransaction,
|
|
254
254
|
writeWorkflowWalFile
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-haf092ak.js";
|
|
256
256
|
import {
|
|
257
257
|
provisionWorktree,
|
|
258
258
|
removeWorktree
|
|
259
|
-
} from "./index-
|
|
259
|
+
} from "./index-5zq3892p.js";
|
|
260
260
|
import {
|
|
261
261
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
262
262
|
canonicalWorkspaceIdentity,
|
|
263
263
|
clearAllScopes,
|
|
264
264
|
clearScopeBindingFromDisk,
|
|
265
265
|
clearScopeBindings
|
|
266
|
-
} from "./index-
|
|
266
|
+
} from "./index-q7ke7kwd.js";
|
|
267
267
|
import {
|
|
268
268
|
appendLedgerEvent,
|
|
269
269
|
computePlanHash,
|
|
@@ -278,7 +278,7 @@ import {
|
|
|
278
278
|
readPlanEpochIdentity,
|
|
279
279
|
replayFromLedgerWithStatus,
|
|
280
280
|
takeSnapshotEvent
|
|
281
|
-
} from "./index-
|
|
281
|
+
} from "./index-x3d9asnz.js";
|
|
282
282
|
import {
|
|
283
283
|
isPathWithinDeclaredScope,
|
|
284
284
|
sanitizeDiagnosticText
|
|
@@ -330,7 +330,7 @@ import {
|
|
|
330
330
|
transactFile,
|
|
331
331
|
transactKnowledge,
|
|
332
332
|
wordBigrams
|
|
333
|
-
} from "./index-
|
|
333
|
+
} from "./index-1w5nnyew.js";
|
|
334
334
|
import {
|
|
335
335
|
MAX_EVENT_LOG_ENTRIES,
|
|
336
336
|
_internals as _internals2,
|
|
@@ -344,10 +344,10 @@ import {
|
|
|
344
344
|
recordKnowledgeEvent,
|
|
345
345
|
recordPhaseCloseIntent,
|
|
346
346
|
resolveKnowledgeEventsPath
|
|
347
|
-
} from "./index-
|
|
347
|
+
} from "./index-ne45ew6z.js";
|
|
348
348
|
import {
|
|
349
349
|
resolveWorktreeIsolationConfig
|
|
350
|
-
} from "./index-
|
|
350
|
+
} from "./index-c6jqkx9d.js";
|
|
351
351
|
import {
|
|
352
352
|
RetrospectiveEvidenceSchema
|
|
353
353
|
} from "./index-gprxjmm7.js";
|
|
@@ -357,7 +357,7 @@ import {
|
|
|
357
357
|
init_loader,
|
|
358
358
|
loadPluginConfig,
|
|
359
359
|
loadPluginConfigWithMeta
|
|
360
|
-
} from "./index-
|
|
360
|
+
} from "./index-59wqcatm.js";
|
|
361
361
|
import {
|
|
362
362
|
DEFAULT_SKILL_OPT_CONFIG,
|
|
363
363
|
FALLBACK_MODELS_MAX,
|
|
@@ -371,7 +371,7 @@ import {
|
|
|
371
371
|
package_default,
|
|
372
372
|
resolveAutoReviewConfig,
|
|
373
373
|
stripKnownSwarmPrefix
|
|
374
|
-
} from "./index-
|
|
374
|
+
} from "./index-yezd5ks6.js";
|
|
375
375
|
import {
|
|
376
376
|
AGENT_TOOL_MAP,
|
|
377
377
|
ALL_AGENT_NAMES,
|
|
@@ -5608,7 +5608,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
|
|
|
5608
5608
|
awaitingMergeByCallID,
|
|
5609
5609
|
cleanupStandardWorktreeForCallId,
|
|
5610
5610
|
standardWorktreeByCallID
|
|
5611
|
-
} = await import("./worktree-isolation-
|
|
5611
|
+
} = await import("./worktree-isolation-ay9d58w4.js");
|
|
5612
5612
|
standardWorktreeByCallID.delete(descriptor.callID);
|
|
5613
5613
|
if (hasResidue)
|
|
5614
5614
|
awaitingMergeByCallID.set(descriptor.callID, {
|
|
@@ -5710,7 +5710,7 @@ async function recoverCoderSettlement(directory, taskId) {
|
|
|
5710
5710
|
awaitingMergeByCallID,
|
|
5711
5711
|
finishStandardWorktreeDispatch,
|
|
5712
5712
|
standardWorktreeByCallID
|
|
5713
|
-
} = await import("./worktree-isolation-
|
|
5713
|
+
} = await import("./worktree-isolation-ay9d58w4.js");
|
|
5714
5714
|
const descriptor = wal.worktree;
|
|
5715
5715
|
const reconstructedDispatch = {
|
|
5716
5716
|
callID: descriptor.callID,
|
|
@@ -18386,7 +18386,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18386
18386
|
};
|
|
18387
18387
|
}
|
|
18388
18388
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18389
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18389
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
|
|
18390
18390
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18391
18391
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18392
18392
|
if (sweepConfig?.enabled === false)
|
|
@@ -19504,7 +19504,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19504
19504
|
}
|
|
19505
19505
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
19506
19506
|
try {
|
|
19507
|
-
const skillModule = await import("./skill-generator-
|
|
19507
|
+
const skillModule = await import("./skill-generator-c65y1h6a.js");
|
|
19508
19508
|
for (const cand of skillCandidates) {
|
|
19509
19509
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
19510
19510
|
continue;
|
|
@@ -19976,7 +19976,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
19976
19976
|
} catch {}
|
|
19977
19977
|
}
|
|
19978
19978
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
19979
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
19979
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-bvrtfdyb.js");
|
|
19980
19980
|
for (const { id } of contradictedEntries) {
|
|
19981
19981
|
try {
|
|
19982
19982
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -20795,7 +20795,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
20795
20795
|
warnings.push("Failed to collect knowledge summary.");
|
|
20796
20796
|
}
|
|
20797
20797
|
try {
|
|
20798
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
20798
|
+
const { getScanStatus } = await import("./scan-cursor-7n0zs72g.js");
|
|
20799
20799
|
const scanStatus = await getScanStatus(directory);
|
|
20800
20800
|
if (scanStatus.remaining_estimate > 0) {
|
|
20801
20801
|
warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
|
|
@@ -20967,9 +20967,9 @@ var _internals26 = {
|
|
|
20967
20967
|
verifyPostMortemKnowledgeActions,
|
|
20968
20968
|
repairPostMortemActions,
|
|
20969
20969
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
20970
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
20970
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
|
|
20971
20971
|
try {
|
|
20972
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
20972
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
|
|
20973
20973
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
20974
20974
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
20975
20975
|
} catch {
|
|
@@ -20977,11 +20977,11 @@ var _internals26 = {
|
|
|
20977
20977
|
}
|
|
20978
20978
|
},
|
|
20979
20979
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
20980
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
20980
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-pffqw3br.js");
|
|
20981
20981
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
20982
20982
|
},
|
|
20983
20983
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
20984
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
20984
|
+
const { checkHivePromotions } = await import("./hive-promoter-jvyzykgx.js");
|
|
20985
20985
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
20986
20986
|
},
|
|
20987
20987
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -20990,7 +20990,7 @@ var _internals26 = {
|
|
|
20990
20990
|
activateProposal,
|
|
20991
20991
|
listSkills: listSkills2,
|
|
20992
20992
|
sanitizeSlug
|
|
20993
|
-
} = await import("./skill-generator-
|
|
20993
|
+
} = await import("./skill-generator-c65y1h6a.js");
|
|
20994
20994
|
const result = {
|
|
20995
20995
|
approved: [],
|
|
20996
20996
|
rejected: [],
|
|
@@ -22326,9 +22326,9 @@ function hashContent(content) {
|
|
|
22326
22326
|
return createHash10("sha1").update(content).digest("hex");
|
|
22327
22327
|
}
|
|
22328
22328
|
async function loadConfigForPolicyCurator(directory) {
|
|
22329
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22329
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
|
|
22330
22330
|
try {
|
|
22331
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22331
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
|
|
22332
22332
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
22333
22333
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
22334
22334
|
} catch {
|
|
@@ -33524,7 +33524,7 @@ async function runFinalizeStage(ctx) {
|
|
|
33524
33524
|
}
|
|
33525
33525
|
}
|
|
33526
33526
|
try {
|
|
33527
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
33527
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-e59spg93.js");
|
|
33528
33528
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
33529
33529
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
33530
33530
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -35717,9 +35717,9 @@ var _internals45 = {
|
|
|
35717
35717
|
loadPluginConfigWithMeta,
|
|
35718
35718
|
loadCuratorDeps: async () => {
|
|
35719
35719
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
35720
|
-
import("./schema-
|
|
35721
|
-
import("./curator-
|
|
35722
|
-
import("./curator-llm-factory-
|
|
35720
|
+
import("./schema-e59spg93.js"),
|
|
35721
|
+
import("./curator-pffqw3br.js"),
|
|
35722
|
+
import("./curator-llm-factory-mbsn281q.js")
|
|
35723
35723
|
]);
|
|
35724
35724
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
35725
35725
|
}
|
|
@@ -36709,7 +36709,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36709
36709
|
let scanCompleted = false;
|
|
36710
36710
|
let scanRemaining = 0;
|
|
36711
36711
|
try {
|
|
36712
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
36712
|
+
const { getScanStatus } = await import("./scan-cursor-7n0zs72g.js");
|
|
36713
36713
|
const status = await getScanStatus(directory);
|
|
36714
36714
|
scanGeneration = status.generation;
|
|
36715
36715
|
scanCompleted = status.completed;
|
|
@@ -36719,10 +36719,10 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36719
36719
|
try {
|
|
36720
36720
|
const { isLinked: isLinked2 } = await import("./knowledge-link-spw879rs.js");
|
|
36721
36721
|
if (isLinked2(directory)) {
|
|
36722
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
36722
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-e59spg93.js");
|
|
36723
36723
|
let config;
|
|
36724
36724
|
try {
|
|
36725
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
36725
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-qbsc2btq.js");
|
|
36726
36726
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
36727
36727
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
36728
36728
|
} catch {
|
|
@@ -38033,7 +38033,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
38033
38033
|
const result = runConfigDoctor(config, directory);
|
|
38034
38034
|
let output;
|
|
38035
38035
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
38036
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
38036
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-6z7x0jnz.js");
|
|
38037
38037
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
38038
38038
|
applyLossy: true
|
|
38039
38039
|
});
|
|
@@ -38973,7 +38973,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
38973
38973
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
38974
38974
|
}
|
|
38975
38975
|
async function handleEvidenceSummaryCommand(directory) {
|
|
38976
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
38976
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-9ajw5tpc.js");
|
|
38977
38977
|
const artifact = await buildEvidenceSummary(directory);
|
|
38978
38978
|
if (!artifact) {
|
|
38979
38979
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -41962,7 +41962,974 @@ var javaRules = [
|
|
|
41962
41962
|
}
|
|
41963
41963
|
];
|
|
41964
41964
|
|
|
41965
|
+
// src/sast/rules/javascript-call-classifier.ts
|
|
41966
|
+
var MAX_ANALYSIS_BYTES = 512 * 1024;
|
|
41967
|
+
var CHILD_PROCESS_MODULES = new Set(["child_process", "node:child_process"]);
|
|
41968
|
+
var analysisByContext = new WeakMap;
|
|
41969
|
+
var dispositionByContext = new WeakMap;
|
|
41970
|
+
var tokenPairsByList = new WeakMap;
|
|
41971
|
+
var ASSIGNMENTS = new Set([
|
|
41972
|
+
"=",
|
|
41973
|
+
"+=",
|
|
41974
|
+
"-=",
|
|
41975
|
+
"*=",
|
|
41976
|
+
"/=",
|
|
41977
|
+
"%=",
|
|
41978
|
+
"&&=",
|
|
41979
|
+
"||=",
|
|
41980
|
+
"??="
|
|
41981
|
+
]);
|
|
41982
|
+
var DECLARATION_KEYWORDS = new Set(["const", "let", "var"]);
|
|
41983
|
+
function isIdentifierStart(char) {
|
|
41984
|
+
return /[A-Za-z_$]/.test(char);
|
|
41985
|
+
}
|
|
41986
|
+
function isIdentifierPart(char) {
|
|
41987
|
+
return /[A-Za-z0-9_$]/.test(char);
|
|
41988
|
+
}
|
|
41989
|
+
function canStartRegex(previous) {
|
|
41990
|
+
if (!previous)
|
|
41991
|
+
return true;
|
|
41992
|
+
if (previous.kind === "identifier") {
|
|
41993
|
+
return [
|
|
41994
|
+
"return",
|
|
41995
|
+
"throw",
|
|
41996
|
+
"case",
|
|
41997
|
+
"delete",
|
|
41998
|
+
"typeof",
|
|
41999
|
+
"void",
|
|
42000
|
+
"yield",
|
|
42001
|
+
"await"
|
|
42002
|
+
].includes(previous.value);
|
|
42003
|
+
}
|
|
42004
|
+
return previous.kind === "punctuator" && [
|
|
42005
|
+
"(",
|
|
42006
|
+
"[",
|
|
42007
|
+
"{",
|
|
42008
|
+
"=",
|
|
42009
|
+
":",
|
|
42010
|
+
",",
|
|
42011
|
+
";",
|
|
42012
|
+
"!",
|
|
42013
|
+
"?",
|
|
42014
|
+
"=>",
|
|
42015
|
+
"&&",
|
|
42016
|
+
"||",
|
|
42017
|
+
"??"
|
|
42018
|
+
].includes(previous.value);
|
|
42019
|
+
}
|
|
42020
|
+
function tokenize2(content) {
|
|
42021
|
+
const tokens = [];
|
|
42022
|
+
let malformed = false;
|
|
42023
|
+
let index = 0;
|
|
42024
|
+
while (index < content.length) {
|
|
42025
|
+
const char = content[index];
|
|
42026
|
+
const next = content[index + 1];
|
|
42027
|
+
if (/\s/.test(char)) {
|
|
42028
|
+
index++;
|
|
42029
|
+
continue;
|
|
42030
|
+
}
|
|
42031
|
+
if (char === "/" && next === "/") {
|
|
42032
|
+
index += 2;
|
|
42033
|
+
while (index < content.length && content[index] !== `
|
|
42034
|
+
`)
|
|
42035
|
+
index++;
|
|
42036
|
+
continue;
|
|
42037
|
+
}
|
|
42038
|
+
if (char === "/" && next === "*") {
|
|
42039
|
+
const start = index;
|
|
42040
|
+
index += 2;
|
|
42041
|
+
while (index < content.length && !(content[index] === "*" && content[index + 1] === "/")) {
|
|
42042
|
+
index++;
|
|
42043
|
+
}
|
|
42044
|
+
if (index >= content.length) {
|
|
42045
|
+
malformed = true;
|
|
42046
|
+
break;
|
|
42047
|
+
}
|
|
42048
|
+
index += 2;
|
|
42049
|
+
if (index <= start)
|
|
42050
|
+
malformed = true;
|
|
42051
|
+
continue;
|
|
42052
|
+
}
|
|
42053
|
+
if (char === '"' || char === "'") {
|
|
42054
|
+
const quote = char;
|
|
42055
|
+
const start = index++;
|
|
42056
|
+
let value2 = "";
|
|
42057
|
+
let closed = false;
|
|
42058
|
+
while (index < content.length) {
|
|
42059
|
+
const current = content[index];
|
|
42060
|
+
if (current === "\\") {
|
|
42061
|
+
value2 += current;
|
|
42062
|
+
if (index + 1 < content.length)
|
|
42063
|
+
value2 += content[index + 1];
|
|
42064
|
+
index += 2;
|
|
42065
|
+
continue;
|
|
42066
|
+
}
|
|
42067
|
+
if (current === quote) {
|
|
42068
|
+
index++;
|
|
42069
|
+
closed = true;
|
|
42070
|
+
break;
|
|
42071
|
+
}
|
|
42072
|
+
value2 += current;
|
|
42073
|
+
index++;
|
|
42074
|
+
}
|
|
42075
|
+
if (!closed)
|
|
42076
|
+
malformed = true;
|
|
42077
|
+
tokens.push({ kind: "string", value: value2, start, end: index });
|
|
42078
|
+
continue;
|
|
42079
|
+
}
|
|
42080
|
+
if (char === "`") {
|
|
42081
|
+
const start = index++;
|
|
42082
|
+
tokens.push({ kind: "template", value: "", start, end: start + 1 });
|
|
42083
|
+
let closed = false;
|
|
42084
|
+
while (index < content.length) {
|
|
42085
|
+
if (content[index] === "\\") {
|
|
42086
|
+
index += 2;
|
|
42087
|
+
continue;
|
|
42088
|
+
}
|
|
42089
|
+
if (content[index] === "$" && content[index + 1] === "{") {
|
|
42090
|
+
const expressionStart = index + 2;
|
|
42091
|
+
let cursor = expressionStart;
|
|
42092
|
+
let depth = 1;
|
|
42093
|
+
let quote = null;
|
|
42094
|
+
while (cursor < content.length && depth > 0) {
|
|
42095
|
+
const current = content[cursor];
|
|
42096
|
+
if (quote) {
|
|
42097
|
+
if (current === "\\")
|
|
42098
|
+
cursor++;
|
|
42099
|
+
else if (current === quote)
|
|
42100
|
+
quote = null;
|
|
42101
|
+
} else if (current === '"' || current === "'")
|
|
42102
|
+
quote = current;
|
|
42103
|
+
else if (current === "{")
|
|
42104
|
+
depth++;
|
|
42105
|
+
else if (current === "}")
|
|
42106
|
+
depth--;
|
|
42107
|
+
cursor++;
|
|
42108
|
+
}
|
|
42109
|
+
if (depth !== 0) {
|
|
42110
|
+
malformed = true;
|
|
42111
|
+
index = cursor;
|
|
42112
|
+
break;
|
|
42113
|
+
}
|
|
42114
|
+
const nested = tokenize2(content.slice(expressionStart, cursor - 1));
|
|
42115
|
+
for (const token of nested.tokens) {
|
|
42116
|
+
tokens.push({
|
|
42117
|
+
...token,
|
|
42118
|
+
start: token.start + expressionStart,
|
|
42119
|
+
end: token.end + expressionStart
|
|
42120
|
+
});
|
|
42121
|
+
}
|
|
42122
|
+
malformed ||= nested.malformed;
|
|
42123
|
+
index = cursor;
|
|
42124
|
+
continue;
|
|
42125
|
+
}
|
|
42126
|
+
if (content[index] === "`") {
|
|
42127
|
+
index++;
|
|
42128
|
+
closed = true;
|
|
42129
|
+
break;
|
|
42130
|
+
}
|
|
42131
|
+
index++;
|
|
42132
|
+
}
|
|
42133
|
+
if (!closed)
|
|
42134
|
+
malformed = true;
|
|
42135
|
+
continue;
|
|
42136
|
+
}
|
|
42137
|
+
if (char === "/" && canStartRegex(tokens.at(-1))) {
|
|
42138
|
+
const start = index++;
|
|
42139
|
+
let inClass = false;
|
|
42140
|
+
let closed = false;
|
|
42141
|
+
while (index < content.length) {
|
|
42142
|
+
const current = content[index];
|
|
42143
|
+
if (current === "\\") {
|
|
42144
|
+
index += 2;
|
|
42145
|
+
continue;
|
|
42146
|
+
}
|
|
42147
|
+
if (current === "[")
|
|
42148
|
+
inClass = true;
|
|
42149
|
+
if (current === "]")
|
|
42150
|
+
inClass = false;
|
|
42151
|
+
if (current === "/" && !inClass) {
|
|
42152
|
+
index++;
|
|
42153
|
+
while (index < content.length && /[A-Za-z]/.test(content[index]))
|
|
42154
|
+
index++;
|
|
42155
|
+
closed = true;
|
|
42156
|
+
break;
|
|
42157
|
+
}
|
|
42158
|
+
if (current === `
|
|
42159
|
+
`)
|
|
42160
|
+
break;
|
|
42161
|
+
index++;
|
|
42162
|
+
}
|
|
42163
|
+
if (!closed)
|
|
42164
|
+
malformed = true;
|
|
42165
|
+
tokens.push({
|
|
42166
|
+
kind: "regex",
|
|
42167
|
+
value: content.slice(start, index),
|
|
42168
|
+
start,
|
|
42169
|
+
end: index
|
|
42170
|
+
});
|
|
42171
|
+
continue;
|
|
42172
|
+
}
|
|
42173
|
+
if (isIdentifierStart(char)) {
|
|
42174
|
+
const start = index++;
|
|
42175
|
+
while (index < content.length && isIdentifierPart(content[index]))
|
|
42176
|
+
index++;
|
|
42177
|
+
tokens.push({
|
|
42178
|
+
kind: "identifier",
|
|
42179
|
+
value: content.slice(start, index),
|
|
42180
|
+
start,
|
|
42181
|
+
end: index
|
|
42182
|
+
});
|
|
42183
|
+
continue;
|
|
42184
|
+
}
|
|
42185
|
+
if (/\d/.test(char)) {
|
|
42186
|
+
const start = index++;
|
|
42187
|
+
while (index < content.length && /[\w.]/.test(content[index]))
|
|
42188
|
+
index++;
|
|
42189
|
+
tokens.push({
|
|
42190
|
+
kind: "number",
|
|
42191
|
+
value: content.slice(start, index),
|
|
42192
|
+
start,
|
|
42193
|
+
end: index
|
|
42194
|
+
});
|
|
42195
|
+
continue;
|
|
42196
|
+
}
|
|
42197
|
+
const punctuator = [
|
|
42198
|
+
"?.",
|
|
42199
|
+
"=>",
|
|
42200
|
+
"===",
|
|
42201
|
+
"!==",
|
|
42202
|
+
"==",
|
|
42203
|
+
"!=",
|
|
42204
|
+
"++",
|
|
42205
|
+
"--",
|
|
42206
|
+
"+=",
|
|
42207
|
+
"-=",
|
|
42208
|
+
"*=",
|
|
42209
|
+
"/=",
|
|
42210
|
+
"%=",
|
|
42211
|
+
"&&=",
|
|
42212
|
+
"||=",
|
|
42213
|
+
"??=",
|
|
42214
|
+
"&&",
|
|
42215
|
+
"||",
|
|
42216
|
+
"??",
|
|
42217
|
+
"..."
|
|
42218
|
+
].find((candidate) => content.startsWith(candidate, index));
|
|
42219
|
+
const value = punctuator ?? char;
|
|
42220
|
+
tokens.push({
|
|
42221
|
+
kind: "punctuator",
|
|
42222
|
+
value,
|
|
42223
|
+
start: index,
|
|
42224
|
+
end: index + value.length
|
|
42225
|
+
});
|
|
42226
|
+
index += value.length;
|
|
42227
|
+
}
|
|
42228
|
+
return { tokens, malformed };
|
|
42229
|
+
}
|
|
42230
|
+
function addDeclaration(analysis, name) {
|
|
42231
|
+
analysis.declarations.set(name, (analysis.declarations.get(name) ?? 0) + 1);
|
|
42232
|
+
}
|
|
42233
|
+
function addFact(analysis, name, fact, tokenIndex) {
|
|
42234
|
+
const facts = analysis.facts.get(name) ?? new Set;
|
|
42235
|
+
facts.add(fact);
|
|
42236
|
+
analysis.facts.set(name, facts);
|
|
42237
|
+
const scope = declarationScope(analysis, tokenIndex);
|
|
42238
|
+
const scopedFacts = analysis.factScopes.get(name) ?? new Map;
|
|
42239
|
+
const factsAtScope = scopedFacts.get(scope) ?? new Set;
|
|
42240
|
+
factsAtScope.add(fact);
|
|
42241
|
+
scopedFacts.set(scope, factsAtScope);
|
|
42242
|
+
analysis.factScopes.set(name, scopedFacts);
|
|
42243
|
+
}
|
|
42244
|
+
function addScopedMarker(store, name, scope) {
|
|
42245
|
+
const scopes = store.get(name) ?? new Set;
|
|
42246
|
+
scopes.add(scope);
|
|
42247
|
+
store.set(name, scopes);
|
|
42248
|
+
}
|
|
42249
|
+
function hasScopedMarker(store, name, scope) {
|
|
42250
|
+
return scope !== null && (store.get(name)?.has(scope) ?? false);
|
|
42251
|
+
}
|
|
42252
|
+
function visibleScopeAt(analysis, name, callIndex) {
|
|
42253
|
+
return visibleDeclarationScope(analysis, name, callIndex) ?? analysis.scopeAtToken[callIndex] ?? 0;
|
|
42254
|
+
}
|
|
42255
|
+
function hasVisibleMarker(analysis, store, name, callIndex) {
|
|
42256
|
+
let scope = visibleScopeAt(analysis, name, callIndex);
|
|
42257
|
+
while (scope >= 0) {
|
|
42258
|
+
if (store.get(name)?.has(scope))
|
|
42259
|
+
return true;
|
|
42260
|
+
scope = analysis.scopeParents[scope] ?? -1;
|
|
42261
|
+
}
|
|
42262
|
+
return false;
|
|
42263
|
+
}
|
|
42264
|
+
function factsAtVisibleScope(analysis, name, callIndex) {
|
|
42265
|
+
const scope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42266
|
+
return scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
|
|
42267
|
+
}
|
|
42268
|
+
function tokenPairs(tokens) {
|
|
42269
|
+
const cached = tokenPairsByList.get(tokens);
|
|
42270
|
+
if (cached)
|
|
42271
|
+
return cached;
|
|
42272
|
+
const pairs = new Map;
|
|
42273
|
+
const stack = [];
|
|
42274
|
+
const matching = { ")": "(", "]": "[", "}": "{" };
|
|
42275
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42276
|
+
const value = tokens[index]?.value;
|
|
42277
|
+
if (value === "(" || value === "[" || value === "{") {
|
|
42278
|
+
stack.push({ value, index });
|
|
42279
|
+
continue;
|
|
42280
|
+
}
|
|
42281
|
+
const open2 = matching[value ?? ""];
|
|
42282
|
+
if (!open2)
|
|
42283
|
+
continue;
|
|
42284
|
+
const top = stack.at(-1);
|
|
42285
|
+
if (!top || top.value !== open2)
|
|
42286
|
+
continue;
|
|
42287
|
+
stack.pop();
|
|
42288
|
+
pairs.set(top.index, index);
|
|
42289
|
+
pairs.set(index, top.index);
|
|
42290
|
+
}
|
|
42291
|
+
tokenPairsByList.set(tokens, pairs);
|
|
42292
|
+
return pairs;
|
|
42293
|
+
}
|
|
42294
|
+
function pairedToken(tokens, index) {
|
|
42295
|
+
return tokenPairs(tokens).get(index) ?? -1;
|
|
42296
|
+
}
|
|
42297
|
+
function buildScopes(tokens) {
|
|
42298
|
+
const scopeAtToken = [];
|
|
42299
|
+
const scopeParents = [-1];
|
|
42300
|
+
const scopeIsFunction = [true];
|
|
42301
|
+
const stack = [0];
|
|
42302
|
+
const braceCreatesScope = [];
|
|
42303
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42304
|
+
scopeAtToken[index] = stack.at(-1);
|
|
42305
|
+
if (tokens[index]?.value === "{") {
|
|
42306
|
+
const previous = tokens[index - 1];
|
|
42307
|
+
let cursor = index - 1;
|
|
42308
|
+
let importClause = false;
|
|
42309
|
+
while (cursor >= 0 && ![";", "{", "}"].includes(tokens[cursor].value)) {
|
|
42310
|
+
if (tokens[cursor]?.value === "import")
|
|
42311
|
+
importClause = true;
|
|
42312
|
+
cursor--;
|
|
42313
|
+
}
|
|
42314
|
+
const createsScope = !importClause && !DECLARATION_KEYWORDS.has(previous?.value ?? "") && !["=", "(", "[", ",", ":", "return"].includes(previous?.value ?? "");
|
|
42315
|
+
braceCreatesScope.push(createsScope);
|
|
42316
|
+
if (createsScope) {
|
|
42317
|
+
const child = scopeParents.length;
|
|
42318
|
+
scopeParents.push(stack.at(-1));
|
|
42319
|
+
const previousValue = previous?.value;
|
|
42320
|
+
let functionBody = previousValue === "=>";
|
|
42321
|
+
if (previousValue === ")") {
|
|
42322
|
+
const open2 = pairedToken(tokens, index - 1);
|
|
42323
|
+
for (let cursor2 = open2 - 1;cursor2 >= 0; cursor2--) {
|
|
42324
|
+
const value = tokens[cursor2]?.value;
|
|
42325
|
+
if (value === "function") {
|
|
42326
|
+
functionBody = true;
|
|
42327
|
+
break;
|
|
42328
|
+
}
|
|
42329
|
+
if (value === ";" || value === "{" || value === "}")
|
|
42330
|
+
break;
|
|
42331
|
+
}
|
|
42332
|
+
}
|
|
42333
|
+
scopeIsFunction.push(functionBody);
|
|
42334
|
+
stack.push(child);
|
|
42335
|
+
}
|
|
42336
|
+
} else if (tokens[index]?.value === "}") {
|
|
42337
|
+
if (braceCreatesScope.pop() && stack.length > 1)
|
|
42338
|
+
stack.pop();
|
|
42339
|
+
}
|
|
42340
|
+
}
|
|
42341
|
+
return { scopeAtToken, scopeParents, scopeIsFunction };
|
|
42342
|
+
}
|
|
42343
|
+
function declarationScope(analysis, tokenIndex) {
|
|
42344
|
+
if (analysis.varDeclarationIndexes.has(tokenIndex)) {
|
|
42345
|
+
let scope = analysis.scopeAtToken[tokenIndex] ?? 0;
|
|
42346
|
+
while (scope > 0 && !analysis.scopeIsFunction[scope]) {
|
|
42347
|
+
scope = analysis.scopeParents[scope] ?? 0;
|
|
42348
|
+
}
|
|
42349
|
+
return scope;
|
|
42350
|
+
}
|
|
42351
|
+
const parameterScope = analysis.parameterScopes.get(tokenIndex);
|
|
42352
|
+
if (parameterScope !== undefined)
|
|
42353
|
+
return parameterScope;
|
|
42354
|
+
return analysis.scopeAtToken[tokenIndex] ?? 0;
|
|
42355
|
+
}
|
|
42356
|
+
function visibleDeclarationScope(analysis, name, callIndex) {
|
|
42357
|
+
const scopes = analysis.declarationScopes.get(name);
|
|
42358
|
+
if (!scopes)
|
|
42359
|
+
return null;
|
|
42360
|
+
let scope = analysis.scopeAtToken[callIndex] ?? 0;
|
|
42361
|
+
while (scope >= 0) {
|
|
42362
|
+
if (scopes.has(scope))
|
|
42363
|
+
return scope;
|
|
42364
|
+
scope = analysis.scopeParents[scope] ?? -1;
|
|
42365
|
+
}
|
|
42366
|
+
return null;
|
|
42367
|
+
}
|
|
42368
|
+
function matchingToken(tokens, start, open2, close) {
|
|
42369
|
+
if (tokens[start]?.value !== open2)
|
|
42370
|
+
return -1;
|
|
42371
|
+
const match = pairedToken(tokens, start);
|
|
42372
|
+
return tokens[match]?.value === close ? match : -1;
|
|
42373
|
+
}
|
|
42374
|
+
function moduleAtCall(tokens, start, callee) {
|
|
42375
|
+
if (tokens[start]?.value !== callee || tokens[start + 1]?.value !== "(" || tokens[start + 2]?.kind !== "string" || tokens[start + 3]?.value !== ")") {
|
|
42376
|
+
return null;
|
|
42377
|
+
}
|
|
42378
|
+
return tokens[start + 2].value;
|
|
42379
|
+
}
|
|
42380
|
+
function declarationNames(tokens, start, end) {
|
|
42381
|
+
const names = [];
|
|
42382
|
+
if (tokens[start]?.value === "{") {
|
|
42383
|
+
for (let index = start + 1;index < end; index++) {
|
|
42384
|
+
const token = tokens[index];
|
|
42385
|
+
if (token?.kind !== "identifier")
|
|
42386
|
+
continue;
|
|
42387
|
+
if (tokens[index + 1]?.value === ":") {
|
|
42388
|
+
const local = tokens[index + 2];
|
|
42389
|
+
if (local?.kind === "identifier")
|
|
42390
|
+
names.push({ name: local.value, index: index + 2 });
|
|
42391
|
+
index += 2;
|
|
42392
|
+
} else if (tokens[index - 1]?.value !== ":") {
|
|
42393
|
+
names.push({ name: token.value, index });
|
|
42394
|
+
}
|
|
42395
|
+
}
|
|
42396
|
+
} else if (tokens[start]?.kind === "identifier") {
|
|
42397
|
+
names.push({ name: tokens[start].value, index: start });
|
|
42398
|
+
}
|
|
42399
|
+
return names;
|
|
42400
|
+
}
|
|
42401
|
+
function nextFunctionOpen(tokens, start) {
|
|
42402
|
+
for (let index = start + 1;index < tokens.length; index++) {
|
|
42403
|
+
const value = tokens[index]?.value;
|
|
42404
|
+
if (value === "(")
|
|
42405
|
+
return index;
|
|
42406
|
+
if (value === "{" || value === ";" || value === "=>")
|
|
42407
|
+
return -1;
|
|
42408
|
+
}
|
|
42409
|
+
return -1;
|
|
42410
|
+
}
|
|
42411
|
+
function nextFunctionBody(tokens, start) {
|
|
42412
|
+
for (let index = start;index < tokens.length; index++) {
|
|
42413
|
+
const value = tokens[index]?.value;
|
|
42414
|
+
if (value === "{")
|
|
42415
|
+
return index;
|
|
42416
|
+
if (value === ";" || value === "=>")
|
|
42417
|
+
return -1;
|
|
42418
|
+
}
|
|
42419
|
+
return -1;
|
|
42420
|
+
}
|
|
42421
|
+
function collectDeclarations(analysis) {
|
|
42422
|
+
const { tokens } = analysis;
|
|
42423
|
+
const declarationTokenIndexes = new Set;
|
|
42424
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42425
|
+
const token = tokens[index];
|
|
42426
|
+
if (!token)
|
|
42427
|
+
continue;
|
|
42428
|
+
if (token.value === "import") {
|
|
42429
|
+
if (tokens[index + 1]?.value === "type")
|
|
42430
|
+
continue;
|
|
42431
|
+
if (tokens[index + 1]?.value === "{") {
|
|
42432
|
+
const close = matchingToken(tokens, index + 1, "{", "}");
|
|
42433
|
+
for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
|
|
42434
|
+
const imported = tokens[cursor];
|
|
42435
|
+
if (imported?.kind !== "identifier")
|
|
42436
|
+
continue;
|
|
42437
|
+
if (imported.value === "type") {
|
|
42438
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42439
|
+
cursor++;
|
|
42440
|
+
continue;
|
|
42441
|
+
}
|
|
42442
|
+
const local = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
|
|
42443
|
+
if (local?.kind === "identifier") {
|
|
42444
|
+
addDeclaration(analysis, local.value);
|
|
42445
|
+
declarationTokenIndexes.add(tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42446
|
+
}
|
|
42447
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42448
|
+
cursor++;
|
|
42449
|
+
}
|
|
42450
|
+
} else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
|
|
42451
|
+
const local = tokens[index + 3];
|
|
42452
|
+
if (local?.kind === "identifier") {
|
|
42453
|
+
addDeclaration(analysis, local.value);
|
|
42454
|
+
declarationTokenIndexes.add(index + 3);
|
|
42455
|
+
}
|
|
42456
|
+
} else if (tokens[index + 1]?.kind === "identifier") {
|
|
42457
|
+
addDeclaration(analysis, tokens[index + 1].value);
|
|
42458
|
+
declarationTokenIndexes.add(index + 1);
|
|
42459
|
+
}
|
|
42460
|
+
}
|
|
42461
|
+
if (DECLARATION_KEYWORDS.has(token.value)) {
|
|
42462
|
+
const start = index + 1;
|
|
42463
|
+
const close = tokens[start]?.value === "{" ? matchingToken(tokens, start, "{", "}") : start + 1;
|
|
42464
|
+
for (const item of declarationNames(tokens, start, close)) {
|
|
42465
|
+
addDeclaration(analysis, item.name);
|
|
42466
|
+
declarationTokenIndexes.add(item.index);
|
|
42467
|
+
if (token.value === "var")
|
|
42468
|
+
analysis.varDeclarationIndexes.add(item.index);
|
|
42469
|
+
}
|
|
42470
|
+
}
|
|
42471
|
+
if ((token.value === "function" || token.value === "class") && tokens[index + 1]?.kind === "identifier") {
|
|
42472
|
+
addDeclaration(analysis, tokens[index + 1].value);
|
|
42473
|
+
declarationTokenIndexes.add(index + 1);
|
|
42474
|
+
}
|
|
42475
|
+
if (token.value === "function") {
|
|
42476
|
+
const open2 = nextFunctionOpen(tokens, index);
|
|
42477
|
+
if (open2 > index) {
|
|
42478
|
+
const close = matchingToken(tokens, open2, "(", ")");
|
|
42479
|
+
const body = close >= 0 ? nextFunctionBody(tokens, close + 1) : -1;
|
|
42480
|
+
const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
|
|
42481
|
+
for (let cursor = open2 + 1;cursor < close; cursor++) {
|
|
42482
|
+
if (tokens[cursor]?.kind === "identifier" && tokens[cursor - 1]?.value !== ".") {
|
|
42483
|
+
addDeclaration(analysis, tokens[cursor].value);
|
|
42484
|
+
declarationTokenIndexes.add(cursor);
|
|
42485
|
+
if (bodyScope !== undefined)
|
|
42486
|
+
analysis.parameterScopes.set(cursor, bodyScope);
|
|
42487
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42488
|
+
cursor++;
|
|
42489
|
+
}
|
|
42490
|
+
}
|
|
42491
|
+
}
|
|
42492
|
+
}
|
|
42493
|
+
if (token.value === "catch" && tokens[index + 1]?.value === "(" && tokens[index + 2]?.kind === "identifier") {
|
|
42494
|
+
addDeclaration(analysis, tokens[index + 2].value);
|
|
42495
|
+
declarationTokenIndexes.add(index + 2);
|
|
42496
|
+
}
|
|
42497
|
+
if (token.kind === "identifier" && tokens[index + 1]?.value === "=>") {
|
|
42498
|
+
addDeclaration(analysis, token.value);
|
|
42499
|
+
declarationTokenIndexes.add(index);
|
|
42500
|
+
const body = nextFunctionBody(tokens, index + 2);
|
|
42501
|
+
if (body >= 0)
|
|
42502
|
+
analysis.parameterScopes.set(index, analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body]);
|
|
42503
|
+
}
|
|
42504
|
+
if (token.value === "=>") {
|
|
42505
|
+
let close = index - 1;
|
|
42506
|
+
while (close >= 0 && tokens[close]?.value !== ")")
|
|
42507
|
+
close--;
|
|
42508
|
+
let cursor = close - 1;
|
|
42509
|
+
let depth = 1;
|
|
42510
|
+
while (cursor >= 0 && depth > 0) {
|
|
42511
|
+
if (tokens[cursor]?.value === ")")
|
|
42512
|
+
depth++;
|
|
42513
|
+
else if (tokens[cursor]?.value === "(")
|
|
42514
|
+
depth--;
|
|
42515
|
+
cursor--;
|
|
42516
|
+
}
|
|
42517
|
+
const body = nextFunctionBody(tokens, index + 1);
|
|
42518
|
+
const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
|
|
42519
|
+
for (cursor += 2;cursor < close; cursor++) {
|
|
42520
|
+
if (tokens[cursor]?.kind === "identifier") {
|
|
42521
|
+
addDeclaration(analysis, tokens[cursor].value);
|
|
42522
|
+
declarationTokenIndexes.add(cursor);
|
|
42523
|
+
if (bodyScope !== undefined)
|
|
42524
|
+
analysis.parameterScopes.set(cursor, bodyScope);
|
|
42525
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42526
|
+
cursor++;
|
|
42527
|
+
}
|
|
42528
|
+
}
|
|
42529
|
+
}
|
|
42530
|
+
}
|
|
42531
|
+
return declarationTokenIndexes;
|
|
42532
|
+
}
|
|
42533
|
+
function collectFacts(analysis) {
|
|
42534
|
+
const { tokens } = analysis;
|
|
42535
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42536
|
+
if (tokens[index]?.value === "import" && tokens[index + 1]?.value !== "type") {
|
|
42537
|
+
if (tokens[index + 1]?.value === "{") {
|
|
42538
|
+
const close = matchingToken(tokens, index + 1, "{", "}");
|
|
42539
|
+
const module2 = tokens[close + 1]?.value === "from" ? tokens[close + 2]?.value : null;
|
|
42540
|
+
for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
|
|
42541
|
+
const imported = tokens[cursor];
|
|
42542
|
+
if (imported?.kind !== "identifier")
|
|
42543
|
+
continue;
|
|
42544
|
+
if (imported.value === "type") {
|
|
42545
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42546
|
+
cursor++;
|
|
42547
|
+
continue;
|
|
42548
|
+
}
|
|
42549
|
+
const local2 = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
|
|
42550
|
+
if (local2?.kind === "identifier") {
|
|
42551
|
+
if (CHILD_PROCESS_MODULES.has(module2 ?? "") && imported.value === "exec") {
|
|
42552
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42553
|
+
} else if (module2)
|
|
42554
|
+
addFact(analysis, local2.value, "other-import", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42555
|
+
}
|
|
42556
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42557
|
+
cursor++;
|
|
42558
|
+
}
|
|
42559
|
+
} else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
|
|
42560
|
+
const local2 = tokens[index + 3];
|
|
42561
|
+
const module2 = tokens[index + 4]?.value === "from" ? tokens[index + 5]?.value : null;
|
|
42562
|
+
if (local2?.kind === "identifier" && module2) {
|
|
42563
|
+
addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 3);
|
|
42564
|
+
analysis.requireDerived.add(local2.value);
|
|
42565
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, index + 3));
|
|
42566
|
+
}
|
|
42567
|
+
} else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "=" && tokens[index + 3]?.value === "require") {
|
|
42568
|
+
const module2 = moduleAtCall(tokens, index + 3, "require");
|
|
42569
|
+
if (module2)
|
|
42570
|
+
addFact(analysis, tokens[index + 1].value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 1);
|
|
42571
|
+
} else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "from" && tokens[index + 3]?.kind === "string") {
|
|
42572
|
+
const local2 = tokens[index + 1];
|
|
42573
|
+
addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(tokens[index + 3].value) ? "child-namespace" : "other-import", index + 1);
|
|
42574
|
+
}
|
|
42575
|
+
}
|
|
42576
|
+
if (!DECLARATION_KEYWORDS.has(tokens[index]?.value ?? ""))
|
|
42577
|
+
continue;
|
|
42578
|
+
const start = index + 1;
|
|
42579
|
+
if (tokens[start]?.value === "{") {
|
|
42580
|
+
const close = matchingToken(tokens, start, "{", "}");
|
|
42581
|
+
const rhs2 = close + 1;
|
|
42582
|
+
const module2 = tokens[rhs2]?.value === "=" ? moduleAtCall(tokens, rhs2 + 1, "require") : null;
|
|
42583
|
+
const namespace = tokens[rhs2]?.value === "=" && tokens[rhs2 + 1]?.kind === "identifier" ? tokens[rhs2 + 1].value : null;
|
|
42584
|
+
for (let cursor = start + 1;cursor < close; cursor++) {
|
|
42585
|
+
const imported = tokens[cursor];
|
|
42586
|
+
if (imported?.kind !== "identifier")
|
|
42587
|
+
continue;
|
|
42588
|
+
const local2 = tokens[cursor + 1]?.value === ":" ? tokens[cursor + 2] : imported;
|
|
42589
|
+
if (local2?.kind === "identifier" && imported.value === "exec") {
|
|
42590
|
+
if (module2 && CHILD_PROCESS_MODULES.has(module2)) {
|
|
42591
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
|
|
42592
|
+
analysis.requireDerived.add(local2.value);
|
|
42593
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
|
|
42594
|
+
} else if (namespace && hasUniqueFact(analysis, namespace, rhs2 + 1, "child-namespace")) {
|
|
42595
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
|
|
42596
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, namespace, visibleDeclarationScope(analysis, namespace, rhs2 + 1))) {
|
|
42597
|
+
analysis.requireDerived.add(local2.value);
|
|
42598
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
|
|
42599
|
+
}
|
|
42600
|
+
}
|
|
42601
|
+
}
|
|
42602
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42603
|
+
cursor++;
|
|
42604
|
+
}
|
|
42605
|
+
continue;
|
|
42606
|
+
}
|
|
42607
|
+
const local = tokens[start];
|
|
42608
|
+
if (local?.kind !== "identifier" || tokens[start + 1]?.value !== "=")
|
|
42609
|
+
continue;
|
|
42610
|
+
const rhs = start + 2;
|
|
42611
|
+
const module = moduleAtCall(tokens, rhs, "require");
|
|
42612
|
+
if (module) {
|
|
42613
|
+
addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(module) ? "child-namespace" : "other-import", start);
|
|
42614
|
+
analysis.requireDerived.add(local.value);
|
|
42615
|
+
addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
|
|
42616
|
+
} else if (tokens[rhs]?.value === "import" || tokens[rhs]?.value === "await" && tokens[rhs + 1]?.value === "import") {
|
|
42617
|
+
const importIndex = tokens[rhs]?.value === "await" ? rhs + 1 : rhs;
|
|
42618
|
+
const importedModule = moduleAtCall(tokens, importIndex, "import");
|
|
42619
|
+
if (importedModule) {
|
|
42620
|
+
addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(importedModule) ? "child-namespace" : "other-import", start);
|
|
42621
|
+
}
|
|
42622
|
+
} else if (tokens[rhs]?.kind === "regex" || tokens[rhs]?.value === "new" && tokens[rhs + 1]?.value === "RegExp") {
|
|
42623
|
+
addFact(analysis, local.value, "regex", start);
|
|
42624
|
+
} else if (tokens[rhs]?.kind === "identifier" && (tokens[rhs + 1]?.value === "." || tokens[rhs + 1]?.value === "?.") && tokens[rhs + 2]?.value === "exec" && hasUniqueFact(analysis, tokens[rhs].value, rhs, "child-namespace")) {
|
|
42625
|
+
addFact(analysis, local.value, "child-direct", start);
|
|
42626
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, tokens[rhs].value, visibleDeclarationScope(analysis, tokens[rhs].value, rhs))) {
|
|
42627
|
+
analysis.requireDerived.add(local.value);
|
|
42628
|
+
addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
|
|
42629
|
+
}
|
|
42630
|
+
}
|
|
42631
|
+
}
|
|
42632
|
+
}
|
|
42633
|
+
function hasUniqueFact(analysis, name, callIndex, fact) {
|
|
42634
|
+
const scope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42635
|
+
const facts = scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
|
|
42636
|
+
return scope !== null && analysis.declarationScopes.get(name)?.get(scope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, scope) && facts?.size === 1 && facts.has(fact);
|
|
42637
|
+
}
|
|
42638
|
+
function buildAnalysis(context) {
|
|
42639
|
+
const lineStarts = [0];
|
|
42640
|
+
for (let index = 0;index < context.content.length; index++) {
|
|
42641
|
+
if (context.content[index] === `
|
|
42642
|
+
`)
|
|
42643
|
+
lineStarts.push(index + 1);
|
|
42644
|
+
}
|
|
42645
|
+
if (context.content.length > MAX_ANALYSIS_BYTES) {
|
|
42646
|
+
return {
|
|
42647
|
+
tokens: [],
|
|
42648
|
+
lineStarts,
|
|
42649
|
+
scopeAtToken: [],
|
|
42650
|
+
scopeParents: [-1],
|
|
42651
|
+
scopeIsFunction: [true],
|
|
42652
|
+
declarations: new Map,
|
|
42653
|
+
declarationScopes: new Map,
|
|
42654
|
+
facts: new Map,
|
|
42655
|
+
factScopes: new Map,
|
|
42656
|
+
reassigned: new Set,
|
|
42657
|
+
reassignedScopes: new Map,
|
|
42658
|
+
mutatedMembers: new Set,
|
|
42659
|
+
mutatedMemberScopes: new Map,
|
|
42660
|
+
requireDerived: new Set,
|
|
42661
|
+
requireDerivedScopes: new Map,
|
|
42662
|
+
parameterScopes: new Map,
|
|
42663
|
+
varDeclarationIndexes: new Set,
|
|
42664
|
+
oversizedOrMalformed: true
|
|
42665
|
+
};
|
|
42666
|
+
}
|
|
42667
|
+
const tokenized = tokenize2(context.content);
|
|
42668
|
+
const scopes = buildScopes(tokenized.tokens);
|
|
42669
|
+
const analysis = {
|
|
42670
|
+
tokens: tokenized.tokens,
|
|
42671
|
+
lineStarts,
|
|
42672
|
+
scopeAtToken: scopes.scopeAtToken,
|
|
42673
|
+
scopeParents: scopes.scopeParents,
|
|
42674
|
+
scopeIsFunction: scopes.scopeIsFunction,
|
|
42675
|
+
declarations: new Map,
|
|
42676
|
+
declarationScopes: new Map,
|
|
42677
|
+
facts: new Map,
|
|
42678
|
+
factScopes: new Map,
|
|
42679
|
+
reassigned: new Set,
|
|
42680
|
+
reassignedScopes: new Map,
|
|
42681
|
+
mutatedMembers: new Set,
|
|
42682
|
+
mutatedMemberScopes: new Map,
|
|
42683
|
+
requireDerived: new Set,
|
|
42684
|
+
requireDerivedScopes: new Map,
|
|
42685
|
+
parameterScopes: new Map,
|
|
42686
|
+
varDeclarationIndexes: new Set,
|
|
42687
|
+
oversizedOrMalformed: tokenized.malformed
|
|
42688
|
+
};
|
|
42689
|
+
const declarationIndexes = collectDeclarations(analysis);
|
|
42690
|
+
for (const index of declarationIndexes) {
|
|
42691
|
+
const name = analysis.tokens[index]?.value;
|
|
42692
|
+
if (!name)
|
|
42693
|
+
continue;
|
|
42694
|
+
const scope = declarationScope(analysis, index);
|
|
42695
|
+
const counts = analysis.declarationScopes.get(name) ?? new Map;
|
|
42696
|
+
counts.set(scope, (counts.get(scope) ?? 0) + 1);
|
|
42697
|
+
analysis.declarationScopes.set(name, counts);
|
|
42698
|
+
}
|
|
42699
|
+
collectFacts(analysis);
|
|
42700
|
+
for (let index = 0;index < analysis.tokens.length; index++) {
|
|
42701
|
+
const token = analysis.tokens[index];
|
|
42702
|
+
if (token?.kind !== "identifier" || declarationIndexes.has(index))
|
|
42703
|
+
continue;
|
|
42704
|
+
const previous = analysis.tokens[index - 1]?.value;
|
|
42705
|
+
if (previous === "." || previous === "?.") {
|
|
42706
|
+
if (token.value === "exec" && (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || analysis.tokens[index - 3]?.value === "delete")) {
|
|
42707
|
+
const receiver = analysis.tokens[index - 2];
|
|
42708
|
+
if (receiver?.kind === "identifier") {
|
|
42709
|
+
analysis.mutatedMembers.add(receiver.value);
|
|
42710
|
+
addScopedMarker(analysis.mutatedMemberScopes, receiver.value, visibleDeclarationScope(analysis, receiver.value, index - 2) ?? analysis.scopeAtToken[index - 2] ?? 0);
|
|
42711
|
+
}
|
|
42712
|
+
}
|
|
42713
|
+
continue;
|
|
42714
|
+
}
|
|
42715
|
+
if (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || previous === "++" || previous === "--" || analysis.tokens[index + 1]?.value === "++" || analysis.tokens[index + 1]?.value === "--") {
|
|
42716
|
+
analysis.reassigned.add(token.value);
|
|
42717
|
+
addScopedMarker(analysis.reassignedScopes, token.value, visibleDeclarationScope(analysis, token.value, index) ?? analysis.scopeAtToken[index] ?? 0);
|
|
42718
|
+
}
|
|
42719
|
+
}
|
|
42720
|
+
return analysis;
|
|
42721
|
+
}
|
|
42722
|
+
function getAnalysis(context) {
|
|
42723
|
+
let analysis = analysisByContext.get(context);
|
|
42724
|
+
if (!analysis) {
|
|
42725
|
+
analysis = buildAnalysis(context);
|
|
42726
|
+
analysisByContext.set(context, analysis);
|
|
42727
|
+
}
|
|
42728
|
+
return analysis;
|
|
42729
|
+
}
|
|
42730
|
+
function tokenIndexAtOffset(tokens, offset) {
|
|
42731
|
+
let low = 0;
|
|
42732
|
+
let high = tokens.length - 1;
|
|
42733
|
+
while (low <= high) {
|
|
42734
|
+
const mid = low + high >>> 1;
|
|
42735
|
+
const token = tokens[mid];
|
|
42736
|
+
if (offset < token.start)
|
|
42737
|
+
high = mid - 1;
|
|
42738
|
+
else if (offset >= token.end)
|
|
42739
|
+
low = mid + 1;
|
|
42740
|
+
else
|
|
42741
|
+
return mid;
|
|
42742
|
+
}
|
|
42743
|
+
return -1;
|
|
42744
|
+
}
|
|
42745
|
+
function directRequireBefore(tokens, dotIndex) {
|
|
42746
|
+
if (tokens[dotIndex - 1]?.value !== ")")
|
|
42747
|
+
return false;
|
|
42748
|
+
for (let start = dotIndex - 2;start >= 0 && start >= dotIndex - 5; start--) {
|
|
42749
|
+
const module = moduleAtCall(tokens, start, "require");
|
|
42750
|
+
if (module && start + 4 === dotIndex)
|
|
42751
|
+
return CHILD_PROCESS_MODULES.has(module);
|
|
42752
|
+
}
|
|
42753
|
+
return false;
|
|
42754
|
+
}
|
|
42755
|
+
function isTransparentWrapperCall(tokens, openIndex) {
|
|
42756
|
+
return tokens[openIndex - 1]?.kind === "identifier" ? tokens[openIndex - 1].value === "promisify" : false;
|
|
42757
|
+
}
|
|
42758
|
+
function shouldSkipTrailingClose(tokens, nameIndex, closeIndex) {
|
|
42759
|
+
const openIndex = pairedToken(tokens, closeIndex);
|
|
42760
|
+
if (openIndex < 0 || openIndex > nameIndex)
|
|
42761
|
+
return false;
|
|
42762
|
+
const beforeOpen = tokens[openIndex - 1];
|
|
42763
|
+
if (!beforeOpen || beforeOpen.kind !== "identifier" && beforeOpen.kind !== "string" && beforeOpen.kind !== "regex" && beforeOpen.value !== ")" && beforeOpen.value !== "]") {
|
|
42764
|
+
return true;
|
|
42765
|
+
}
|
|
42766
|
+
return isTransparentWrapperCall(tokens, openIndex);
|
|
42767
|
+
}
|
|
42768
|
+
function parseCallee(tokens, nameIndex) {
|
|
42769
|
+
const nameToken = tokens[nameIndex];
|
|
42770
|
+
if (!nameToken)
|
|
42771
|
+
return null;
|
|
42772
|
+
let cursor = nameIndex + 1;
|
|
42773
|
+
if (nameToken.kind === "string") {
|
|
42774
|
+
if (tokens[nameIndex - 1]?.value !== "[" || tokens[nameIndex + 1]?.value !== "]")
|
|
42775
|
+
return null;
|
|
42776
|
+
cursor = nameIndex + 2;
|
|
42777
|
+
}
|
|
42778
|
+
while (tokens[cursor]?.value === ")" && shouldSkipTrailingClose(tokens, nameIndex, cursor)) {
|
|
42779
|
+
cursor++;
|
|
42780
|
+
}
|
|
42781
|
+
if (tokens[cursor]?.value === "?.")
|
|
42782
|
+
cursor++;
|
|
42783
|
+
if (tokens[cursor]?.value !== "(")
|
|
42784
|
+
return null;
|
|
42785
|
+
const callee = { name: nameToken.value, openParen: cursor };
|
|
42786
|
+
const accessIndex = nameToken.kind === "string" ? nameIndex - 1 : nameIndex - 1;
|
|
42787
|
+
if (nameToken.kind === "string") {
|
|
42788
|
+
const receiver = tokens[nameIndex - 2];
|
|
42789
|
+
if (receiver?.kind === "identifier") {
|
|
42790
|
+
callee.receiver = receiver.value;
|
|
42791
|
+
callee.receiverKind = "identifier";
|
|
42792
|
+
} else if (receiver?.kind === "regex")
|
|
42793
|
+
callee.receiverKind = "regex";
|
|
42794
|
+
return callee;
|
|
42795
|
+
}
|
|
42796
|
+
if (tokens[accessIndex]?.value === "." || tokens[accessIndex]?.value === "?.") {
|
|
42797
|
+
const receiver = tokens[accessIndex - 1];
|
|
42798
|
+
if (receiver?.kind === "identifier") {
|
|
42799
|
+
callee.receiver = receiver.value;
|
|
42800
|
+
callee.receiverKind = "identifier";
|
|
42801
|
+
} else if (receiver?.kind === "regex")
|
|
42802
|
+
callee.receiverKind = "regex";
|
|
42803
|
+
else if (directRequireBefore(tokens, accessIndex))
|
|
42804
|
+
callee.receiverKind = "direct-child-require";
|
|
42805
|
+
}
|
|
42806
|
+
return callee;
|
|
42807
|
+
}
|
|
42808
|
+
function bindingDisposition(analysis, name, confirmedFact, callIndex) {
|
|
42809
|
+
const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42810
|
+
if (visibleScope === null)
|
|
42811
|
+
return "ambiguous";
|
|
42812
|
+
const declarationCount = analysis.declarationScopes.get(name)?.get(visibleScope) ?? 0;
|
|
42813
|
+
const facts = analysis.factScopes.get(name)?.get(visibleScope);
|
|
42814
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, name, visibleScope) && globalDisposition(analysis, "require", callIndex) !== "confirmed") {
|
|
42815
|
+
return "ambiguous";
|
|
42816
|
+
}
|
|
42817
|
+
if (declarationCount !== 1 || hasScopedMarker(analysis.reassignedScopes, name, visibleScope) || !facts || facts.size !== 1) {
|
|
42818
|
+
return "ambiguous";
|
|
42819
|
+
}
|
|
42820
|
+
if (facts.has(confirmedFact))
|
|
42821
|
+
return "confirmed";
|
|
42822
|
+
if (facts.has("other-import") || facts.has("regex"))
|
|
42823
|
+
return "safe";
|
|
42824
|
+
return "ambiguous";
|
|
42825
|
+
}
|
|
42826
|
+
function globalDisposition(analysis, name, callIndex) {
|
|
42827
|
+
const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42828
|
+
if (visibleScope === null && !hasVisibleMarker(analysis, analysis.reassignedScopes, name, callIndex)) {
|
|
42829
|
+
return "confirmed";
|
|
42830
|
+
}
|
|
42831
|
+
const facts = visibleScope === null ? undefined : analysis.factScopes.get(name)?.get(visibleScope);
|
|
42832
|
+
if (facts?.size === 1 && facts.has("other-import") && visibleScope !== null && analysis.declarationScopes.get(name)?.get(visibleScope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, visibleScope)) {
|
|
42833
|
+
return "safe";
|
|
42834
|
+
}
|
|
42835
|
+
return "ambiguous";
|
|
42836
|
+
}
|
|
42837
|
+
function firstArgument(tokens, openParen) {
|
|
42838
|
+
return tokens[openParen + 1];
|
|
42839
|
+
}
|
|
42840
|
+
function oversizedCandidate(match, family) {
|
|
42841
|
+
const expected = family === "exec" ? ["exec"] : family === "eval" ? ["eval"] : family === "function-constructor" ? ["Function"] : family === "timer-string" ? ["setTimeout", "setInterval"] : family === "document-write" ? ["write"] : ["addEventListener"];
|
|
42842
|
+
return expected.includes(match.text) ? "ambiguous" : "none";
|
|
42843
|
+
}
|
|
42844
|
+
function classifyJavascriptCallUncached(match, context, family) {
|
|
42845
|
+
const analysis = getAnalysis(context);
|
|
42846
|
+
if (analysis.oversizedOrMalformed)
|
|
42847
|
+
return oversizedCandidate(match, family);
|
|
42848
|
+
const offset = (analysis.lineStarts[match.line - 1] ?? 0) + match.column - 1;
|
|
42849
|
+
const tokenIndex = tokenIndexAtOffset(analysis.tokens, offset);
|
|
42850
|
+
if (tokenIndex < 0)
|
|
42851
|
+
return "none";
|
|
42852
|
+
const callee = parseCallee(analysis.tokens, tokenIndex);
|
|
42853
|
+
if (!callee)
|
|
42854
|
+
return "none";
|
|
42855
|
+
const argument = firstArgument(analysis.tokens, callee.openParen);
|
|
42856
|
+
switch (family) {
|
|
42857
|
+
case "exec":
|
|
42858
|
+
if (!argument || argument.value === ")")
|
|
42859
|
+
return "none";
|
|
42860
|
+
if (callee.receiverKind === "regex")
|
|
42861
|
+
return "safe";
|
|
42862
|
+
if (callee.receiverKind === "direct-child-require") {
|
|
42863
|
+
if (callee.name !== "exec")
|
|
42864
|
+
return "none";
|
|
42865
|
+
return globalDisposition(analysis, "require", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
|
|
42866
|
+
}
|
|
42867
|
+
if (callee.receiver) {
|
|
42868
|
+
if (callee.name !== "exec")
|
|
42869
|
+
return "none";
|
|
42870
|
+
if (hasScopedMarker(analysis.mutatedMemberScopes, callee.receiver, visibleDeclarationScope(analysis, callee.receiver, tokenIndex))) {
|
|
42871
|
+
return "ambiguous";
|
|
42872
|
+
}
|
|
42873
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex);
|
|
42874
|
+
}
|
|
42875
|
+
if (callee.name === "exec" || factsAtVisibleScope(analysis, callee.name, tokenIndex)?.has("child-direct")) {
|
|
42876
|
+
return bindingDisposition(analysis, callee.name, "child-direct", tokenIndex);
|
|
42877
|
+
}
|
|
42878
|
+
return "none";
|
|
42879
|
+
case "eval":
|
|
42880
|
+
if (callee.name !== "eval")
|
|
42881
|
+
return "none";
|
|
42882
|
+
if (callee.receiver) {
|
|
42883
|
+
if (["globalThis", "window", "self"].includes(callee.receiver)) {
|
|
42884
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42885
|
+
}
|
|
42886
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42887
|
+
}
|
|
42888
|
+
return globalDisposition(analysis, "eval", tokenIndex);
|
|
42889
|
+
case "function-constructor":
|
|
42890
|
+
if (callee.name !== "Function" || analysis.tokens[tokenIndex - 1]?.value !== "new")
|
|
42891
|
+
return "none";
|
|
42892
|
+
return globalDisposition(analysis, "Function", tokenIndex);
|
|
42893
|
+
case "timer-string":
|
|
42894
|
+
if (!["setTimeout", "setInterval"].includes(callee.name) || !argument || !["string", "template"].includes(argument.kind))
|
|
42895
|
+
return "none";
|
|
42896
|
+
if (callee.receiver) {
|
|
42897
|
+
if (["globalThis", "window", "self"].includes(callee.receiver))
|
|
42898
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42899
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42900
|
+
}
|
|
42901
|
+
return globalDisposition(analysis, callee.name, tokenIndex);
|
|
42902
|
+
case "document-write":
|
|
42903
|
+
if (callee.name !== "write" || callee.receiver !== "document")
|
|
42904
|
+
return "none";
|
|
42905
|
+
return globalDisposition(analysis, "document", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
|
|
42906
|
+
case "postmessage":
|
|
42907
|
+
if (callee.name !== "addEventListener" || argument?.kind !== "string" || argument.value !== "message")
|
|
42908
|
+
return "none";
|
|
42909
|
+
if (callee.receiver) {
|
|
42910
|
+
if (["globalThis", "window", "self"].includes(callee.receiver))
|
|
42911
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42912
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42913
|
+
}
|
|
42914
|
+
return globalDisposition(analysis, "addEventListener", tokenIndex);
|
|
42915
|
+
}
|
|
42916
|
+
}
|
|
42917
|
+
function classifyJavascriptCall(match, context, family) {
|
|
42918
|
+
const key = `${family}:${match.line}:${match.column}:${match.text}`;
|
|
42919
|
+
const cache2 = dispositionByContext.get(context) ?? new Map;
|
|
42920
|
+
const cached = cache2.get(key);
|
|
42921
|
+
if (cached !== undefined)
|
|
42922
|
+
return cached;
|
|
42923
|
+
const disposition = classifyJavascriptCallUncached(match, context, family);
|
|
42924
|
+
cache2.set(key, disposition);
|
|
42925
|
+
dispositionByContext.set(context, cache2);
|
|
42926
|
+
return disposition;
|
|
42927
|
+
}
|
|
42928
|
+
|
|
41965
42929
|
// src/sast/rules/javascript.ts
|
|
42930
|
+
function hasDisposition(family, disposition) {
|
|
42931
|
+
return (match, context) => classifyJavascriptCall(match, context, family) === disposition;
|
|
42932
|
+
}
|
|
41966
42933
|
var javascriptRules = [
|
|
41967
42934
|
{
|
|
41968
42935
|
id: "sast/js-eval",
|
|
@@ -41971,7 +42938,18 @@ var javascriptRules = [
|
|
|
41971
42938
|
languages: ["javascript", "typescript"],
|
|
41972
42939
|
description: "Dangerous use of eval() detected - allows arbitrary code execution",
|
|
41973
42940
|
remediation: "Avoid using eval(). If you must parse dynamic content, use JSON.parse() or a proper parser instead.",
|
|
41974
|
-
pattern: /\beval\
|
|
42941
|
+
pattern: /\beval\b/,
|
|
42942
|
+
validate: hasDisposition("eval", "confirmed")
|
|
42943
|
+
},
|
|
42944
|
+
{
|
|
42945
|
+
id: "sast/js-eval-review",
|
|
42946
|
+
name: "Unresolved eval-like call",
|
|
42947
|
+
severity: "low",
|
|
42948
|
+
languages: ["javascript", "typescript"],
|
|
42949
|
+
description: "Unresolved eval-like call requires manual review",
|
|
42950
|
+
remediation: "Verify the callee binding and avoid dynamic code evaluation.",
|
|
42951
|
+
pattern: /\beval\b/,
|
|
42952
|
+
validate: hasDisposition("eval", "ambiguous")
|
|
41975
42953
|
},
|
|
41976
42954
|
{
|
|
41977
42955
|
id: "sast/js-dangerous-function",
|
|
@@ -41980,7 +42958,18 @@ var javascriptRules = [
|
|
|
41980
42958
|
languages: ["javascript", "typescript"],
|
|
41981
42959
|
description: "Dangerous use of new Function() detected - allows arbitrary code execution",
|
|
41982
42960
|
remediation: "Avoid using new Function(). Use a safer alternative like JSON.parse() or a proper expression parser.",
|
|
41983
|
-
pattern: /\
|
|
42961
|
+
pattern: /\bFunction\b/,
|
|
42962
|
+
validate: hasDisposition("function-constructor", "confirmed")
|
|
42963
|
+
},
|
|
42964
|
+
{
|
|
42965
|
+
id: "sast/js-function-constructor-review",
|
|
42966
|
+
name: "Unresolved Function-like constructor",
|
|
42967
|
+
severity: "low",
|
|
42968
|
+
languages: ["javascript", "typescript"],
|
|
42969
|
+
description: "Unresolved Function-like constructor requires manual review",
|
|
42970
|
+
remediation: "Verify the constructor binding and avoid dynamic code construction.",
|
|
42971
|
+
pattern: /\bFunction\b/,
|
|
42972
|
+
validate: hasDisposition("function-constructor", "ambiguous")
|
|
41984
42973
|
},
|
|
41985
42974
|
{
|
|
41986
42975
|
id: "sast/js-command-injection",
|
|
@@ -41989,10 +42978,18 @@ var javascriptRules = [
|
|
|
41989
42978
|
languages: ["javascript", "typescript"],
|
|
41990
42979
|
description: "Potential command injection via child_process.exec() with unsanitized input",
|
|
41991
42980
|
remediation: "Never pass user input directly to exec(). Use execFile() with arguments array or sanitize input thoroughly.",
|
|
41992
|
-
pattern: /
|
|
41993
|
-
validate: (
|
|
41994
|
-
|
|
41995
|
-
|
|
42981
|
+
pattern: /[A-Za-z_$][\w$]*/,
|
|
42982
|
+
validate: hasDisposition("exec", "confirmed")
|
|
42983
|
+
},
|
|
42984
|
+
{
|
|
42985
|
+
id: "sast/js-command-exec-review",
|
|
42986
|
+
name: "Unresolved exec-like call",
|
|
42987
|
+
severity: "low",
|
|
42988
|
+
languages: ["javascript", "typescript"],
|
|
42989
|
+
description: "Unresolved exec-like call requires manual review",
|
|
42990
|
+
remediation: "Verify whether the callee reaches child_process; prefer execFile() with an arguments array.",
|
|
42991
|
+
pattern: /[A-Za-z_$][\w$]*/,
|
|
42992
|
+
validate: hasDisposition("exec", "ambiguous")
|
|
41996
42993
|
},
|
|
41997
42994
|
{
|
|
41998
42995
|
id: "sast/js-set-timeout-string",
|
|
@@ -42001,7 +42998,18 @@ var javascriptRules = [
|
|
|
42001
42998
|
languages: ["javascript", "typescript"],
|
|
42002
42999
|
description: "setTimeout/setInterval called with string argument - similar to eval()",
|
|
42003
43000
|
remediation: 'Use function references instead of strings: setTimeout(() => ..., 1000) instead of setTimeout("...", 1000)',
|
|
42004
|
-
pattern:
|
|
43001
|
+
pattern: /\b(?:setTimeout|setInterval)\b/,
|
|
43002
|
+
validate: hasDisposition("timer-string", "confirmed")
|
|
43003
|
+
},
|
|
43004
|
+
{
|
|
43005
|
+
id: "sast/js-timer-string-review",
|
|
43006
|
+
name: "Unresolved string timer call",
|
|
43007
|
+
severity: "low",
|
|
43008
|
+
languages: ["javascript", "typescript"],
|
|
43009
|
+
description: "Unresolved string timer call requires manual review",
|
|
43010
|
+
remediation: "Verify the timer binding and replace string callbacks with functions.",
|
|
43011
|
+
pattern: /\b(?:setTimeout|setInterval)\b/,
|
|
43012
|
+
validate: hasDisposition("timer-string", "ambiguous")
|
|
42005
43013
|
},
|
|
42006
43014
|
{
|
|
42007
43015
|
id: "sast/js-innerhtml",
|
|
@@ -42019,7 +43027,18 @@ var javascriptRules = [
|
|
|
42019
43027
|
languages: ["javascript", "typescript"],
|
|
42020
43028
|
description: "document.write() can introduce XSS vulnerabilities",
|
|
42021
43029
|
remediation: "Use DOM manipulation methods (createElement, appendChild, textContent) instead.",
|
|
42022
|
-
pattern:
|
|
43030
|
+
pattern: /\bwrite\b/,
|
|
43031
|
+
validate: hasDisposition("document-write", "confirmed")
|
|
43032
|
+
},
|
|
43033
|
+
{
|
|
43034
|
+
id: "sast/js-document-write-review",
|
|
43035
|
+
name: "Unresolved document.write-like call",
|
|
43036
|
+
severity: "low",
|
|
43037
|
+
languages: ["javascript", "typescript"],
|
|
43038
|
+
description: "Unresolved document.write-like call requires manual review",
|
|
43039
|
+
remediation: "Verify the document binding and use safe DOM construction.",
|
|
43040
|
+
pattern: /\bwrite\b/,
|
|
43041
|
+
validate: hasDisposition("document-write", "ambiguous")
|
|
42023
43042
|
},
|
|
42024
43043
|
{
|
|
42025
43044
|
id: "sast/js-postmessage",
|
|
@@ -42028,7 +43047,18 @@ var javascriptRules = [
|
|
|
42028
43047
|
languages: ["javascript", "typescript"],
|
|
42029
43048
|
description: "postMessage event listener without origin validation",
|
|
42030
43049
|
remediation: "Always validate the origin in postMessage event handlers: event.origin === expectedOrigin",
|
|
42031
|
-
pattern:
|
|
43050
|
+
pattern: /\baddEventListener\b/,
|
|
43051
|
+
validate: hasDisposition("postmessage", "confirmed")
|
|
43052
|
+
},
|
|
43053
|
+
{
|
|
43054
|
+
id: "sast/js-postmessage-review",
|
|
43055
|
+
name: "Unresolved message-listener call",
|
|
43056
|
+
severity: "low",
|
|
43057
|
+
languages: ["javascript", "typescript"],
|
|
43058
|
+
description: "Unresolved message-listener call requires manual review",
|
|
43059
|
+
remediation: "Verify the event target and validate message origins where applicable.",
|
|
43060
|
+
pattern: /\baddEventListener\b/,
|
|
43061
|
+
validate: hasDisposition("postmessage", "ambiguous")
|
|
42032
43062
|
},
|
|
42033
43063
|
{
|
|
42034
43064
|
id: "sast/js-hardcoded-secret",
|
|
@@ -42338,23 +43368,23 @@ function executeRulesSync(filePath, content, language) {
|
|
|
42338
43368
|
const findings = [];
|
|
42339
43369
|
const normalizedLang = language.toLowerCase();
|
|
42340
43370
|
const rules = getRulesForLanguage(normalizedLang);
|
|
43371
|
+
const lines = content.split(`
|
|
43372
|
+
`);
|
|
43373
|
+
const context = {
|
|
43374
|
+
filePath,
|
|
43375
|
+
content,
|
|
43376
|
+
language: normalizedLang
|
|
43377
|
+
};
|
|
42341
43378
|
for (const rule of rules) {
|
|
42342
43379
|
if (!rule.pattern)
|
|
42343
43380
|
continue;
|
|
42344
43381
|
const matches = findPatternMatches(content, rule.pattern);
|
|
42345
43382
|
for (const match of matches) {
|
|
42346
43383
|
if (rule.validate) {
|
|
42347
|
-
const context = {
|
|
42348
|
-
filePath,
|
|
42349
|
-
content,
|
|
42350
|
-
language: normalizedLang
|
|
42351
|
-
};
|
|
42352
43384
|
if (!rule.validate(match, context)) {
|
|
42353
43385
|
continue;
|
|
42354
43386
|
}
|
|
42355
43387
|
}
|
|
42356
|
-
const lines = content.split(`
|
|
42357
|
-
`);
|
|
42358
43388
|
const excerpt = lines[match.line - 1]?.trim() || "";
|
|
42359
43389
|
findings.push({
|
|
42360
43390
|
rule_id: rule.id,
|
|
@@ -70409,7 +71439,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
70409
71439
|
async function handleHelpCommand(ctx) {
|
|
70410
71440
|
const targetCommand = ctx.args.join(" ");
|
|
70411
71441
|
if (!targetCommand) {
|
|
70412
|
-
const { buildHelpText } = await import("./index-
|
|
71442
|
+
const { buildHelpText } = await import("./index-ag9bv589.js");
|
|
70413
71443
|
return buildHelpText();
|
|
70414
71444
|
}
|
|
70415
71445
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -70418,7 +71448,7 @@ async function handleHelpCommand(ctx) {
|
|
|
70418
71448
|
return _internals98.buildDetailedHelp(resolved.key, resolved.entry);
|
|
70419
71449
|
}
|
|
70420
71450
|
const similar = _internals98.findSimilarCommands(targetCommand);
|
|
70421
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
71451
|
+
const { buildHelpText: fullHelp } = await import("./index-ag9bv589.js");
|
|
70422
71452
|
if (similar.length > 0) {
|
|
70423
71453
|
return `Command '/swarm ${targetCommand}' not found.
|
|
70424
71454
|
|
|
@@ -70598,7 +71628,7 @@ var COMMAND_REGISTRY = {
|
|
|
70598
71628
|
},
|
|
70599
71629
|
"guardrail explain": {
|
|
70600
71630
|
handler: async (ctx) => {
|
|
70601
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71631
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-a8706sq1.js");
|
|
70602
71632
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70603
71633
|
},
|
|
70604
71634
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70608,7 +71638,7 @@ var COMMAND_REGISTRY = {
|
|
|
70608
71638
|
},
|
|
70609
71639
|
"guardrail reset": {
|
|
70610
71640
|
handler: async (ctx) => {
|
|
70611
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71641
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-sy0vztrd.js");
|
|
70612
71642
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70613
71643
|
},
|
|
70614
71644
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70617,7 +71647,7 @@ var COMMAND_REGISTRY = {
|
|
|
70617
71647
|
},
|
|
70618
71648
|
"guardrail-explain": {
|
|
70619
71649
|
handler: async (ctx) => {
|
|
70620
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71650
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-a8706sq1.js");
|
|
70621
71651
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70622
71652
|
},
|
|
70623
71653
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70627,7 +71657,7 @@ var COMMAND_REGISTRY = {
|
|
|
70627
71657
|
},
|
|
70628
71658
|
"guardrail-reset": {
|
|
70629
71659
|
handler: async (ctx) => {
|
|
70630
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71660
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-sy0vztrd.js");
|
|
70631
71661
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70632
71662
|
},
|
|
70633
71663
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70637,7 +71667,7 @@ var COMMAND_REGISTRY = {
|
|
|
70637
71667
|
},
|
|
70638
71668
|
"guardrail-log": {
|
|
70639
71669
|
handler: async (ctx) => {
|
|
70640
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
71670
|
+
const { handleGuardrailLog } = await import("./guardrail-log-wx43bj32.js");
|
|
70641
71671
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
70642
71672
|
},
|
|
70643
71673
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -77628,7 +78658,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
77628
78658
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
|
|
77629
78659
|
if (laneProfile) {
|
|
77630
78660
|
try {
|
|
77631
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
78661
|
+
const { writeLaneProfileToDiskReal } = await import("./core-0ph6pb2y.js");
|
|
77632
78662
|
await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
77633
78663
|
} catch {}
|
|
77634
78664
|
}
|
|
@@ -78286,7 +79316,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
78286
79316
|
}
|
|
78287
79317
|
clearWorktreeMergeStatus(statusKey);
|
|
78288
79318
|
try {
|
|
78289
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
79319
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-0ph6pb2y.js");
|
|
78290
79320
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
78291
79321
|
} catch {}
|
|
78292
79322
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|