@event4u/agent-config 16.1.0 → 16.2.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 +237 -248
- package/dist/agent-src/commands/roadmap/process-full.md +1 -1
- package/dist/agent-src/commands/work.md +4 -0
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +4 -8
- package/dist/agent-src/rules/ui-audit-gate.md +1 -2
- package/dist/agent-src/skills/accessibility-auditor/data/aria-patterns.csv +1 -1
- package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +2 -2
- package/dist/agent-src/skills/design-review/SKILL.md +30 -4
- package/dist/agent-src/skills/design-review/references/verification-automation.md +32 -0
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +16 -1
- package/dist/agent-src/skills/existing-ui-audit/references/component-taxonomy-detection.md +56 -0
- package/dist/agent-src/skills/markitdown/SKILL.md +4 -0
- package/dist/agent-src/skills/playwright-testing/SKILL.md +30 -6
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +23 -0
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +30 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/app_spec.ts +10 -4
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +260 -21
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +22 -3
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +6 -1
- package/dist/agent-src/templates/scripts/work_engine/state.ts +57 -7
- package/dist/agent-src/templates/scripts/work_engine/taxonomy/detect.ts +500 -0
- package/dist/agent-src/templates/scripts/work_engine/taxonomy/place.ts +183 -0
- package/dist/cli/python/knowledge_ingest.js +1 -1
- package/dist/cli/python/workspace_drive.js +1 -1
- package/dist/cli-delegate/{chunk-S3VFXMTM.js → chunk-4XFP2Y3E.js} +1 -1
- package/dist/cli-delegate/{chunk-HDVVGPQW.js → chunk-7XGBX6ZH.js} +471 -387
- package/dist/cli-delegate/{chunk-GJCBB2UG.js → chunk-FP36SWJD.js} +432 -144
- package/dist/cli-delegate/{chunk-UNCRJBT3.js → chunk-IGD6ERX6.js} +31 -0
- package/dist/cli-delegate/{chunk-FXYUYU4N.js → chunk-JNMVLWLR.js} +42 -1
- package/dist/cli-delegate/{chunk-QJWAUMJW.js → chunk-YJ72UIAK.js} +730 -15
- package/dist/cli-delegate/cmd_conformance.js +902 -782
- package/dist/cli-delegate/cmd_doctor.js +2 -2
- package/dist/cli-delegate/cmd_export.js +2 -2
- package/dist/cli-delegate/cmd_handoff.js +4 -4
- package/dist/cli-delegate/cmd_memory_get.js +1 -1
- package/dist/cli-delegate/cmd_prune.js +2 -2
- package/dist/cli-delegate/cmd_route_audit.js +1 -1
- package/dist/cli-delegate/cmd_session_recycle.js +2 -2
- package/dist/cli-delegate/cmd_settings_migrate.js +2 -2
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +2 -2
- package/dist/cli-delegate/cmd_uninstall.js +2 -2
- package/dist/cli-delegate/cmd_validate.js +2 -2
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +10 -10
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/hooks/dispatch.js +6666 -2581
- package/dist/hooks/dispatch.sha256 +1 -0
- package/dist/install/install.mjs +848 -733
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +2747 -1510
- package/dist/server/schemas/settings.js +23 -0
- package/dist/ui/assets/index-Cwq4d0hX.js +23 -0
- package/dist/ui/assets/index-Cyjy8bWO.css +1 -0
- package/dist/ui/index.html +2 -2
- package/docs/contracts/settings-classes.md +6 -4
- package/package.json +4 -4
- package/src/agent-src/templates/scripts/work_engine/directives/ui/app_spec.ts +10 -4
- package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +260 -21
- package/src/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +22 -3
- package/src/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +6 -1
- package/src/agent-src/templates/scripts/work_engine/state.ts +57 -7
- package/src/agent-src/templates/scripts/work_engine/taxonomy/detect.ts +500 -0
- package/src/agent-src/templates/scripts/work_engine/taxonomy/place.ts +183 -0
- package/src/config/agent-settings.template.yml +29 -0
- package/src/config/ci-local-parity.yml +18 -0
- package/src/config/continuity-surface.json +2 -2
- package/src/config/gate-coverage.yml +234 -3
- package/src/config/gate-violation-baselines.json +7 -3
- package/src/config/hook-latency-budget.json +21 -0
- package/src/config/hook-token-budget.json +2 -2
- package/src/config/metric-registry.yml +114 -0
- package/src/config/placeholder-drift-budget.json +10 -0
- package/src/config/routing-coverage-seed.json +18 -4
- package/src/scripts/_cli/cmd_doctor.ts +5 -19
- package/src/scripts/_cli/doctor_execution.ts +100 -17
- package/src/scripts/_cli/doctor_network_posture.ts +226 -0
- package/src/scripts/_lib/body_portable.ts +102 -0
- package/src/scripts/_lib/cc_transcript.ts +132 -1
- package/src/scripts/_lib/concern_sla_window.ts +200 -0
- package/src/scripts/_lib/forge_protection.ts +114 -0
- package/src/scripts/_lib/forge_reader.ts +558 -0
- package/src/scripts/_lib/host_env_write.ts +111 -0
- package/src/scripts/_lib/llm_proposer_transport.ts +14 -4
- package/src/scripts/_lib/obligations.ts +119 -8
- package/src/scripts/_lib/probe_inputs.ts +271 -0
- package/src/scripts/_lib/read_surface_scan.ts +322 -0
- package/src/scripts/_lib/release_highlights.ts +2 -1
- package/src/scripts/_lib/retrieval_sanitize.ts +77 -16
- package/src/scripts/_lib/shell_write_shapes.ts +108 -0
- package/src/scripts/_lib/structural_hiding.ts +622 -0
- package/src/scripts/_lib/turn_end_refusals.ts +525 -4
- package/src/scripts/_lib/turn_end_transcript.ts +216 -0
- package/src/scripts/_lib/verification_command.ts +324 -0
- package/src/scripts/_lib/verification_evidence.ts +647 -0
- package/src/scripts/_lib/verify_clause.ts +280 -0
- package/src/scripts/ai_team/team_dispatch.ts +4 -0
- package/src/scripts/before_complete_hook.ts +340 -23
- package/src/scripts/bench_hook_latency.ts +412 -5
- package/src/scripts/cache_realization_report.ts +61 -1
- package/src/scripts/check_argument_hint.ts +287 -0
- package/src/scripts/check_claims.ts +125 -1
- package/src/scripts/check_enforcement_coverage.ts +38 -9
- package/src/scripts/check_enforcement_matrix.ts +245 -3
- package/src/scripts/check_finding_dispositions.ts +22 -3
- package/src/scripts/check_generator_sync.ts +71 -0
- package/src/scripts/check_host_docs_digest.ts +786 -0
- package/src/scripts/check_host_format_column.ts +559 -0
- package/src/scripts/check_input_references.ts +228 -0
- package/src/scripts/check_inputs_parity.ts +235 -0
- package/src/scripts/check_kernel_edit_ratified.ts +47 -5
- package/src/scripts/check_kill_switch_table.ts +294 -0
- package/src/scripts/check_placeholder_drift.ts +221 -0
- package/src/scripts/check_read_surface_coverage.ts +515 -0
- package/src/scripts/check_release_holds.ts +2 -1
- package/src/scripts/check_routing_coverage.ts +378 -11
- package/src/scripts/check_static_parity.ts +17 -0
- package/src/scripts/ci_settle.ts +145 -19
- package/src/scripts/closure_scan.ts +115 -1
- package/src/scripts/compile_hook_manifest.ts +60 -16
- package/src/scripts/external_sources_denylist.json +29 -4
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +42 -5
- package/src/scripts/hooks/block_config_weakening.ts +229 -4
- package/src/scripts/hooks/block_kernel_rule_writes.ts +9 -78
- package/src/scripts/hooks/block_plumbing_writes.ts +314 -0
- package/src/scripts/hooks/bundle_integrity.ts +291 -0
- package/src/scripts/hooks/chain_nudge_hook.ts +1 -2
- package/src/scripts/hooks/code_graph_context_hook.ts +1 -2
- package/src/scripts/hooks/comment_discipline_hook.ts +1 -3
- package/src/scripts/hooks/concern_registry.ts +2 -0
- package/src/scripts/hooks/concern_timings.ts +94 -0
- package/src/scripts/hooks/delegation_nudge_hook.ts +1 -2
- package/src/scripts/hooks/design_pass_hook.ts +100 -9
- package/src/scripts/hooks/design_slop_hook.ts +1 -2
- package/src/scripts/hooks/dispatch_hook.ts +25 -19
- package/src/scripts/hooks/edit_shape_hook.ts +1 -2
- package/src/scripts/hooks/end_review_nudge_hook.ts +1 -1
- package/src/scripts/hooks/evidence_independence.ts +1 -2
- package/src/scripts/hooks/exit_codes.ts +128 -0
- package/src/scripts/hooks/host_lowering.json +1 -0
- package/src/scripts/hooks/host_lowering.ts +128 -3
- package/src/scripts/hooks/host_lowering.yaml +262 -46
- package/src/scripts/hooks/host_semantics.ts +30 -2
- package/src/scripts/hooks/injection_budget.ts +9 -2
- package/src/scripts/hooks/interruption_ledger_hook.ts +1 -2
- package/src/scripts/hooks/journal_record_hook.ts +1 -2
- package/src/scripts/hooks/memory_recall_hook.ts +1 -2
- package/src/scripts/hooks/obligation_settle_hook.ts +151 -5
- package/src/scripts/hooks/one_question_per_ask_hook.ts +25 -4
- package/src/scripts/hooks/orchestration_record_hook.ts +1 -2
- package/src/scripts/hooks/permission_gate.ts +1 -2
- package/src/scripts/hooks/push_settle_hook.ts +1 -3
- package/src/scripts/hooks/replay_hook.ts +2 -1
- package/src/scripts/hooks/reread_guard_hook.ts +1 -2
- package/src/scripts/hooks/review_baseline_hook.ts +1 -2
- package/src/scripts/hooks/rtk_wrap_hook.ts +1 -2
- package/src/scripts/hooks/rule_inject_hook.ts +8 -5
- package/src/scripts/hooks/run_continuation_hook.ts +13 -15
- package/src/scripts/hooks/skill_route_hook.ts +1 -2
- package/src/scripts/hooks/source_first_gate_hook.ts +1 -2
- package/src/scripts/hooks/spawn_guard_shadow_hook.ts +1 -2
- package/src/scripts/hooks/subagent_ledger_hook.ts +1 -2
- package/src/scripts/hooks/suggestion_capture_hook.ts +1 -1
- package/src/scripts/hooks/table_fingerprint.ts +49 -0
- package/src/scripts/hooks/telemetry_flush_hook.ts +1 -2
- package/src/scripts/hooks/telemetry_usage_hook.ts +1 -2
- package/src/scripts/hooks/tool_result_bytes_hook.ts +93 -9
- package/src/scripts/hooks/turn_end_gate_hook.ts +337 -324
- package/src/scripts/hooks/ui_route_nudge_hook.ts +1 -2
- package/src/scripts/install.ts +3 -4
- package/src/scripts/lint_deny_text.ts +419 -0
- package/src/scripts/lint_exit_codes.ts +262 -0
- package/src/scripts/lint_hook_manifest.ts +55 -0
- package/src/scripts/lint_roadmap_blockers.ts +78 -12
- package/src/scripts/lint_skill_descriptions.ts +1 -1
- package/src/scripts/lint_skill_scripts_readonly.ts +1 -1
- package/src/scripts/mcp_server/prompts.ts +142 -1
- package/src/scripts/measure_skill_ranker_baseline.ts +305 -51
- package/src/scripts/measure_turn_end_gate.ts +193 -0
- package/src/scripts/memory_lookup.ts +1 -1
- package/src/scripts/prepack-check.mjs +53 -0
- package/src/scripts/release_publication.ts +13 -1
- package/src/scripts/report_invocation_surface.ts +383 -0
- package/src/scripts/report_obligation_carriers.ts +699 -0
- package/src/scripts/report_obligation_writer_split.ts +236 -0
- package/src/scripts/report_skill_menu_census.ts +208 -0
- package/src/scripts/report_standing_payload_by_host.ts +1 -1
- package/src/scripts/roadmap_verify_share.ts +213 -0
- package/src/scripts/schemas/command.schema.json +44 -0
- package/src/scripts/schemas/review-findings.schema.json +4 -0
- package/src/scripts/schemas/skill.schema.json +44 -0
- package/src/scripts/self_review_gate.ts +359 -10
- package/src/scripts/semantic_parity_census.ts +314 -0
- package/src/scripts/session_eol_report.ts +54 -1
- package/src/scripts/sweep_dead_scan_roots.ts +1 -1
- package/src/scripts/trigger_eval_grandfather.json +0 -2
- package/src/scripts/trigger_eval_rotation.ts +122 -27
- package/src/scripts/ui_conformance_probe.ts +156 -4
- package/src/scripts/update_prices.ts +85 -3
- package/src/scripts/write_bundle_digest.mjs +74 -0
- package/src/server/schemas/settings.ts +31 -0
- package/src/templates/consumer-settings/ONBOARDING.md +1 -0
- package/dist/ui/assets/index-DH1xc62v.js +0 -29
- package/dist/ui/assets/index-jSfMW8_t.css +0 -1
- /package/dist/cli-delegate/{chunk-YUM5KURG.js → chunk-7RQP4UDH.js} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __acCreateRequire } from 'node:module'; const require
|
|
|
2
2
|
import {
|
|
3
3
|
ZodFirstPartyTypeKind,
|
|
4
4
|
settingsSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-IGD6ERX6.js";
|
|
6
6
|
import {
|
|
7
7
|
main
|
|
8
8
|
} from "./chunk-6KFEC3G7.js";
|
|
@@ -283,12 +283,62 @@ function subtract_pointers(doc, entries) {
|
|
|
283
283
|
// src/scripts/install.ts
|
|
284
284
|
import { spawn, spawnSync } from "node:child_process";
|
|
285
285
|
import * as crypto5 from "node:crypto";
|
|
286
|
-
import * as
|
|
286
|
+
import * as fs15 from "node:fs";
|
|
287
287
|
import * as os3 from "node:os";
|
|
288
|
-
import * as
|
|
288
|
+
import * as path13 from "node:path";
|
|
289
289
|
import process2 from "node:process";
|
|
290
290
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
291
291
|
|
|
292
|
+
// src/scripts/_lib/host_env_write.ts
|
|
293
|
+
var YAML = __toESM(require_dist(), 1);
|
|
294
|
+
import * as fs from "node:fs";
|
|
295
|
+
import * as path from "node:path";
|
|
296
|
+
var WRITABLE_HOST_ENV = [
|
|
297
|
+
{ variable: "BASH_MAX_OUTPUT_LENGTH", settingsKey: "bash_max_output_length" },
|
|
298
|
+
{ variable: "MAX_MCP_OUTPUT_TOKENS", settingsKey: "max_mcp_output_tokens" }
|
|
299
|
+
];
|
|
300
|
+
var SETTINGS_CANDIDATES = [
|
|
301
|
+
["agents", "settings", ".agent-settings.yml"],
|
|
302
|
+
[".agent-settings.yml"]
|
|
303
|
+
];
|
|
304
|
+
function readSettingsDoc(projectRoot) {
|
|
305
|
+
for (const parts of SETTINGS_CANDIDATES) {
|
|
306
|
+
const p = path.join(projectRoot, ...parts);
|
|
307
|
+
let text;
|
|
308
|
+
try {
|
|
309
|
+
text = fs.readFileSync(p, "utf-8");
|
|
310
|
+
} catch {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
let doc;
|
|
314
|
+
try {
|
|
315
|
+
doc = YAML.parse(text, { version: "1.1" });
|
|
316
|
+
} catch {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
return doc === null || doc === void 0 || typeof doc !== "object" ? null : doc;
|
|
320
|
+
}
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
function hostEnvBlock(settings) {
|
|
324
|
+
const root = settings;
|
|
325
|
+
const he = root?.["host_environment"];
|
|
326
|
+
const caps = he?.["request_size_caps"];
|
|
327
|
+
if (caps === void 0) return null;
|
|
328
|
+
const out = {};
|
|
329
|
+
for (const { variable, settingsKey } of WRITABLE_HOST_ENV) {
|
|
330
|
+
const v = caps[settingsKey];
|
|
331
|
+
if (typeof v === "number" && Number.isInteger(v) && v > 0) out[variable] = String(v);
|
|
332
|
+
}
|
|
333
|
+
return Object.keys(out).length === 0 ? null : out;
|
|
334
|
+
}
|
|
335
|
+
function withHostEnv(bridge, projectRoot, announce) {
|
|
336
|
+
const env = hostEnvBlock(readSettingsDoc(projectRoot));
|
|
337
|
+
if (env === null) return bridge;
|
|
338
|
+
announce(`.claude/settings.json: wrote ${Object.keys(env).join(", ")} (request-size caps)`);
|
|
339
|
+
return { ...bridge, env };
|
|
340
|
+
}
|
|
341
|
+
|
|
292
342
|
// src/scripts/_lib/json_python_parity.ts
|
|
293
343
|
function jsonStrNoAscii(s) {
|
|
294
344
|
let out = '"';
|
|
@@ -497,8 +547,8 @@ function is_claude_builtin_name(slug) {
|
|
|
497
547
|
}
|
|
498
548
|
|
|
499
549
|
// src/scripts/_lib/mcp_bridge.ts
|
|
500
|
-
import * as
|
|
501
|
-
import * as
|
|
550
|
+
import * as fs2 from "node:fs";
|
|
551
|
+
import * as path2 from "node:path";
|
|
502
552
|
var MCP_SERVER_KEY = "agent-config";
|
|
503
553
|
var MCP_PACKAGE_NAME = "@event4u/agent-config";
|
|
504
554
|
function mcpBridgeEntry(packageRoot) {
|
|
@@ -515,7 +565,7 @@ function mcpBridgeEntry(packageRoot) {
|
|
|
515
565
|
}
|
|
516
566
|
function readPackageVersion(packageRoot) {
|
|
517
567
|
try {
|
|
518
|
-
const raw =
|
|
568
|
+
const raw = fs2.readFileSync(path2.join(packageRoot, "package.json"), "utf-8");
|
|
519
569
|
const v = JSON.parse(raw).version;
|
|
520
570
|
return typeof v === "string" && v.trim() !== "" ? v : null;
|
|
521
571
|
} catch {
|
|
@@ -524,7 +574,7 @@ function readPackageVersion(packageRoot) {
|
|
|
524
574
|
}
|
|
525
575
|
function makeEnsureMcpBridge(mergeJsonFile) {
|
|
526
576
|
return (projectRoot, force, packageRoot = projectRoot) => mergeJsonFile(
|
|
527
|
-
|
|
577
|
+
path2.join(projectRoot, ".mcp.json"),
|
|
528
578
|
mcpBridgeEntry(packageRoot),
|
|
529
579
|
force,
|
|
530
580
|
".mcp.json"
|
|
@@ -550,7 +600,7 @@ function makeEnsureMcpRegistrations(mergeJsonFile) {
|
|
|
550
600
|
const merged = {};
|
|
551
601
|
for (const t of targets) {
|
|
552
602
|
merged[t.toolId] = mergeJsonFile(
|
|
553
|
-
|
|
603
|
+
path2.join(projectRoot, ...t.relPath.split("/")),
|
|
554
604
|
mcpBridgeEntry(packageRoot),
|
|
555
605
|
force,
|
|
556
606
|
t.relPath
|
|
@@ -581,10 +631,10 @@ function projectionModeOf(raw) {
|
|
|
581
631
|
return raw === "scoped" ? "scoped" : raw === "tiered" ? "tiered" : "legacy-all";
|
|
582
632
|
}
|
|
583
633
|
function resolveTierB(packageRoot) {
|
|
584
|
-
const p =
|
|
585
|
-
if (!
|
|
634
|
+
const p = path2.join(packageRoot, "agents", "runtime", "state", "skill-tiers.json");
|
|
635
|
+
if (!fs2.existsSync(p)) return null;
|
|
586
636
|
try {
|
|
587
|
-
const parsed = JSON.parse(
|
|
637
|
+
const parsed = JSON.parse(fs2.readFileSync(p, "utf-8"));
|
|
588
638
|
if (!Array.isArray(parsed.tier_b)) return null;
|
|
589
639
|
return new Set(parsed.tier_b.filter((n) => typeof n === "string"));
|
|
590
640
|
} catch {
|
|
@@ -592,7 +642,7 @@ function resolveTierB(packageRoot) {
|
|
|
592
642
|
}
|
|
593
643
|
}
|
|
594
644
|
function tierBPrunePredicate(tierB) {
|
|
595
|
-
return (mdPath) => tierB.has(
|
|
645
|
+
return (mdPath) => tierB.has(path2.basename(path2.dirname(mdPath)));
|
|
596
646
|
}
|
|
597
647
|
function tierBAdvisory(packageRoot) {
|
|
598
648
|
const tierB = resolveTierB(packageRoot);
|
|
@@ -621,35 +671,35 @@ function applyTieredPrune(deployResults, packageRoot, pruneBy) {
|
|
|
621
671
|
|
|
622
672
|
// src/install/conflictTracker.ts
|
|
623
673
|
import * as crypto2 from "node:crypto";
|
|
624
|
-
import * as
|
|
625
|
-
import * as
|
|
674
|
+
import * as fs4 from "node:fs";
|
|
675
|
+
import * as path4 from "node:path";
|
|
626
676
|
|
|
627
677
|
// src/install/fsPrimitives.ts
|
|
628
678
|
import * as crypto from "node:crypto";
|
|
629
|
-
import * as
|
|
630
|
-
import * as
|
|
679
|
+
import * as fs3 from "node:fs";
|
|
680
|
+
import * as path3 from "node:path";
|
|
631
681
|
function resolvePath(p) {
|
|
632
682
|
try {
|
|
633
|
-
return
|
|
683
|
+
return fs3.realpathSync(path3.resolve(p));
|
|
634
684
|
} catch {
|
|
635
|
-
return
|
|
685
|
+
return path3.resolve(p);
|
|
636
686
|
}
|
|
637
687
|
}
|
|
638
688
|
function pathExists(p) {
|
|
639
689
|
try {
|
|
640
|
-
|
|
690
|
+
fs3.statSync(p);
|
|
641
691
|
return true;
|
|
642
692
|
} catch {
|
|
643
693
|
return false;
|
|
644
694
|
}
|
|
645
695
|
}
|
|
646
696
|
function mkdirp(p) {
|
|
647
|
-
|
|
697
|
+
fs3.mkdirSync(p, { recursive: true });
|
|
648
698
|
}
|
|
649
699
|
function sha256OfFile(p) {
|
|
650
700
|
let data;
|
|
651
701
|
try {
|
|
652
|
-
data =
|
|
702
|
+
data = fs3.readFileSync(p);
|
|
653
703
|
} catch {
|
|
654
704
|
return null;
|
|
655
705
|
}
|
|
@@ -690,20 +740,20 @@ function createConflictTracker(host) {
|
|
|
690
740
|
function recordedHashFor(target) {
|
|
691
741
|
if (conflictState.root === null) return void 0;
|
|
692
742
|
conflictState.recorded ??= recordedHashesForRoot(conflictState.root);
|
|
693
|
-
const plain =
|
|
743
|
+
const plain = path4.resolve(target);
|
|
694
744
|
if (conflictState.recorded.has(plain)) return conflictState.recorded.get(plain);
|
|
695
745
|
const real = resolvePath(target);
|
|
696
746
|
return real === plain ? void 0 : conflictState.recorded.get(real);
|
|
697
747
|
}
|
|
698
748
|
function stageInto(target, sidecar, produce) {
|
|
699
|
-
mkdirp(
|
|
700
|
-
const tmp =
|
|
701
|
-
|
|
702
|
-
`.${
|
|
749
|
+
mkdirp(path4.dirname(sidecar));
|
|
750
|
+
const tmp = path4.join(
|
|
751
|
+
path4.dirname(sidecar),
|
|
752
|
+
`.${path4.basename(sidecar)}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}${path4.extname(target)}`
|
|
703
753
|
);
|
|
704
754
|
const discard = () => {
|
|
705
755
|
try {
|
|
706
|
-
|
|
756
|
+
fs4.unlinkSync(tmp);
|
|
707
757
|
} catch {
|
|
708
758
|
}
|
|
709
759
|
};
|
|
@@ -730,7 +780,7 @@ function createConflictTracker(host) {
|
|
|
730
780
|
}
|
|
731
781
|
}
|
|
732
782
|
try {
|
|
733
|
-
|
|
783
|
+
fs4.renameSync(tmp, sidecar);
|
|
734
784
|
} catch (exc) {
|
|
735
785
|
discard();
|
|
736
786
|
host.fail(
|
|
@@ -779,7 +829,7 @@ function createConflictTracker(host) {
|
|
|
779
829
|
preserve(target, source, packageRoot) {
|
|
780
830
|
const sidecar = sidecarPathFor(target);
|
|
781
831
|
stageInto(target, sidecar, (tmp) => {
|
|
782
|
-
|
|
832
|
+
fs4.copyFileSync(source, tmp);
|
|
783
833
|
host.tagDeployed(tmp, source, packageRoot);
|
|
784
834
|
});
|
|
785
835
|
record(target, sidecar);
|
|
@@ -795,7 +845,7 @@ function createConflictTracker(host) {
|
|
|
795
845
|
*/
|
|
796
846
|
preserveContent(target, content) {
|
|
797
847
|
const sidecar = sidecarPathFor(target);
|
|
798
|
-
stageInto(target, sidecar, (tmp) =>
|
|
848
|
+
stageInto(target, sidecar, (tmp) => fs4.writeFileSync(tmp, content, "utf-8"));
|
|
799
849
|
record(target, sidecar);
|
|
800
850
|
},
|
|
801
851
|
/**
|
|
@@ -814,10 +864,10 @@ function createConflictTracker(host) {
|
|
|
814
864
|
}
|
|
815
865
|
|
|
816
866
|
// src/install/manifestFiles.ts
|
|
817
|
-
var
|
|
818
|
-
import { existsSync as existsSync2, readFileSync as
|
|
867
|
+
var YAML2 = __toESM(require_dist(), 1);
|
|
868
|
+
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
|
|
819
869
|
import { homedir } from "node:os";
|
|
820
|
-
import { isAbsolute, join as
|
|
870
|
+
import { isAbsolute, join as join4, resolve as resolve3 } from "node:path";
|
|
821
871
|
function fileEntry(p, kind, hashContent) {
|
|
822
872
|
return { path: p, kind, sha256: hashContent ? sha256OfFile(p) : null };
|
|
823
873
|
}
|
|
@@ -840,7 +890,7 @@ function filesByToolFromBridges(tools, projectRoot, scope, bridgeMarker) {
|
|
|
840
890
|
for (const toolId of [...tools].sort()) {
|
|
841
891
|
const marker = bridgeMarker(toolId, scope);
|
|
842
892
|
if (!marker) continue;
|
|
843
|
-
const markerPath = isAbsolute(marker) ? marker :
|
|
893
|
+
const markerPath = isAbsolute(marker) ? marker : join4(projectRoot, marker);
|
|
844
894
|
out[toolId] = [fileEntry(markerPath, "bridge", false)];
|
|
845
895
|
}
|
|
846
896
|
return out;
|
|
@@ -848,7 +898,7 @@ function filesByToolFromBridges(tools, projectRoot, scope, bridgeMarker) {
|
|
|
848
898
|
function expanduser(p) {
|
|
849
899
|
if (p === "~") return homedir();
|
|
850
900
|
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
851
|
-
return
|
|
901
|
+
return join4(homedir(), p.slice(2));
|
|
852
902
|
}
|
|
853
903
|
return p;
|
|
854
904
|
}
|
|
@@ -861,7 +911,7 @@ function readRecordedByTool(manifestPath, projectRoot) {
|
|
|
861
911
|
if (!existsSync2(manifestPath)) return out;
|
|
862
912
|
let doc;
|
|
863
913
|
try {
|
|
864
|
-
doc =
|
|
914
|
+
doc = YAML2.parse(readFileSync4(manifestPath, "utf8"));
|
|
865
915
|
} catch {
|
|
866
916
|
return out;
|
|
867
917
|
}
|
|
@@ -940,8 +990,8 @@ function preservedIndex(preservedTargets, staged) {
|
|
|
940
990
|
}
|
|
941
991
|
|
|
942
992
|
// src/scripts/_lib/rule_layer_overlap.ts
|
|
943
|
-
import * as
|
|
944
|
-
import * as
|
|
993
|
+
import * as fs5 from "node:fs";
|
|
994
|
+
import * as path5 from "node:path";
|
|
945
995
|
var INSTALLER_PROVENANCE_KEYS = ["package", "source_path"];
|
|
946
996
|
function stripProvenance(text) {
|
|
947
997
|
const lines = text.split("\n");
|
|
@@ -995,14 +1045,14 @@ function compareLayers(global_layer, project_layer) {
|
|
|
995
1045
|
function readRuleLayer(dir) {
|
|
996
1046
|
let names;
|
|
997
1047
|
try {
|
|
998
|
-
names =
|
|
1048
|
+
names = fs5.readdirSync(dir);
|
|
999
1049
|
} catch {
|
|
1000
1050
|
return null;
|
|
1001
1051
|
}
|
|
1002
1052
|
const files = /* @__PURE__ */ new Map();
|
|
1003
1053
|
for (const name of names.filter((n) => n.endsWith(".md")).sort()) {
|
|
1004
1054
|
try {
|
|
1005
|
-
files.set(name,
|
|
1055
|
+
files.set(name, fs5.readFileSync(path5.join(dir, name), "utf-8"));
|
|
1006
1056
|
} catch {
|
|
1007
1057
|
continue;
|
|
1008
1058
|
}
|
|
@@ -1010,7 +1060,7 @@ function readRuleLayer(dir) {
|
|
|
1010
1060
|
return { dir, files };
|
|
1011
1061
|
}
|
|
1012
1062
|
function claudeMdExcludesGlob(dir) {
|
|
1013
|
-
return `${
|
|
1063
|
+
return `${path5.resolve(dir).replace(/\/+$/, "")}/**`;
|
|
1014
1064
|
}
|
|
1015
1065
|
function mergeClaudeMdExcludes(existing, entry) {
|
|
1016
1066
|
if (!Array.isArray(existing)) return [entry];
|
|
@@ -1041,25 +1091,25 @@ function decideLayerAction(report, choice, global_dir, project_dir) {
|
|
|
1041
1091
|
// src/scripts/_lib/install_drift.ts
|
|
1042
1092
|
var import_yaml = __toESM(require_dist(), 1);
|
|
1043
1093
|
import * as crypto3 from "node:crypto";
|
|
1044
|
-
import * as
|
|
1094
|
+
import * as fs6 from "node:fs";
|
|
1045
1095
|
import * as os from "node:os";
|
|
1046
|
-
import * as
|
|
1096
|
+
import * as path6 from "node:path";
|
|
1047
1097
|
function expanduser2(p) {
|
|
1048
1098
|
if (p === "~") {
|
|
1049
1099
|
return os.homedir();
|
|
1050
1100
|
}
|
|
1051
1101
|
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
1052
|
-
return
|
|
1102
|
+
return path6.join(os.homedir(), p.slice(2));
|
|
1053
1103
|
}
|
|
1054
1104
|
return p;
|
|
1055
1105
|
}
|
|
1056
1106
|
function resolve_entry_path(project_root, raw) {
|
|
1057
1107
|
const p = expanduser2(raw);
|
|
1058
|
-
return
|
|
1108
|
+
return path6.isAbsolute(p) ? p : path6.join(project_root, p);
|
|
1059
1109
|
}
|
|
1060
1110
|
function sha256_of_file(p) {
|
|
1061
1111
|
try {
|
|
1062
|
-
return crypto3.createHash("sha256").update(
|
|
1112
|
+
return crypto3.createHash("sha256").update(fs6.readFileSync(p)).digest("hex");
|
|
1063
1113
|
} catch {
|
|
1064
1114
|
return null;
|
|
1065
1115
|
}
|
|
@@ -1068,7 +1118,7 @@ function collect_drift(project_root, env) {
|
|
|
1068
1118
|
const target = manifest_path(project_root, env);
|
|
1069
1119
|
let text;
|
|
1070
1120
|
try {
|
|
1071
|
-
text =
|
|
1121
|
+
text = fs6.readFileSync(target, "utf-8");
|
|
1072
1122
|
} catch {
|
|
1073
1123
|
return null;
|
|
1074
1124
|
}
|
|
@@ -1113,7 +1163,7 @@ function collect_drift(project_root, env) {
|
|
|
1113
1163
|
continue;
|
|
1114
1164
|
}
|
|
1115
1165
|
const resolved = resolve_entry_path(project_root, raw_path);
|
|
1116
|
-
if (!
|
|
1166
|
+
if (!fs6.existsSync(resolved)) {
|
|
1117
1167
|
out.push({
|
|
1118
1168
|
tool_id,
|
|
1119
1169
|
path: resolved,
|
|
@@ -1166,15 +1216,15 @@ function format_drift_report(entries) {
|
|
|
1166
1216
|
}
|
|
1167
1217
|
|
|
1168
1218
|
// src/scripts/_lib/skill_catalogue.ts
|
|
1169
|
-
import * as
|
|
1170
|
-
import * as
|
|
1219
|
+
import * as fs7 from "node:fs";
|
|
1220
|
+
import * as path7 from "node:path";
|
|
1171
1221
|
var PROJECT_CATALOGUE_ROOTS = ["src/skills", ".claude/skills"];
|
|
1172
1222
|
var HOST_CATALOGUE_ROOT = ".claude/skills";
|
|
1173
1223
|
var DEFAULT_CATALOGUE_ROOTS = [
|
|
1174
1224
|
...PROJECT_CATALOGUE_ROOTS,
|
|
1175
1225
|
`~/${HOST_CATALOGUE_ROOT}`
|
|
1176
1226
|
];
|
|
1177
|
-
var OBSERVATION_LOG =
|
|
1227
|
+
var OBSERVATION_LOG = path7.join(
|
|
1178
1228
|
"agents",
|
|
1179
1229
|
"evidence",
|
|
1180
1230
|
"metrics",
|
|
@@ -1218,9 +1268,9 @@ function descriptionOf(frontmatter) {
|
|
|
1218
1268
|
return "";
|
|
1219
1269
|
}
|
|
1220
1270
|
function readProjectedCatalogue(root) {
|
|
1221
|
-
const names =
|
|
1271
|
+
const names = fs7.readdirSync(root).filter((n) => fs7.existsSync(path7.join(root, n, "SKILL.md"))).sort();
|
|
1222
1272
|
return names.map((name, index) => {
|
|
1223
|
-
const content =
|
|
1273
|
+
const content = fs7.readFileSync(path7.join(root, name, "SKILL.md"), "utf-8");
|
|
1224
1274
|
const frontmatter = frontmatterOf(content);
|
|
1225
1275
|
const description = descriptionOf(frontmatter);
|
|
1226
1276
|
return {
|
|
@@ -1237,12 +1287,12 @@ function truncationModeOf(record) {
|
|
|
1237
1287
|
return record.truncation_mode ?? "per-entry";
|
|
1238
1288
|
}
|
|
1239
1289
|
function markdownFilesUnder(root) {
|
|
1240
|
-
if (!
|
|
1290
|
+
if (!fs7.existsSync(root)) return [];
|
|
1241
1291
|
const out = [];
|
|
1242
1292
|
const walk = (dir) => {
|
|
1243
|
-
for (const entry of
|
|
1244
|
-
const full =
|
|
1245
|
-
if (
|
|
1293
|
+
for (const entry of fs7.readdirSync(dir, { withFileTypes: true })) {
|
|
1294
|
+
const full = path7.join(dir, entry.name);
|
|
1295
|
+
if (fs7.statSync(full).isDirectory()) walk(full);
|
|
1246
1296
|
else if (entry.name.endsWith(".md")) out.push(full);
|
|
1247
1297
|
}
|
|
1248
1298
|
};
|
|
@@ -1250,9 +1300,9 @@ function markdownFilesUnder(root) {
|
|
|
1250
1300
|
return out;
|
|
1251
1301
|
}
|
|
1252
1302
|
function measureCatalogueVolume(host, root) {
|
|
1253
|
-
const skillsRoot =
|
|
1254
|
-
const skills =
|
|
1255
|
-
const commandEntries = markdownFilesUnder(
|
|
1303
|
+
const skillsRoot = path7.join(root, "skills");
|
|
1304
|
+
const skills = fs7.existsSync(skillsRoot) ? readProjectedCatalogue(skillsRoot) : [];
|
|
1305
|
+
const commandEntries = markdownFilesUnder(path7.join(root, "commands")).length;
|
|
1256
1306
|
return {
|
|
1257
1307
|
host,
|
|
1258
1308
|
root,
|
|
@@ -1330,9 +1380,9 @@ function migrationPromptLines(host, eligibility, settingsPath) {
|
|
|
1330
1380
|
];
|
|
1331
1381
|
}
|
|
1332
1382
|
function readObservationLog(logPath) {
|
|
1333
|
-
if (!
|
|
1383
|
+
if (!fs7.existsSync(logPath)) return [];
|
|
1334
1384
|
const out = [];
|
|
1335
|
-
for (const line of
|
|
1385
|
+
for (const line of fs7.readFileSync(logPath, "utf-8").split("\n")) {
|
|
1336
1386
|
const trimmed = line.trim();
|
|
1337
1387
|
if (trimmed.length === 0) continue;
|
|
1338
1388
|
try {
|
|
@@ -1373,8 +1423,8 @@ function isInteractiveSession(probe) {
|
|
|
1373
1423
|
|
|
1374
1424
|
// src/scripts/_lib/claude_desktop_bundler.ts
|
|
1375
1425
|
import * as crypto4 from "node:crypto";
|
|
1376
|
-
import * as
|
|
1377
|
-
import * as
|
|
1426
|
+
import * as fs8 from "node:fs";
|
|
1427
|
+
import * as path8 from "node:path";
|
|
1378
1428
|
|
|
1379
1429
|
// src/scripts/_lib/zip_min.ts
|
|
1380
1430
|
import * as zlib from "node:zlib";
|
|
@@ -1481,7 +1531,7 @@ function _is_excluded(rel_parts) {
|
|
|
1481
1531
|
}
|
|
1482
1532
|
function _is_dir(p) {
|
|
1483
1533
|
try {
|
|
1484
|
-
return
|
|
1534
|
+
return fs8.statSync(p).isDirectory();
|
|
1485
1535
|
} catch {
|
|
1486
1536
|
return false;
|
|
1487
1537
|
}
|
|
@@ -1493,12 +1543,12 @@ function _compare_rel_parts(a, b) {
|
|
|
1493
1543
|
}
|
|
1494
1544
|
function _walk_skill_files(skill_dir) {
|
|
1495
1545
|
const out = [];
|
|
1496
|
-
const resolved =
|
|
1546
|
+
const resolved = fs8.realpathSync(skill_dir);
|
|
1497
1547
|
const walk = (root, relRoot) => {
|
|
1498
1548
|
const dirNames = [];
|
|
1499
1549
|
const fileNames = [];
|
|
1500
|
-
for (const dirent of
|
|
1501
|
-
const full =
|
|
1550
|
+
for (const dirent of fs8.readdirSync(root, { withFileTypes: true })) {
|
|
1551
|
+
const full = path8.join(root, dirent.name);
|
|
1502
1552
|
const isDir2 = dirent.isDirectory() || dirent.isSymbolicLink() && _is_dir(full);
|
|
1503
1553
|
if (isDir2) {
|
|
1504
1554
|
dirNames.push(dirent.name);
|
|
@@ -1511,13 +1561,13 @@ function _walk_skill_files(skill_dir) {
|
|
|
1511
1561
|
if (_is_excluded(rel_parts)) {
|
|
1512
1562
|
continue;
|
|
1513
1563
|
}
|
|
1514
|
-
out.push([
|
|
1564
|
+
out.push([path8.join(root, fname), rel_parts]);
|
|
1515
1565
|
}
|
|
1516
1566
|
for (const dname of dirNames) {
|
|
1517
1567
|
if (_is_excluded([dname])) {
|
|
1518
1568
|
continue;
|
|
1519
1569
|
}
|
|
1520
|
-
walk(
|
|
1570
|
+
walk(path8.join(root, dname), [...relRoot, dname]);
|
|
1521
1571
|
}
|
|
1522
1572
|
};
|
|
1523
1573
|
walk(resolved, []);
|
|
@@ -1530,53 +1580,53 @@ function _manifest_digest(files) {
|
|
|
1530
1580
|
const rel = rel_parts.join("/");
|
|
1531
1581
|
h.update(Buffer.from(rel, "utf-8"));
|
|
1532
1582
|
h.update(Buffer.from([0]));
|
|
1533
|
-
h.update(crypto4.createHash("sha256").update(
|
|
1583
|
+
h.update(crypto4.createHash("sha256").update(fs8.readFileSync(abs_path)).digest());
|
|
1534
1584
|
h.update(Buffer.from([0]));
|
|
1535
1585
|
}
|
|
1536
1586
|
return h.digest("hex");
|
|
1537
1587
|
}
|
|
1538
1588
|
function _atomic_write_zip(zip_path, files) {
|
|
1539
|
-
|
|
1540
|
-
const stem =
|
|
1541
|
-
const tmp_path =
|
|
1542
|
-
|
|
1589
|
+
fs8.mkdirSync(path8.dirname(zip_path), { recursive: true });
|
|
1590
|
+
const stem = path8.basename(zip_path, path8.extname(zip_path));
|
|
1591
|
+
const tmp_path = path8.join(
|
|
1592
|
+
path8.dirname(zip_path),
|
|
1543
1593
|
`.${stem}.${crypto4.randomBytes(6).toString("hex")}.zip.tmp`
|
|
1544
1594
|
);
|
|
1545
1595
|
try {
|
|
1546
1596
|
const entries = files.map(([abs_path, rel_parts]) => ({
|
|
1547
1597
|
name: rel_parts.join("/"),
|
|
1548
|
-
data:
|
|
1598
|
+
data: fs8.readFileSync(abs_path)
|
|
1549
1599
|
}));
|
|
1550
|
-
|
|
1551
|
-
|
|
1600
|
+
fs8.writeFileSync(tmp_path, zip_write_sync(entries));
|
|
1601
|
+
fs8.renameSync(tmp_path, zip_path);
|
|
1552
1602
|
} finally {
|
|
1553
|
-
if (
|
|
1554
|
-
|
|
1603
|
+
if (fs8.existsSync(tmp_path)) {
|
|
1604
|
+
fs8.unlinkSync(tmp_path);
|
|
1555
1605
|
}
|
|
1556
1606
|
}
|
|
1557
1607
|
}
|
|
1558
1608
|
function _write_if_changed(dest_dir, slug, files, force, written) {
|
|
1559
1609
|
const digest = _manifest_digest(files);
|
|
1560
|
-
const zip_path =
|
|
1561
|
-
const digest_path =
|
|
1562
|
-
const recorded =
|
|
1563
|
-
if (!force && recorded === digest &&
|
|
1610
|
+
const zip_path = path8.join(dest_dir, `${slug}.zip`);
|
|
1611
|
+
const digest_path = path8.join(dest_dir, `${slug}.sha256`);
|
|
1612
|
+
const recorded = fs8.existsSync(digest_path) ? fs8.readFileSync(digest_path, "utf-8").trim() : "";
|
|
1613
|
+
if (!force && recorded === digest && fs8.existsSync(zip_path)) {
|
|
1564
1614
|
return;
|
|
1565
1615
|
}
|
|
1566
1616
|
_atomic_write_zip(zip_path, files);
|
|
1567
|
-
|
|
1617
|
+
fs8.writeFileSync(digest_path, digest + "\n", "utf-8");
|
|
1568
1618
|
written.push(zip_path);
|
|
1569
1619
|
}
|
|
1570
1620
|
function build_skill_bundles(package_root, dest_dir, force = false, curation = null) {
|
|
1571
|
-
const skills_root =
|
|
1621
|
+
const skills_root = path8.join(package_root, "dist/agent-src", "skills");
|
|
1572
1622
|
if (!_is_dir(skills_root)) {
|
|
1573
1623
|
return [];
|
|
1574
1624
|
}
|
|
1575
|
-
|
|
1625
|
+
fs8.mkdirSync(dest_dir, { recursive: true });
|
|
1576
1626
|
const written = [];
|
|
1577
|
-
for (const name of
|
|
1578
|
-
const entry =
|
|
1579
|
-
const isSymlink2 =
|
|
1627
|
+
for (const name of fs8.readdirSync(skills_root).sort()) {
|
|
1628
|
+
const entry = path8.join(skills_root, name);
|
|
1629
|
+
const isSymlink2 = fs8.lstatSync(entry).isSymbolicLink();
|
|
1580
1630
|
if (!(_is_dir(entry) || isSymlink2)) {
|
|
1581
1631
|
continue;
|
|
1582
1632
|
}
|
|
@@ -1584,8 +1634,8 @@ function build_skill_bundles(package_root, dest_dir, force = false, curation = n
|
|
|
1584
1634
|
if (curation !== null && !curation.includes(skill_name)) {
|
|
1585
1635
|
continue;
|
|
1586
1636
|
}
|
|
1587
|
-
const skill_md =
|
|
1588
|
-
if (!
|
|
1637
|
+
const skill_md = path8.join(entry, "SKILL.md");
|
|
1638
|
+
if (!fs8.existsSync(skill_md)) {
|
|
1589
1639
|
continue;
|
|
1590
1640
|
}
|
|
1591
1641
|
const files = _walk_skill_files(entry);
|
|
@@ -1597,15 +1647,15 @@ function build_skill_bundles(package_root, dest_dir, force = false, curation = n
|
|
|
1597
1647
|
return written;
|
|
1598
1648
|
}
|
|
1599
1649
|
function _command_slug(source_file, commands_root) {
|
|
1600
|
-
const rel =
|
|
1601
|
-
const noExt = rel.slice(0, rel.length -
|
|
1602
|
-
return noExt.split(
|
|
1650
|
+
const rel = path8.relative(commands_root, source_file);
|
|
1651
|
+
const noExt = rel.slice(0, rel.length - path8.extname(rel).length);
|
|
1652
|
+
return noExt.split(path8.sep).join("-");
|
|
1603
1653
|
}
|
|
1604
1654
|
function _iter_command_files(commands_root) {
|
|
1605
1655
|
const found = [];
|
|
1606
1656
|
const walk = (dir) => {
|
|
1607
|
-
for (const dirent of
|
|
1608
|
-
const full =
|
|
1657
|
+
for (const dirent of fs8.readdirSync(dir, { withFileTypes: true })) {
|
|
1658
|
+
const full = path8.join(dir, dirent.name);
|
|
1609
1659
|
if (dirent.isDirectory() || dirent.isSymbolicLink() && _is_dir(full)) {
|
|
1610
1660
|
walk(full);
|
|
1611
1661
|
} else if (dirent.name.endsWith(".md")) {
|
|
@@ -1615,21 +1665,21 @@ function _iter_command_files(commands_root) {
|
|
|
1615
1665
|
};
|
|
1616
1666
|
walk(commands_root);
|
|
1617
1667
|
found.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
1618
|
-
return found.filter((source_file) =>
|
|
1668
|
+
return found.filter((source_file) => path8.basename(source_file) !== "AGENTS.md");
|
|
1619
1669
|
}
|
|
1620
1670
|
function build_command_bundles(package_root, dest_dir, force = false, curation = null) {
|
|
1621
|
-
const commands_root =
|
|
1671
|
+
const commands_root = path8.join(package_root, "dist/agent-src", "commands");
|
|
1622
1672
|
if (!_is_dir(commands_root)) {
|
|
1623
1673
|
return [];
|
|
1624
1674
|
}
|
|
1625
|
-
const skills_root =
|
|
1675
|
+
const skills_root = path8.join(package_root, "dist/agent-src", "skills");
|
|
1626
1676
|
let skill_names = /* @__PURE__ */ new Set();
|
|
1627
1677
|
if (_is_dir(skills_root)) {
|
|
1628
1678
|
skill_names = new Set(
|
|
1629
|
-
|
|
1679
|
+
fs8.readdirSync(skills_root).filter((name) => _is_dir(path8.join(skills_root, name)))
|
|
1630
1680
|
);
|
|
1631
1681
|
}
|
|
1632
|
-
|
|
1682
|
+
fs8.mkdirSync(dest_dir, { recursive: true });
|
|
1633
1683
|
const written = [];
|
|
1634
1684
|
for (const source_file of _iter_command_files(commands_root)) {
|
|
1635
1685
|
const slug = _command_slug(source_file, commands_root);
|
|
@@ -1639,7 +1689,7 @@ function build_command_bundles(package_root, dest_dir, force = false, curation =
|
|
|
1639
1689
|
if (curation !== null && !curation.includes(slug)) {
|
|
1640
1690
|
continue;
|
|
1641
1691
|
}
|
|
1642
|
-
const files = [[
|
|
1692
|
+
const files = [[fs8.realpathSync(source_file), ["SKILL.md"]]];
|
|
1643
1693
|
_write_if_changed(dest_dir, slug, files, force, written);
|
|
1644
1694
|
}
|
|
1645
1695
|
return written;
|
|
@@ -1647,15 +1697,25 @@ function build_command_bundles(package_root, dest_dir, force = false, curation =
|
|
|
1647
1697
|
|
|
1648
1698
|
// src/scripts/hooks/host_lowering.ts
|
|
1649
1699
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
1650
|
-
import * as
|
|
1651
|
-
import * as
|
|
1700
|
+
import * as fs9 from "node:fs";
|
|
1701
|
+
import * as path9 from "node:path";
|
|
1652
1702
|
import { fileURLToPath } from "node:url";
|
|
1703
|
+
|
|
1704
|
+
// src/scripts/hooks/table_fingerprint.ts
|
|
1705
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
1706
|
+
function tableFingerprint(text) {
|
|
1707
|
+
const digest = createHash5("sha256").update(text, "utf-8").digest("hex");
|
|
1708
|
+
return `${digest}:${String(text.length)}`;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
// src/scripts/hooks/host_lowering.ts
|
|
1653
1712
|
var _IN_BUNDLE = true;
|
|
1654
|
-
var _REPO_ROOT =
|
|
1655
|
-
|
|
1713
|
+
var _REPO_ROOT = path9.resolve(
|
|
1714
|
+
path9.dirname(fileURLToPath(import.meta.url)),
|
|
1656
1715
|
..._IN_BUNDLE ? ["..", ".."] : ["..", "..", ".."]
|
|
1657
1716
|
);
|
|
1658
|
-
var HOST_LOWERING_PATH =
|
|
1717
|
+
var HOST_LOWERING_PATH = path9.join(_REPO_ROOT, "src", "scripts", "hooks", "host_lowering.yaml");
|
|
1718
|
+
var HOST_LOWERING_JSON_PATH = path9.join(_REPO_ROOT, "src", "scripts", "hooks", "host_lowering.json");
|
|
1659
1719
|
var DEFAULT_SURFACE = "any";
|
|
1660
1720
|
function _asString(v) {
|
|
1661
1721
|
if (v === null || v === void 0) return null;
|
|
@@ -1663,7 +1723,9 @@ function _asString(v) {
|
|
|
1663
1723
|
return String(v);
|
|
1664
1724
|
}
|
|
1665
1725
|
function _parse(text) {
|
|
1666
|
-
|
|
1726
|
+
return _structure((0, import_yaml2.parse)(text));
|
|
1727
|
+
}
|
|
1728
|
+
function _structure(raw) {
|
|
1667
1729
|
const hostsRaw = raw?.["hosts"];
|
|
1668
1730
|
if (typeof hostsRaw !== "object" || hostsRaw === null) {
|
|
1669
1731
|
throw new Error("host_lowering.yaml: missing `hosts:` map");
|
|
@@ -1687,6 +1749,7 @@ function _parse(text) {
|
|
|
1687
1749
|
verified = {
|
|
1688
1750
|
docs_at: _asString(verifiedRaw["docs_at"]),
|
|
1689
1751
|
docs_url: _asString(verifiedRaw["docs_url"]),
|
|
1752
|
+
docs_digest: _asString(verifiedRaw["docs_digest"]),
|
|
1690
1753
|
probe_at: _asString(verifiedRaw["probe_at"]),
|
|
1691
1754
|
host_version: _asString(verifiedRaw["host_version"]),
|
|
1692
1755
|
expires
|
|
@@ -1700,7 +1763,9 @@ function _parse(text) {
|
|
|
1700
1763
|
const be = rv["block_exit"];
|
|
1701
1764
|
const row = {
|
|
1702
1765
|
native,
|
|
1703
|
-
block_exit: typeof be === "number" ? be : null
|
|
1766
|
+
block_exit: typeof be === "number" ? be : null,
|
|
1767
|
+
answered_at: _asString(rv["answered_at"]),
|
|
1768
|
+
docs_url: _asString(rv["docs_url"])
|
|
1704
1769
|
};
|
|
1705
1770
|
if (typeof rv["matcher"] === "string") row.matcher = rv["matcher"];
|
|
1706
1771
|
slots.set(slot, row);
|
|
@@ -1721,9 +1786,30 @@ function _parse(text) {
|
|
|
1721
1786
|
}
|
|
1722
1787
|
var _cache = null;
|
|
1723
1788
|
function loadHostLowering() {
|
|
1724
|
-
if (_cache
|
|
1789
|
+
if (_cache !== null) return _cache;
|
|
1790
|
+
const text = fs9.readFileSync(HOST_LOWERING_PATH, "utf-8");
|
|
1791
|
+
let compiled;
|
|
1792
|
+
try {
|
|
1793
|
+
compiled = fs9.readFileSync(HOST_LOWERING_JSON_PATH, "utf-8");
|
|
1794
|
+
} catch {
|
|
1795
|
+
compiled = null;
|
|
1796
|
+
}
|
|
1797
|
+
_cache = resolveTable(text, compiled);
|
|
1725
1798
|
return _cache;
|
|
1726
1799
|
}
|
|
1800
|
+
function resolveTable(yamlText, compiledText) {
|
|
1801
|
+
if (compiledText !== null) {
|
|
1802
|
+
try {
|
|
1803
|
+
const raw = JSON.parse(compiledText);
|
|
1804
|
+
const table = raw["table"];
|
|
1805
|
+
if (raw["fingerprint"] === tableFingerprint(yamlText) && typeof table === "object" && table !== null) {
|
|
1806
|
+
return _structure(table);
|
|
1807
|
+
}
|
|
1808
|
+
} catch {
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
return _parse(yamlText);
|
|
1812
|
+
}
|
|
1727
1813
|
function surfaceRow(host, surface = DEFAULT_SURFACE, table = loadHostLowering()) {
|
|
1728
1814
|
return table.get(host)?.get(surface) ?? table.get(host)?.get(DEFAULT_SURFACE) ?? null;
|
|
1729
1815
|
}
|
|
@@ -1740,26 +1826,26 @@ function hostBindings(host, table = loadHostLowering()) {
|
|
|
1740
1826
|
}
|
|
1741
1827
|
|
|
1742
1828
|
// src/install/partitionEligibility.ts
|
|
1743
|
-
import * as
|
|
1829
|
+
import * as fs11 from "node:fs";
|
|
1744
1830
|
import * as os2 from "node:os";
|
|
1745
1831
|
|
|
1746
1832
|
// src/install/hostLayerFingerprint.ts
|
|
1747
|
-
import { createHash as
|
|
1748
|
-
import * as
|
|
1749
|
-
import * as
|
|
1833
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
1834
|
+
import * as fs10 from "node:fs";
|
|
1835
|
+
import * as path10 from "node:path";
|
|
1750
1836
|
var FINGERPRINT_SCHEMA = 1;
|
|
1751
1837
|
function collectFiles(dir) {
|
|
1752
1838
|
const out = [];
|
|
1753
1839
|
const walk = (d) => {
|
|
1754
1840
|
let entries;
|
|
1755
1841
|
try {
|
|
1756
|
-
entries =
|
|
1842
|
+
entries = fs10.readdirSync(d, { withFileTypes: true });
|
|
1757
1843
|
} catch {
|
|
1758
1844
|
return;
|
|
1759
1845
|
}
|
|
1760
1846
|
const sorted = [...entries].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
1761
1847
|
for (const e of sorted) {
|
|
1762
|
-
const p =
|
|
1848
|
+
const p = path10.join(d, e.name);
|
|
1763
1849
|
if (e.isDirectory()) {
|
|
1764
1850
|
walk(p);
|
|
1765
1851
|
} else if (e.isFile()) {
|
|
@@ -1771,15 +1857,15 @@ function collectFiles(dir) {
|
|
|
1771
1857
|
return out.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
1772
1858
|
}
|
|
1773
1859
|
function fingerprintLayers(layers) {
|
|
1774
|
-
const h =
|
|
1860
|
+
const h = createHash6("sha256");
|
|
1775
1861
|
h.update(`v${FINGERPRINT_SCHEMA}\0`);
|
|
1776
1862
|
for (const layer of layers) {
|
|
1777
1863
|
h.update(`layer:${layer.label}\0`);
|
|
1778
1864
|
for (const file of collectFiles(layer.root)) {
|
|
1779
|
-
h.update(
|
|
1865
|
+
h.update(path10.relative(layer.root, file));
|
|
1780
1866
|
h.update("\0");
|
|
1781
1867
|
try {
|
|
1782
|
-
h.update(
|
|
1868
|
+
h.update(fs10.readFileSync(file));
|
|
1783
1869
|
} catch {
|
|
1784
1870
|
h.update("\0unreadable\0");
|
|
1785
1871
|
}
|
|
@@ -1789,11 +1875,11 @@ function fingerprintLayers(layers) {
|
|
|
1789
1875
|
return h.digest("hex");
|
|
1790
1876
|
}
|
|
1791
1877
|
function hostLayerInputs(userHome) {
|
|
1792
|
-
const claude =
|
|
1878
|
+
const claude = path10.join(userHome, ".claude");
|
|
1793
1879
|
return [
|
|
1794
|
-
{ label: "rules", root:
|
|
1795
|
-
{ label: "skills", root:
|
|
1796
|
-
{ label: "commands", root:
|
|
1880
|
+
{ label: "rules", root: path10.join(claude, "rules") },
|
|
1881
|
+
{ label: "skills", root: path10.join(claude, "skills") },
|
|
1882
|
+
{ label: "commands", root: path10.join(claude, "commands") }
|
|
1797
1883
|
];
|
|
1798
1884
|
}
|
|
1799
1885
|
|
|
@@ -1802,7 +1888,7 @@ var MAINTAINER_WORKSPACE = "agent-config-maintainer";
|
|
|
1802
1888
|
function isExclusivelyPackageOnly(source_path) {
|
|
1803
1889
|
let meta;
|
|
1804
1890
|
try {
|
|
1805
|
-
[meta] = parseFrontmatter(
|
|
1891
|
+
[meta] = parseFrontmatter(fs11.readFileSync(source_path, "utf-8"));
|
|
1806
1892
|
} catch {
|
|
1807
1893
|
return false;
|
|
1808
1894
|
}
|
|
@@ -1833,8 +1919,8 @@ function stampHostLayerFingerprint(installedVersion, tools, lockfilePath, skip2,
|
|
|
1833
1919
|
}
|
|
1834
1920
|
|
|
1835
1921
|
// src/install/claudeRuleRewrite.ts
|
|
1836
|
-
import * as
|
|
1837
|
-
import * as
|
|
1922
|
+
import * as fs12 from "node:fs";
|
|
1923
|
+
import * as path11 from "node:path";
|
|
1838
1924
|
|
|
1839
1925
|
// src/install/claudePathsPlan.ts
|
|
1840
1926
|
function derive_trigger_globs(meta) {
|
|
@@ -1990,23 +2076,23 @@ function rewriteClaudeRules(rulesDir, preserved = /* @__PURE__ */ new Set()) {
|
|
|
1990
2076
|
const result = { rewritten: 0, scoped: [], dropped: [], failed: [] };
|
|
1991
2077
|
let entries;
|
|
1992
2078
|
try {
|
|
1993
|
-
entries =
|
|
2079
|
+
entries = fs12.readdirSync(rulesDir);
|
|
1994
2080
|
} catch {
|
|
1995
2081
|
return result;
|
|
1996
2082
|
}
|
|
1997
2083
|
for (const name of entries.filter((n) => n.endsWith(".md")).sort()) {
|
|
1998
|
-
const full =
|
|
1999
|
-
if (preserved.has(
|
|
2084
|
+
const full = path11.join(rulesDir, name);
|
|
2085
|
+
if (preserved.has(path11.resolve(full))) continue;
|
|
2000
2086
|
let stat;
|
|
2001
2087
|
try {
|
|
2002
|
-
stat =
|
|
2088
|
+
stat = fs12.lstatSync(full);
|
|
2003
2089
|
} catch {
|
|
2004
2090
|
continue;
|
|
2005
2091
|
}
|
|
2006
2092
|
if (!stat.isFile() || stat.isSymbolicLink()) continue;
|
|
2007
2093
|
let text;
|
|
2008
2094
|
try {
|
|
2009
|
-
text =
|
|
2095
|
+
text = fs12.readFileSync(full, "utf-8");
|
|
2010
2096
|
} catch {
|
|
2011
2097
|
continue;
|
|
2012
2098
|
}
|
|
@@ -2016,7 +2102,7 @@ function rewriteClaudeRules(rulesDir, preserved = /* @__PURE__ */ new Set()) {
|
|
|
2016
2102
|
const withOwnership = _withPreservedKeys(rendered.text, text);
|
|
2017
2103
|
if (withOwnership !== text) {
|
|
2018
2104
|
try {
|
|
2019
|
-
|
|
2105
|
+
fs12.writeFileSync(full, withOwnership, "utf-8");
|
|
2020
2106
|
} catch (e) {
|
|
2021
2107
|
result.failed.push({
|
|
2022
2108
|
rule: name.slice(0, -3),
|
|
@@ -3390,8 +3476,8 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
3390
3476
|
};
|
|
3391
3477
|
|
|
3392
3478
|
// src/scripts/_lib/module_detection.ts
|
|
3393
|
-
import * as
|
|
3394
|
-
import * as
|
|
3479
|
+
import * as fs13 from "node:fs";
|
|
3480
|
+
import * as path12 from "node:path";
|
|
3395
3481
|
var _SKIP_DIRS = /* @__PURE__ */ new Set([".module-template", ".example"]);
|
|
3396
3482
|
var _RULES = [
|
|
3397
3483
|
["app/Modules", "laravel-hmvc", "App\\Modules\\{ModuleName}"],
|
|
@@ -3405,14 +3491,14 @@ var _RULES = [
|
|
|
3405
3491
|
];
|
|
3406
3492
|
function _isDir(p) {
|
|
3407
3493
|
try {
|
|
3408
|
-
return
|
|
3494
|
+
return fs13.statSync(p).isDirectory();
|
|
3409
3495
|
} catch {
|
|
3410
3496
|
return false;
|
|
3411
3497
|
}
|
|
3412
3498
|
}
|
|
3413
3499
|
function _isFile(p) {
|
|
3414
3500
|
try {
|
|
3415
|
-
return
|
|
3501
|
+
return fs13.statSync(p).isFile();
|
|
3416
3502
|
} catch {
|
|
3417
3503
|
return false;
|
|
3418
3504
|
}
|
|
@@ -3426,13 +3512,13 @@ function _isUpperChar(ch) {
|
|
|
3426
3512
|
function _list_module_subdirs(root) {
|
|
3427
3513
|
let entries;
|
|
3428
3514
|
try {
|
|
3429
|
-
entries =
|
|
3515
|
+
entries = fs13.readdirSync(root).sort();
|
|
3430
3516
|
} catch {
|
|
3431
3517
|
return [];
|
|
3432
3518
|
}
|
|
3433
3519
|
const out = [];
|
|
3434
3520
|
for (const name of entries) {
|
|
3435
|
-
if (!_isDir(
|
|
3521
|
+
if (!_isDir(path12.join(root, name))) {
|
|
3436
3522
|
continue;
|
|
3437
3523
|
}
|
|
3438
3524
|
if (name.startsWith(".")) {
|
|
@@ -3454,11 +3540,11 @@ function _score_confidence(stack, root, subdirs) {
|
|
|
3454
3540
|
return capitalized.length > 0 ? "high" : "medium";
|
|
3455
3541
|
}
|
|
3456
3542
|
if (stack === "node-monorepo") {
|
|
3457
|
-
const withPkgJson = subdirs.filter((name) => _isFile(
|
|
3543
|
+
const withPkgJson = subdirs.filter((name) => _isFile(path12.join(root, name, "package.json")));
|
|
3458
3544
|
return withPkgJson.length > 0 ? "high" : "medium";
|
|
3459
3545
|
}
|
|
3460
3546
|
if (stack === "python-src") {
|
|
3461
|
-
const withInit = subdirs.filter((name) => _isFile(
|
|
3547
|
+
const withInit = subdirs.filter((name) => _isFile(path12.join(root, name, "__init__.py")));
|
|
3462
3548
|
return withInit.length > 0 ? "high" : "medium";
|
|
3463
3549
|
}
|
|
3464
3550
|
if (stack === "go-internal") {
|
|
@@ -3470,7 +3556,7 @@ function detect_module_roots(project_root) {
|
|
|
3470
3556
|
const high = [];
|
|
3471
3557
|
const medium = [];
|
|
3472
3558
|
for (const [rel_path, stack, namespace_template] of _RULES) {
|
|
3473
|
-
const abs_path =
|
|
3559
|
+
const abs_path = path12.join(project_root, rel_path);
|
|
3474
3560
|
if (!_isDir(abs_path)) {
|
|
3475
3561
|
continue;
|
|
3476
3562
|
}
|
|
@@ -3492,7 +3578,7 @@ function detect_module_roots(project_root) {
|
|
|
3492
3578
|
}
|
|
3493
3579
|
|
|
3494
3580
|
// src/scripts/_lib/model_tier.ts
|
|
3495
|
-
import
|
|
3581
|
+
import fs14 from "node:fs";
|
|
3496
3582
|
var TIER_TO_CLAUDE_MODEL = {
|
|
3497
3583
|
frontier: "fable",
|
|
3498
3584
|
high: "opus",
|
|
@@ -3501,8 +3587,8 @@ var TIER_TO_CLAUDE_MODEL = {
|
|
|
3501
3587
|
};
|
|
3502
3588
|
var MODEL_TIER_RE = /^model_tier:\s*"?([a-z]+)"?\s*$/m;
|
|
3503
3589
|
function read_model_tier(skill_md) {
|
|
3504
|
-
if (!
|
|
3505
|
-
const text =
|
|
3590
|
+
if (!fs14.existsSync(skill_md)) return null;
|
|
3591
|
+
const text = fs14.readFileSync(skill_md).toString("utf-8");
|
|
3506
3592
|
if (!text.startsWith("---\n")) return null;
|
|
3507
3593
|
const end = text.indexOf("\n---\n", 4);
|
|
3508
3594
|
if (end === -1) return null;
|
|
@@ -3519,7 +3605,7 @@ function render_native_model_md(text, tier) {
|
|
|
3519
3605
|
|
|
3520
3606
|
// src/install/paths.ts
|
|
3521
3607
|
import { homedir as homedir4, tmpdir } from "node:os";
|
|
3522
|
-
import { join as
|
|
3608
|
+
import { join as join13 } from "node:path";
|
|
3523
3609
|
var INSTALL_ROOT_SUBPATH = ".event4u/agent-config";
|
|
3524
3610
|
var INSTALL_LOG_FILENAME = "install-log.jsonl";
|
|
3525
3611
|
function resolveHome(home) {
|
|
@@ -3535,10 +3621,10 @@ function resolveHome(home) {
|
|
|
3535
3621
|
return fromOs;
|
|
3536
3622
|
}
|
|
3537
3623
|
function getInstallRoot(home) {
|
|
3538
|
-
return
|
|
3624
|
+
return join13(resolveHome(home), INSTALL_ROOT_SUBPATH);
|
|
3539
3625
|
}
|
|
3540
3626
|
function getLogPath(home) {
|
|
3541
|
-
return
|
|
3627
|
+
return join13(getInstallRoot(home), INSTALL_LOG_FILENAME);
|
|
3542
3628
|
}
|
|
3543
3629
|
|
|
3544
3630
|
// src/scripts/install.ts
|
|
@@ -3560,41 +3646,41 @@ var ArgparseExit = class extends Error {
|
|
|
3560
3646
|
function expanduser3(p) {
|
|
3561
3647
|
if (p === "~") return os3.homedir();
|
|
3562
3648
|
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
3563
|
-
return
|
|
3649
|
+
return path13.join(os3.homedir(), p.slice(2));
|
|
3564
3650
|
}
|
|
3565
3651
|
return p;
|
|
3566
3652
|
}
|
|
3567
3653
|
function isFile(p) {
|
|
3568
3654
|
try {
|
|
3569
|
-
return
|
|
3655
|
+
return fs15.statSync(p).isFile();
|
|
3570
3656
|
} catch {
|
|
3571
3657
|
return false;
|
|
3572
3658
|
}
|
|
3573
3659
|
}
|
|
3574
3660
|
function isDir(p) {
|
|
3575
3661
|
try {
|
|
3576
|
-
return
|
|
3662
|
+
return fs15.statSync(p).isDirectory();
|
|
3577
3663
|
} catch {
|
|
3578
3664
|
return false;
|
|
3579
3665
|
}
|
|
3580
3666
|
}
|
|
3581
3667
|
function isSymlink(p) {
|
|
3582
3668
|
try {
|
|
3583
|
-
return
|
|
3669
|
+
return fs15.lstatSync(p).isSymbolicLink();
|
|
3584
3670
|
} catch {
|
|
3585
3671
|
return false;
|
|
3586
3672
|
}
|
|
3587
3673
|
}
|
|
3588
3674
|
function readText(p) {
|
|
3589
|
-
return
|
|
3675
|
+
return fs15.readFileSync(p, "utf-8");
|
|
3590
3676
|
}
|
|
3591
3677
|
function writeText(p, content) {
|
|
3592
|
-
|
|
3678
|
+
fs15.writeFileSync(p, content, "utf-8");
|
|
3593
3679
|
}
|
|
3594
3680
|
function sortedGlobStems(directory, suffix) {
|
|
3595
3681
|
let entries;
|
|
3596
3682
|
try {
|
|
3597
|
-
entries =
|
|
3683
|
+
entries = fs15.readdirSync(directory);
|
|
3598
3684
|
} catch {
|
|
3599
3685
|
return [];
|
|
3600
3686
|
}
|
|
@@ -3614,34 +3700,34 @@ function sortedGlobStems(directory, suffix) {
|
|
|
3614
3700
|
function countZips(directory) {
|
|
3615
3701
|
if (!isDir(directory)) return 0;
|
|
3616
3702
|
let n = 0;
|
|
3617
|
-
for (const name of
|
|
3703
|
+
for (const name of fs15.readdirSync(directory)) {
|
|
3618
3704
|
if (name.endsWith(".zip")) n += 1;
|
|
3619
3705
|
}
|
|
3620
3706
|
return n;
|
|
3621
3707
|
}
|
|
3622
3708
|
function atomicWrite0644(target, body, prefix) {
|
|
3623
|
-
const dir =
|
|
3624
|
-
const tmpName =
|
|
3709
|
+
const dir = path13.dirname(target);
|
|
3710
|
+
const tmpName = path13.join(
|
|
3625
3711
|
dir,
|
|
3626
3712
|
`${prefix}${process2.pid}.${crypto5.randomBytes(6).toString("hex")}.yml.tmp`
|
|
3627
3713
|
);
|
|
3628
3714
|
let fd = null;
|
|
3629
3715
|
try {
|
|
3630
|
-
fd =
|
|
3631
|
-
|
|
3632
|
-
|
|
3716
|
+
fd = fs15.openSync(tmpName, "wx", 420);
|
|
3717
|
+
fs15.writeFileSync(fd, body, "utf-8");
|
|
3718
|
+
fs15.closeSync(fd);
|
|
3633
3719
|
fd = null;
|
|
3634
|
-
|
|
3635
|
-
|
|
3720
|
+
fs15.chmodSync(tmpName, 420);
|
|
3721
|
+
fs15.renameSync(tmpName, target);
|
|
3636
3722
|
} catch (err) {
|
|
3637
3723
|
if (fd !== null) {
|
|
3638
3724
|
try {
|
|
3639
|
-
|
|
3725
|
+
fs15.closeSync(fd);
|
|
3640
3726
|
} catch {
|
|
3641
3727
|
}
|
|
3642
3728
|
}
|
|
3643
3729
|
try {
|
|
3644
|
-
|
|
3730
|
+
fs15.unlinkSync(tmpName);
|
|
3645
3731
|
} catch {
|
|
3646
3732
|
}
|
|
3647
3733
|
throw err;
|
|
@@ -3653,14 +3739,14 @@ function utcStamp(now) {
|
|
|
3653
3739
|
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}Z`;
|
|
3654
3740
|
}
|
|
3655
3741
|
function yamlSafeLoad(text) {
|
|
3656
|
-
let
|
|
3742
|
+
let YAML3;
|
|
3657
3743
|
try {
|
|
3658
|
-
|
|
3744
|
+
YAML3 = require_dist();
|
|
3659
3745
|
} catch {
|
|
3660
3746
|
return null;
|
|
3661
3747
|
}
|
|
3662
3748
|
try {
|
|
3663
|
-
const data =
|
|
3749
|
+
const data = YAML3.parse(text, { version: "1.1" });
|
|
3664
3750
|
return data;
|
|
3665
3751
|
} catch {
|
|
3666
3752
|
return void 0;
|
|
@@ -3676,12 +3762,12 @@ var LEGACY_SETTINGS_FILE = ".agent-settings";
|
|
|
3676
3762
|
var LEGACY_BACKUP_FILE = ".agent-settings.backup.key-value";
|
|
3677
3763
|
var SETTINGS_SUBDIR = ["agents", "settings"];
|
|
3678
3764
|
function _canonical_settings_target(project_root) {
|
|
3679
|
-
return
|
|
3765
|
+
return path13.join(project_root, ...SETTINGS_SUBDIR, SETTINGS_FILE);
|
|
3680
3766
|
}
|
|
3681
3767
|
function _resolve_settings_read(project_root) {
|
|
3682
3768
|
const canonical = _canonical_settings_target(project_root);
|
|
3683
3769
|
if (pathExists(canonical)) return canonical;
|
|
3684
|
-
const legacy =
|
|
3770
|
+
const legacy = path13.join(project_root, SETTINGS_FILE);
|
|
3685
3771
|
if (pathExists(legacy)) return legacy;
|
|
3686
3772
|
return canonical;
|
|
3687
3773
|
}
|
|
@@ -3747,9 +3833,9 @@ function fail(msg) {
|
|
|
3747
3833
|
throw new SystemExitError(1);
|
|
3748
3834
|
}
|
|
3749
3835
|
function detect_package_root(project_root) {
|
|
3750
|
-
const npm_path =
|
|
3836
|
+
const npm_path = path13.join(project_root, "node_modules", "@event4u", "agent-config");
|
|
3751
3837
|
if (isDir(npm_path)) return resolvePath(npm_path);
|
|
3752
|
-
if (pathExists(
|
|
3838
|
+
if (pathExists(path13.join(project_root, "src", "config", "profiles", "minimal.ini"))) {
|
|
3753
3839
|
return project_root;
|
|
3754
3840
|
}
|
|
3755
3841
|
fail(
|
|
@@ -3757,12 +3843,12 @@ function detect_package_root(project_root) {
|
|
|
3757
3843
|
);
|
|
3758
3844
|
}
|
|
3759
3845
|
function detect_package_type(package_root) {
|
|
3760
|
-
if (package_root.split(
|
|
3846
|
+
if (package_root.split(path13.sep).includes("node_modules")) return "npm";
|
|
3761
3847
|
return "local";
|
|
3762
3848
|
}
|
|
3763
3849
|
function detect_package_type_for_project(project_root, package_root) {
|
|
3764
3850
|
const npm_path = resolvePath(
|
|
3765
|
-
|
|
3851
|
+
path13.join(project_root, "node_modules", "@event4u", "agent-config")
|
|
3766
3852
|
);
|
|
3767
3853
|
const package_resolved = resolvePath(package_root);
|
|
3768
3854
|
if (package_resolved === npm_path) return "npm";
|
|
@@ -3786,7 +3872,7 @@ function ensure_directory(p) {
|
|
|
3786
3872
|
mkdirp(p);
|
|
3787
3873
|
}
|
|
3788
3874
|
function write_file(p, content) {
|
|
3789
|
-
ensure_directory(
|
|
3875
|
+
ensure_directory(path13.dirname(p));
|
|
3790
3876
|
writeText(p, content);
|
|
3791
3877
|
}
|
|
3792
3878
|
function read_json_file(p) {
|
|
@@ -3957,7 +4043,7 @@ function _append_unknown_legacy(rendered, legacy_values, unknown_keys) {
|
|
|
3957
4043
|
return rendered + "\n" + suffix;
|
|
3958
4044
|
}
|
|
3959
4045
|
function _migrate_legacy_if_present(project_root, template_body) {
|
|
3960
|
-
const legacy_target =
|
|
4046
|
+
const legacy_target = path13.join(project_root, LEGACY_SETTINGS_FILE);
|
|
3961
4047
|
if (!isFile(legacy_target)) return null;
|
|
3962
4048
|
const legacy_text = readText(legacy_target);
|
|
3963
4049
|
const [values, unknown] = _parse_legacy_settings(legacy_text);
|
|
@@ -3972,9 +4058,9 @@ function _migrate_legacy_if_present(project_root, template_body) {
|
|
|
3972
4058
|
}
|
|
3973
4059
|
}
|
|
3974
4060
|
rendered = _append_unknown_legacy(rendered, values, unknown);
|
|
3975
|
-
const backup_target =
|
|
4061
|
+
const backup_target = path13.join(project_root, LEGACY_BACKUP_FILE);
|
|
3976
4062
|
writeText(backup_target, legacy_text);
|
|
3977
|
-
|
|
4063
|
+
fs15.unlinkSync(legacy_target);
|
|
3978
4064
|
info(`Migrated legacy ${LEGACY_SETTINGS_FILE} \u2192 ${SETTINGS_FILE}`);
|
|
3979
4065
|
info(`Backup saved to ${LEGACY_BACKUP_FILE}`);
|
|
3980
4066
|
if (unknown.length > 0) {
|
|
@@ -4009,7 +4095,7 @@ function _render_template(template, profile_values) {
|
|
|
4009
4095
|
return body;
|
|
4010
4096
|
}
|
|
4011
4097
|
function _load_valid_user_types(package_root) {
|
|
4012
|
-
const directory =
|
|
4098
|
+
const directory = path13.join(package_root, USER_TYPES_DIR);
|
|
4013
4099
|
if (!isDir(directory)) return [];
|
|
4014
4100
|
return sortedGlobStems(directory, ".yml");
|
|
4015
4101
|
}
|
|
@@ -4066,8 +4152,8 @@ function splitlinesKeepends(text) {
|
|
|
4066
4152
|
}
|
|
4067
4153
|
function ensure_agent_settings(project_root, package_root, profile, force, user_type = "", packs = null) {
|
|
4068
4154
|
const target = _canonical_settings_target(project_root);
|
|
4069
|
-
const profile_source =
|
|
4070
|
-
const template_source =
|
|
4155
|
+
const profile_source = path13.join(package_root, "src", "config", "profiles", `${profile}.ini`);
|
|
4156
|
+
const template_source = path13.join(package_root, "src", "config", "agent-settings.template.yml");
|
|
4071
4157
|
if (!pathExists(profile_source)) fail(`Missing profile preset: ${profile_source}`);
|
|
4072
4158
|
if (!pathExists(template_source)) fail(`Missing settings template: ${template_source}`);
|
|
4073
4159
|
const template = readText(template_source);
|
|
@@ -4081,21 +4167,21 @@ function ensure_agent_settings(project_root, package_root, profile, force, user_
|
|
|
4081
4167
|
if (profile_values["rule_loading_tier"] !== profile) {
|
|
4082
4168
|
const got = "rule_loading_tier" in profile_values ? `'${profile_values["rule_loading_tier"]}'` : "None";
|
|
4083
4169
|
fail(
|
|
4084
|
-
`Profile preset ${
|
|
4170
|
+
`Profile preset ${path13.basename(profile_source)} has rule_loading_tier=${got} but --profile=${profile}`
|
|
4085
4171
|
);
|
|
4086
4172
|
}
|
|
4087
4173
|
profile_values["user_type"] = _validate_user_type(package_root, user_type);
|
|
4088
4174
|
let template_body = _render_template(template, profile_values);
|
|
4089
4175
|
template_body = _inject_packs(template_body, packs ?? []);
|
|
4090
|
-
const legacy_root =
|
|
4176
|
+
const legacy_root = path13.join(project_root, SETTINGS_FILE);
|
|
4091
4177
|
if (isFile(legacy_root) && !pathExists(target)) {
|
|
4092
|
-
mkdirp(
|
|
4178
|
+
mkdirp(path13.dirname(target));
|
|
4093
4179
|
writeText(target, readText(legacy_root));
|
|
4094
|
-
|
|
4180
|
+
fs15.unlinkSync(legacy_root);
|
|
4095
4181
|
success(`Migrated ${SETTINGS_FILE} \u2192 agents/settings/${SETTINGS_FILE} (ADR-038)`);
|
|
4096
4182
|
return;
|
|
4097
4183
|
}
|
|
4098
|
-
const legacy_target =
|
|
4184
|
+
const legacy_target = path13.join(project_root, LEGACY_SETTINGS_FILE);
|
|
4099
4185
|
if (isFile(legacy_target) && pathExists(target)) {
|
|
4100
4186
|
warn(
|
|
4101
4187
|
`Both ${SETTINGS_FILE} and legacy ${LEGACY_SETTINGS_FILE} exist. Skipping migration to avoid overwriting ${SETTINGS_FILE}. Delete one of them manually and re-run.`
|
|
@@ -4112,7 +4198,7 @@ function ensure_agent_settings(project_root, package_root, profile, force, user_
|
|
|
4112
4198
|
skip(`${SETTINGS_FILE} already exists`);
|
|
4113
4199
|
return;
|
|
4114
4200
|
}
|
|
4115
|
-
mkdirp(
|
|
4201
|
+
mkdirp(path13.dirname(target));
|
|
4116
4202
|
write_file(target, template_body);
|
|
4117
4203
|
const user_type_value = profile_values["user_type"] ?? "";
|
|
4118
4204
|
const suffix = user_type_value ? `, user_type=${user_type_value}` : "";
|
|
@@ -4125,7 +4211,7 @@ function ensure_vscode_bridge(project_root, package_type, force) {
|
|
|
4125
4211
|
const plugin_path = plugin_paths[package_type] ?? "./plugin/agent-config";
|
|
4126
4212
|
const bridge = { "chat.pluginLocations": { [plugin_path]: true } };
|
|
4127
4213
|
return merge_json_file(
|
|
4128
|
-
|
|
4214
|
+
path13.join(project_root, ".vscode", "settings.json"),
|
|
4129
4215
|
bridge,
|
|
4130
4216
|
force,
|
|
4131
4217
|
".vscode/settings.json"
|
|
@@ -4134,14 +4220,14 @@ function ensure_vscode_bridge(project_root, package_type, force) {
|
|
|
4134
4220
|
function ensure_augment_bridge(project_root, force) {
|
|
4135
4221
|
const bridge = { enabledPlugins: { "agent-config@event4u": true } };
|
|
4136
4222
|
return merge_json_file(
|
|
4137
|
-
|
|
4223
|
+
path13.join(project_root, ".augment", "settings.json"),
|
|
4138
4224
|
bridge,
|
|
4139
4225
|
force,
|
|
4140
4226
|
".augment/settings.json"
|
|
4141
4227
|
);
|
|
4142
4228
|
}
|
|
4143
|
-
var AUGMENT_USER_DIR =
|
|
4144
|
-
var AUGMENT_USER_HOOKS_DIR =
|
|
4229
|
+
var AUGMENT_USER_DIR = path13.join(os3.homedir(), ".augment");
|
|
4230
|
+
var AUGMENT_USER_HOOKS_DIR = path13.join(AUGMENT_USER_DIR, "hooks");
|
|
4145
4231
|
var AUGMENT_DISPATCHER_TRAMPOLINE = "augment-dispatcher.sh";
|
|
4146
4232
|
var AUGMENT_LEGACY_TRAMPOLINES = [
|
|
4147
4233
|
"augment-chat-history.sh",
|
|
@@ -4150,29 +4236,29 @@ var AUGMENT_LEGACY_TRAMPOLINES = [
|
|
|
4150
4236
|
"augment-context-hygiene.sh"
|
|
4151
4237
|
];
|
|
4152
4238
|
function _deploy_augment_trampoline(package_root, name, force) {
|
|
4153
|
-
const src =
|
|
4239
|
+
const src = path13.join(package_root, "scripts", "hooks", name);
|
|
4154
4240
|
if (!pathExists(src)) {
|
|
4155
4241
|
skip(`augment trampoline missing in package: ${src}`);
|
|
4156
4242
|
return null;
|
|
4157
4243
|
}
|
|
4158
4244
|
mkdirp(AUGMENT_USER_HOOKS_DIR);
|
|
4159
|
-
const dst =
|
|
4245
|
+
const dst = path13.join(AUGMENT_USER_HOOKS_DIR, name);
|
|
4160
4246
|
const src_text = readText(src);
|
|
4161
4247
|
if (pathExists(dst) && readText(dst) === src_text && !force) {
|
|
4162
4248
|
skip(`~/.augment/hooks/${name} already up to date`);
|
|
4163
4249
|
} else {
|
|
4164
4250
|
writeText(dst, src_text);
|
|
4165
|
-
|
|
4251
|
+
fs15.chmodSync(dst, 493);
|
|
4166
4252
|
success(`~/.augment/hooks/${name} installed`);
|
|
4167
4253
|
}
|
|
4168
4254
|
return dst;
|
|
4169
4255
|
}
|
|
4170
4256
|
function _remove_legacy_augment_trampolines() {
|
|
4171
4257
|
for (const name of AUGMENT_LEGACY_TRAMPOLINES) {
|
|
4172
|
-
const legacy =
|
|
4258
|
+
const legacy = path13.join(AUGMENT_USER_HOOKS_DIR, name);
|
|
4173
4259
|
try {
|
|
4174
4260
|
if (isFile(legacy)) {
|
|
4175
|
-
|
|
4261
|
+
fs15.unlinkSync(legacy);
|
|
4176
4262
|
skip(`removed legacy ~/.augment/hooks/${name}`);
|
|
4177
4263
|
}
|
|
4178
4264
|
} catch (err) {
|
|
@@ -4192,7 +4278,7 @@ function ensure_augment_user_hooks(package_root, force) {
|
|
|
4192
4278
|
}
|
|
4193
4279
|
const settings_patch = { hooks: per_event };
|
|
4194
4280
|
return merge_json_file(
|
|
4195
|
-
|
|
4281
|
+
path13.join(AUGMENT_USER_DIR, "settings.json"),
|
|
4196
4282
|
settings_patch,
|
|
4197
4283
|
force,
|
|
4198
4284
|
"~/.augment/settings.json"
|
|
@@ -4217,12 +4303,10 @@ function _heal_legacy_claude_plugin_ids(p) {
|
|
|
4217
4303
|
return removed;
|
|
4218
4304
|
}
|
|
4219
4305
|
function ensure_claude_bridge(project_root, force) {
|
|
4220
|
-
const target =
|
|
4306
|
+
const target = path13.join(project_root, ".claude", "settings.json");
|
|
4221
4307
|
const healed = _heal_legacy_claude_plugin_ids(target);
|
|
4222
|
-
for (const pid of healed) {
|
|
4223
|
-
|
|
4224
|
-
}
|
|
4225
|
-
const bridge = { enabledPlugins: { [CLAUDE_PLUGIN_ID]: true } };
|
|
4308
|
+
for (const pid of healed) success(`.claude/settings.json: removed stale plugin id \`${pid}\``);
|
|
4309
|
+
const bridge = withHostEnv({ enabledPlugins: { [CLAUDE_PLUGIN_ID]: true } }, project_root, success);
|
|
4226
4310
|
return merge_json_file(target, bridge, force || healed.length > 0, ".claude/settings.json");
|
|
4227
4311
|
}
|
|
4228
4312
|
var ensure_mcp_bridge = makeEnsureMcpBridge(merge_json_file);
|
|
@@ -4237,29 +4321,29 @@ function ensure_cursor_bridge(project_root, force) {
|
|
|
4237
4321
|
}
|
|
4238
4322
|
const bridge = { version: 1, hooks };
|
|
4239
4323
|
return merge_json_file(
|
|
4240
|
-
|
|
4324
|
+
path13.join(project_root, ".cursor", "hooks.json"),
|
|
4241
4325
|
bridge,
|
|
4242
4326
|
force,
|
|
4243
4327
|
".cursor/hooks.json"
|
|
4244
4328
|
);
|
|
4245
4329
|
}
|
|
4246
|
-
var CURSOR_USER_DIR =
|
|
4247
|
-
var CURSOR_USER_HOOKS_DIR =
|
|
4330
|
+
var CURSOR_USER_DIR = path13.join(os3.homedir(), ".cursor");
|
|
4331
|
+
var CURSOR_USER_HOOKS_DIR = path13.join(CURSOR_USER_DIR, "hooks");
|
|
4248
4332
|
var CURSOR_DISPATCHER_TRAMPOLINE = "cursor-dispatcher.sh";
|
|
4249
4333
|
function ensure_cursor_user_hooks(package_root, force) {
|
|
4250
|
-
const src =
|
|
4334
|
+
const src = path13.join(package_root, "scripts", "hooks", CURSOR_DISPATCHER_TRAMPOLINE);
|
|
4251
4335
|
if (!pathExists(src)) {
|
|
4252
4336
|
skip(`cursor trampoline missing in package: ${src}`);
|
|
4253
4337
|
return [];
|
|
4254
4338
|
}
|
|
4255
4339
|
mkdirp(CURSOR_USER_HOOKS_DIR);
|
|
4256
|
-
const dst =
|
|
4340
|
+
const dst = path13.join(CURSOR_USER_HOOKS_DIR, CURSOR_DISPATCHER_TRAMPOLINE);
|
|
4257
4341
|
const src_text = readText(src);
|
|
4258
4342
|
if (pathExists(dst) && readText(dst) === src_text && !force) {
|
|
4259
4343
|
skip(`~/.cursor/hooks/${CURSOR_DISPATCHER_TRAMPOLINE} already up to date`);
|
|
4260
4344
|
} else {
|
|
4261
4345
|
writeText(dst, src_text);
|
|
4262
|
-
|
|
4346
|
+
fs15.chmodSync(dst, 493);
|
|
4263
4347
|
success(`~/.cursor/hooks/${CURSOR_DISPATCHER_TRAMPOLINE} installed`);
|
|
4264
4348
|
}
|
|
4265
4349
|
const hooks = {};
|
|
@@ -4268,7 +4352,7 @@ function ensure_cursor_user_hooks(package_root, force) {
|
|
|
4268
4352
|
}
|
|
4269
4353
|
const settings_patch = { version: 1, hooks };
|
|
4270
4354
|
return merge_json_file(
|
|
4271
|
-
|
|
4355
|
+
path13.join(CURSOR_USER_DIR, "hooks.json"),
|
|
4272
4356
|
settings_patch,
|
|
4273
4357
|
force,
|
|
4274
4358
|
"~/.cursor/hooks.json"
|
|
@@ -4303,12 +4387,12 @@ exit 0
|
|
|
4303
4387
|
`;
|
|
4304
4388
|
}
|
|
4305
4389
|
function ensure_cline_bridge(project_root, force) {
|
|
4306
|
-
const hooks_dir =
|
|
4390
|
+
const hooks_dir = path13.join(project_root, ".clinerules", "hooks");
|
|
4307
4391
|
mkdirp(hooks_dir);
|
|
4308
4392
|
const workspace_quoted = shlexQuote(resolvePath(project_root));
|
|
4309
4393
|
let written = 0;
|
|
4310
4394
|
for (const { slot, native } of hostBindings("cline")) {
|
|
4311
|
-
const target =
|
|
4395
|
+
const target = path13.join(hooks_dir, native);
|
|
4312
4396
|
const body = clineProjectHookBody(native, slot, workspace_quoted);
|
|
4313
4397
|
if (pathExists(target) && readText(target) === body && !force) {
|
|
4314
4398
|
continue;
|
|
@@ -4318,7 +4402,7 @@ function ensure_cline_bridge(project_root, force) {
|
|
|
4318
4402
|
continue;
|
|
4319
4403
|
}
|
|
4320
4404
|
writeText(target, body);
|
|
4321
|
-
|
|
4405
|
+
fs15.chmodSync(target, 493);
|
|
4322
4406
|
written += 1;
|
|
4323
4407
|
}
|
|
4324
4408
|
if (written) {
|
|
@@ -4327,27 +4411,27 @@ function ensure_cline_bridge(project_root, force) {
|
|
|
4327
4411
|
skip(".clinerules/hooks/ already up to date");
|
|
4328
4412
|
}
|
|
4329
4413
|
}
|
|
4330
|
-
var CLINE_USER_DIR =
|
|
4414
|
+
var CLINE_USER_DIR = path13.join(os3.homedir(), "Documents", "Cline", "Hooks");
|
|
4331
4415
|
var CLINE_DISPATCHER_TRAMPOLINE = "cline-dispatcher.sh";
|
|
4332
4416
|
function ensure_cline_user_hooks(package_root, force) {
|
|
4333
|
-
const src =
|
|
4417
|
+
const src = path13.join(package_root, "scripts", "hooks", CLINE_DISPATCHER_TRAMPOLINE);
|
|
4334
4418
|
if (!pathExists(src)) {
|
|
4335
4419
|
skip(`cline trampoline missing in package: ${src}`);
|
|
4336
4420
|
return;
|
|
4337
4421
|
}
|
|
4338
4422
|
mkdirp(CLINE_USER_DIR);
|
|
4339
|
-
const trampoline =
|
|
4423
|
+
const trampoline = path13.join(CLINE_USER_DIR, CLINE_DISPATCHER_TRAMPOLINE);
|
|
4340
4424
|
const src_text = readText(src);
|
|
4341
4425
|
if (pathExists(trampoline) && readText(trampoline) === src_text && !force) {
|
|
4342
4426
|
skip(`~/Documents/Cline/Hooks/${CLINE_DISPATCHER_TRAMPOLINE} already up to date`);
|
|
4343
4427
|
} else {
|
|
4344
4428
|
writeText(trampoline, src_text);
|
|
4345
|
-
|
|
4429
|
+
fs15.chmodSync(trampoline, 493);
|
|
4346
4430
|
success(`~/Documents/Cline/Hooks/${CLINE_DISPATCHER_TRAMPOLINE} installed`);
|
|
4347
4431
|
}
|
|
4348
4432
|
const trampoline_quoted = shlexQuote(trampoline);
|
|
4349
4433
|
for (const { slot, native } of hostBindings("cline")) {
|
|
4350
|
-
const wrapper =
|
|
4434
|
+
const wrapper = path13.join(CLINE_USER_DIR, native);
|
|
4351
4435
|
const body = `#!/usr/bin/env bash
|
|
4352
4436
|
# Generated by event4u/agent-config \u2014 DO NOT EDIT.
|
|
4353
4437
|
# User-scope Cline hook for ${native} \u2192 agent-config ${slot}.
|
|
@@ -4357,7 +4441,7 @@ exec ${trampoline_quoted} ${slot} ${native}
|
|
|
4357
4441
|
continue;
|
|
4358
4442
|
}
|
|
4359
4443
|
writeText(wrapper, body);
|
|
4360
|
-
|
|
4444
|
+
fs15.chmodSync(wrapper, 493);
|
|
4361
4445
|
}
|
|
4362
4446
|
}
|
|
4363
4447
|
function _windsurf_dispatch_command(ac_event, native) {
|
|
@@ -4373,29 +4457,29 @@ function ensure_windsurf_bridge(project_root, force) {
|
|
|
4373
4457
|
}
|
|
4374
4458
|
const bridge = { hooks };
|
|
4375
4459
|
return merge_json_file(
|
|
4376
|
-
|
|
4460
|
+
path13.join(project_root, ".windsurf", "hooks.json"),
|
|
4377
4461
|
bridge,
|
|
4378
4462
|
force,
|
|
4379
4463
|
".windsurf/hooks.json"
|
|
4380
4464
|
);
|
|
4381
4465
|
}
|
|
4382
|
-
var WINDSURF_USER_DIR =
|
|
4383
|
-
var WINDSURF_USER_HOOKS_DIR =
|
|
4466
|
+
var WINDSURF_USER_DIR = path13.join(os3.homedir(), ".codeium", "windsurf");
|
|
4467
|
+
var WINDSURF_USER_HOOKS_DIR = path13.join(WINDSURF_USER_DIR, "hooks");
|
|
4384
4468
|
var WINDSURF_DISPATCHER_TRAMPOLINE = "windsurf-dispatcher.sh";
|
|
4385
4469
|
function ensure_windsurf_user_hooks(package_root, force) {
|
|
4386
|
-
const src =
|
|
4470
|
+
const src = path13.join(package_root, "scripts", "hooks", WINDSURF_DISPATCHER_TRAMPOLINE);
|
|
4387
4471
|
if (!pathExists(src)) {
|
|
4388
4472
|
skip(`windsurf trampoline missing in package: ${src}`);
|
|
4389
4473
|
return [];
|
|
4390
4474
|
}
|
|
4391
4475
|
mkdirp(WINDSURF_USER_HOOKS_DIR);
|
|
4392
|
-
const dst =
|
|
4476
|
+
const dst = path13.join(WINDSURF_USER_HOOKS_DIR, WINDSURF_DISPATCHER_TRAMPOLINE);
|
|
4393
4477
|
const src_text = readText(src);
|
|
4394
4478
|
if (pathExists(dst) && readText(dst) === src_text && !force) {
|
|
4395
4479
|
skip(`~/.codeium/windsurf/hooks/${WINDSURF_DISPATCHER_TRAMPOLINE} already up to date`);
|
|
4396
4480
|
} else {
|
|
4397
4481
|
writeText(dst, src_text);
|
|
4398
|
-
|
|
4482
|
+
fs15.chmodSync(dst, 493);
|
|
4399
4483
|
success(`~/.codeium/windsurf/hooks/${WINDSURF_DISPATCHER_TRAMPOLINE} installed`);
|
|
4400
4484
|
}
|
|
4401
4485
|
const hooks = {};
|
|
@@ -4407,7 +4491,7 @@ function ensure_windsurf_user_hooks(package_root, force) {
|
|
|
4407
4491
|
}
|
|
4408
4492
|
const settings_patch = { hooks };
|
|
4409
4493
|
return merge_json_file(
|
|
4410
|
-
|
|
4494
|
+
path13.join(WINDSURF_USER_DIR, "hooks.json"),
|
|
4411
4495
|
settings_patch,
|
|
4412
4496
|
force,
|
|
4413
4497
|
"~/.codeium/windsurf/hooks.json"
|
|
@@ -4429,43 +4513,43 @@ function _gemini_hooks_dict(command_factory) {
|
|
|
4429
4513
|
function ensure_gemini_bridge(project_root, force) {
|
|
4430
4514
|
const bridge = { hooks: _gemini_hooks_dict(_gemini_dispatch_command) };
|
|
4431
4515
|
return merge_json_file(
|
|
4432
|
-
|
|
4516
|
+
path13.join(project_root, ".gemini", "settings.json"),
|
|
4433
4517
|
bridge,
|
|
4434
4518
|
force,
|
|
4435
4519
|
".gemini/settings.json"
|
|
4436
4520
|
);
|
|
4437
4521
|
}
|
|
4438
|
-
var GEMINI_USER_DIR =
|
|
4439
|
-
var GEMINI_USER_HOOKS_DIR =
|
|
4522
|
+
var GEMINI_USER_DIR = path13.join(os3.homedir(), ".gemini");
|
|
4523
|
+
var GEMINI_USER_HOOKS_DIR = path13.join(GEMINI_USER_DIR, "hooks");
|
|
4440
4524
|
var GEMINI_DISPATCHER_TRAMPOLINE = "gemini-dispatcher.sh";
|
|
4441
4525
|
function ensure_gemini_user_hooks(package_root, force) {
|
|
4442
|
-
const src =
|
|
4526
|
+
const src = path13.join(package_root, "scripts", "hooks", GEMINI_DISPATCHER_TRAMPOLINE);
|
|
4443
4527
|
if (!pathExists(src)) {
|
|
4444
4528
|
skip(`gemini trampoline missing in package: ${src}`);
|
|
4445
4529
|
return [];
|
|
4446
4530
|
}
|
|
4447
4531
|
mkdirp(GEMINI_USER_HOOKS_DIR);
|
|
4448
|
-
const dst =
|
|
4532
|
+
const dst = path13.join(GEMINI_USER_HOOKS_DIR, GEMINI_DISPATCHER_TRAMPOLINE);
|
|
4449
4533
|
const src_text = readText(src);
|
|
4450
4534
|
if (pathExists(dst) && readText(dst) === src_text && !force) {
|
|
4451
4535
|
skip(`~/.gemini/hooks/${GEMINI_DISPATCHER_TRAMPOLINE} already up to date`);
|
|
4452
4536
|
} else {
|
|
4453
4537
|
writeText(dst, src_text);
|
|
4454
|
-
|
|
4538
|
+
fs15.chmodSync(dst, 493);
|
|
4455
4539
|
success(`~/.gemini/hooks/${GEMINI_DISPATCHER_TRAMPOLINE} installed`);
|
|
4456
4540
|
}
|
|
4457
4541
|
const settings_patch = {
|
|
4458
4542
|
hooks: _gemini_hooks_dict((ac_event, native) => `${dst} ${ac_event} ${native}`)
|
|
4459
4543
|
};
|
|
4460
4544
|
return merge_json_file(
|
|
4461
|
-
|
|
4545
|
+
path13.join(GEMINI_USER_DIR, "settings.json"),
|
|
4462
4546
|
settings_patch,
|
|
4463
4547
|
force,
|
|
4464
4548
|
"~/.gemini/settings.json"
|
|
4465
4549
|
);
|
|
4466
4550
|
}
|
|
4467
4551
|
function ensure_copilot_bridge(project_root, force) {
|
|
4468
|
-
const target =
|
|
4552
|
+
const target = path13.join(project_root, ".github", "plugin", "marketplace.json");
|
|
4469
4553
|
const bridge = {
|
|
4470
4554
|
marketplace: {
|
|
4471
4555
|
name: "event4u-agent-marketplace",
|
|
@@ -4508,7 +4592,7 @@ See \`docs/setup/per-ide/roocode.md\` for the full activation guide.
|
|
|
4508
4592
|
Run \`./agent-config --help\` for available commands.
|
|
4509
4593
|
`;
|
|
4510
4594
|
function ensure_roocode_bridge(project_root, force) {
|
|
4511
|
-
const target =
|
|
4595
|
+
const target = path13.join(project_root, ".roo", "rules", "agent-config.md");
|
|
4512
4596
|
if (pathExists(target) && !force) {
|
|
4513
4597
|
skip(".roo/rules/agent-config.md already exists");
|
|
4514
4598
|
return;
|
|
@@ -4530,7 +4614,7 @@ To wire Claude Desktop to this project's rules, run:
|
|
|
4530
4614
|
Canonical rule and skill source: \`.augment/\` (see \`AGENTS.md\`).
|
|
4531
4615
|
`;
|
|
4532
4616
|
function ensure_claude_desktop_bridge(project_root, force) {
|
|
4533
|
-
const target =
|
|
4617
|
+
const target = path13.join(project_root, ".claude-desktop", "agent-config.md");
|
|
4534
4618
|
if (pathExists(target) && !force) {
|
|
4535
4619
|
skip(".claude-desktop/agent-config.md already exists");
|
|
4536
4620
|
return;
|
|
@@ -4555,7 +4639,7 @@ Or pass \`--read .aider/agent-config.md\` on the command line.
|
|
|
4555
4639
|
Canonical rule and skill source: \`.augment/\` (see \`AGENTS.md\`).
|
|
4556
4640
|
`;
|
|
4557
4641
|
function ensure_aider_bridge(project_root, force) {
|
|
4558
|
-
const target =
|
|
4642
|
+
const target = path13.join(project_root, ".aider", "agent-config.md");
|
|
4559
4643
|
if (pathExists(target) && !force) {
|
|
4560
4644
|
skip(".aider/agent-config.md already exists");
|
|
4561
4645
|
return;
|
|
@@ -4574,7 +4658,7 @@ developers where the rules and skills live.
|
|
|
4574
4658
|
Canonical rule and skill source: \`.augment/\` (see project \`AGENTS.md\`).
|
|
4575
4659
|
`;
|
|
4576
4660
|
function ensure_codex_bridge(project_root, force) {
|
|
4577
|
-
const target =
|
|
4661
|
+
const target = path13.join(project_root, ".codex", "agent-config.md");
|
|
4578
4662
|
if (pathExists(target) && !force) {
|
|
4579
4663
|
skip(".codex/agent-config.md already exists");
|
|
4580
4664
|
return;
|
|
@@ -4592,7 +4676,7 @@ rules per session. The canonical rule and skill source lives under
|
|
|
4592
4676
|
orientation).
|
|
4593
4677
|
`;
|
|
4594
4678
|
function ensure_continue_bridge(project_root, force) {
|
|
4595
|
-
const target =
|
|
4679
|
+
const target = path13.join(project_root, ".continue", "rules", "agent-config.md");
|
|
4596
4680
|
if (pathExists(target) && !force) {
|
|
4597
4681
|
skip(".continue/rules/agent-config.md already exists");
|
|
4598
4682
|
return;
|
|
@@ -4623,7 +4707,7 @@ orientation).
|
|
|
4623
4707
|
See \`docs/setup/per-ide/kilocode.md\` for the full activation guide.
|
|
4624
4708
|
`;
|
|
4625
4709
|
function ensure_kilocode_bridge(project_root, force) {
|
|
4626
|
-
const target =
|
|
4710
|
+
const target = path13.join(project_root, ".kilocode", "rules", "agent-config.md");
|
|
4627
4711
|
if (pathExists(target) && !force) {
|
|
4628
4712
|
skip(".kilocode/rules/agent-config.md already exists");
|
|
4629
4713
|
return;
|
|
@@ -4650,7 +4734,7 @@ canonical source (or symlink it):
|
|
|
4650
4734
|
Canonical rule and skill source: \`.augment/\` (see \`AGENTS.md\`).
|
|
4651
4735
|
`;
|
|
4652
4736
|
function ensure_zed_bridge(project_root, force) {
|
|
4653
|
-
const target =
|
|
4737
|
+
const target = path13.join(project_root, ".zed", "agent-config.md");
|
|
4654
4738
|
if (pathExists(target) && !force) {
|
|
4655
4739
|
skip(".zed/agent-config.md already exists");
|
|
4656
4740
|
return;
|
|
@@ -4671,7 +4755,7 @@ rules into your JetBrains profile.
|
|
|
4671
4755
|
Canonical rule and skill source: \`.augment/\` (see \`AGENTS.md\`).
|
|
4672
4756
|
`;
|
|
4673
4757
|
function ensure_jetbrains_bridge(project_root, force) {
|
|
4674
|
-
const target =
|
|
4758
|
+
const target = path13.join(project_root, ".jetbrains", "agent-config.md");
|
|
4675
4759
|
if (pathExists(target) && !force) {
|
|
4676
4760
|
skip(".jetbrains/agent-config.md already exists");
|
|
4677
4761
|
return;
|
|
@@ -4702,7 +4786,7 @@ session. The canonical rule and skill source lives under \`.augment/\`
|
|
|
4702
4786
|
See \`docs/setup/per-ide/kiro.md\` for the full activation guide.
|
|
4703
4787
|
`;
|
|
4704
4788
|
function ensure_kiro_bridge(project_root, force) {
|
|
4705
|
-
const target =
|
|
4789
|
+
const target = path13.join(project_root, ".kiro", "steering", "agent-config.md");
|
|
4706
4790
|
if (pathExists(target) && !force) {
|
|
4707
4791
|
skip(".kiro/steering/agent-config.md already exists");
|
|
4708
4792
|
return;
|
|
@@ -4739,35 +4823,35 @@ var SMOKE_BRIDGE_PATHS = {
|
|
|
4739
4823
|
};
|
|
4740
4824
|
function dirHasEntries(p) {
|
|
4741
4825
|
try {
|
|
4742
|
-
return
|
|
4826
|
+
return fs15.readdirSync(p).length > 0;
|
|
4743
4827
|
} catch {
|
|
4744
4828
|
return false;
|
|
4745
4829
|
}
|
|
4746
4830
|
}
|
|
4747
4831
|
function _resolve_tsx_invocation(scriptPath, scriptArgs) {
|
|
4748
4832
|
const binName = process2.platform === "win32" ? "tsx.cmd" : "tsx";
|
|
4749
|
-
let dir =
|
|
4833
|
+
let dir = path13.dirname(scriptPath);
|
|
4750
4834
|
for (; ; ) {
|
|
4751
|
-
const candidate =
|
|
4835
|
+
const candidate = path13.join(dir, "node_modules", ".bin", binName);
|
|
4752
4836
|
if (isFile(candidate)) {
|
|
4753
4837
|
return { command: candidate, args: [scriptPath, ...scriptArgs] };
|
|
4754
4838
|
}
|
|
4755
|
-
const parent =
|
|
4839
|
+
const parent = path13.dirname(dir);
|
|
4756
4840
|
if (parent === dir) break;
|
|
4757
4841
|
dir = parent;
|
|
4758
4842
|
}
|
|
4759
4843
|
return { command: "npx", args: ["tsx", scriptPath, ...scriptArgs] };
|
|
4760
4844
|
}
|
|
4761
4845
|
function _smoke_test_hooks(project_root, package_root) {
|
|
4762
|
-
const dispatcher =
|
|
4763
|
-
const manifest =
|
|
4846
|
+
const dispatcher = path13.join(package_root, "scripts", "hooks", "dispatch_hook.ts");
|
|
4847
|
+
const manifest = path13.join(package_root, "scripts", "hook_manifest.yaml");
|
|
4764
4848
|
if (!isFile(dispatcher) || !isFile(manifest)) return 0;
|
|
4765
4849
|
const failed = [];
|
|
4766
4850
|
const skipped = [];
|
|
4767
4851
|
const passed = [];
|
|
4768
4852
|
for (const [platform, native] of smokeProbeEvents()) {
|
|
4769
4853
|
const rel_bridge = SMOKE_BRIDGE_PATHS[platform] ?? "";
|
|
4770
|
-
const bridge_path = rel_bridge ?
|
|
4854
|
+
const bridge_path = rel_bridge ? path13.join(project_root, rel_bridge) : null;
|
|
4771
4855
|
const bridge_present = Boolean(
|
|
4772
4856
|
bridge_path && (isFile(bridge_path) || isDir(bridge_path) && dirHasEntries(bridge_path))
|
|
4773
4857
|
);
|
|
@@ -4967,9 +5051,9 @@ To remove this marker, delete this file.
|
|
|
4967
5051
|
`;
|
|
4968
5052
|
}
|
|
4969
5053
|
var _CLAUDE_DESKTOP_BUNDLES_SUBPATH = "claude-desktop/bundles";
|
|
4970
|
-
var GLOBAL_ROOT =
|
|
4971
|
-
var GLOBAL_USER_SETTINGS_PATH =
|
|
4972
|
-
var GLOBAL_AGENT_SETTINGS_PATH =
|
|
5054
|
+
var GLOBAL_ROOT = path13.join(os3.homedir(), ".event4u", "agent-config");
|
|
5055
|
+
var GLOBAL_USER_SETTINGS_PATH = path13.join(GLOBAL_ROOT, ".agent-user.yml");
|
|
5056
|
+
var GLOBAL_AGENT_SETTINGS_PATH = path13.join(GLOBAL_ROOT, ".agent-settings.yml");
|
|
4973
5057
|
function _bridge_marker(tool_id, scope) {
|
|
4974
5058
|
if (scope === "global") return USER_SCOPE_PATHS[tool_id] ?? "";
|
|
4975
5059
|
return PROJECT_BRIDGE_MARKERS[tool_id] ?? "";
|
|
@@ -5018,7 +5102,7 @@ function _load_yaml_doc(p) {
|
|
|
5018
5102
|
return _isPlainObject(data) ? data : {};
|
|
5019
5103
|
}
|
|
5020
5104
|
function _load_default_settings(package_root) {
|
|
5021
|
-
const template_source =
|
|
5105
|
+
const template_source = path13.join(package_root, "src", "config", "agent-settings.template.yml");
|
|
5022
5106
|
if (!pathExists(template_source)) return {};
|
|
5023
5107
|
let text;
|
|
5024
5108
|
try {
|
|
@@ -5032,11 +5116,11 @@ function _load_default_settings(package_root) {
|
|
|
5032
5116
|
}
|
|
5033
5117
|
var RULE_LAYER_CHOICES = ["global", "project", "both-acknowledged"];
|
|
5034
5118
|
function _suppress_rule_layer(project_root, suppress_dir) {
|
|
5035
|
-
const target =
|
|
5119
|
+
const target = path13.join(project_root, ".claude", "settings.local.json");
|
|
5036
5120
|
const existing = pathExists(target) ? read_json_file(target) : {};
|
|
5037
5121
|
let real_dir = suppress_dir;
|
|
5038
5122
|
try {
|
|
5039
|
-
real_dir =
|
|
5123
|
+
real_dir = fs15.realpathSync(suppress_dir);
|
|
5040
5124
|
} catch {
|
|
5041
5125
|
real_dir = suppress_dir;
|
|
5042
5126
|
}
|
|
@@ -5047,8 +5131,8 @@ function _suppress_rule_layer(project_root, suppress_dir) {
|
|
|
5047
5131
|
success(`.claude/settings.local.json: claudeMdExcludes += ${entry}`);
|
|
5048
5132
|
}
|
|
5049
5133
|
function _gate_rule_layer_overlap(project_root, layer, dry_run) {
|
|
5050
|
-
const global_dir =
|
|
5051
|
-
const project_dir =
|
|
5134
|
+
const global_dir = path13.join(os3.homedir(), ".claude", "rules");
|
|
5135
|
+
const project_dir = path13.join(project_root, ".claude", "rules");
|
|
5052
5136
|
const g = readRuleLayer(global_dir);
|
|
5053
5137
|
const p = readRuleLayer(project_dir);
|
|
5054
5138
|
if (g === null || p === null) return true;
|
|
@@ -5136,9 +5220,9 @@ function detect_scope(cwd) {
|
|
|
5136
5220
|
if (pathExists(_resolve_settings_read(cwd))) {
|
|
5137
5221
|
return ["project", `existing ${SETTINGS_FILE}`];
|
|
5138
5222
|
}
|
|
5139
|
-
const has_manifest = SCOPE_DETECT_MANIFESTS.find((m) => pathExists(
|
|
5140
|
-
const has_ai_dir = SCOPE_DETECT_AI_DIRS.find((d) => isDir(
|
|
5141
|
-
const has_ai_file = SCOPE_DETECT_AI_FILES.find((f) => pathExists(
|
|
5223
|
+
const has_manifest = SCOPE_DETECT_MANIFESTS.find((m) => pathExists(path13.join(cwd, m))) ?? null;
|
|
5224
|
+
const has_ai_dir = SCOPE_DETECT_AI_DIRS.find((d) => isDir(path13.join(cwd, d))) ?? null;
|
|
5225
|
+
const has_ai_file = SCOPE_DETECT_AI_FILES.find((f) => pathExists(path13.join(cwd, f))) ?? null;
|
|
5142
5226
|
if (has_manifest && (has_ai_dir || has_ai_file)) {
|
|
5143
5227
|
const marker = has_ai_dir || has_ai_file;
|
|
5144
5228
|
return ["prompt", `manifest (${has_manifest}) + AI-tool config (${marker})`];
|
|
@@ -5159,7 +5243,7 @@ function readLineSyncRaw(promptText) {
|
|
|
5159
5243
|
for (; ; ) {
|
|
5160
5244
|
let n;
|
|
5161
5245
|
try {
|
|
5162
|
-
n =
|
|
5246
|
+
n = fs15.readSync(0, buf, 0, 1, null);
|
|
5163
5247
|
} catch (err) {
|
|
5164
5248
|
const code = err.code;
|
|
5165
5249
|
if (code === "EAGAIN") {
|
|
@@ -5242,26 +5326,26 @@ function _update_installed_tools_manifest(project_root, tools, scope, force, fil
|
|
|
5242
5326
|
}
|
|
5243
5327
|
write_manifest(target, version, entries);
|
|
5244
5328
|
if (!state.QUIET) {
|
|
5245
|
-
const rel = isRelativeTo(target, project_root) ?
|
|
5329
|
+
const rel = isRelativeTo(target, project_root) ? path13.relative(project_root, target) : target;
|
|
5246
5330
|
info(`Manifest updated: ${rel}`);
|
|
5247
5331
|
}
|
|
5248
5332
|
return 0;
|
|
5249
5333
|
}
|
|
5250
5334
|
function isRelativeTo(child, parent) {
|
|
5251
|
-
const rel =
|
|
5252
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
5335
|
+
const rel = path13.relative(parent, child);
|
|
5336
|
+
return rel === "" || !rel.startsWith("..") && !path13.isAbsolute(rel);
|
|
5253
5337
|
}
|
|
5254
5338
|
function _resolve_package_root_for_global() {
|
|
5255
5339
|
const here = resolvePath(_HERE);
|
|
5256
|
-
const candidate =
|
|
5257
|
-
if (!pathExists(
|
|
5340
|
+
const candidate = path13.dirname(path13.dirname(path13.dirname(here)));
|
|
5341
|
+
if (!pathExists(path13.join(candidate, "src", "config", "profiles", "minimal.ini"))) {
|
|
5258
5342
|
fail(
|
|
5259
5343
|
`Could not locate agent-config package root from ${here}. Expected src/config/profiles/minimal.ini at the parent directory.`
|
|
5260
5344
|
);
|
|
5261
5345
|
}
|
|
5262
5346
|
return candidate;
|
|
5263
5347
|
}
|
|
5264
|
-
var CONSUMER_BRIDGE_MARKER_RELPATH =
|
|
5348
|
+
var CONSUMER_BRIDGE_MARKER_RELPATH = path13.join("agents", ".event4u-bridge.yml");
|
|
5265
5349
|
var MIGRATE_LEGACY_YAML_FILES = [".agent-settings.yml", ".agent-user.yml"];
|
|
5266
5350
|
var MIGRATE_LEGACY_TOOL_DIRS = [".augment", ".claude", ".cursor"];
|
|
5267
5351
|
var AGENT_CONFIG_PACKAGE_NAME = "@event4u/agent-config";
|
|
@@ -5269,7 +5353,7 @@ function _is_agent_config_source_repo(project_root) {
|
|
|
5269
5353
|
if (process2.env["AGENT_CONFIG_CONSUMER_MODE"] === "1") {
|
|
5270
5354
|
return [false, "consumer-mode-override"];
|
|
5271
5355
|
}
|
|
5272
|
-
const pkg_json =
|
|
5356
|
+
const pkg_json = path13.join(project_root, "package.json");
|
|
5273
5357
|
if (isFile(pkg_json)) {
|
|
5274
5358
|
let data = {};
|
|
5275
5359
|
try {
|
|
@@ -5281,13 +5365,13 @@ function _is_agent_config_source_repo(project_root) {
|
|
|
5281
5365
|
return [true, "package.json:name"];
|
|
5282
5366
|
}
|
|
5283
5367
|
}
|
|
5284
|
-
if (isDir(
|
|
5368
|
+
if (isDir(path13.join(project_root, ".agent-src.uncondensed"))) {
|
|
5285
5369
|
return [true, ".agent-src.uncondensed/"];
|
|
5286
5370
|
}
|
|
5287
|
-
const packages_dir =
|
|
5371
|
+
const packages_dir = path13.join(project_root, "packages");
|
|
5288
5372
|
if (isDir(packages_dir)) {
|
|
5289
|
-
for (const child of
|
|
5290
|
-
if (isDir(
|
|
5373
|
+
for (const child of fs15.readdirSync(packages_dir)) {
|
|
5374
|
+
if (isDir(path13.join(packages_dir, child, ".agent-src.uncondensed"))) {
|
|
5291
5375
|
return [true, `packages/${child}/.agent-src.uncondensed/`];
|
|
5292
5376
|
}
|
|
5293
5377
|
}
|
|
@@ -5305,17 +5389,17 @@ function _detect_legacy_for_migration(project_root) {
|
|
|
5305
5389
|
}
|
|
5306
5390
|
return [];
|
|
5307
5391
|
}
|
|
5308
|
-
if (isFile(
|
|
5392
|
+
if (isFile(path13.join(project_root, INSTALL_MODE_MARKER_REL))) return [];
|
|
5309
5393
|
const found = [];
|
|
5310
5394
|
for (const name of MIGRATE_LEGACY_YAML_FILES) {
|
|
5311
|
-
if (isFile(
|
|
5395
|
+
if (isFile(path13.join(project_root, name))) {
|
|
5312
5396
|
found.push(name);
|
|
5313
|
-
} else if (isFile(
|
|
5397
|
+
} else if (isFile(path13.join(project_root, "settings", name))) {
|
|
5314
5398
|
found.push(`settings/${name}`);
|
|
5315
5399
|
}
|
|
5316
5400
|
}
|
|
5317
5401
|
for (const name of MIGRATE_LEGACY_TOOL_DIRS) {
|
|
5318
|
-
const p =
|
|
5402
|
+
const p = path13.join(project_root, name);
|
|
5319
5403
|
if (isDir(p) && !isSymlink(p)) {
|
|
5320
5404
|
found.push(`${name}/`);
|
|
5321
5405
|
}
|
|
@@ -5327,7 +5411,7 @@ function _prompt_migrate_to_global(project_root, artefacts) {
|
|
|
5327
5411
|
process2.stdout.write("\n");
|
|
5328
5412
|
warn("Legacy project-local artefacts detected \u2014 pre-ADR-020 layout:");
|
|
5329
5413
|
for (const rel of artefacts) {
|
|
5330
|
-
info(` ${
|
|
5414
|
+
info(` ${path13.join(project_root, rel)}`);
|
|
5331
5415
|
}
|
|
5332
5416
|
info("The unified `agent-config migrate` sweeps these in one pass.");
|
|
5333
5417
|
info("The wizard recreates fresh config afterwards.");
|
|
@@ -5358,20 +5442,20 @@ function _run_migrate_to_global(project_root) {
|
|
|
5358
5442
|
function _format_global_root_for_marker(global_root) {
|
|
5359
5443
|
const home = resolvePath(os3.homedir());
|
|
5360
5444
|
const resolved = resolvePath(global_root);
|
|
5361
|
-
const rel =
|
|
5362
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
5445
|
+
const rel = path13.relative(home, resolved);
|
|
5446
|
+
if (rel === "" || rel.startsWith("..") || path13.isAbsolute(rel)) {
|
|
5363
5447
|
return global_root;
|
|
5364
5448
|
}
|
|
5365
|
-
return `~/${rel.split(
|
|
5449
|
+
return `~/${rel.split(path13.sep).join("/")}`;
|
|
5366
5450
|
}
|
|
5367
5451
|
function _remove_legacy_consumer_bridge_marker(project_root, env = null) {
|
|
5368
5452
|
const env_map = env ?? process2.env;
|
|
5369
5453
|
if (env_map["AGENT_CONFIG_DEV_MODE"] === "1") return null;
|
|
5370
|
-
if (isDir(
|
|
5371
|
-
const target =
|
|
5454
|
+
if (isDir(path13.join(project_root, ".agent-src.uncondensed"))) return null;
|
|
5455
|
+
const target = path13.join(project_root, CONSUMER_BRIDGE_MARKER_RELPATH);
|
|
5372
5456
|
if (!isFile(target)) return null;
|
|
5373
5457
|
try {
|
|
5374
|
-
|
|
5458
|
+
fs15.rmSync(target);
|
|
5375
5459
|
} catch {
|
|
5376
5460
|
return null;
|
|
5377
5461
|
}
|
|
@@ -5385,7 +5469,7 @@ var PROJECT_ANCHOR_TOOLS = {
|
|
|
5385
5469
|
function _write_per_tool_project_anchors(project_root, tools, env = null, now = null) {
|
|
5386
5470
|
const env_map = env ?? process2.env;
|
|
5387
5471
|
if (env_map["AGENT_CONFIG_DEV_MODE"] === "1") return [];
|
|
5388
|
-
if (isDir(
|
|
5472
|
+
if (isDir(path13.join(project_root, ".agent-src.uncondensed"))) return [];
|
|
5389
5473
|
const global_root_str = _format_global_root_for_marker(
|
|
5390
5474
|
event4u_root(env_map)
|
|
5391
5475
|
);
|
|
@@ -5394,8 +5478,8 @@ function _write_per_tool_project_anchors(project_root, tools, env = null, now =
|
|
|
5394
5478
|
for (const tool_id of Object.keys(PROJECT_ANCHOR_TOOLS).sort()) {
|
|
5395
5479
|
const rel_path = PROJECT_ANCHOR_TOOLS[tool_id];
|
|
5396
5480
|
if (!tools.has(tool_id)) continue;
|
|
5397
|
-
const target =
|
|
5398
|
-
mkdirp(
|
|
5481
|
+
const target = path13.join(project_root, rel_path);
|
|
5482
|
+
mkdirp(path13.dirname(target));
|
|
5399
5483
|
const body = `# event4u/agent-config \u2014 per-tool project anchor (auto-written).
|
|
5400
5484
|
# Spec: docs/contracts/consumer-bridge.md \xA7 Per-tool anchor strategy.
|
|
5401
5485
|
# Tool: ${tool_id}. Resolves the global install directly \u2014 no
|
|
@@ -5413,7 +5497,7 @@ installed_at: ${stamp}
|
|
|
5413
5497
|
}
|
|
5414
5498
|
var PACKAGE_TAG_ID = "event4u/agent-config";
|
|
5415
5499
|
function _inject_package_tag(target, source, package_root) {
|
|
5416
|
-
if (
|
|
5500
|
+
if (path13.extname(target) !== ".md") return;
|
|
5417
5501
|
let text;
|
|
5418
5502
|
try {
|
|
5419
5503
|
text = readText(target);
|
|
@@ -5441,8 +5525,8 @@ function _inject_package_tag(target, source, package_root) {
|
|
|
5441
5525
|
resolved_src = source;
|
|
5442
5526
|
}
|
|
5443
5527
|
if (package_root !== null) {
|
|
5444
|
-
const rel =
|
|
5445
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
5528
|
+
const rel = path13.relative(resolvePath(package_root), resolved_src);
|
|
5529
|
+
if (rel !== "" && !rel.startsWith("..") && !path13.isAbsolute(rel)) {
|
|
5446
5530
|
source_value = rel;
|
|
5447
5531
|
} else {
|
|
5448
5532
|
source_value = resolved_src;
|
|
@@ -5477,7 +5561,7 @@ function _escapes_package_root(resolved, package_root) {
|
|
|
5477
5561
|
if (package_root === null) return false;
|
|
5478
5562
|
let root;
|
|
5479
5563
|
try {
|
|
5480
|
-
root =
|
|
5564
|
+
root = fs15.realpathSync(package_root);
|
|
5481
5565
|
} catch {
|
|
5482
5566
|
return false;
|
|
5483
5567
|
}
|
|
@@ -5503,7 +5587,7 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5503
5587
|
if (file_filter !== null && !file_filter(src)) return [0, 0, written_paths];
|
|
5504
5588
|
let resolved_src = src;
|
|
5505
5589
|
try {
|
|
5506
|
-
resolved_src =
|
|
5590
|
+
resolved_src = fs15.realpathSync(src);
|
|
5507
5591
|
} catch {
|
|
5508
5592
|
resolved_src = src;
|
|
5509
5593
|
}
|
|
@@ -5511,14 +5595,14 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5511
5595
|
warn(`refused: ${src} dereferences outside the package root \u2014 not copied`);
|
|
5512
5596
|
return [0, 0, written_paths];
|
|
5513
5597
|
}
|
|
5514
|
-
mkdirp(
|
|
5598
|
+
mkdirp(path13.dirname(dest));
|
|
5515
5599
|
const decision = tracker.resolve(dest, force);
|
|
5516
5600
|
if (decision === "preserve") {
|
|
5517
5601
|
tracker.preserve(dest, resolved_src, package_root);
|
|
5518
5602
|
_log_tx_entry("skip", dest);
|
|
5519
5603
|
return [0, 1, written_paths];
|
|
5520
5604
|
}
|
|
5521
|
-
|
|
5605
|
+
fs15.copyFileSync(src, dest);
|
|
5522
5606
|
_inject_package_tag(dest, src, package_root);
|
|
5523
5607
|
_log_tx_entry("write", dest);
|
|
5524
5608
|
written_paths.push(dest);
|
|
@@ -5527,11 +5611,11 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5527
5611
|
mkdirp(dest);
|
|
5528
5612
|
const walk = (node) => {
|
|
5529
5613
|
const acc = [];
|
|
5530
|
-
const names =
|
|
5614
|
+
const names = fs15.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
5531
5615
|
for (const name of names) {
|
|
5532
|
-
const entry =
|
|
5616
|
+
const entry = path13.join(node, name);
|
|
5533
5617
|
acc.push(entry);
|
|
5534
|
-
const lst =
|
|
5618
|
+
const lst = fs15.lstatSync(entry);
|
|
5535
5619
|
if (lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
5536
5620
|
acc.push(...walk(entry));
|
|
5537
5621
|
}
|
|
@@ -5539,9 +5623,9 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5539
5623
|
return acc;
|
|
5540
5624
|
};
|
|
5541
5625
|
for (const entry of walk(src)) {
|
|
5542
|
-
const rel =
|
|
5543
|
-
const target =
|
|
5544
|
-
const lst =
|
|
5626
|
+
const rel = path13.relative(src, entry);
|
|
5627
|
+
const target = path13.join(dest, rel);
|
|
5628
|
+
const lst = fs15.lstatSync(entry);
|
|
5545
5629
|
if (lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
5546
5630
|
mkdirp(target);
|
|
5547
5631
|
continue;
|
|
@@ -5549,8 +5633,8 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5549
5633
|
let resolvedIsDir = false;
|
|
5550
5634
|
let resolved = entry;
|
|
5551
5635
|
try {
|
|
5552
|
-
resolved =
|
|
5553
|
-
resolvedIsDir =
|
|
5636
|
+
resolved = fs15.realpathSync(entry);
|
|
5637
|
+
resolvedIsDir = fs15.statSync(entry).isDirectory();
|
|
5554
5638
|
} catch {
|
|
5555
5639
|
resolvedIsDir = false;
|
|
5556
5640
|
}
|
|
@@ -5582,8 +5666,8 @@ function _copy_dir_dereferencing_symlinks(src, dest, force, package_root = null,
|
|
|
5582
5666
|
_log_tx_entry("skip", target);
|
|
5583
5667
|
continue;
|
|
5584
5668
|
}
|
|
5585
|
-
mkdirp(
|
|
5586
|
-
|
|
5669
|
+
mkdirp(path13.dirname(target));
|
|
5670
|
+
fs15.copyFileSync(resolved, target);
|
|
5587
5671
|
_inject_package_tag(target, resolved, package_root);
|
|
5588
5672
|
_log_tx_entry("write", target);
|
|
5589
5673
|
written += 1;
|
|
@@ -5596,7 +5680,7 @@ function _claude_desktop_bundles_dir() {
|
|
|
5596
5680
|
}
|
|
5597
5681
|
function _write_claude_desktop_marker(force, lockfile_path2, bundles_dir, bundle_count) {
|
|
5598
5682
|
const anchor = expanduser3(USER_SCOPE_PATHS["claude-desktop"]);
|
|
5599
|
-
const target =
|
|
5683
|
+
const target = path13.join(anchor, "agent-config.md");
|
|
5600
5684
|
mkdirp(anchor);
|
|
5601
5685
|
const body = claudeDesktopMarkerBody(lockfile_path2, anchor, bundles_dir, bundle_count);
|
|
5602
5686
|
if (tracker.resolve(target, force) === "preserve") {
|
|
@@ -5625,23 +5709,23 @@ function _apply_claude_flat_command_wrappers(anchor, package_root, current_files
|
|
|
5625
5709
|
const wrapped = [];
|
|
5626
5710
|
const collisions = [];
|
|
5627
5711
|
const reserved = [];
|
|
5628
|
-
const commands_dir =
|
|
5712
|
+
const commands_dir = path13.join(anchor, "commands");
|
|
5629
5713
|
let flat_entries = [];
|
|
5630
5714
|
try {
|
|
5631
|
-
flat_entries =
|
|
5715
|
+
flat_entries = fs15.readdirSync(commands_dir).filter((f) => f.endsWith(".md"));
|
|
5632
5716
|
} catch {
|
|
5633
5717
|
}
|
|
5634
5718
|
for (const fname of flat_entries.sort()) {
|
|
5635
5719
|
const slug = fname.slice(0, -".md".length);
|
|
5636
5720
|
if (!is_claude_builtin_name(slug)) continue;
|
|
5637
|
-
|
|
5721
|
+
fs15.rmSync(path13.join(commands_dir, fname), { force: true });
|
|
5638
5722
|
current_files.delete(`commands/${fname}`);
|
|
5639
5723
|
reserved.push(slug);
|
|
5640
5724
|
}
|
|
5641
5725
|
const eligible = new Set(_CLAUDE_FLAT_WRAPPER_EXTRA);
|
|
5642
5726
|
try {
|
|
5643
5727
|
const manifest = JSON.parse(
|
|
5644
|
-
|
|
5728
|
+
fs15.readFileSync(path13.join(package_root, "dist", "discovery", "discovery-manifest.json"), "utf8")
|
|
5645
5729
|
);
|
|
5646
5730
|
for (const a of manifest.artefacts ?? []) {
|
|
5647
5731
|
if (a.category !== "command" || typeof a.slug !== "string") continue;
|
|
@@ -5652,22 +5736,22 @@ function _apply_claude_flat_command_wrappers(anchor, package_root, current_files
|
|
|
5652
5736
|
}
|
|
5653
5737
|
for (const slug of [...eligible].sort()) {
|
|
5654
5738
|
const flat_rel = `commands/${slug}.md`;
|
|
5655
|
-
const flat_abs =
|
|
5656
|
-
if (!
|
|
5657
|
-
const skill_dir =
|
|
5658
|
-
if (
|
|
5739
|
+
const flat_abs = path13.join(anchor, "commands", `${slug}.md`);
|
|
5740
|
+
if (!fs15.existsSync(flat_abs)) continue;
|
|
5741
|
+
const skill_dir = path13.join(anchor, "skills", slug);
|
|
5742
|
+
if (fs15.existsSync(skill_dir)) {
|
|
5659
5743
|
collisions.push(slug);
|
|
5660
5744
|
continue;
|
|
5661
5745
|
}
|
|
5662
|
-
let body =
|
|
5746
|
+
let body = fs15.readFileSync(flat_abs, "utf8");
|
|
5663
5747
|
if (body.startsWith("---\n") && !/^name:/m.test(body.split("\n---")[0] ?? "")) {
|
|
5664
5748
|
body = body.replace("---\n", `---
|
|
5665
5749
|
name: ${slug}
|
|
5666
5750
|
`);
|
|
5667
5751
|
}
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5752
|
+
fs15.mkdirSync(skill_dir, { recursive: true });
|
|
5753
|
+
fs15.writeFileSync(path13.join(skill_dir, "SKILL.md"), body, "utf8");
|
|
5754
|
+
fs15.rmSync(flat_abs, { force: true });
|
|
5671
5755
|
current_files.delete(flat_rel);
|
|
5672
5756
|
current_files.add(`skills/${slug}/SKILL.md`);
|
|
5673
5757
|
wrapped.push(slug);
|
|
@@ -5699,8 +5783,8 @@ function _deploy_global_content(tools, force, package_root, lockfile_path2) {
|
|
|
5699
5783
|
const written_paths = [];
|
|
5700
5784
|
let current_files = /* @__PURE__ */ new Set();
|
|
5701
5785
|
for (const [src_rel, dest_sub] of plan) {
|
|
5702
|
-
const src =
|
|
5703
|
-
const dest = dest_sub ?
|
|
5786
|
+
const src = path13.join(package_root, src_rel);
|
|
5787
|
+
const dest = dest_sub ? path13.join(anchor, dest_sub) : anchor;
|
|
5704
5788
|
const rule_filter = _rule_filter_for_source(src_rel, rule_scope);
|
|
5705
5789
|
const [w, s, paths] = _copy_dir_dereferencing_symlinks(
|
|
5706
5790
|
src,
|
|
@@ -5724,12 +5808,12 @@ function _deploy_global_content(tools, force, package_root, lockfile_path2) {
|
|
|
5724
5808
|
if (tool_id === "claude-code") {
|
|
5725
5809
|
const res = _apply_claude_flat_command_wrappers(anchor, package_root, current_files);
|
|
5726
5810
|
rewriteAndReport(
|
|
5727
|
-
|
|
5811
|
+
path13.join(anchor, "rules"),
|
|
5728
5812
|
state.QUIET,
|
|
5729
5813
|
info,
|
|
5730
5814
|
warn,
|
|
5731
5815
|
res,
|
|
5732
|
-
new Set(tracker.conflictState.preserved.map((p) =>
|
|
5816
|
+
new Set(tracker.conflictState.preserved.map((p) => path13.resolve(p)))
|
|
5733
5817
|
);
|
|
5734
5818
|
}
|
|
5735
5819
|
const missing_targets = _verify_deploy_targets(anchor, plan);
|
|
@@ -5772,10 +5856,10 @@ function _deploy_global_content(tools, force, package_root, lockfile_path2) {
|
|
|
5772
5856
|
results[tool_id] = [written_total, skipped_total, "deployed", written_paths];
|
|
5773
5857
|
if (tool_id === "claude-code") {
|
|
5774
5858
|
try {
|
|
5775
|
-
const manifest =
|
|
5859
|
+
const manifest = path13.join(package_root, "src", "scripts", "hook_manifest.yaml");
|
|
5776
5860
|
const matrix = build_claude_hook_matrix(manifest);
|
|
5777
5861
|
const res = ensure_managed_hooks(
|
|
5778
|
-
|
|
5862
|
+
path13.join(anchor, "settings.json"),
|
|
5779
5863
|
matrix
|
|
5780
5864
|
);
|
|
5781
5865
|
if (!state.QUIET) {
|
|
@@ -5812,7 +5896,7 @@ function _preview_global_reap(tools, package_root) {
|
|
|
5812
5896
|
const anchor = expanduser3(anchor_raw);
|
|
5813
5897
|
let current_files = /* @__PURE__ */ new Set();
|
|
5814
5898
|
for (const [src_rel, dest_sub] of plan) {
|
|
5815
|
-
const src =
|
|
5899
|
+
const src = path13.join(package_root, src_rel);
|
|
5816
5900
|
current_files = setUnion(
|
|
5817
5901
|
current_files,
|
|
5818
5902
|
expected_deploy_files(
|
|
@@ -5846,14 +5930,14 @@ function _preview_global_reap(tools, package_root) {
|
|
|
5846
5930
|
function _verify_deploy_targets(anchor, plan) {
|
|
5847
5931
|
const missing = [];
|
|
5848
5932
|
for (const [, dest_sub] of plan) {
|
|
5849
|
-
const target = dest_sub ?
|
|
5933
|
+
const target = dest_sub ? path13.join(anchor, dest_sub) : anchor;
|
|
5850
5934
|
const label = dest_sub || ".";
|
|
5851
5935
|
if (!isDir(target)) {
|
|
5852
5936
|
missing.push(label);
|
|
5853
5937
|
continue;
|
|
5854
5938
|
}
|
|
5855
5939
|
try {
|
|
5856
|
-
const entries =
|
|
5940
|
+
const entries = fs15.readdirSync(target);
|
|
5857
5941
|
if (entries.length === 0) missing.push(label);
|
|
5858
5942
|
} catch {
|
|
5859
5943
|
missing.push(label);
|
|
@@ -5871,9 +5955,9 @@ function _resolve_global_settings_doc() {
|
|
|
5871
5955
|
}
|
|
5872
5956
|
function _resolve_global_settings_path() {
|
|
5873
5957
|
const root = event4u_root();
|
|
5874
|
-
const canonical =
|
|
5958
|
+
const canonical = path13.join(root, "settings", SETTINGS_FILE);
|
|
5875
5959
|
if (pathExists(canonical)) return canonical;
|
|
5876
|
-
const legacy =
|
|
5960
|
+
const legacy = path13.join(root, SETTINGS_FILE);
|
|
5877
5961
|
if (pathExists(legacy)) return legacy;
|
|
5878
5962
|
return null;
|
|
5879
5963
|
}
|
|
@@ -5984,7 +6068,7 @@ function install_global(tools, force, project_root = null, core_only = false) {
|
|
|
5984
6068
|
info(` schema_version=1, agent_config_version=${installed_version}`);
|
|
5985
6069
|
info(` tools=${merged_tools.join(",")}`);
|
|
5986
6070
|
}
|
|
5987
|
-
if (project_root !== null && pathExists(_resolve_settings_read(project_root)) && !isDir(
|
|
6071
|
+
if (project_root !== null && pathExists(_resolve_settings_read(project_root)) && !isDir(path13.join(project_root, ".agent-src.uncondensed"))) {
|
|
5988
6072
|
const drift = collect_drift(project_root);
|
|
5989
6073
|
if (!state.QUIET) {
|
|
5990
6074
|
process2.stdout.write("\n");
|
|
@@ -6098,19 +6182,19 @@ function install_global(tools, force, project_root = null, core_only = false) {
|
|
|
6098
6182
|
}
|
|
6099
6183
|
}
|
|
6100
6184
|
}
|
|
6101
|
-
if (project_root !== null && pathExists(_resolve_settings_read(project_root)) && !isDir(
|
|
6185
|
+
if (project_root !== null && pathExists(_resolve_settings_read(project_root)) && !isDir(path13.join(project_root, ".agent-src.uncondensed"))) {
|
|
6102
6186
|
const files_by_tool = filesByToolFromDeploy(deploy_results);
|
|
6103
6187
|
const rc = _update_installed_tools_manifest(project_root, tools, "global", force, files_by_tool);
|
|
6104
6188
|
if (rc !== 0) return rc;
|
|
6105
6189
|
const removed_marker = _remove_legacy_consumer_bridge_marker(project_root);
|
|
6106
6190
|
if (removed_marker !== null && !state.QUIET) {
|
|
6107
|
-
const rel = isRelativeTo(removed_marker, project_root) ?
|
|
6191
|
+
const rel = isRelativeTo(removed_marker, project_root) ? path13.relative(project_root, removed_marker) : removed_marker;
|
|
6108
6192
|
info(`Removed legacy bridge marker: ${rel}`);
|
|
6109
6193
|
}
|
|
6110
6194
|
const anchor_paths = _write_per_tool_project_anchors(project_root, tools);
|
|
6111
6195
|
if (anchor_paths.length > 0 && !state.QUIET) {
|
|
6112
6196
|
for (const p of anchor_paths) {
|
|
6113
|
-
const rel = isRelativeTo(p, project_root) ?
|
|
6197
|
+
const rel = isRelativeTo(p, project_root) ? path13.relative(project_root, p) : p;
|
|
6114
6198
|
info(`Project anchor written: ${rel}`);
|
|
6115
6199
|
}
|
|
6116
6200
|
}
|
|
@@ -6146,8 +6230,8 @@ function install_global(tools, force, project_root = null, core_only = false) {
|
|
|
6146
6230
|
}
|
|
6147
6231
|
function _catalogue_truncation_warnings(deploy_results, project_root) {
|
|
6148
6232
|
const log_candidates = [
|
|
6149
|
-
|
|
6150
|
-
...project_root ? [
|
|
6233
|
+
path13.join(event4u_root(), "state", "skill-catalogue.jsonl"),
|
|
6234
|
+
...project_root ? [path13.join(project_root, OBSERVATION_LOG)] : []
|
|
6151
6235
|
];
|
|
6152
6236
|
const records = log_candidates.flatMap((p) => readObservationLog(p));
|
|
6153
6237
|
if (records.length === 0) return [];
|
|
@@ -6170,13 +6254,13 @@ function _catalogue_truncation_warnings(deploy_results, project_root) {
|
|
|
6170
6254
|
function _scoped_migration_notice(deploy_results, project_root, package_root, probe) {
|
|
6171
6255
|
if (!isInteractiveSession(probe)) return [];
|
|
6172
6256
|
const log_candidates = [
|
|
6173
|
-
|
|
6174
|
-
...project_root ? [
|
|
6257
|
+
path13.join(event4u_root(), "state", "skill-catalogue.jsonl"),
|
|
6258
|
+
...project_root ? [path13.join(project_root, OBSERVATION_LOG)] : []
|
|
6175
6259
|
];
|
|
6176
6260
|
const limits = knownHostLimits(log_candidates.flatMap((p) => readObservationLog(p)));
|
|
6177
6261
|
if (limits.size === 0) return [];
|
|
6178
6262
|
const resolved = _resolve_scoped_projection(package_root);
|
|
6179
|
-
const settings_path = _resolve_global_settings_path() ??
|
|
6263
|
+
const settings_path = _resolve_global_settings_path() ?? path13.join(event4u_root(), "settings", SETTINGS_FILE);
|
|
6180
6264
|
for (const tool_id of Object.keys(deploy_results).sort()) {
|
|
6181
6265
|
const [, , status] = deploy_results[tool_id];
|
|
6182
6266
|
if (status !== "deployed") continue;
|
|
@@ -6195,8 +6279,8 @@ function _scoped_migration_notice(deploy_results, project_root, package_root, pr
|
|
|
6195
6279
|
}
|
|
6196
6280
|
return [];
|
|
6197
6281
|
}
|
|
6198
|
-
var SETTINGS_SURFACE_REL =
|
|
6199
|
-
var SETTINGS_DELTA_REL =
|
|
6282
|
+
var SETTINGS_SURFACE_REL = path13.join("state", "settings-surface.json");
|
|
6283
|
+
var SETTINGS_DELTA_REL = path13.join("state", "settings-delta.json");
|
|
6200
6284
|
function _current_settings_surface(version) {
|
|
6201
6285
|
const jsonSchema = zodToJsonSchema(settingsSchema, {
|
|
6202
6286
|
name: "AgentSettings",
|
|
@@ -6207,20 +6291,20 @@ function _current_settings_surface(version) {
|
|
|
6207
6291
|
}
|
|
6208
6292
|
function _write_settings_surface_snapshot(installed_version) {
|
|
6209
6293
|
const root = event4u_root();
|
|
6210
|
-
const surface_path =
|
|
6211
|
-
const delta_path =
|
|
6294
|
+
const surface_path = path13.join(root, SETTINGS_SURFACE_REL);
|
|
6295
|
+
const delta_path = path13.join(root, SETTINGS_DELTA_REL);
|
|
6212
6296
|
const next = _current_settings_surface(installed_version);
|
|
6213
6297
|
let previous = null;
|
|
6214
6298
|
try {
|
|
6215
|
-
const parsed = JSON.parse(
|
|
6299
|
+
const parsed = JSON.parse(fs15.readFileSync(surface_path, "utf8"));
|
|
6216
6300
|
if (parsed !== null && typeof parsed === "object" && parsed.entries !== void 0) previous = parsed;
|
|
6217
6301
|
} catch {
|
|
6218
6302
|
}
|
|
6219
6303
|
if (previous !== null && previous.version !== next.version) {
|
|
6220
6304
|
const delta = computeSurfaceDelta(previous, next);
|
|
6221
6305
|
if (delta.changes.length > 0) {
|
|
6222
|
-
|
|
6223
|
-
|
|
6306
|
+
fs15.mkdirSync(path13.dirname(delta_path), { recursive: true, mode: 448 });
|
|
6307
|
+
fs15.writeFileSync(delta_path, `${JSON.stringify(delta, null, 2)}
|
|
6224
6308
|
`, { mode: 384 });
|
|
6225
6309
|
if (!state.QUIET) {
|
|
6226
6310
|
const counts = {};
|
|
@@ -6232,8 +6316,8 @@ function _write_settings_surface_snapshot(installed_version) {
|
|
|
6232
6316
|
}
|
|
6233
6317
|
}
|
|
6234
6318
|
}
|
|
6235
|
-
|
|
6236
|
-
|
|
6319
|
+
fs15.mkdirSync(path13.dirname(surface_path), { recursive: true, mode: 448 });
|
|
6320
|
+
fs15.writeFileSync(surface_path, `${JSON.stringify(next, null, 2)}
|
|
6237
6321
|
`, { mode: 384 });
|
|
6238
6322
|
}
|
|
6239
6323
|
function arrayStrEqual(a, b) {
|
|
@@ -6453,13 +6537,13 @@ function _minimal_templates_root() {
|
|
|
6453
6537
|
const chain = [start];
|
|
6454
6538
|
let cur = start;
|
|
6455
6539
|
for (; ; ) {
|
|
6456
|
-
const parent =
|
|
6540
|
+
const parent = path13.dirname(cur);
|
|
6457
6541
|
if (parent === cur) break;
|
|
6458
6542
|
chain.push(parent);
|
|
6459
6543
|
cur = parent;
|
|
6460
6544
|
}
|
|
6461
6545
|
for (const ancestor of chain) {
|
|
6462
|
-
const candidate =
|
|
6546
|
+
const candidate = path13.join(ancestor, "src", "templates", "minimal");
|
|
6463
6547
|
if (isDir(candidate)) return candidate;
|
|
6464
6548
|
}
|
|
6465
6549
|
fail("Could not locate src/templates/minimal/ \u2014 package install is corrupt.");
|
|
@@ -6467,9 +6551,9 @@ function _minimal_templates_root() {
|
|
|
6467
6551
|
var INSTALL_MODE_MARKER_REL = "agents/.agent-state/install-mode.txt";
|
|
6468
6552
|
function _write_install_mode_marker(project_root, mode) {
|
|
6469
6553
|
if (mode !== "minimal" && mode !== "full") return;
|
|
6470
|
-
const marker =
|
|
6554
|
+
const marker = path13.join(project_root, INSTALL_MODE_MARKER_REL);
|
|
6471
6555
|
try {
|
|
6472
|
-
mkdirp(
|
|
6556
|
+
mkdirp(path13.dirname(marker));
|
|
6473
6557
|
writeText(marker, `${mode}
|
|
6474
6558
|
`);
|
|
6475
6559
|
} catch {
|
|
@@ -6478,7 +6562,7 @@ function _write_install_mode_marker(project_root, mode) {
|
|
|
6478
6562
|
function install_minimal(target_root_in, force, user_type = "") {
|
|
6479
6563
|
let target_root = resolvePath(target_root_in);
|
|
6480
6564
|
mkdirp(target_root);
|
|
6481
|
-
const parent =
|
|
6565
|
+
const parent = path13.dirname(target_root);
|
|
6482
6566
|
if (parent !== target_root) {
|
|
6483
6567
|
const existing = find_project_root_with_anchor(parent);
|
|
6484
6568
|
if (existing !== null && existing[0] !== target_root) {
|
|
@@ -6489,21 +6573,21 @@ function install_minimal(target_root_in, force, user_type = "") {
|
|
|
6489
6573
|
}
|
|
6490
6574
|
}
|
|
6491
6575
|
const templates = _minimal_templates_root();
|
|
6492
|
-
const settings_src =
|
|
6493
|
-
const overrides_gitkeep_src =
|
|
6494
|
-
const overrides_readme_src =
|
|
6576
|
+
const settings_src = path13.join(templates, SETTINGS_FILE);
|
|
6577
|
+
const overrides_gitkeep_src = path13.join(templates, "overrides-gitkeep");
|
|
6578
|
+
const overrides_readme_src = path13.join(templates, "agents-overrides-readme.md");
|
|
6495
6579
|
if (!isFile(settings_src)) fail(`Bundled minimal settings template missing under ${templates}`);
|
|
6496
6580
|
if (!isFile(overrides_gitkeep_src) || !isFile(overrides_readme_src)) {
|
|
6497
6581
|
fail(`Bundled overrides scaffold templates missing under ${templates}`);
|
|
6498
6582
|
}
|
|
6499
6583
|
info(`Minimal init \u2192 ${target_root}`);
|
|
6500
|
-
const overrides_root =
|
|
6584
|
+
const overrides_root = path13.join(target_root, "agents", "overrides");
|
|
6501
6585
|
mkdirp(overrides_root);
|
|
6502
6586
|
const gitkeep_body = readText(overrides_gitkeep_src);
|
|
6503
6587
|
for (const sub of ["rules", "skills", "commands"]) {
|
|
6504
|
-
const sub_dir =
|
|
6588
|
+
const sub_dir = path13.join(overrides_root, sub);
|
|
6505
6589
|
mkdirp(sub_dir);
|
|
6506
|
-
const gitkeep_dst =
|
|
6590
|
+
const gitkeep_dst = path13.join(sub_dir, ".gitkeep");
|
|
6507
6591
|
if (pathExists(gitkeep_dst) && !force) {
|
|
6508
6592
|
skip(`agents/overrides/${sub}/.gitkeep already exists (use --force to overwrite)`);
|
|
6509
6593
|
} else {
|
|
@@ -6511,7 +6595,7 @@ function install_minimal(target_root_in, force, user_type = "") {
|
|
|
6511
6595
|
success(`Wrote agents/overrides/${sub}/.gitkeep`);
|
|
6512
6596
|
}
|
|
6513
6597
|
}
|
|
6514
|
-
const readme_dst =
|
|
6598
|
+
const readme_dst = path13.join(overrides_root, "README.md");
|
|
6515
6599
|
if (pathExists(readme_dst) && !force) {
|
|
6516
6600
|
skip("agents/overrides/README.md already exists (use --force to overwrite)");
|
|
6517
6601
|
} else {
|
|
@@ -6529,14 +6613,14 @@ function install_minimal(target_root_in, force, user_type = "") {
|
|
|
6529
6613
|
personal:
|
|
6530
6614
|
user_type: ${user_type}
|
|
6531
6615
|
`;
|
|
6532
|
-
mkdirp(
|
|
6616
|
+
mkdirp(path13.dirname(settings_dst));
|
|
6533
6617
|
writeText(settings_dst, body);
|
|
6534
6618
|
success(`Wrote ${SETTINGS_FILE} (user_type=${user_type})`);
|
|
6535
6619
|
}
|
|
6536
6620
|
}
|
|
6537
6621
|
const removed_marker = _remove_legacy_consumer_bridge_marker(target_root);
|
|
6538
6622
|
if (removed_marker !== null) {
|
|
6539
|
-
const rel = isRelativeTo(removed_marker, target_root) ?
|
|
6623
|
+
const rel = isRelativeTo(removed_marker, target_root) ? path13.relative(target_root, removed_marker) : removed_marker;
|
|
6540
6624
|
success(`Removed legacy bridge marker: ${rel}`);
|
|
6541
6625
|
}
|
|
6542
6626
|
_write_install_mode_marker(target_root, "minimal");
|
|
@@ -6610,7 +6694,7 @@ function run_interactive_init(project_root, force) {
|
|
|
6610
6694
|
);
|
|
6611
6695
|
return 0;
|
|
6612
6696
|
}
|
|
6613
|
-
const target =
|
|
6697
|
+
const target = path13.join(project_root, _LOCAL_CONFIG_FILE);
|
|
6614
6698
|
if (pathExists(target) && !force) {
|
|
6615
6699
|
warn(
|
|
6616
6700
|
`${_LOCAL_CONFIG_FILE} already exists; re-run with --force to overwrite. Skipping interactive init.`
|
|
@@ -6637,7 +6721,7 @@ function run_interactive_init(project_root, force) {
|
|
|
6637
6721
|
warn(`Could not write ${target}: ${String(exc)}`);
|
|
6638
6722
|
return 1;
|
|
6639
6723
|
}
|
|
6640
|
-
success(`Wrote ${
|
|
6724
|
+
success(`Wrote ${path13.relative(project_root, target)} (${user_type} / ${stack} / ${verbosity})`);
|
|
6641
6725
|
return 0;
|
|
6642
6726
|
}
|
|
6643
6727
|
var _WIZARD_READY_RE = /^WIZARD_READY (http:\/\/(?:127\.0\.0\.1|localhost):\d+\/\S*)\r?$/;
|
|
@@ -6655,12 +6739,12 @@ function _wizard_should_launch(opts) {
|
|
|
6655
6739
|
return [true, ""];
|
|
6656
6740
|
}
|
|
6657
6741
|
function _wizard_cli_dist(_project_root) {
|
|
6658
|
-
const package_root =
|
|
6659
|
-
const cli =
|
|
6742
|
+
const package_root = path13.dirname(path13.dirname(path13.dirname(resolvePath(_HERE))));
|
|
6743
|
+
const cli = path13.join(package_root, "dist", "cli", "agent-config.js");
|
|
6660
6744
|
return pathExists(cli) ? cli : null;
|
|
6661
6745
|
}
|
|
6662
6746
|
function _server_info_path() {
|
|
6663
|
-
return
|
|
6747
|
+
return path13.join(os3.homedir(), ".event4u", "agent-config", "local-server.json");
|
|
6664
6748
|
}
|
|
6665
6749
|
function _pid_is_agent_config(pid) {
|
|
6666
6750
|
let res;
|
|
@@ -6677,7 +6761,7 @@ function _pid_is_agent_config(pid) {
|
|
|
6677
6761
|
}
|
|
6678
6762
|
function unlinkMissingOk(p) {
|
|
6679
6763
|
try {
|
|
6680
|
-
|
|
6764
|
+
fs15.unlinkSync(p);
|
|
6681
6765
|
} catch {
|
|
6682
6766
|
}
|
|
6683
6767
|
}
|
|
@@ -6755,14 +6839,14 @@ function _wizard_spawn(project_root, pass_project_root = true) {
|
|
|
6755
6839
|
}
|
|
6756
6840
|
function _wizard_run_sync(cmd, env, cli) {
|
|
6757
6841
|
const total = _WIZARD_TIMEOUTS.reduce((a, b) => a + b, 0);
|
|
6758
|
-
const log_path =
|
|
6842
|
+
const log_path = path13.join(
|
|
6759
6843
|
os3.tmpdir(),
|
|
6760
6844
|
`agent-config-wizard-${process2.pid}-${Date.now()}.log`
|
|
6761
6845
|
);
|
|
6762
6846
|
let child;
|
|
6763
6847
|
let log_fd = null;
|
|
6764
6848
|
try {
|
|
6765
|
-
log_fd =
|
|
6849
|
+
log_fd = fs15.openSync(log_path, "w");
|
|
6766
6850
|
child = spawn(cmd[0], cmd.slice(1), {
|
|
6767
6851
|
env,
|
|
6768
6852
|
detached: true,
|
|
@@ -6780,7 +6864,7 @@ function _wizard_run_sync(cmd, env, cli) {
|
|
|
6780
6864
|
} finally {
|
|
6781
6865
|
if (log_fd !== null) {
|
|
6782
6866
|
try {
|
|
6783
|
-
|
|
6867
|
+
fs15.closeSync(log_fd);
|
|
6784
6868
|
} catch {
|
|
6785
6869
|
}
|
|
6786
6870
|
}
|
|
@@ -7030,8 +7114,8 @@ function main2(argv) {
|
|
|
7030
7114
|
const target_root = resolvePath(
|
|
7031
7115
|
opts.custom_path || opts.project || process2.env["PROJECT_ROOT"] || process2.cwd()
|
|
7032
7116
|
);
|
|
7033
|
-
const minimal_package_root =
|
|
7034
|
-
|
|
7117
|
+
const minimal_package_root = path13.dirname(
|
|
7118
|
+
path13.dirname(path13.dirname(_minimal_templates_root()))
|
|
7035
7119
|
);
|
|
7036
7120
|
const validated_user_type = _validate_user_type(minimal_package_root, opts.user_type);
|
|
7037
7121
|
return install_minimal(target_root, opts.force, validated_user_type);
|
|
@@ -7067,7 +7151,7 @@ function main2(argv) {
|
|
|
7067
7151
|
return rc2;
|
|
7068
7152
|
}
|
|
7069
7153
|
const project_root = custom_path || resolvePath(opts.project || process2.env["PROJECT_ROOT"] || process2.cwd());
|
|
7070
|
-
const is_first_run = !pathExists(
|
|
7154
|
+
const is_first_run = !pathExists(path13.join(project_root, SETTINGS_FILE));
|
|
7071
7155
|
tracker.begin(project_root);
|
|
7072
7156
|
let rc = _main_project_install(opts, project_root, parsed_tools, is_first_run);
|
|
7073
7157
|
if (rc === 0 && opts.interactive) {
|
|
@@ -7133,16 +7217,16 @@ function _team_setup_hint_line(project_root) {
|
|
|
7133
7217
|
return " \u2022 Claude Code team mode (optional cross-model review via the official codex plugin): run `agent-config doctor --check team` for setup status.";
|
|
7134
7218
|
}
|
|
7135
7219
|
function finalize_claude_model_tiers(project_root) {
|
|
7136
|
-
const claude_skills =
|
|
7137
|
-
const augment_skills =
|
|
7220
|
+
const claude_skills = path13.join(project_root, ".claude", "skills");
|
|
7221
|
+
const augment_skills = path13.join(project_root, ".augment", "skills");
|
|
7138
7222
|
if (!isDir(claude_skills) || !isDir(augment_skills)) return 0;
|
|
7139
7223
|
if (_read_consumer_auto_switch(project_root) !== "auto") return 0;
|
|
7140
7224
|
let rendered = 0;
|
|
7141
|
-
const entries =
|
|
7225
|
+
const entries = fs15.readdirSync(claude_skills).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
7142
7226
|
for (const name of entries) {
|
|
7143
|
-
const entry =
|
|
7144
|
-
const src_dir =
|
|
7145
|
-
const src_md =
|
|
7227
|
+
const entry = path13.join(claude_skills, name);
|
|
7228
|
+
const src_dir = path13.join(augment_skills, name);
|
|
7229
|
+
const src_md = path13.join(src_dir, "SKILL.md");
|
|
7146
7230
|
let tier;
|
|
7147
7231
|
try {
|
|
7148
7232
|
tier = read_model_tier(src_md);
|
|
@@ -7151,22 +7235,22 @@ function finalize_claude_model_tiers(project_root) {
|
|
|
7151
7235
|
}
|
|
7152
7236
|
if (tier === null || !(tier in TIER_TO_CLAUDE_MODEL) || !isDir(src_dir)) continue;
|
|
7153
7237
|
if (isSymlink(entry) || isFile(entry)) {
|
|
7154
|
-
|
|
7238
|
+
fs15.unlinkSync(entry);
|
|
7155
7239
|
} else if (isDir(entry)) {
|
|
7156
|
-
|
|
7240
|
+
fs15.rmSync(entry, { recursive: true, force: true });
|
|
7157
7241
|
}
|
|
7158
7242
|
mkdirp(entry);
|
|
7159
|
-
const srcFiles =
|
|
7243
|
+
const srcFiles = fs15.readdirSync(src_dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
7160
7244
|
for (const fname of srcFiles) {
|
|
7161
7245
|
if (fname === "SKILL.md") {
|
|
7162
7246
|
writeText(
|
|
7163
|
-
|
|
7247
|
+
path13.join(entry, "SKILL.md"),
|
|
7164
7248
|
render_native_model_md(readText(src_md), tier)
|
|
7165
7249
|
);
|
|
7166
7250
|
} else {
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7251
|
+
fs15.symlinkSync(
|
|
7252
|
+
path13.join("../../../.augment/skills", name, fname),
|
|
7253
|
+
path13.join(entry, fname)
|
|
7170
7254
|
);
|
|
7171
7255
|
}
|
|
7172
7256
|
}
|
|
@@ -7184,7 +7268,7 @@ function _main_project_install(opts, project_root, parsed_tools, is_first_run) {
|
|
|
7184
7268
|
let package_type;
|
|
7185
7269
|
if (opts.package) {
|
|
7186
7270
|
package_root = resolvePath(opts.package);
|
|
7187
|
-
if (!pathExists(
|
|
7271
|
+
if (!pathExists(path13.join(package_root, "src", "config", "profiles", "minimal.ini"))) {
|
|
7188
7272
|
fail(`Invalid --package path (missing src/config/profiles/minimal.ini): ${package_root}`);
|
|
7189
7273
|
}
|
|
7190
7274
|
package_type = detect_package_type_for_project(project_root, package_root);
|
|
@@ -7327,9 +7411,9 @@ function _main_project_install(opts, project_root, parsed_tools, is_first_run) {
|
|
|
7327
7411
|
function _resolvedArgv1() {
|
|
7328
7412
|
if (process2.argv[1] === void 0) return void 0;
|
|
7329
7413
|
try {
|
|
7330
|
-
return
|
|
7414
|
+
return fs15.realpathSync(path13.resolve(process2.argv[1]));
|
|
7331
7415
|
} catch {
|
|
7332
|
-
return
|
|
7416
|
+
return path13.resolve(process2.argv[1]);
|
|
7333
7417
|
}
|
|
7334
7418
|
}
|
|
7335
7419
|
var _argv1 = _resolvedArgv1();
|