@event4u/agent-config 14.6.0 → 14.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +255 -145
- package/README.md +1 -1
- package/dist/agent-src/commands/analyze/inbox.md +264 -10
- package/dist/agent-src/commands/analyze.md +1 -1
- package/dist/agent-src/commands/evals/git-pr-merge.json +13 -0
- package/dist/agent-src/commands/evals/roadmap.json +17 -1
- package/dist/agent-src/commands/pr/create.md +14 -2
- package/dist/agent-src/commands/pr/merge.md +379 -0
- package/dist/agent-src/commands/roadmap/process-full.md +272 -32
- package/dist/agent-src/commands/roadmap.md +1 -1
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +46 -36
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +37 -2
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +95 -2
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +289 -106
- package/dist/agent-src/rules/artifact-drafting-protocol.md +5 -1
- package/dist/agent-src/rules/context-hygiene.md +2 -0
- package/dist/agent-src/rules/decision-revisit-gate.md +67 -32
- package/dist/agent-src/rules/fix-what-you-see.md +108 -0
- package/dist/agent-src/rules/no-roadmap-references.md +0 -5
- package/dist/agent-src/rules/recurring-criticism.md +110 -0
- package/dist/agent-src/rules/roadmap-progress-sync.md +20 -1
- package/dist/agent-src/rules/rule-type-governance.md +0 -2
- package/dist/agent-src/rules/self-repair-loop.md +17 -0
- package/dist/agent-src/rules/skill-quality.md +0 -2
- package/dist/agent-src/rules/source-confidentiality.md +37 -7
- package/dist/agent-src/scripts/archival_sweep.ts +117 -0
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
- package/dist/agent-src/scripts/dashboard_mode.ts +212 -0
- package/dist/agent-src/scripts/gate_budget.ts +282 -0
- package/dist/agent-src/scripts/gate_execute.ts +72 -31
- package/dist/agent-src/scripts/roadmap_gates.ts +74 -3
- package/dist/agent-src/scripts/update_roadmap_progress.ts +296 -53
- package/dist/agent-src/skills/adr-create/SKILL.md +124 -5
- package/dist/agent-src/skills/ai-council/SKILL.md +48 -807
- package/dist/agent-src/skills/ai-council/references/advanced-modes.md +320 -0
- package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +99 -0
- package/dist/agent-src/skills/ai-council/references/execution-modes.md +162 -0
- package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +125 -0
- package/dist/agent-src/skills/ai-council/references/procedure.md +143 -0
- package/dist/agent-src/skills/decision-record/SKILL.md +61 -3
- package/dist/agent-src/skills/decision-review/SKILL.md +65 -0
- package/dist/agent-src/skills/merge-conflicts/SKILL.md +26 -0
- package/dist/agent-src/skills/quality-tools/SKILL.md +34 -326
- package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +113 -0
- package/dist/agent-src/skills/quality-tools/references/php-tools.md +222 -0
- package/dist/agent-src/skills/roadmap-management/SKILL.md +15 -409
- package/dist/agent-src/skills/roadmap-management/references/archival.md +226 -0
- package/dist/agent-src/skills/roadmap-management/references/authoring.md +107 -0
- package/dist/agent-src/skills/roadmap-management/references/dashboard.md +47 -0
- package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +58 -0
- package/dist/agent-src/skills/security/SKILL.md +8 -0
- package/dist/agent-src/skills/security-audit/SKILL.md +12 -1
- package/dist/agent-src/skills/skill-writing/SKILL.md +34 -570
- package/dist/agent-src/skills/skill-writing/references/procedure.md +275 -0
- package/dist/agent-src/skills/skill-writing/references/read-only-scripts.md +18 -0
- package/dist/agent-src/skills/skill-writing/references/section-patterns.md +298 -0
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +65 -4
- package/dist/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
- package/dist/agent-src/templates/scripts/telemetry/remote.ts +160 -7
- package/dist/agent-src/templates/scripts/telemetry/transport.ts +169 -0
- package/dist/cli/registry.js +2 -1
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/chunk-2GNWGMAL.js +172 -0
- package/dist/cli-delegate/{chunk-P6LQDIWK.js → chunk-7PRE6ZV2.js} +338 -0
- package/dist/cli-delegate/{chunk-BKO2AZ7Z.js → chunk-B2ERU2VA.js} +1 -1
- package/dist/cli-delegate/chunk-E4XIZDIB.js +402 -0
- package/dist/cli-delegate/{chunk-3UCJWMMP.js → chunk-EEJUMCDZ.js} +16 -16
- package/dist/cli-delegate/{chunk-NXFWFAYV.js → chunk-G23AT6GD.js} +1 -0
- package/dist/cli-delegate/{chunk-XURJ4AQC.js → chunk-H4VIVD4C.js} +385 -284
- package/dist/cli-delegate/chunk-I3EIN2YG.js +36 -0
- package/dist/cli-delegate/{chunk-RLN73PR5.js → chunk-LPPWO5CE.js} +12 -8
- package/dist/cli-delegate/chunk-MWRD5YOH.js +100 -0
- package/dist/cli-delegate/{chunk-UEZ7D35A.js → chunk-N7CDDGI3.js} +4 -23
- package/dist/cli-delegate/{chunk-63WSP6YZ.js → chunk-PMEKGDED.js} +74 -167
- package/dist/cli-delegate/{chunk-GRRPEPRN.js → chunk-T7L2QK3K.js} +24 -5
- package/dist/cli-delegate/{chunk-EVTY7ISR.js → chunk-YM4GZDJG.js} +9 -1
- package/dist/cli-delegate/cmd_adr_effective.js +1162 -0
- package/dist/cli-delegate/cmd_conformance.js +466 -716
- package/dist/cli-delegate/cmd_converge.js +3 -3
- package/dist/cli-delegate/cmd_doctor.js +10 -10
- package/dist/cli-delegate/cmd_explain.js +1 -1
- package/dist/cli-delegate/cmd_export.js +10 -9
- package/dist/cli-delegate/cmd_handoff.js +10 -9
- package/dist/cli-delegate/cmd_memory_get.js +2 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +1 -1
- package/dist/cli-delegate/cmd_preflight.js +5 -5
- package/dist/cli-delegate/cmd_prune.js +11 -10
- package/dist/cli-delegate/cmd_route_audit.js +6 -5
- package/dist/cli-delegate/cmd_route_explain.js +3 -3
- package/dist/cli-delegate/cmd_session_recycle.js +840 -30
- package/dist/cli-delegate/cmd_settings_get.js +3 -3
- package/dist/cli-delegate/cmd_settings_migrate.js +10 -9
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +11 -10
- package/dist/cli-delegate/cmd_uninstall.js +13 -11
- package/dist/cli-delegate/cmd_update.js +4 -4
- package/dist/cli-delegate/cmd_upgrade.js +4 -4
- package/dist/cli-delegate/cmd_validate.js +11 -10
- package/dist/cli-delegate/cmd_versions.js +3 -3
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +111 -37
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +5 -5
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +15 -12
- package/dist/discovery/trust-report.md +3 -3
- package/dist/discovery/workspaces.json +11 -8
- package/dist/hooks/dispatch.js +3165 -2192
- package/dist/install/claudePathsPlan.js +187 -0
- package/dist/install/claudePathsPlan.js.map +1 -0
- package/dist/install/globalRuleLayers.js +169 -0
- package/dist/install/globalRuleLayers.js.map +1 -0
- package/dist/install/hostLayerFingerprint.js +136 -0
- package/dist/install/hostLayerFingerprint.js.map +1 -0
- package/dist/install/install.mjs +553 -425
- package/dist/install/partitionEligibility.js +432 -0
- package/dist/install/partitionEligibility.js.map +1 -0
- package/dist/install/ruleLayerPartition.js +157 -0
- package/dist/install/ruleLayerPartition.js.map +1 -0
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +1863 -1234
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_src.js +41 -0
- package/dist/scripts/_lib/agent_src.js.map +1 -1
- package/dist/scripts/_lib/install_layout.js +83 -0
- package/dist/scripts/_lib/install_layout.js.map +1 -0
- package/dist/scripts/_lib/installed_lock.js +444 -0
- package/dist/scripts/_lib/installed_lock.js.map +1 -0
- package/dist/scripts/_lib/prune_empty_dirs.js +85 -0
- package/dist/scripts/_lib/prune_empty_dirs.js.map +1 -0
- package/dist/scripts/condense.js +63 -251
- package/dist/scripts/condense.js.map +1 -1
- package/dist/server/schemas/settings.js +4 -0
- package/dist/server/schemas/settings.js.map +1 -1
- package/docs/contracts/settings-classes.md +12 -6
- package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +8 -3
- package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +45 -1
- package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +26 -0
- package/docs/guidelines/agent-infra/false-green.md +47 -1
- package/docs/guidelines/agent-infra/memory-access.md +17 -0
- package/docs/guidelines/agent-infra/recurring-criticism-mechanics.md +96 -0
- package/package.json +1 -1
- package/src/agent-src/scripts/archival_sweep.ts +117 -0
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
- package/src/agent-src/scripts/dashboard_mode.ts +212 -0
- package/src/agent-src/scripts/gate_budget.ts +282 -0
- package/src/agent-src/scripts/gate_execute.ts +72 -31
- package/src/agent-src/scripts/roadmap_gates.ts +74 -3
- package/src/agent-src/scripts/update_roadmap_progress.ts +296 -53
- package/src/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
- package/src/agent-src/templates/scripts/telemetry/remote.ts +160 -7
- package/src/agent-src/templates/scripts/telemetry/transport.ts +169 -0
- package/src/config/agent-settings.template.yml +27 -2
- package/src/config/ci-local-parity.yml +39 -0
- package/src/config/estate-count-budget.json +612 -3
- package/src/config/evaluator-budgets.json +3 -3
- package/src/config/gate-coverage.yml +220 -12
- package/src/config/gate-violation-baselines.json +73 -63
- package/src/config/gitignore-block.txt +15 -2
- package/src/config/hook-latency-budget.json +5 -0
- package/src/config/rule-activation-census.json +14 -6
- package/src/config/rule-stub-ceilings.json +34 -7
- package/src/install/claudePathsPlan.ts +196 -0
- package/src/install/globalRuleLayers.ts +197 -0
- package/src/install/hostLayerFingerprint.ts +145 -0
- package/src/install/partitionEligibility.ts +502 -0
- package/src/install/ruleLayerPartition.ts +212 -0
- package/src/scripts/_cli/cmd_adr_effective.ts +484 -0
- package/src/scripts/_cli/cmd_session_recycle.ts +9 -1
- package/src/scripts/_dispatch.bash +17 -1
- package/src/scripts/_lib/ac_heading.ts +30 -0
- package/src/scripts/_lib/adr_frontmatter.test.ts +365 -0
- package/src/scripts/_lib/adr_frontmatter.ts +459 -0
- package/src/scripts/_lib/agent_src.ts +42 -0
- package/src/scripts/_lib/bench_ab_pinned_repo.ts +162 -0
- package/src/scripts/_lib/bench_ab_workspace.ts +10 -1
- package/src/scripts/_lib/envelope_grounding.ts +49 -9
- package/src/scripts/_lib/installed_lock.ts +50 -5
- package/src/scripts/_lib/layer_overlap_notice.ts +11 -2
- package/src/scripts/_lib/md_section.ts +129 -0
- package/src/scripts/_lib/prune_empty_dirs.ts +80 -0
- package/src/scripts/_lib/scope_guard.sh +26 -3
- package/src/scripts/_lib/self_repair.ts +19 -0
- package/src/scripts/_lib/self_repair_class_b.ts +171 -0
- package/src/scripts/adr/evidence_census.ts +899 -0
- package/src/scripts/adr/regenerate_index.ts +12 -32
- package/src/scripts/adr_cite_check.ts +540 -39
- package/src/scripts/ai_council/cli_help.ts +55 -0
- package/src/scripts/audit_adr_coverage.ts +103 -17
- package/src/scripts/before_complete_hook.ts +153 -28
- package/src/scripts/bench_ab_v2_complexity.ts +27 -7
- package/src/scripts/bench_hook_latency.ts +204 -0
- package/src/scripts/build_archive_index.ts +34 -0
- package/src/scripts/check_adr_frontmatter.ts +574 -39
- package/src/scripts/check_hook_bundle_content.ts +219 -0
- package/src/scripts/check_new_adr_evidence.ts +529 -0
- package/src/scripts/check_references.ts +78 -0
- package/src/scripts/check_release_published.ts +32 -11
- package/src/scripts/check_rule_layer_partition.ts +531 -0
- package/src/scripts/check_single_delivery.ts +194 -17
- package/src/scripts/check_standing_rule_delivery.ts +8 -2
- package/src/scripts/ci_settle.ts +170 -0
- package/src/scripts/condense.ts +79 -259
- package/src/scripts/council_cli.ts +3 -3
- package/src/scripts/dispatch_r2_reviewer.ts +6 -14
- package/src/scripts/external_sources_denylist.json +4 -1
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +77 -14
- package/src/scripts/hooks/block_no_verify.ts +61 -10
- package/src/scripts/hooks/block_unauthorized_git.ts +21 -1
- package/src/scripts/hooks/concern_registry.ts +4 -0
- package/src/scripts/hooks/dispatch_hook.ts +154 -187
- package/src/scripts/hooks/dispatch_issues.ts +38 -19
- package/src/scripts/hooks/fallback_yaml.ts +66 -0
- package/src/scripts/hooks/host_semantics.ts +21 -0
- package/src/scripts/hooks/injection_budget.ts +13 -3
- package/src/scripts/hooks/py_json_dumps.ts +103 -0
- package/src/scripts/hooks/rtk_wrap_hook.ts +8 -3
- package/src/scripts/hooks/run_continuation_hook.ts +8 -5
- package/src/scripts/hooks/ship_diff_volume_hook.ts +81 -15
- package/src/scripts/hooks/source_first_gate_hook.ts +464 -0
- package/src/scripts/hooks/state_io.ts +870 -21
- package/src/scripts/hooks/stdin_failure_policy.ts +96 -0
- package/src/scripts/hooks/subagent_ledger_hook.ts +44 -15
- package/src/scripts/hooks/telemetry_flush_hook.ts +139 -0
- package/src/scripts/hooks/telemetry_self_repair.ts +128 -0
- package/src/scripts/hooks/telemetry_usage_hook.ts +22 -4
- package/src/scripts/hooks/turn_end_gate_hook.ts +81 -15
- package/src/scripts/injection_scan_hook.ts +137 -5
- package/src/scripts/install.ts +16 -11
- package/src/scripts/language_mirror_hook.ts +561 -25
- package/src/scripts/lint_framework_leakage_allowlist.json +2 -2
- package/src/scripts/lint_hook_manifest.ts +49 -0
- package/src/scripts/lint_plan_risk_register.ts +4 -3
- package/src/scripts/lint_provenance_vocabulary.ts +472 -4
- package/src/scripts/lint_skill_router_head.ts +4 -4
- package/src/scripts/mcp_server/tools.ts +2 -2
- package/src/scripts/new_roadmap.ts +136 -0
- package/src/scripts/pack_mcp_content.ts +20 -5
- package/src/scripts/release.ts +37 -38
- package/src/scripts/report_layer_overlap.ts +6 -0
- package/src/scripts/routing_doctor.ts +5 -1
- package/src/scripts/self_repair_hook.ts +37 -5
- package/src/scripts/session_register_hook.ts +11 -0
- package/src/scripts/skill_usage_collect.ts +11 -1
- package/src/scripts/skill_usage_report.ts +278 -8
- package/src/scripts/sync_pr_branch.ts +170 -20
- package/src/server/schemas/settings.ts +8 -0
- package/dist/cli-delegate/chunk-EJITJBJX.js +0 -172
- package/dist/cli-delegate/chunk-PZWRPRWP.js +0 -38
- package/dist/cli-delegate/{chunk-PPQO4NGR.js → chunk-6RJA2F5A.js} +3 -3
- package/dist/cli-delegate/{chunk-RYNADUFG.js → chunk-LWTYTX6F.js} +0 -0
- package/dist/cli-delegate/{chunk-FBKL6JWT.js → chunk-MMSGVZKV.js} +3 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/scripts/_lib/scan_scope.ts
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
var DeadScopeError = class extends Error {
|
|
6
|
+
gate;
|
|
7
|
+
constructor(gate, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "DeadScopeError";
|
|
10
|
+
this.gate = gate;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function assertScanned(opts) {
|
|
14
|
+
if (opts.scanned > 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (opts.allowEmpty !== void 0 && opts.allowEmpty.trim() !== "") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const roots = opts.roots.length > 0 ? opts.roots.join(", ") : "(no root declared)";
|
|
21
|
+
throw new DeadScopeError(
|
|
22
|
+
opts.gate,
|
|
23
|
+
`${opts.gate}: scanned 0 ${opts.units} under ${roots} \u2014 the scan scope is dead or the root moved. A gate that read nothing has not passed. Repoint the root (prefer the shared resolver in _lib/agent_src.ts), or declare a justified \`allowEmpty\` reason if an empty corpus is genuinely expected.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function reportScanned(opts, write = process.stdout.write.bind(process.stdout)) {
|
|
27
|
+
assertScanned(opts);
|
|
28
|
+
write(`scanned: ${String(opts.scanned)}
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
DeadScopeError,
|
|
34
|
+
assertScanned,
|
|
35
|
+
reportScanned
|
|
36
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
statePathFor
|
|
4
|
+
} from "./chunk-7PRE6ZV2.js";
|
|
2
5
|
import {
|
|
3
6
|
git_common_dir
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-E4XIZDIB.js";
|
|
5
8
|
|
|
6
9
|
// src/scripts/_lib/envelope_grounding.ts
|
|
7
10
|
import { execFileSync } from "node:child_process";
|
|
@@ -78,10 +81,10 @@ function collectRepoAnchor(root) {
|
|
|
78
81
|
head: git(root, ["rev-parse", "HEAD"])
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
function readLastVerify(root, session_id) {
|
|
85
|
+
if (typeof session_id !== "string" || session_id.trim() === "") return null;
|
|
83
86
|
try {
|
|
84
|
-
const raw = fs.readFileSync(path.join(root,
|
|
87
|
+
const raw = fs.readFileSync(path.join(root, statePathFor(session_id)), "utf-8");
|
|
85
88
|
const state = JSON.parse(raw);
|
|
86
89
|
const lv = state["last_verification"];
|
|
87
90
|
if (typeof lv !== "object" || lv === null || Array.isArray(lv)) return null;
|
|
@@ -89,16 +92,17 @@ function readLastVerify(root) {
|
|
|
89
92
|
const command = typeof rec["command"] === "string" ? rec["command"] : null;
|
|
90
93
|
if (!command) return null;
|
|
91
94
|
const at = typeof rec["at"] === "string" ? rec["at"] : "unknown time";
|
|
92
|
-
|
|
95
|
+
const flat = `${command} @ ${at} (no exit status is recorded anywhere)`.replace(/\s+/g, " ").trim();
|
|
96
|
+
return flat.slice(0, MAX_FIELD_CHARS);
|
|
93
97
|
} catch {
|
|
94
98
|
return null;
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
|
-
function collectGrounding(root) {
|
|
101
|
+
function collectGrounding(root, session_id) {
|
|
98
102
|
const anchor = collectRepoAnchor(root);
|
|
99
103
|
const porcelain = git(root, ["status", "--porcelain"]);
|
|
100
104
|
if (porcelain === null) {
|
|
101
|
-
return { ...anchor, uncommitted_paths: [], status_summary: null, last_verify: readLastVerify(root) };
|
|
105
|
+
return { ...anchor, uncommitted_paths: [], status_summary: null, last_verify: readLastVerify(root, session_id) };
|
|
102
106
|
}
|
|
103
107
|
const lines = porcelain.split("\n").filter((l) => l.trim().length > 0);
|
|
104
108
|
const paths = lines.map((l) => l.slice(3).trim()).filter((p) => p.length > 0 && p.length <= MAX_FIELD_CHARS).slice(0, MAX_PATHS);
|
|
@@ -106,7 +110,7 @@ function collectGrounding(root) {
|
|
|
106
110
|
...anchor,
|
|
107
111
|
uncommitted_paths: paths,
|
|
108
112
|
status_summary: lines.length === 0 ? "clean working tree" : `${lines.length} uncommitted path(s)${lines.length > MAX_PATHS ? `, first ${MAX_PATHS} listed` : ""}`,
|
|
109
|
-
last_verify: readLastVerify(root)
|
|
113
|
+
last_verify: readLastVerify(root, session_id)
|
|
110
114
|
};
|
|
111
115
|
}
|
|
112
116
|
function describeDrift(envelope, actual) {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/scripts/_lib/fs_atomic.ts
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
function _normalize_encoding(encoding) {
|
|
8
|
+
const compact = encoding.toLowerCase().replace(/[-_\s]/g, "");
|
|
9
|
+
const candidates = [encoding, compact];
|
|
10
|
+
if (compact === "latin1" || compact === "iso88591") candidates.push("latin1");
|
|
11
|
+
if (compact === "utf8") candidates.push("utf8");
|
|
12
|
+
if (compact === "utf16le" || compact === "utf16") candidates.push("utf16le");
|
|
13
|
+
if (compact === "usascii") candidates.push("ascii");
|
|
14
|
+
for (const c of candidates) {
|
|
15
|
+
if (Buffer.isEncoding(c)) return c;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`unknown encoding: ${encoding}`);
|
|
18
|
+
}
|
|
19
|
+
function write_atomic(p, data, options = {}) {
|
|
20
|
+
const encoding = options.encoding ?? "utf-8";
|
|
21
|
+
const target = path.normalize(p);
|
|
22
|
+
const parent = path.dirname(target);
|
|
23
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
24
|
+
let payload;
|
|
25
|
+
if (typeof data === "string") {
|
|
26
|
+
payload = Buffer.from(data, _normalize_encoding(encoding));
|
|
27
|
+
} else if (data instanceof Uint8Array) {
|
|
28
|
+
payload = Buffer.from(data);
|
|
29
|
+
} else {
|
|
30
|
+
throw new TypeError(
|
|
31
|
+
`write_atomic: data must be str or bytes, got ${typeof data}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
let fd = null;
|
|
35
|
+
let tmp_path = "";
|
|
36
|
+
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
37
|
+
tmp_path = path.join(
|
|
38
|
+
parent,
|
|
39
|
+
`.${path.basename(target)}.tmp.${randomBytes(6).toString("hex")}`
|
|
40
|
+
);
|
|
41
|
+
try {
|
|
42
|
+
fd = fs.openSync(tmp_path, "wx", 384);
|
|
43
|
+
break;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (err.code === "EEXIST") continue;
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (fd === null) {
|
|
50
|
+
throw new Error("write_atomic: could not create a unique temp file");
|
|
51
|
+
}
|
|
52
|
+
let closed = false;
|
|
53
|
+
try {
|
|
54
|
+
let offset = 0;
|
|
55
|
+
while (offset < payload.length) {
|
|
56
|
+
offset += fs.writeSync(fd, payload, offset, payload.length - offset);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
fs.fsyncSync(fd);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
fs.closeSync(fd);
|
|
63
|
+
closed = true;
|
|
64
|
+
fs.renameSync(tmp_path, target);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (!closed) {
|
|
67
|
+
try {
|
|
68
|
+
fs.closeSync(fd);
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
fs.unlinkSync(tmp_path);
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
_fsync_dir(parent);
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
function _fsync_dir(directory) {
|
|
82
|
+
let dir_fd;
|
|
83
|
+
try {
|
|
84
|
+
dir_fd = fs.openSync(directory, fs.constants.O_RDONLY);
|
|
85
|
+
} catch {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
try {
|
|
90
|
+
fs.fsyncSync(dir_fd);
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
fs.closeSync(dir_fd);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
write_atomic
|
|
100
|
+
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
DeadScopeError,
|
|
4
|
+
assertScanned
|
|
5
|
+
} from "./chunk-I3EIN2YG.js";
|
|
2
6
|
import {
|
|
3
7
|
require_dist
|
|
4
8
|
} from "./chunk-OY53J6II.js";
|
|
@@ -458,29 +462,6 @@ function _pyJsonScalarAscii(value) {
|
|
|
458
462
|
return _pyJsonScalar(value);
|
|
459
463
|
}
|
|
460
464
|
|
|
461
|
-
// src/scripts/_lib/scan_scope.ts
|
|
462
|
-
var DeadScopeError = class extends Error {
|
|
463
|
-
gate;
|
|
464
|
-
constructor(gate, message) {
|
|
465
|
-
super(message);
|
|
466
|
-
this.name = "DeadScopeError";
|
|
467
|
-
this.gate = gate;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
function assertScanned(opts) {
|
|
471
|
-
if (opts.scanned > 0) {
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
if (opts.allowEmpty !== void 0 && opts.allowEmpty.trim() !== "") {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
const roots = opts.roots.length > 0 ? opts.roots.join(", ") : "(no root declared)";
|
|
478
|
-
throw new DeadScopeError(
|
|
479
|
-
opts.gate,
|
|
480
|
-
`${opts.gate}: scanned 0 ${opts.units} under ${roots} \u2014 the scan scope is dead or the root moved. A gate that read nothing has not passed. Repoint the root (prefer the shared resolver in _lib/agent_src.ts), or declare a justified \`allowEmpty\` reason if an empty corpus is genuinely expected.`
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
465
|
// src/scripts/lint_hidden_unicode.ts
|
|
485
466
|
var CHECK = "hidden-unicode";
|
|
486
467
|
var _BIDI = /* @__PURE__ */ new Set([
|