@event4u/agent-config 14.5.0 → 14.7.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 +384 -3
- package/README.md +1 -1
- package/dist/agent-src/commands/analyze/decision.md +7 -0
- package/dist/agent-src/commands/analyze/inbox.md +264 -10
- package/dist/agent-src/commands/analyze.md +1 -1
- package/dist/agent-src/commands/optimize/project.md +10 -0
- package/dist/agent-src/commands/roadmap/process-full.md +132 -4
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +31 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +161 -1
- package/dist/agent-src/rules/context-hygiene.md +2 -0
- package/dist/agent-src/rules/decision-revisit-gate.md +111 -7
- 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 +1 -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 +19 -3
- 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 +251 -7
- package/dist/agent-src/skills/adr-create/SKILL.md +25 -3
- 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-review/SKILL.md +18 -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/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 +45 -2
- 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 +1 -1
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/chunk-2GNWGMAL.js +172 -0
- package/dist/cli-delegate/{chunk-RLN73PR5.js → chunk-4VR4ORQ6.js} +10 -7
- package/dist/cli-delegate/chunk-6EOCNQAM.js +402 -0
- package/dist/cli-delegate/{chunk-XURJ4AQC.js → chunk-74E3TKWV.js} +381 -280
- package/dist/cli-delegate/{chunk-3UCJWMMP.js → chunk-7F3VYSM2.js} +4 -4
- package/dist/cli-delegate/{chunk-BKO2AZ7Z.js → chunk-B2ERU2VA.js} +1 -1
- package/dist/cli-delegate/{chunk-NXFWFAYV.js → chunk-G23AT6GD.js} +1 -0
- package/dist/cli-delegate/{chunk-63WSP6YZ.js → chunk-GJ5BVHXM.js} +72 -165
- package/dist/cli-delegate/{chunk-ZPSXJTLI.js → chunk-JZ4NR2TW.js} +353 -1
- package/dist/cli-delegate/chunk-MWRD5YOH.js +100 -0
- 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_conformance.js +459 -709
- package/dist/cli-delegate/cmd_doctor.js +6 -6
- package/dist/cli-delegate/cmd_explain.js +1 -1
- package/dist/cli-delegate/cmd_export.js +7 -6
- package/dist/cli-delegate/cmd_handoff.js +6 -6
- package/dist/cli-delegate/cmd_packs_active.js +1 -1
- package/dist/cli-delegate/cmd_preflight.js +2 -2
- package/dist/cli-delegate/cmd_prune.js +7 -6
- package/dist/cli-delegate/cmd_session_recycle.js +840 -30
- package/dist/cli-delegate/cmd_settings_migrate.js +7 -6
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +7 -6
- package/dist/cli-delegate/cmd_uninstall.js +9 -7
- package/dist/cli-delegate/cmd_update.js +1 -1
- package/dist/cli-delegate/cmd_upgrade.js +1 -1
- package/dist/cli-delegate/cmd_validate.js +7 -6
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +72 -29
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +4 -4
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +10 -8
- package/dist/discovery/trust-report.md +3 -3
- package/dist/discovery/workspaces.json +8 -6
- package/dist/hooks/dispatch.js +3127 -2022
- package/dist/install/claudePathsPlan.js +187 -0
- package/dist/install/claudePathsPlan.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 +276 -0
- package/dist/install/partitionEligibility.js.map +1 -0
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +1744 -1191
- 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/condense.js +13 -164
- 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/context-hygiene-mechanics.md +26 -0
- package/docs/guidelines/agent-infra/engineering-memory-data-format.md +49 -0
- 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 +19 -3
- 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 +251 -7
- 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 +18 -0
- package/src/config/estate-count-budget.json +367 -3
- package/src/config/gate-violation-baselines.json +41 -41
- package/src/config/pack-size-budget.json +3 -2
- package/src/config/rule-activation-census.json +14 -6
- package/src/config/rule-stub-ceilings.json +19 -6
- package/src/install/claudePathsPlan.ts +196 -0
- package/src/install/hostLayerFingerprint.ts +145 -0
- package/src/install/partitionEligibility.ts +325 -0
- package/src/scripts/_cli/cmd_session_recycle.ts +9 -1
- package/src/scripts/_dispatch.bash +6 -1
- package/src/scripts/_lib/ac_heading.ts +30 -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 +38 -8
- package/src/scripts/_lib/installed_lock.ts +50 -5
- package/src/scripts/_lib/layer_overlap_notice.ts +85 -0
- package/src/scripts/_lib/md_section.ts +129 -0
- package/src/scripts/_lib/scope_guard.sh +86 -4
- package/src/scripts/_lib/self_repair.ts +19 -0
- package/src/scripts/_lib/self_repair_class_b.ts +171 -0
- package/src/scripts/_lib/subagent_capsule.ts +81 -1
- package/src/scripts/adr/regenerate_index.ts +13 -2
- package/src/scripts/adr_cite_check.ts +424 -0
- package/src/scripts/ai_council/cli_help.ts +55 -0
- package/src/scripts/before_complete_hook.ts +153 -28
- package/src/scripts/bench_ab_v2_complexity.ts +27 -7
- package/src/scripts/check_adr_frontmatter.ts +187 -1
- package/src/scripts/check_references.ts +60 -0
- package/src/scripts/check_release_published.ts +32 -11
- package/src/scripts/check_single_delivery.ts +517 -0
- package/src/scripts/ci_settle.ts +170 -0
- package/src/scripts/condense.ts +20 -170
- package/src/scripts/council_cli.ts +3 -3
- package/src/scripts/dispatch_r2_reviewer.ts +6 -14
- 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 +1 -1
- package/src/scripts/hooks/concern_registry.ts +4 -0
- package/src/scripts/hooks/rtk_wrap_hook.ts +8 -3
- package/src/scripts/hooks/run_continuation_hook.ts +887 -68
- 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 +782 -20
- 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/install.sh +12 -2
- 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_plan_risk_register.ts +4 -3
- package/src/scripts/lint_skill_router_head.ts +4 -4
- package/src/scripts/mcp_server/tools.ts +2 -2
- package/src/scripts/memory_consolidation.ts +189 -0
- package/src/scripts/memory_eviction.ts +384 -0
- 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 +78 -0
- package/src/scripts/report_memory_pointers.ts +622 -0
- package/src/scripts/self_repair_hook.ts +37 -5
- package/src/scripts/session_register_hook.ts +115 -15
- 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 +7 -0
- 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-RYNADUFG.js → chunk-LWTYTX6F.js} +0 -0
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-FBKL6JWT.js";
|
|
25
25
|
import {
|
|
26
26
|
git_common_dir
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6EOCNQAM.js";
|
|
28
28
|
import {
|
|
29
29
|
DEFAULT_GITATTRIBUTES,
|
|
30
30
|
SECTION_HEADER,
|
|
@@ -38,15 +38,15 @@ import {
|
|
|
38
38
|
global_deploy_inventory_exports,
|
|
39
39
|
manifest_path,
|
|
40
40
|
read_manifest
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-GJ5BVHXM.js";
|
|
42
42
|
import {
|
|
43
43
|
read_lockfile
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-T7L2QK3K.js";
|
|
45
45
|
import {
|
|
46
46
|
LEGACY_ALL,
|
|
47
47
|
excludedRuleBasenames,
|
|
48
48
|
ruleScopeFromSettings
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-G23AT6GD.js";
|
|
50
50
|
import {
|
|
51
51
|
PROJECT_ROOT_ENV,
|
|
52
52
|
ProjectRootError,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
write_atomic
|
|
4
|
+
} from "./chunk-MWRD5YOH.js";
|
|
2
5
|
import {
|
|
3
6
|
write_target
|
|
4
7
|
} from "./chunk-NDJLNC6Q.js";
|
|
@@ -10,103 +13,8 @@ import {
|
|
|
10
13
|
__toESM
|
|
11
14
|
} from "./chunk-J55WI3RR.js";
|
|
12
15
|
|
|
13
|
-
// src/scripts/_lib/fs_atomic.ts
|
|
14
|
-
import fs from "node:fs";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { randomBytes } from "node:crypto";
|
|
17
|
-
function _normalize_encoding(encoding) {
|
|
18
|
-
const compact = encoding.toLowerCase().replace(/[-_\s]/g, "");
|
|
19
|
-
const candidates = [encoding, compact];
|
|
20
|
-
if (compact === "latin1" || compact === "iso88591") candidates.push("latin1");
|
|
21
|
-
if (compact === "utf8") candidates.push("utf8");
|
|
22
|
-
if (compact === "utf16le" || compact === "utf16") candidates.push("utf16le");
|
|
23
|
-
if (compact === "usascii") candidates.push("ascii");
|
|
24
|
-
for (const c of candidates) {
|
|
25
|
-
if (Buffer.isEncoding(c)) return c;
|
|
26
|
-
}
|
|
27
|
-
throw new Error(`unknown encoding: ${encoding}`);
|
|
28
|
-
}
|
|
29
|
-
function write_atomic(p, data, options = {}) {
|
|
30
|
-
const encoding = options.encoding ?? "utf-8";
|
|
31
|
-
const target = path.normalize(p);
|
|
32
|
-
const parent = path.dirname(target);
|
|
33
|
-
fs.mkdirSync(parent, { recursive: true });
|
|
34
|
-
let payload;
|
|
35
|
-
if (typeof data === "string") {
|
|
36
|
-
payload = Buffer.from(data, _normalize_encoding(encoding));
|
|
37
|
-
} else if (data instanceof Uint8Array) {
|
|
38
|
-
payload = Buffer.from(data);
|
|
39
|
-
} else {
|
|
40
|
-
throw new TypeError(
|
|
41
|
-
`write_atomic: data must be str or bytes, got ${typeof data}`
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
let fd = null;
|
|
45
|
-
let tmp_path = "";
|
|
46
|
-
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
47
|
-
tmp_path = path.join(
|
|
48
|
-
parent,
|
|
49
|
-
`.${path.basename(target)}.tmp.${randomBytes(6).toString("hex")}`
|
|
50
|
-
);
|
|
51
|
-
try {
|
|
52
|
-
fd = fs.openSync(tmp_path, "wx", 384);
|
|
53
|
-
break;
|
|
54
|
-
} catch (err) {
|
|
55
|
-
if (err.code === "EEXIST") continue;
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (fd === null) {
|
|
60
|
-
throw new Error("write_atomic: could not create a unique temp file");
|
|
61
|
-
}
|
|
62
|
-
let closed = false;
|
|
63
|
-
try {
|
|
64
|
-
let offset = 0;
|
|
65
|
-
while (offset < payload.length) {
|
|
66
|
-
offset += fs.writeSync(fd, payload, offset, payload.length - offset);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
fs.fsyncSync(fd);
|
|
70
|
-
} catch {
|
|
71
|
-
}
|
|
72
|
-
fs.closeSync(fd);
|
|
73
|
-
closed = true;
|
|
74
|
-
fs.renameSync(tmp_path, target);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
if (!closed) {
|
|
77
|
-
try {
|
|
78
|
-
fs.closeSync(fd);
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
fs.unlinkSync(tmp_path);
|
|
84
|
-
} catch {
|
|
85
|
-
}
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
88
|
-
_fsync_dir(parent);
|
|
89
|
-
return target;
|
|
90
|
-
}
|
|
91
|
-
function _fsync_dir(directory) {
|
|
92
|
-
let dir_fd;
|
|
93
|
-
try {
|
|
94
|
-
dir_fd = fs.openSync(directory, fs.constants.O_RDONLY);
|
|
95
|
-
} catch {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
try {
|
|
100
|
-
fs.fsyncSync(dir_fd);
|
|
101
|
-
} catch {
|
|
102
|
-
}
|
|
103
|
-
} finally {
|
|
104
|
-
fs.closeSync(dir_fd);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
16
|
// src/scripts/_lib/installed_tools.ts
|
|
109
|
-
import * as
|
|
17
|
+
import * as fs from "node:fs";
|
|
110
18
|
import * as os from "node:os";
|
|
111
19
|
import * as fsPath from "node:path";
|
|
112
20
|
var MANIFEST_ENV = "AGENT_CONFIG_INSTALLED_TOOLS";
|
|
@@ -144,18 +52,18 @@ function manifest_path(project_root, env) {
|
|
|
144
52
|
var _TOP_KEY_RE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
145
53
|
var _LIST_DASH_RE = /^\s*-\s*(.+?)\s*$/;
|
|
146
54
|
var _INDENT_KEY_RE = /^\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
147
|
-
function read_manifest(
|
|
55
|
+
function read_manifest(path3) {
|
|
148
56
|
let text;
|
|
149
57
|
try {
|
|
150
|
-
text = require_read_text(
|
|
58
|
+
text = require_read_text(path3);
|
|
151
59
|
} catch {
|
|
152
60
|
return null;
|
|
153
61
|
}
|
|
154
62
|
const data = _parse_manual(text);
|
|
155
63
|
return _normalise_v2_shape(data);
|
|
156
64
|
}
|
|
157
|
-
function require_read_text(
|
|
158
|
-
return
|
|
65
|
+
function require_read_text(path3) {
|
|
66
|
+
return fs.readFileSync(path3, { encoding: "utf-8" });
|
|
159
67
|
}
|
|
160
68
|
function _normalise_v2_shape(data) {
|
|
161
69
|
if (data["tools"] === void 0 || data["tools"] === null) {
|
|
@@ -336,9 +244,9 @@ function stable_sort(items, key) {
|
|
|
336
244
|
return a.index - b.index;
|
|
337
245
|
}).map((entry) => entry.item);
|
|
338
246
|
}
|
|
339
|
-
function write_manifest(
|
|
247
|
+
function write_manifest(path3, version, tools, options = {}) {
|
|
340
248
|
const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
|
|
341
|
-
return write_atomic(
|
|
249
|
+
return write_atomic(path3, rendered);
|
|
342
250
|
}
|
|
343
251
|
var ScopeMismatchError = class extends Error {
|
|
344
252
|
name_;
|
|
@@ -483,8 +391,8 @@ function randSuffix() {
|
|
|
483
391
|
|
|
484
392
|
// src/scripts/_lib/claude_settings_hooks.ts
|
|
485
393
|
var YAML = __toESM(require_dist(), 1);
|
|
486
|
-
import * as
|
|
487
|
-
import * as
|
|
394
|
+
import * as fs2 from "node:fs";
|
|
395
|
+
import * as path from "node:path";
|
|
488
396
|
function _yaml_parse(text) {
|
|
489
397
|
return YAML.parse(text);
|
|
490
398
|
}
|
|
@@ -506,7 +414,7 @@ var SettingsLockError = class extends Error {
|
|
|
506
414
|
}
|
|
507
415
|
};
|
|
508
416
|
function build_claude_hook_matrix(manifest_path2) {
|
|
509
|
-
const raw =
|
|
417
|
+
const raw = fs2.readFileSync(manifest_path2, "utf8");
|
|
510
418
|
const manifest = _yaml_parse(raw) ?? {};
|
|
511
419
|
const hook_spec = manifest["schema_version"] ?? 1;
|
|
512
420
|
const platforms = manifest["platforms"] ?? {};
|
|
@@ -536,8 +444,8 @@ function _is_managed_group(group) {
|
|
|
536
444
|
);
|
|
537
445
|
}
|
|
538
446
|
function _read_settings(settings_path) {
|
|
539
|
-
if (!
|
|
540
|
-
const raw =
|
|
447
|
+
if (!fs2.existsSync(settings_path)) return {};
|
|
448
|
+
const raw = fs2.readFileSync(settings_path, "utf8");
|
|
541
449
|
if (raw.trim() === "") return {};
|
|
542
450
|
let parsed;
|
|
543
451
|
try {
|
|
@@ -552,18 +460,18 @@ function _read_settings(settings_path) {
|
|
|
552
460
|
}
|
|
553
461
|
function _with_lock(settings_path, fn) {
|
|
554
462
|
const lockPath = settings_path + ".agent-config.lock";
|
|
555
|
-
|
|
463
|
+
fs2.mkdirSync(path.dirname(lockPath), { recursive: true });
|
|
556
464
|
let fd;
|
|
557
465
|
try {
|
|
558
|
-
fd =
|
|
466
|
+
fd = fs2.openSync(lockPath, "wx");
|
|
559
467
|
} catch {
|
|
560
468
|
throw new SettingsLockError(lockPath);
|
|
561
469
|
}
|
|
562
470
|
try {
|
|
563
471
|
return fn();
|
|
564
472
|
} finally {
|
|
565
|
-
|
|
566
|
-
|
|
473
|
+
fs2.closeSync(fd);
|
|
474
|
+
fs2.rmSync(lockPath, { force: true });
|
|
567
475
|
}
|
|
568
476
|
}
|
|
569
477
|
function ensure_managed_hooks(settings_path, matrix) {
|
|
@@ -592,7 +500,7 @@ function ensure_managed_hooks(settings_path, matrix) {
|
|
|
592
500
|
});
|
|
593
501
|
}
|
|
594
502
|
function remove_managed_hooks(settings_path) {
|
|
595
|
-
if (!
|
|
503
|
+
if (!fs2.existsSync(settings_path)) return { changed: false, events: [] };
|
|
596
504
|
return _with_lock(settings_path, () => {
|
|
597
505
|
const settings = _read_settings(settings_path);
|
|
598
506
|
const hooks = settings["hooks"];
|
|
@@ -637,10 +545,10 @@ __export(global_deploy_inventory_exports, {
|
|
|
637
545
|
record_deploy: () => record_deploy,
|
|
638
546
|
save_inventory: () => save_inventory
|
|
639
547
|
});
|
|
640
|
-
import { randomBytes
|
|
641
|
-
import * as
|
|
548
|
+
import { randomBytes } from "node:crypto";
|
|
549
|
+
import * as fs3 from "node:fs";
|
|
642
550
|
import * as os2 from "node:os";
|
|
643
|
-
import * as
|
|
551
|
+
import * as path2 from "node:path";
|
|
644
552
|
var SCHEMA_VERSION2 = 1;
|
|
645
553
|
var INVENTORY_BASENAME = "deployed-files.json";
|
|
646
554
|
var INVENTORY_ENV = "AGENT_CONFIG_DEPLOY_INVENTORY";
|
|
@@ -649,22 +557,22 @@ function expanduser2(p) {
|
|
|
649
557
|
return os2.homedir();
|
|
650
558
|
}
|
|
651
559
|
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
652
|
-
return
|
|
560
|
+
return path2.join(os2.homedir(), p.slice(2));
|
|
653
561
|
}
|
|
654
562
|
return p;
|
|
655
563
|
}
|
|
656
564
|
function resolve_path(p) {
|
|
657
565
|
try {
|
|
658
|
-
return
|
|
566
|
+
return fs3.realpathSync(p);
|
|
659
567
|
} catch {
|
|
660
|
-
const abs =
|
|
661
|
-
const parts = abs.split(
|
|
568
|
+
const abs = path2.resolve(p);
|
|
569
|
+
const parts = abs.split(path2.sep);
|
|
662
570
|
for (let i = parts.length; i > 0; i -= 1) {
|
|
663
|
-
const prefix = parts.slice(0, i).join(
|
|
571
|
+
const prefix = parts.slice(0, i).join(path2.sep) || path2.sep;
|
|
664
572
|
try {
|
|
665
|
-
const real =
|
|
573
|
+
const real = fs3.realpathSync(prefix);
|
|
666
574
|
const rest = parts.slice(i);
|
|
667
|
-
return rest.length > 0 ?
|
|
575
|
+
return rest.length > 0 ? path2.join(real, ...rest) : real;
|
|
668
576
|
} catch {
|
|
669
577
|
continue;
|
|
670
578
|
}
|
|
@@ -674,7 +582,7 @@ function resolve_path(p) {
|
|
|
674
582
|
}
|
|
675
583
|
function path_exists(p) {
|
|
676
584
|
try {
|
|
677
|
-
|
|
585
|
+
fs3.statSync(p);
|
|
678
586
|
return true;
|
|
679
587
|
} catch {
|
|
680
588
|
return false;
|
|
@@ -692,7 +600,7 @@ function load_inventory(p) {
|
|
|
692
600
|
const target = p ?? inventory_path();
|
|
693
601
|
let data;
|
|
694
602
|
try {
|
|
695
|
-
data = JSON.parse(
|
|
603
|
+
data = JSON.parse(fs3.readFileSync(target, { encoding: "utf-8" }));
|
|
696
604
|
} catch {
|
|
697
605
|
return { schema_version: SCHEMA_VERSION2, tools: {} };
|
|
698
606
|
}
|
|
@@ -703,15 +611,15 @@ function load_inventory(p) {
|
|
|
703
611
|
}
|
|
704
612
|
function save_inventory(data, p) {
|
|
705
613
|
const target = p ?? inventory_path();
|
|
706
|
-
|
|
614
|
+
fs3.mkdirSync(path2.dirname(target), { recursive: true });
|
|
707
615
|
const payload = json_dumps_sorted(data, 2) + "\n";
|
|
708
|
-
const parent =
|
|
616
|
+
const parent = path2.dirname(target);
|
|
709
617
|
let fd = null;
|
|
710
618
|
let tmp_name = "";
|
|
711
619
|
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
712
|
-
tmp_name =
|
|
620
|
+
tmp_name = path2.join(parent, `${path2.basename(target)}.${randomBytes(6).toString("hex")}`);
|
|
713
621
|
try {
|
|
714
|
-
fd =
|
|
622
|
+
fd = fs3.openSync(tmp_name, "wx", 384);
|
|
715
623
|
break;
|
|
716
624
|
} catch (err) {
|
|
717
625
|
if (err.code === "EEXIST") {
|
|
@@ -724,16 +632,16 @@ function save_inventory(data, p) {
|
|
|
724
632
|
throw new Error("save_inventory: could not create a unique temp file");
|
|
725
633
|
}
|
|
726
634
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
635
|
+
fs3.writeFileSync(fd, payload, { encoding: "utf-8" });
|
|
636
|
+
fs3.closeSync(fd);
|
|
637
|
+
fs3.renameSync(tmp_name, target);
|
|
730
638
|
} catch (err) {
|
|
731
639
|
try {
|
|
732
|
-
|
|
640
|
+
fs3.closeSync(fd);
|
|
733
641
|
} catch {
|
|
734
642
|
}
|
|
735
643
|
try {
|
|
736
|
-
|
|
644
|
+
fs3.unlinkSync(tmp_name);
|
|
737
645
|
} catch {
|
|
738
646
|
}
|
|
739
647
|
throw err;
|
|
@@ -792,7 +700,7 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
|
|
|
792
700
|
const out = /* @__PURE__ */ new Set();
|
|
793
701
|
let src_stat;
|
|
794
702
|
try {
|
|
795
|
-
src_stat =
|
|
703
|
+
src_stat = fs3.statSync(src);
|
|
796
704
|
} catch {
|
|
797
705
|
return out;
|
|
798
706
|
}
|
|
@@ -804,23 +712,23 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
|
|
|
804
712
|
return out;
|
|
805
713
|
}
|
|
806
714
|
const _walk = (node, prefix) => {
|
|
807
|
-
const entries =
|
|
715
|
+
const entries = fs3.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
808
716
|
for (const name of entries) {
|
|
809
|
-
const entry =
|
|
717
|
+
const entry = path2.join(node, name);
|
|
810
718
|
const rel = join_rel(prefix, name);
|
|
811
|
-
const lst =
|
|
719
|
+
const lst = fs3.lstatSync(entry);
|
|
812
720
|
if (lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
813
721
|
_walk(entry, rel);
|
|
814
722
|
continue;
|
|
815
723
|
}
|
|
816
724
|
let resolved_is_dir = false;
|
|
817
725
|
try {
|
|
818
|
-
resolved_is_dir =
|
|
726
|
+
resolved_is_dir = fs3.statSync(entry).isDirectory();
|
|
819
727
|
} catch {
|
|
820
728
|
resolved_is_dir = false;
|
|
821
729
|
}
|
|
822
730
|
if (resolved_is_dir) {
|
|
823
|
-
_walk(
|
|
731
|
+
_walk(fs3.realpathSync(entry), rel);
|
|
824
732
|
continue;
|
|
825
733
|
}
|
|
826
734
|
if (file_filter !== null && !file_filter(entry)) {
|
|
@@ -833,13 +741,13 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
|
|
|
833
741
|
return out;
|
|
834
742
|
}
|
|
835
743
|
function join_rel(prefix, name) {
|
|
836
|
-
return prefix ?
|
|
744
|
+
return prefix ? path2.join(prefix, name) : name;
|
|
837
745
|
}
|
|
838
746
|
function as_posix(p) {
|
|
839
747
|
if (p === "") {
|
|
840
748
|
return ".";
|
|
841
749
|
}
|
|
842
|
-
return p.split(
|
|
750
|
+
return p.split(path2.sep).join("/");
|
|
843
751
|
}
|
|
844
752
|
function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false) {
|
|
845
753
|
const tools = inventory["tools"] ?? {};
|
|
@@ -864,15 +772,15 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
|
|
|
864
772
|
if (typeof rel !== "string" || !rel || rel.startsWith("/") || rel.startsWith("..")) {
|
|
865
773
|
continue;
|
|
866
774
|
}
|
|
867
|
-
const target =
|
|
775
|
+
const target = path2.join(anchor_resolved, rel);
|
|
868
776
|
try {
|
|
869
|
-
relative_to(resolve_path(
|
|
777
|
+
relative_to(resolve_path(path2.dirname(target)), anchor_resolved);
|
|
870
778
|
} catch {
|
|
871
779
|
continue;
|
|
872
780
|
}
|
|
873
781
|
let lst = null;
|
|
874
782
|
try {
|
|
875
|
-
lst =
|
|
783
|
+
lst = fs3.lstatSync(target);
|
|
876
784
|
} catch {
|
|
877
785
|
lst = null;
|
|
878
786
|
}
|
|
@@ -886,12 +794,12 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
|
|
|
886
794
|
continue;
|
|
887
795
|
}
|
|
888
796
|
try {
|
|
889
|
-
|
|
797
|
+
fs3.unlinkSync(target);
|
|
890
798
|
} catch {
|
|
891
799
|
continue;
|
|
892
800
|
}
|
|
893
801
|
deleted.push(target);
|
|
894
|
-
prune_candidates.add(
|
|
802
|
+
prune_candidates.add(path2.dirname(target));
|
|
895
803
|
}
|
|
896
804
|
prune_empty_dirs(prune_candidates, anchor_resolved);
|
|
897
805
|
return deleted;
|
|
@@ -902,10 +810,10 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
|
|
|
902
810
|
const prune_candidates = /* @__PURE__ */ new Set();
|
|
903
811
|
const needle = `package: ${package_tag}`;
|
|
904
812
|
for (const dest_sub of dest_subs) {
|
|
905
|
-
const root = dest_sub ?
|
|
813
|
+
const root = dest_sub ? path2.join(anchor_resolved, dest_sub) : anchor_resolved;
|
|
906
814
|
let root_stat;
|
|
907
815
|
try {
|
|
908
|
-
root_stat =
|
|
816
|
+
root_stat = fs3.statSync(root);
|
|
909
817
|
} catch {
|
|
910
818
|
continue;
|
|
911
819
|
}
|
|
@@ -915,7 +823,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
|
|
|
915
823
|
for (const md of rglob_md(root)) {
|
|
916
824
|
let md_lst;
|
|
917
825
|
try {
|
|
918
|
-
md_lst =
|
|
826
|
+
md_lst = fs3.lstatSync(md);
|
|
919
827
|
} catch {
|
|
920
828
|
continue;
|
|
921
829
|
}
|
|
@@ -927,13 +835,13 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
|
|
|
927
835
|
continue;
|
|
928
836
|
}
|
|
929
837
|
try {
|
|
930
|
-
relative_to(resolve_path(
|
|
838
|
+
relative_to(resolve_path(path2.dirname(md)), anchor_resolved);
|
|
931
839
|
} catch {
|
|
932
840
|
continue;
|
|
933
841
|
}
|
|
934
842
|
let head;
|
|
935
843
|
try {
|
|
936
|
-
head =
|
|
844
|
+
head = fs3.readFileSync(md, { encoding: "utf-8" });
|
|
937
845
|
} catch {
|
|
938
846
|
continue;
|
|
939
847
|
}
|
|
@@ -951,12 +859,12 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
|
|
|
951
859
|
continue;
|
|
952
860
|
}
|
|
953
861
|
try {
|
|
954
|
-
|
|
862
|
+
fs3.unlinkSync(md);
|
|
955
863
|
} catch {
|
|
956
864
|
continue;
|
|
957
865
|
}
|
|
958
866
|
deleted.push(md);
|
|
959
|
-
prune_candidates.add(
|
|
867
|
+
prune_candidates.add(path2.dirname(md));
|
|
960
868
|
}
|
|
961
869
|
}
|
|
962
870
|
prune_empty_dirs(prune_candidates, anchor_resolved);
|
|
@@ -976,51 +884,51 @@ function record_deploy(tool_id, anchor, current_files, inventory) {
|
|
|
976
884
|
}
|
|
977
885
|
function prune_empty_dirs(prune_candidates, anchor_resolved) {
|
|
978
886
|
const ordered = [...prune_candidates].sort(
|
|
979
|
-
(a, b) => b.split(
|
|
887
|
+
(a, b) => b.split(path2.sep).length - a.split(path2.sep).length
|
|
980
888
|
);
|
|
981
889
|
for (const start of ordered) {
|
|
982
890
|
let node = start;
|
|
983
891
|
while (node !== anchor_resolved && is_ancestor(anchor_resolved, node)) {
|
|
984
892
|
try {
|
|
985
|
-
|
|
893
|
+
fs3.rmdirSync(node);
|
|
986
894
|
} catch {
|
|
987
895
|
break;
|
|
988
896
|
}
|
|
989
|
-
node =
|
|
897
|
+
node = path2.dirname(node);
|
|
990
898
|
}
|
|
991
899
|
}
|
|
992
900
|
}
|
|
993
901
|
function is_ancestor(anchor, node) {
|
|
994
|
-
const rel =
|
|
995
|
-
return rel !== "" && !rel.startsWith("..") && !
|
|
902
|
+
const rel = path2.relative(anchor, node);
|
|
903
|
+
return rel !== "" && !rel.startsWith("..") && !path2.isAbsolute(rel);
|
|
996
904
|
}
|
|
997
905
|
function relative_to(child, parent) {
|
|
998
906
|
if (child === parent) {
|
|
999
907
|
return "";
|
|
1000
908
|
}
|
|
1001
|
-
const rel =
|
|
1002
|
-
if (rel.startsWith("..") ||
|
|
909
|
+
const rel = path2.relative(parent, child);
|
|
910
|
+
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
1003
911
|
throw new Error(`'${child}' is not in the subpath of '${parent}'`);
|
|
1004
912
|
}
|
|
1005
913
|
return rel;
|
|
1006
914
|
}
|
|
1007
915
|
function relative_to_posix(child, parent) {
|
|
1008
|
-
return
|
|
916
|
+
return path2.relative(parent, child).split(path2.sep).join("/");
|
|
1009
917
|
}
|
|
1010
918
|
function rglob_md(root) {
|
|
1011
919
|
const out = [];
|
|
1012
920
|
const walk = (dir) => {
|
|
1013
921
|
let names;
|
|
1014
922
|
try {
|
|
1015
|
-
names =
|
|
923
|
+
names = fs3.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
1016
924
|
} catch {
|
|
1017
925
|
return;
|
|
1018
926
|
}
|
|
1019
927
|
for (const name of names) {
|
|
1020
|
-
const full =
|
|
928
|
+
const full = path2.join(dir, name);
|
|
1021
929
|
let lst;
|
|
1022
930
|
try {
|
|
1023
|
-
lst =
|
|
931
|
+
lst = fs3.lstatSync(full);
|
|
1024
932
|
} catch {
|
|
1025
933
|
continue;
|
|
1026
934
|
}
|
|
@@ -1061,7 +969,6 @@ function splitlines2(text) {
|
|
|
1061
969
|
}
|
|
1062
970
|
|
|
1063
971
|
export {
|
|
1064
|
-
write_atomic,
|
|
1065
972
|
SCHEMA_VERSIONS_SUPPORTED,
|
|
1066
973
|
DEFAULT_DEPLOY_ROOTS,
|
|
1067
974
|
manifest_path,
|