@event4u/agent-config 16.0.0 → 16.1.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/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +297 -137
- package/CONTRIBUTING.md +9 -0
- package/README.md +2 -2
- package/dist/agent-src/commands/analyze/inbox.md +26 -0
- package/dist/agent-src/commands/analyze/roadmap-repos.md +27 -0
- package/dist/agent-src/commands/challenge-me/closure.md +178 -0
- package/dist/agent-src/commands/challenge-me.md +9 -2
- package/dist/agent-src/commands/council/default.md +25 -5
- package/dist/agent-src/commands/feature/plan.md +28 -1
- package/dist/agent-src/commands/feature/roadmap.md +28 -1
- package/dist/agent-src/commands/implement-ticket.md +27 -0
- package/dist/agent-src/commands/jira-ticket.md +27 -0
- package/dist/agent-src/commands/pr/create.md +29 -0
- package/dist/agent-src/commands/pr/merge.md +60 -9
- package/dist/agent-src/commands/roadmap/ai-council.md +7 -1
- package/dist/agent-src/commands/roadmap/create.md +74 -27
- package/dist/agent-src/commands/roadmap/materialize.md +27 -0
- package/dist/agent-src/commands/roadmap/process-full.md +123 -18
- package/dist/agent-src/commands/team.md +22 -0
- package/dist/agent-src/contexts/authority/scope-growth-ownership.md +80 -0
- package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +47 -0
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +44 -3
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +15 -15
- package/dist/agent-src/contexts/execution/decision-closure-execution.md +93 -0
- package/dist/agent-src/contexts/execution/fix-loop-ladder.md +108 -0
- package/dist/agent-src/contexts/execution/plan-confidence-gate.md +4 -2
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +75 -6
- package/dist/agent-src/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
- package/dist/agent-src/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
- package/dist/agent-src/guidelines/design-fidelity-routing.md +29 -0
- package/dist/agent-src/rules/autonomous-execution.md +15 -8
- package/dist/agent-src/rules/delegation-policy.md +23 -45
- package/dist/agent-src/rules/design-fidelity.md +32 -37
- package/dist/agent-src/rules/evaluator-independence.md +43 -49
- package/dist/agent-src/rules/test-first.md +41 -0
- package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +3 -3
- package/dist/agent-src/skills/ai-council/SKILL.md +11 -3
- package/dist/agent-src/skills/api-design/data/manifest.json +3 -3
- package/dist/agent-src/skills/database/data/manifest.json +4 -4
- package/dist/agent-src/skills/database/data/query-tuning.csv +3 -3
- package/dist/agent-src/skills/design-review/SKILL.md +50 -0
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -4
- package/dist/agent-src/skills/experiment-loop/SKILL.md +31 -1
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +1 -1
- package/dist/agent-src/skills/storybook-workshop/SKILL.md +42 -3
- package/dist/agent-src/skills/threat-modeling/SKILL.md +9 -4
- package/dist/agent-src/skills/threat-modeling/data/manifest.json +4 -4
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +37 -3
- package/dist/agent-src/templates/agent-settings.md +1 -1
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +188 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
- package/dist/cli-delegate/check_update_banner.js +40 -2
- package/dist/cli-delegate/chunk-4E2W63DA.js +335 -0
- package/dist/cli-delegate/chunk-5R7HOLAF.js +99 -0
- package/dist/cli-delegate/{chunk-IVBPRCQO.js → chunk-6KFEC3G7.js} +1 -1
- package/dist/cli-delegate/{chunk-2TAQ2K4V.js → chunk-6KM6ORRY.js} +55 -386
- package/dist/cli-delegate/{chunk-2XY7ILBT.js → chunk-FC75PGJE.js} +42 -2
- package/dist/cli-delegate/{chunk-GYC3VRYN.js → chunk-FXYUYU4N.js} +57 -13
- package/dist/cli-delegate/{chunk-55ACLDUE.js → chunk-GJCBB2UG.js} +168 -10
- package/dist/cli-delegate/{chunk-AK6HODNQ.js → chunk-HDVVGPQW.js} +873 -539
- package/dist/cli-delegate/{chunk-H32DGUJH.js → chunk-P6ZHP5W2.js} +1 -1
- package/dist/cli-delegate/{chunk-57PN4GYJ.js → chunk-RGNIWTEA.js} +1 -1
- package/dist/cli-delegate/chunk-ROYYTEZU.js +39 -0
- package/dist/cli-delegate/{chunk-3FKR64R5.js → chunk-UNCRJBT3.js} +31 -7
- package/dist/cli-delegate/{chunk-2DK2VJWG.js → chunk-WGXTVKCQ.js} +20 -6
- package/dist/cli-delegate/chunk-YDPILCOL.js +152 -0
- package/dist/cli-delegate/cmd_analyze_session.js +1 -1
- package/dist/cli-delegate/cmd_brand_status.js +1 -1
- package/dist/cli-delegate/cmd_conformance.js +90 -56
- package/dist/cli-delegate/cmd_doctor.js +7 -5
- package/dist/cli-delegate/cmd_explain.js +2 -2
- package/dist/cli-delegate/cmd_export.js +9 -7
- package/dist/cli-delegate/cmd_fleet.js +4 -2
- package/dist/cli-delegate/cmd_handoff.js +4 -4
- package/dist/cli-delegate/cmd_mcp_available.js +1 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +2 -2
- package/dist/cli-delegate/cmd_preflight.js +4 -2
- package/dist/cli-delegate/cmd_prune.js +10 -8
- package/dist/cli-delegate/cmd_route_audit.js +2 -2
- package/dist/cli-delegate/cmd_route_explain.js +1 -1
- package/dist/cli-delegate/cmd_session_recycle.js +2 -2
- package/dist/cli-delegate/cmd_settings_get.js +28 -2
- package/dist/cli-delegate/cmd_settings_migrate.js +9 -7
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +10 -8
- package/dist/cli-delegate/cmd_uninstall.js +16 -13
- 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 +12 -10
- package/dist/cli-delegate/cmd_versions.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +85 -38
- 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 +1832 -1007
- package/dist/install/claudeRuleRewrite.js +14 -3
- package/dist/install/conflict.js +60 -10
- package/dist/install/conflictTracker.js +218 -0
- package/dist/install/fsPrimitives.js +54 -0
- package/dist/install/install.mjs +2007 -1481
- package/dist/install/manifestFiles.js +259 -0
- package/dist/install/preflight.js +14 -2
- package/dist/install/preserve.js +157 -0
- package/dist/install/recordedOwnership.js +132 -0
- package/dist/install/txlog.js +11 -2
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +398 -39
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_settings.js +3 -2
- package/dist/scripts/_lib/fs_atomic.js +167 -0
- package/dist/scripts/_lib/installed_tools.js +460 -0
- package/dist/scripts/_lib/lean_projection_mode.js +3 -2
- package/dist/scripts/_lib/settings_renamed_keys.js +78 -0
- package/dist/server/routes/install.js +8 -0
- package/dist/server/routes/wizard.js +9 -3
- package/dist/server/schemas/settings.js +17 -5
- package/dist/shared/missionExecution.js +97 -0
- package/dist/ui/assets/{index-D0jaCRPM.js → index-DH1xc62v.js} +17 -17
- package/dist/ui/index.html +1 -1
- package/docs/MIGRATION.md +103 -0
- package/docs/contracts/settings-classes.md +26 -7
- package/docs/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
- package/docs/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
- package/docs/guidelines/design-fidelity-routing.md +29 -0
- package/package.json +1 -1
- package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
- package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
- package/src/config/agent-settings.template.yml +139 -27
- package/src/config/auto-rule-budget.json +16 -0
- package/src/config/ci-local-parity.yml +18 -5
- package/src/config/continuity-surface.json +21 -0
- package/src/config/gate-coverage.yml +146 -13
- package/src/config/gate-violation-baselines.json +6 -6
- package/src/config/hook-token-budget.json +2 -0
- package/src/config/loop-surfaces.yaml +215 -0
- package/src/config/platform-anchor.json +3 -2
- package/src/config/release-gate-locality.yml +11 -0
- package/src/config/routing-coverage-seed.json +18 -4
- package/src/config/rule-enforcement-baseline.json +0 -1
- package/src/install/claudeRuleRewrite.ts +16 -2
- package/src/install/conflict.ts +65 -9
- package/src/install/conflictTracker.ts +299 -0
- package/src/install/fsPrimitives.ts +54 -0
- package/src/install/manifestFiles.ts +312 -0
- package/src/install/preflight.ts +16 -2
- package/src/install/preserve.ts +205 -0
- package/src/install/recordedOwnership.ts +149 -0
- package/src/install/txlog.ts +11 -2
- package/src/install/types.ts +19 -4
- package/src/scripts/_cli/cmd_conformance.ts +88 -15
- package/src/scripts/_cli/cmd_doctor.ts +4 -3
- package/src/scripts/_cli/cmd_route_explain.ts +9 -2
- package/src/scripts/_cli/cmd_settings_get.ts +44 -0
- package/src/scripts/_cli/doctor_execution.ts +90 -0
- package/src/scripts/_lib/activation_payload.ts +247 -0
- package/src/scripts/_lib/agent_settings.ts +4 -2
- package/src/scripts/_lib/authority_path.ts +102 -0
- package/src/scripts/_lib/cascade_base.ts +94 -0
- package/src/scripts/_lib/changelog_eras.ts +7 -2
- package/src/scripts/_lib/continuation_ladder.ts +149 -2
- package/src/scripts/_lib/council_transport.ts +129 -0
- package/src/scripts/_lib/delivery_ready.ts +112 -0
- package/src/scripts/_lib/forge_protection.ts +267 -0
- package/src/scripts/_lib/hook_platform_keys.ts +27 -0
- package/src/scripts/_lib/json_python_parity.ts +127 -0
- package/src/scripts/_lib/lean_projection_mode.ts +14 -3
- package/src/scripts/_lib/loop_surfaces.ts +382 -0
- package/src/scripts/_lib/mission_record.ts +190 -0
- package/src/scripts/_lib/obligation_frequency.ts +217 -0
- package/src/scripts/_lib/obligations.ts +402 -0
- package/src/scripts/_lib/orchestration_record.ts +11 -20
- package/src/scripts/_lib/release_highlights.ts +199 -10
- package/src/scripts/_lib/release_holds.ts +493 -0
- package/src/scripts/_lib/release_migration_gate.ts +184 -0
- package/src/scripts/_lib/rides_along.ts +102 -0
- package/src/scripts/_lib/settings_renamed_keys.ts +82 -0
- package/src/scripts/_lib/test_delta.ts +166 -0
- package/src/scripts/_lib/test_provenance.ts +171 -0
- package/src/scripts/_lib/typed_op_grant.ts +246 -0
- package/src/scripts/_lib/typed_op_watch.ts +185 -0
- package/src/scripts/ai_council/config.ts +8 -11
- package/src/scripts/ai_council/fallback_config.ts +5 -3
- package/src/scripts/ai_council/ownership_classes.ts +118 -0
- package/src/scripts/ask_block_census.ts +285 -15
- package/src/scripts/check_enforcement_matrix.ts +624 -0
- package/src/scripts/check_gate_reachability.ts +173 -10
- package/src/scripts/check_generator_sync.ts +954 -0
- package/src/scripts/check_preamble_payload_budget.ts +75 -2
- package/src/scripts/check_release_highlights.ts +33 -1
- package/src/scripts/check_release_holds.ts +567 -0
- package/src/scripts/check_rule_projection_integrity.ts +22 -12
- package/src/scripts/check_test_delta.ts +294 -0
- package/src/scripts/check_test_weakening.ts +299 -0
- package/src/scripts/closure_scan.ts +333 -0
- package/src/scripts/compile_hook_manifest.ts +43 -3
- package/src/scripts/council_record_shape.ts +209 -0
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +88 -9
- package/src/scripts/hooks/concern_registry.ts +4 -0
- package/src/scripts/hooks/design_pass_hook.ts +128 -3
- package/src/scripts/hooks/evidence_independence.ts +96 -0
- package/src/scripts/hooks/memory_recall_hook.ts +540 -0
- package/src/scripts/hooks/obligation_settle_hook.ts +182 -0
- package/src/scripts/hooks/rule_inject_hook.ts +49 -1
- package/src/scripts/hooks/run_continuation_hook.ts +17 -20
- package/src/scripts/hooks_doctor.ts +85 -0
- package/src/scripts/hooks_status.ts +19 -0
- package/src/scripts/install.ts +106 -206
- package/src/scripts/janitor.ts +7 -0
- package/src/scripts/lint_decision_classes.ts +464 -0
- package/src/scripts/lint_hook_manifest.ts +11 -0
- package/src/scripts/lint_major_migration_sections.ts +450 -0
- package/src/scripts/lint_plan_risk_register.ts +47 -3
- package/src/scripts/lint_roadmap_blockers.ts +61 -0
- package/src/scripts/lint_roadmap_producers.ts +202 -0
- package/src/scripts/measure_rule_budget.ts +101 -5
- package/src/scripts/new_roadmap.ts +37 -0
- package/src/scripts/orchestration_record.ts +0 -5
- package/src/scripts/release.ts +14 -98
- package/src/scripts/release_drill.ts +267 -1
- package/src/scripts/release_publication.ts +51 -0
- package/src/scripts/report_enforcement_drift.ts +566 -0
- package/src/scripts/report_host_injection_effect.ts +3 -11
- package/src/scripts/report_standing_payload_by_host.ts +26 -152
- package/src/scripts/schemas/agent-settings.schema.json +23 -0
- package/src/scripts/schemas/command.schema.json +4 -0
- package/src/scripts/scope_growth.ts +219 -0
- package/src/scripts/trigger_eval_grandfather.json +0 -1
- package/src/scripts/ui_conformance_probe.ts +622 -0
- package/src/server/schemas/settings.ts +31 -7
- package/src/shared/missionExecution.ts +126 -0
- package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
|
@@ -123,6 +123,44 @@ function carveOutKeys() {
|
|
|
123
123
|
return SETTINGS_CARVE_OUT.map((c) => c.key);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// src/scripts/_lib/settings_renamed_keys.ts
|
|
127
|
+
var RENAMED_KEYS = /* @__PURE__ */ new Map([
|
|
128
|
+
["planning.challenge_on_create", "planning.closure_pass"]
|
|
129
|
+
]);
|
|
130
|
+
var _warned = /* @__PURE__ */ new Set();
|
|
131
|
+
function _read(tree, dotted) {
|
|
132
|
+
let cur = tree;
|
|
133
|
+
for (const part of dotted.split(".")) {
|
|
134
|
+
if (cur === null || typeof cur !== "object" || Array.isArray(cur)) return void 0;
|
|
135
|
+
cur = cur[part];
|
|
136
|
+
}
|
|
137
|
+
return cur;
|
|
138
|
+
}
|
|
139
|
+
function _write(tree, dotted, value) {
|
|
140
|
+
const parts = dotted.split(".");
|
|
141
|
+
let cur = tree;
|
|
142
|
+
for (const part of parts.slice(0, -1)) {
|
|
143
|
+
const next = cur[part];
|
|
144
|
+
if (next === null || typeof next !== "object" || Array.isArray(next)) cur[part] = {};
|
|
145
|
+
cur = cur[part];
|
|
146
|
+
}
|
|
147
|
+
cur[parts[parts.length - 1]] = value;
|
|
148
|
+
}
|
|
149
|
+
function applyRenamedKeys(layer) {
|
|
150
|
+
for (const [oldKey, newKey] of RENAMED_KEYS) {
|
|
151
|
+
const oldValue = _read(layer, oldKey);
|
|
152
|
+
if (oldValue === void 0) continue;
|
|
153
|
+
if (_read(layer, newKey) === void 0) _write(layer, newKey, oldValue);
|
|
154
|
+
if (_warned.has(oldKey)) continue;
|
|
155
|
+
_warned.add(oldKey);
|
|
156
|
+
process.stderr.write(
|
|
157
|
+
`\u26A0\uFE0F settings: \`${oldKey}\` was renamed to \`${newKey}\`. The old key still works for one minor; rename it in your .agent-settings.yml.
|
|
158
|
+
`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return layer;
|
|
162
|
+
}
|
|
163
|
+
|
|
126
164
|
// src/scripts/_lib/agent_settings.ts
|
|
127
165
|
var _require = createRequire(import.meta.url);
|
|
128
166
|
var Logger = class {
|
|
@@ -426,9 +464,9 @@ function load_agent_settings(options = {}) {
|
|
|
426
464
|
}
|
|
427
465
|
const cascade = _resolve_cascade_paths(cwd, project_path);
|
|
428
466
|
const merged = template_defaults(template_path ?? void 0);
|
|
429
|
-
_deep_merge(merged, user_global_filtered);
|
|
467
|
+
_deep_merge(merged, applyRenamedKeys(user_global_filtered));
|
|
430
468
|
for (const p of cascade) {
|
|
431
|
-
const layer = _read_yaml(p) ?? {};
|
|
469
|
+
const layer = applyRenamedKeys(_read_yaml(p) ?? {});
|
|
432
470
|
if (Object.keys(layer).length > 0) {
|
|
433
471
|
_deep_merge(merged, layer);
|
|
434
472
|
}
|
|
@@ -0,0 +1,335 @@
|
|
|
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";
|
|
5
|
+
|
|
6
|
+
// src/scripts/_lib/installed_tools.ts
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
import * as fsPath from "node:path";
|
|
10
|
+
var MANIFEST_ENV = "AGENT_CONFIG_INSTALLED_TOOLS";
|
|
11
|
+
var DEFAULT_MANIFEST_RELATIVE = fsPath.join("agents", "installed-tools.lock");
|
|
12
|
+
var SCHEMA_VERSION = 2;
|
|
13
|
+
var SCHEMA_VERSIONS_SUPPORTED = [1, 2];
|
|
14
|
+
var _VALID_SCOPES = ["global", "project"];
|
|
15
|
+
var DEFAULT_DEPLOY_ROOTS = [
|
|
16
|
+
".augment/rules",
|
|
17
|
+
".augment/skills",
|
|
18
|
+
".augment/commands",
|
|
19
|
+
".cursor/rules",
|
|
20
|
+
".claude/skills",
|
|
21
|
+
".claude/commands",
|
|
22
|
+
".clinerules",
|
|
23
|
+
".windsurf/rules"
|
|
24
|
+
];
|
|
25
|
+
function expanduser(p) {
|
|
26
|
+
if (p === "~") {
|
|
27
|
+
return os.homedir();
|
|
28
|
+
}
|
|
29
|
+
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
30
|
+
return fsPath.join(os.homedir(), p.slice(2));
|
|
31
|
+
}
|
|
32
|
+
return p;
|
|
33
|
+
}
|
|
34
|
+
function manifest_path(project_root, env) {
|
|
35
|
+
const env_map = env ?? process.env;
|
|
36
|
+
const override = env_map[MANIFEST_ENV];
|
|
37
|
+
if (override) {
|
|
38
|
+
return expanduser(override);
|
|
39
|
+
}
|
|
40
|
+
return fsPath.join(project_root, DEFAULT_MANIFEST_RELATIVE);
|
|
41
|
+
}
|
|
42
|
+
var _TOP_KEY_RE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
43
|
+
var _LIST_DASH_RE = /^\s*-\s*(.+?)\s*$/;
|
|
44
|
+
var _INDENT_KEY_RE = /^\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
45
|
+
function read_manifest(path) {
|
|
46
|
+
let text;
|
|
47
|
+
try {
|
|
48
|
+
text = require_read_text(path);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const data = _parse_manual(text);
|
|
53
|
+
return _normalise_v2_shape(data);
|
|
54
|
+
}
|
|
55
|
+
function require_read_text(path) {
|
|
56
|
+
return fs.readFileSync(path, { encoding: "utf-8" });
|
|
57
|
+
}
|
|
58
|
+
function _normalise_v2_shape(data) {
|
|
59
|
+
if (data["tools"] === void 0 || data["tools"] === null) {
|
|
60
|
+
data["tools"] = [];
|
|
61
|
+
}
|
|
62
|
+
if (data["deploy_roots"] === void 0 || data["deploy_roots"] === null) {
|
|
63
|
+
data["deploy_roots"] = [];
|
|
64
|
+
}
|
|
65
|
+
const tools = data["tools"];
|
|
66
|
+
for (const tool of tools) {
|
|
67
|
+
if (typeof tool !== "object" || tool === null) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const t = tool;
|
|
71
|
+
if (t["files"] === void 0 || t["files"] === null) {
|
|
72
|
+
t["files"] = [];
|
|
73
|
+
}
|
|
74
|
+
if (t["merged_keys"] === void 0 || t["merged_keys"] === null) {
|
|
75
|
+
t["merged_keys"] = [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
function _parse_manual(text) {
|
|
81
|
+
const data = { tools: [] };
|
|
82
|
+
const tools = data["tools"];
|
|
83
|
+
let in_tools = false;
|
|
84
|
+
let current = null;
|
|
85
|
+
let skip_until_outdent = false;
|
|
86
|
+
for (const raw of splitlines(text)) {
|
|
87
|
+
const stripped = raw.trim();
|
|
88
|
+
if (!stripped || stripped.startsWith("#")) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (stripped === "tools:") {
|
|
92
|
+
in_tools = true;
|
|
93
|
+
current = null;
|
|
94
|
+
skip_until_outdent = false;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (in_tools) {
|
|
98
|
+
const indent = raw.length - lstrip_spaces(raw).length;
|
|
99
|
+
if (skip_until_outdent && indent > 4) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
skip_until_outdent = false;
|
|
103
|
+
const m = _LIST_DASH_RE.exec(raw);
|
|
104
|
+
if (m && indent === 2) {
|
|
105
|
+
const first = m[1];
|
|
106
|
+
current = {};
|
|
107
|
+
tools.push(current);
|
|
108
|
+
const inline = _TOP_KEY_RE.exec(first);
|
|
109
|
+
if (inline) {
|
|
110
|
+
current[inline[1]] = inline[2];
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const mk = _INDENT_KEY_RE.exec(raw);
|
|
115
|
+
if (mk && current !== null && indent === 4) {
|
|
116
|
+
const key = mk[1];
|
|
117
|
+
const val = mk[2];
|
|
118
|
+
if ((key === "files" || key === "merged_keys") && !val) {
|
|
119
|
+
skip_until_outdent = true;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
current[key] = val;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const m_top = _TOP_KEY_RE.exec(raw);
|
|
127
|
+
if (m_top) {
|
|
128
|
+
const key = m_top[1];
|
|
129
|
+
const value = m_top[2];
|
|
130
|
+
if (key === "deploy_roots" && !value) {
|
|
131
|
+
in_tools = false;
|
|
132
|
+
current = null;
|
|
133
|
+
skip_until_outdent = true;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (key === "schema_version") {
|
|
137
|
+
const parsed = parse_int_strict(value);
|
|
138
|
+
data[key] = parsed === null ? value : parsed;
|
|
139
|
+
} else {
|
|
140
|
+
data[key] = value;
|
|
141
|
+
}
|
|
142
|
+
in_tools = false;
|
|
143
|
+
current = null;
|
|
144
|
+
skip_until_outdent = false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return data;
|
|
148
|
+
}
|
|
149
|
+
function splitlines(text) {
|
|
150
|
+
const parts = text.split("\n");
|
|
151
|
+
if (parts.length > 0 && parts[parts.length - 1] === "") {
|
|
152
|
+
parts.pop();
|
|
153
|
+
}
|
|
154
|
+
return parts;
|
|
155
|
+
}
|
|
156
|
+
function lstrip_spaces(s) {
|
|
157
|
+
let i = 0;
|
|
158
|
+
while (i < s.length && s[i] === " ") {
|
|
159
|
+
i += 1;
|
|
160
|
+
}
|
|
161
|
+
return s.slice(i);
|
|
162
|
+
}
|
|
163
|
+
function parse_int_strict(value) {
|
|
164
|
+
if (!/^[+-]?\d+$/.test(value.trim())) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
return Number.parseInt(value, 10);
|
|
168
|
+
}
|
|
169
|
+
function _render(version, tools, options = {}) {
|
|
170
|
+
const deploy_roots = options.deploy_roots ?? null;
|
|
171
|
+
const lines = [
|
|
172
|
+
`schema_version: ${SCHEMA_VERSION}`,
|
|
173
|
+
`agent_config_version: "${version}"`
|
|
174
|
+
];
|
|
175
|
+
if (deploy_roots && deploy_roots.length > 0) {
|
|
176
|
+
lines.push("deploy_roots:");
|
|
177
|
+
for (const root of deploy_roots) {
|
|
178
|
+
lines.push(` - ${root}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
lines.push("tools:");
|
|
182
|
+
for (const tool of tools) {
|
|
183
|
+
lines.push(` - name: ${String(tool["name"])}`);
|
|
184
|
+
lines.push(` scope: ${String(tool["scope"])}`);
|
|
185
|
+
lines.push(` bridge_marker: ${String(tool["bridge_marker"])}`);
|
|
186
|
+
lines.push(` installed_at: "${String(tool["installed_at"])}"`);
|
|
187
|
+
const status = tool["status"];
|
|
188
|
+
if (status) {
|
|
189
|
+
lines.push(` status: ${String(status)}`);
|
|
190
|
+
}
|
|
191
|
+
let files = tool["files"] ?? [];
|
|
192
|
+
if (files.length > 0) {
|
|
193
|
+
files = stable_sort(files, (f) => [String(f["path"])]);
|
|
194
|
+
lines.push(" files:");
|
|
195
|
+
for (const entry of files) {
|
|
196
|
+
lines.push(` - path: ${String(entry["path"])}`);
|
|
197
|
+
lines.push(` kind: ${String(entry["kind"])}`);
|
|
198
|
+
const sha = entry["sha256"];
|
|
199
|
+
if (sha === null || sha === void 0) {
|
|
200
|
+
lines.push(" sha256: null");
|
|
201
|
+
} else {
|
|
202
|
+
lines.push(` sha256: "${String(sha)}"`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let merged = tool["merged_keys"] ?? [];
|
|
207
|
+
if (merged.length > 0) {
|
|
208
|
+
merged = stable_sort(merged, (e) => [
|
|
209
|
+
String(e["file"]),
|
|
210
|
+
String(e["json_pointer"])
|
|
211
|
+
]);
|
|
212
|
+
lines.push(" merged_keys:");
|
|
213
|
+
for (const entry of merged) {
|
|
214
|
+
lines.push(` - file: ${String(entry["file"])}`);
|
|
215
|
+
lines.push(` json_pointer: "${String(entry["json_pointer"])}"`);
|
|
216
|
+
const vh = entry["value_hash"];
|
|
217
|
+
if (vh !== null && vh !== void 0) {
|
|
218
|
+
lines.push(` value_hash: "${String(vh)}"`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return lines.join("\n") + "\n";
|
|
224
|
+
}
|
|
225
|
+
function stable_sort(items, key) {
|
|
226
|
+
return items.map((item, index) => ({ item, index, k: key(item) })).sort((a, b) => {
|
|
227
|
+
const len = Math.max(a.k.length, b.k.length);
|
|
228
|
+
for (let i = 0; i < len; i += 1) {
|
|
229
|
+
const av = a.k[i] ?? "";
|
|
230
|
+
const bv = b.k[i] ?? "";
|
|
231
|
+
if (av < bv) return -1;
|
|
232
|
+
if (av > bv) return 1;
|
|
233
|
+
}
|
|
234
|
+
return a.index - b.index;
|
|
235
|
+
}).map((entry) => entry.item);
|
|
236
|
+
}
|
|
237
|
+
function write_manifest(path, version, tools, options = {}) {
|
|
238
|
+
const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
|
|
239
|
+
return write_atomic(path, rendered);
|
|
240
|
+
}
|
|
241
|
+
var ScopeMismatchError = class extends Error {
|
|
242
|
+
name_;
|
|
243
|
+
recorded_scope;
|
|
244
|
+
new_scope;
|
|
245
|
+
constructor(name, recorded_scope, new_scope) {
|
|
246
|
+
super(
|
|
247
|
+
`tool '${name}' is committed as scope=${recorded_scope}; refusing to change it to scope=${new_scope} without --force`
|
|
248
|
+
);
|
|
249
|
+
this.name = "ScopeMismatchError";
|
|
250
|
+
this.name_ = name;
|
|
251
|
+
this.recorded_scope = recorded_scope;
|
|
252
|
+
this.new_scope = new_scope;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
function upsert_tool(existing, options) {
|
|
256
|
+
const {
|
|
257
|
+
name,
|
|
258
|
+
scope,
|
|
259
|
+
bridge_marker,
|
|
260
|
+
installed_at = null,
|
|
261
|
+
force = false,
|
|
262
|
+
files = null,
|
|
263
|
+
merged_keys = null
|
|
264
|
+
} = options;
|
|
265
|
+
if (!_VALID_SCOPES.includes(scope)) {
|
|
266
|
+
throw new ValueError(`scope must be one of ${_VALID_SCOPES.join(",")}: '${scope}'`);
|
|
267
|
+
}
|
|
268
|
+
const stamp = installed_at || _today();
|
|
269
|
+
const _build = (prior = null) => {
|
|
270
|
+
const entry = {
|
|
271
|
+
name,
|
|
272
|
+
scope,
|
|
273
|
+
bridge_marker,
|
|
274
|
+
installed_at: stamp
|
|
275
|
+
};
|
|
276
|
+
if (files !== null) {
|
|
277
|
+
entry["files"] = [...files];
|
|
278
|
+
} else if (prior !== null && Array.isArray(prior["files"]) && prior["files"].length > 0) {
|
|
279
|
+
entry["files"] = [...prior["files"]];
|
|
280
|
+
}
|
|
281
|
+
if (merged_keys !== null) {
|
|
282
|
+
entry["merged_keys"] = [...merged_keys];
|
|
283
|
+
} else if (prior !== null && Array.isArray(prior["merged_keys"]) && prior["merged_keys"].length > 0) {
|
|
284
|
+
entry["merged_keys"] = [...prior["merged_keys"]];
|
|
285
|
+
}
|
|
286
|
+
return entry;
|
|
287
|
+
};
|
|
288
|
+
const result = [];
|
|
289
|
+
let found = false;
|
|
290
|
+
for (const entry of existing) {
|
|
291
|
+
if (entry["name"] === name) {
|
|
292
|
+
found = true;
|
|
293
|
+
const recorded = String(entry["scope"] ?? "");
|
|
294
|
+
if (recorded === scope) {
|
|
295
|
+
if (files === null && merged_keys === null) {
|
|
296
|
+
result.push(entry);
|
|
297
|
+
} else {
|
|
298
|
+
const refreshed = _build(entry);
|
|
299
|
+
refreshed["installed_at"] = entry["installed_at"] ?? stamp;
|
|
300
|
+
result.push(refreshed);
|
|
301
|
+
}
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (!force) {
|
|
305
|
+
throw new ScopeMismatchError(name, recorded, scope);
|
|
306
|
+
}
|
|
307
|
+
result.push(_build(entry));
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
result.push(entry);
|
|
311
|
+
}
|
|
312
|
+
if (!found) {
|
|
313
|
+
result.push(_build());
|
|
314
|
+
}
|
|
315
|
+
return result;
|
|
316
|
+
}
|
|
317
|
+
var ValueError = class extends Error {
|
|
318
|
+
constructor(message) {
|
|
319
|
+
super(message);
|
|
320
|
+
this.name = "ValueError";
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
function _today() {
|
|
324
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export {
|
|
328
|
+
SCHEMA_VERSIONS_SUPPORTED,
|
|
329
|
+
DEFAULT_DEPLOY_ROOTS,
|
|
330
|
+
manifest_path,
|
|
331
|
+
read_manifest,
|
|
332
|
+
write_manifest,
|
|
333
|
+
ScopeMismatchError,
|
|
334
|
+
upsert_tool
|
|
335
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
atomicAppendLine
|
|
4
|
+
} from "./chunk-6KM6ORRY.js";
|
|
5
|
+
|
|
6
|
+
// src/install/txlog.ts
|
|
7
|
+
import { createGzip } from "node:zlib";
|
|
8
|
+
import { createReadStream, createWriteStream, existsSync, readFileSync, renameSync, statSync, unlinkSync } from "node:fs";
|
|
9
|
+
import { pipeline } from "node:stream/promises";
|
|
10
|
+
var ROTATION_MAX_BYTES = 10 * 1024 * 1024;
|
|
11
|
+
var ROTATION_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
12
|
+
var RECOVERY_DEPTH_CAP = 500;
|
|
13
|
+
function appendTxLog(logPath, entry) {
|
|
14
|
+
if (shouldRotate(logPath)) {
|
|
15
|
+
rotateLogSync(logPath);
|
|
16
|
+
}
|
|
17
|
+
atomicAppendLine(logPath, JSON.stringify(entry));
|
|
18
|
+
}
|
|
19
|
+
function readRecentEntries(logPath) {
|
|
20
|
+
if (!existsSync(logPath)) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const raw = readFileSync(logPath, "utf8");
|
|
24
|
+
const lines = raw.split("\n").filter((l) => l.length > 0);
|
|
25
|
+
const tail = lines.slice(-RECOVERY_DEPTH_CAP);
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const line of tail) {
|
|
28
|
+
const parsed = tryParseEntry(line);
|
|
29
|
+
if (parsed !== null) {
|
|
30
|
+
out.push(parsed);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function shouldRotate(logPath, now = /* @__PURE__ */ new Date()) {
|
|
36
|
+
if (!existsSync(logPath)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
let size = 0;
|
|
40
|
+
try {
|
|
41
|
+
size = statSync(logPath).size;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (size >= ROTATION_MAX_BYTES) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const firstTs = readFirstTimestamp(logPath);
|
|
49
|
+
if (firstTs === null) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return now.getTime() - firstTs >= ROTATION_MAX_AGE_MS;
|
|
53
|
+
}
|
|
54
|
+
function rotateLogSync(logPath) {
|
|
55
|
+
if (!existsSync(logPath)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
59
|
+
const rotated = logPath.replace(/\.jsonl$/, `.${stamp}.jsonl`);
|
|
60
|
+
renameSync(logPath, rotated);
|
|
61
|
+
void gzipInPlace(rotated).catch(() => {
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function gzipInPlace(source) {
|
|
65
|
+
const target = `${source}.gz`;
|
|
66
|
+
await pipeline(createReadStream(source), createGzip(), createWriteStream(target));
|
|
67
|
+
try {
|
|
68
|
+
unlinkSync(source);
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function readFirstTimestamp(logPath) {
|
|
73
|
+
try {
|
|
74
|
+
const raw = readFileSync(logPath, "utf8");
|
|
75
|
+
const firstLine = raw.split("\n", 1)[0] ?? "";
|
|
76
|
+
const parsed = tryParseEntry(firstLine);
|
|
77
|
+
if (parsed === null) return null;
|
|
78
|
+
const t = Date.parse(parsed.ts);
|
|
79
|
+
return Number.isFinite(t) ? t : null;
|
|
80
|
+
} catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function tryParseEntry(line) {
|
|
85
|
+
try {
|
|
86
|
+
const obj = JSON.parse(line);
|
|
87
|
+
if (typeof obj.ts !== "string" || typeof obj.kind !== "string" || typeof obj.path !== "string") {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return obj;
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
appendTxLog,
|
|
98
|
+
readRecentEntries
|
|
99
|
+
};
|