@event4u/agent-config 17.2.1 → 17.4.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.
Files changed (225) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/.claude-plugin/skills/install-agent-config/SKILL.md +9 -9
  5. package/CHANGELOG.md +167 -193
  6. package/CREDITS.md +2 -2
  7. package/README.md +1 -1
  8. package/dist/agent-src/skills/code-intelligence/SKILL.md +16 -12
  9. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  10. package/dist/agent-src/templates/scripts/check_memory.ts +1 -1
  11. package/dist/cli/commands/recordTriggerEval.js +1 -1
  12. package/dist/cli/registry.js +2 -2
  13. package/dist/cli-delegate/{chunk-KR5ZIFPO.js → chunk-5AYJGUA3.js} +1 -3
  14. package/dist/cli-delegate/chunk-DIFZBP4G.js +1336 -0
  15. package/dist/cli-delegate/chunk-E7ACTJTJ.js +6792 -0
  16. package/dist/cli-delegate/{chunk-VYZGJLCA.js → chunk-RKNT4LIK.js} +22 -1286
  17. package/dist/cli-delegate/{chunk-BZJ4Y3CI.js → chunk-WY5ZZPGL.js} +2 -2
  18. package/dist/cli-delegate/{chunk-CMZEKSNN.js → chunk-X6LZ7W5A.js} +73 -10
  19. package/dist/cli-delegate/cmd_conformance.js +190 -192
  20. package/dist/cli-delegate/cmd_doctor.js +5 -5
  21. package/dist/cli-delegate/cmd_doctor_neighbours.js +3 -3
  22. package/dist/cli-delegate/cmd_explain.js +1 -1
  23. package/dist/cli-delegate/cmd_export.js +2 -2
  24. package/dist/cli-delegate/cmd_handoff.js +2 -2
  25. package/dist/cli-delegate/cmd_memory_get.js +1 -1
  26. package/dist/cli-delegate/cmd_prune.js +2 -2
  27. package/dist/cli-delegate/cmd_route_audit.js +1 -1
  28. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  29. package/dist/cli-delegate/cmd_settings_migrate.js +2 -2
  30. package/dist/cli-delegate/cmd_settings_set.js +8 -4
  31. package/dist/cli-delegate/cmd_sync.js +2 -2
  32. package/dist/cli-delegate/cmd_uninstall.js +2 -2
  33. package/dist/cli-delegate/cmd_update.js +24 -13
  34. package/dist/cli-delegate/cmd_upgrade.js +2 -2
  35. package/dist/cli-delegate/cmd_validate.js +2 -2
  36. package/dist/cli-delegate/dist-25AZAHOP.js +3240 -0
  37. package/dist/cli-delegate/dist-P7MFPMF3.js +411 -0
  38. package/dist/cli-delegate/dist-XAS5ZLQB.js +6 -0
  39. package/dist/cli-delegate/{upgrade_unattended-VVL6JLSX.js → upgrade_unattended-QCWOKTUN.js} +178 -163
  40. package/dist/discovery/deprecation-report.md +1 -1
  41. package/dist/discovery/discovery-manifest.json +3 -3
  42. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  43. package/dist/discovery/discovery-manifest.summary.md +1 -1
  44. package/dist/discovery/dormancy-report.md +1 -1
  45. package/dist/discovery/orphan-report.md +1 -1
  46. package/dist/discovery/packs.json +2 -2
  47. package/dist/discovery/trust-report.md +1 -1
  48. package/dist/discovery/workspaces.json +2 -2
  49. package/dist/hooks/code_graph_refresh.chunk.cjs +443 -0
  50. package/dist/hooks/code_graph_refresh.chunk.cjs.sha256 +1 -0
  51. package/dist/hooks/dispatch.js +1001 -938
  52. package/dist/hooks/dispatch.sha256 +1 -1
  53. package/dist/hooks/egress_engine.chunk.cjs +57 -7
  54. package/dist/hooks/egress_engine.chunk.cjs.sha256 +1 -1
  55. package/dist/hooks/update_notice.chunk.cjs +914 -0
  56. package/dist/hooks/update_notice.chunk.cjs.sha256 +1 -0
  57. package/dist/install/install.mjs +6974 -6037
  58. package/dist/mcp/mcp-cloudflare-catalogue.json +1 -0
  59. package/dist/mcp/registry-manifest.json +3 -2
  60. package/dist/mcp/server.json +13 -4
  61. package/dist/mcp/server.mjs +71202 -63282
  62. package/dist/scripts/_lib/egress_rules.js +8 -2
  63. package/dist/scripts/condense.js +18 -15
  64. package/dist/server/routes/discovery.js +1 -1
  65. package/dist/server/routes/install.js +1 -1
  66. package/dist/server/routes/ping.js +1 -1
  67. package/dist/server/routes/schema.js +4 -4
  68. package/dist/server/routes/settings.js +2 -6
  69. package/dist/server/routes/wizard.js +6 -6
  70. package/dist/server/schemas/settings.js +42 -42
  71. package/dist/shared/settingsSurface.js +1 -1
  72. package/dist/shared/userMd/schema.js +1 -1
  73. package/dist/shared/zodJsonSchema.js +47 -0
  74. package/dist/ui/assets/index-B0bcIgi0.js +77 -0
  75. package/dist/ui/index.html +1 -1
  76. package/package.json +6 -3
  77. package/src/agent-src/templates/scripts/check_memory.ts +1 -1
  78. package/src/config/ci-local-parity.yml +11 -0
  79. package/src/config/continuity-surface.json +9 -2
  80. package/src/config/evaluator-budgets.json +9 -8
  81. package/src/config/gate-violation-baselines.json +3 -3
  82. package/src/config/gitignore-block.txt +6 -5
  83. package/src/config/hook-bundle-budget.json +46 -6
  84. package/src/config/pack-size-budget.json +12 -1
  85. package/src/config/packed-binary-manifest.json +18 -0
  86. package/src/config/sigstore/npm_keys.json +50 -0
  87. package/src/config/sigstore/trust-material.json +9 -0
  88. package/src/config/sigstore/trusted_root.json +126 -0
  89. package/src/config/skill-body-budget.json +7 -1
  90. package/src/scripts/_cli/cmd_settings_set.ts +3 -2
  91. package/src/scripts/_cli/cmd_update.ts +48 -20
  92. package/src/scripts/_cli/cmd_upgrade.ts +7 -1
  93. package/src/scripts/_cli/upgrade_unattended.ts +90 -76
  94. package/src/scripts/_dispatch.bash +4 -3
  95. package/src/scripts/_lib/confusables.ts +0 -19
  96. package/src/scripts/_lib/egress_normalize.ts +53 -23
  97. package/src/scripts/_lib/egress_rules.ts +8 -2
  98. package/src/scripts/_lib/egress_text.ts +5 -3
  99. package/src/scripts/_lib/egress_token.ts +7 -5
  100. package/src/scripts/_lib/gate_collector_experimental.ts +633 -0
  101. package/src/scripts/_lib/git_common_dir.ts +10 -0
  102. package/src/scripts/_lib/graph_feeder_record.ts +3 -2
  103. package/src/scripts/_lib/install_reach_checks.ts +32 -2
  104. package/src/scripts/_lib/lineage_backfill.ts +136 -0
  105. package/src/scripts/_lib/lineage_ledger.ts +211 -0
  106. package/src/scripts/_lib/lineage_map.ts +55 -0
  107. package/src/scripts/_lib/lineage_query.ts +140 -0
  108. package/src/scripts/_lib/lineage_seed.ts +116 -0
  109. package/src/scripts/_lib/lineage_watch.ts +249 -0
  110. package/src/scripts/_lib/link_crypto.ts +8 -4
  111. package/src/scripts/_lib/listing_manifests.ts +85 -0
  112. package/src/scripts/_lib/neighbour_census.ts +1 -0
  113. package/src/scripts/_lib/production_reach.ts +3 -3
  114. package/src/scripts/_lib/project_registry.ts +227 -0
  115. package/src/scripts/_lib/provenance_verify.ts +14 -242
  116. package/src/scripts/_lib/release_settings_surface.ts +2 -6
  117. package/src/scripts/_lib/sigstore_provenance.ts +177 -0
  118. package/src/scripts/_lib/source_id.ts +48 -0
  119. package/src/scripts/_lib/source_shape.ts +4 -0
  120. package/src/scripts/_lib/unattended_gates.ts +6 -1
  121. package/src/scripts/adoption_status.ts +231 -27
  122. package/src/scripts/advisories.ts +26 -10
  123. package/src/scripts/ai_council/council_egress.ts +5 -6
  124. package/src/scripts/bench_graph_feeder_latency.ts +10 -3
  125. package/src/scripts/build_mcp_registry_manifest.ts +23 -12
  126. package/src/scripts/check_dependency_floors.ts +14 -0
  127. package/src/scripts/check_egress_mutations.ts +1 -0
  128. package/src/scripts/check_release_manifest_content.ts +17 -2
  129. package/src/scripts/check_release_pr_shape.ts +5 -0
  130. package/src/scripts/code_graph/build.ts +145 -45
  131. package/src/scripts/code_graph/cli.ts +382 -35
  132. package/src/scripts/code_graph/conventions_default.ts +247 -0
  133. package/src/scripts/code_graph/detect.ts +5 -5
  134. package/src/scripts/code_graph/estate_cli.ts +135 -0
  135. package/src/scripts/code_graph/estate_index.ts +394 -0
  136. package/src/scripts/code_graph/estate_manifests.ts +223 -0
  137. package/src/scripts/code_graph/estate_map.ts +141 -0
  138. package/src/scripts/code_graph/extract.ts +8 -2
  139. package/src/scripts/code_graph/extract_more.ts +241 -2
  140. package/src/scripts/code_graph/graph_budget.ts +158 -0
  141. package/src/scripts/code_graph/graph_home.ts +80 -0
  142. package/src/scripts/code_graph/lineage_cli.ts +315 -0
  143. package/src/scripts/code_graph/loader.ts +10 -2
  144. package/src/scripts/code_graph/map.ts +195 -53
  145. package/src/scripts/code_graph/map_model.ts +113 -20
  146. package/src/scripts/code_graph/map_verify.ts +80 -5
  147. package/src/scripts/code_graph/map_viewer/viewer.css +18 -0
  148. package/src/scripts/code_graph/map_viewer/viewer.js +146 -15
  149. package/src/scripts/code_graph/passes.ts +173 -0
  150. package/src/scripts/code_graph/project_ref.ts +25 -0
  151. package/src/scripts/code_graph/projects_cli.ts +254 -0
  152. package/src/scripts/code_graph/providers/angular.ts +55 -0
  153. package/src/scripts/code_graph/providers/aspnetcore.ts +182 -0
  154. package/src/scripts/code_graph/providers/catalog.ts +299 -0
  155. package/src/scripts/code_graph/providers/django.ts +206 -0
  156. package/src/scripts/code_graph/providers/express.ts +25 -0
  157. package/src/scripts/code_graph/providers/fastapi.ts +49 -0
  158. package/src/scripts/code_graph/providers/flask.ts +99 -0
  159. package/src/scripts/code_graph/providers/go_http.ts +121 -0
  160. package/src/scripts/code_graph/providers/index.ts +103 -0
  161. package/src/scripts/code_graph/{laravel_overlay.ts → providers/laravel.ts} +113 -7
  162. package/src/scripts/code_graph/providers/nestjs.ts +34 -0
  163. package/src/scripts/code_graph/providers/nextjs.ts +91 -0
  164. package/src/scripts/code_graph/providers/nuxt.ts +55 -0
  165. package/src/scripts/code_graph/providers/rails.ts +204 -0
  166. package/src/scripts/code_graph/providers/react-router.ts +58 -0
  167. package/src/scripts/code_graph/providers/shared/detect.ts +78 -0
  168. package/src/scripts/code_graph/providers/shared/extractors.ts +249 -0
  169. package/src/scripts/code_graph/providers/shared/js.ts +252 -0
  170. package/src/scripts/code_graph/providers/shared/kit.ts +210 -0
  171. package/src/scripts/code_graph/providers/shared/php.ts +64 -0
  172. package/src/scripts/code_graph/providers/shared/python.ts +223 -0
  173. package/src/scripts/code_graph/providers/spring.ts +175 -0
  174. package/src/scripts/code_graph/providers/sqlalchemy.ts +62 -0
  175. package/src/scripts/code_graph/providers/sveltekit.ts +59 -0
  176. package/src/scripts/code_graph/providers/symfony.ts +142 -0
  177. package/src/scripts/code_graph/providers/typeorm.ts +58 -0
  178. package/src/scripts/code_graph/providers/types.ts +56 -0
  179. package/src/scripts/code_graph/providers/vue-router.ts +21 -0
  180. package/src/scripts/code_graph/providers/wordpress.ts +128 -0
  181. package/src/scripts/code_graph/query.ts +9 -9
  182. package/src/scripts/code_graph/refresh_cli.ts +81 -0
  183. package/src/scripts/code_graph/refresh_lock.ts +197 -0
  184. package/src/scripts/code_graph/repo_identity.ts +169 -0
  185. package/src/scripts/code_graph/resolution_tiers.ts +19 -7
  186. package/src/scripts/code_graph/scip_reader.ts +2 -2
  187. package/src/scripts/code_graph/sqlite_store.ts +31 -28
  188. package/src/scripts/code_graph/types.ts +79 -41
  189. package/src/scripts/code_graph/validate.ts +6 -8
  190. package/src/scripts/condense.ts +15 -15
  191. package/src/scripts/generate_settings_reference.ts +2 -6
  192. package/src/scripts/hook_chunks.mjs +11 -0
  193. package/src/scripts/hook_manifest.json +1 -1
  194. package/src/scripts/hook_manifest.yaml +43 -23
  195. package/src/scripts/hooks/code_graph_refresh_hook.ts +163 -0
  196. package/src/scripts/hooks/dispatch_hook.ts +6 -7
  197. package/src/scripts/hooks/host_semantics.ts +72 -0
  198. package/src/scripts/hooks/lazy_concern.ts +8 -0
  199. package/src/scripts/hooks/user_notice.ts +105 -0
  200. package/src/scripts/install-hooks.sh +54 -33
  201. package/src/scripts/install.ts +2 -6
  202. package/src/scripts/lint_harvest_provenance.ts +137 -11
  203. package/src/scripts/lint_hook_manifest.ts +2 -0
  204. package/src/scripts/lint_marketplace.ts +33 -0
  205. package/src/scripts/lint_mcp_registry_manifest.ts +36 -0
  206. package/src/scripts/mcp_server/consumer_tool_catalog.json +70 -15
  207. package/src/scripts/mcp_server/graph_tools.ts +165 -41
  208. package/src/scripts/network_sources.ts +24 -6
  209. package/src/scripts/release.ts +2 -5
  210. package/src/scripts/release_drill.ts +4 -1
  211. package/src/scripts/release_env.ts +17 -0
  212. package/src/scripts/release_mix_taxonomy.json +3 -0
  213. package/src/scripts/schemas/provenance-mechanism.schema.json +46 -0
  214. package/src/scripts/update_notice_hook.ts +75 -7
  215. package/src/server/schemas/settings.ts +42 -42
  216. package/src/shared/settingsSurface.ts +1 -1
  217. package/src/shared/userMd/schema.ts +1 -1
  218. package/src/shared/zodJsonSchema.ts +41 -0
  219. package/src/vendor/grammars/README.md +8 -6
  220. package/src/vendor/grammars/tree-sitter-c_sharp.wasm +0 -0
  221. package/src/vendor/grammars/tree-sitter-ruby.wasm +0 -0
  222. package/dist/cli-delegate/chunk-XIAPY44N.js +0 -4587
  223. package/dist/ui/assets/index-w70Ado09.js +0 -23
  224. /package/dist/cli-delegate/{chunk-FKYZOWVD.js → chunk-QBAFP67O.js} +0 -0
  225. /package/dist/cli-delegate/{chunk-BMGUGSY6.js → chunk-TQG6UMPC.js} +0 -0
@@ -0,0 +1,443 @@
1
+ #!/usr/bin/env tsx
2
+ const __acChunkMetaUrl = require('node:url').pathToFileURL(__filename).href; const __acChunkMeta = { url: __acChunkMetaUrl, dirname: __dirname, filename: __filename };
3
+ "use strict";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/scripts/hooks/code_graph_refresh_hook.ts
33
+ var code_graph_refresh_hook_exports = {};
34
+ __export(code_graph_refresh_hook_exports, {
35
+ REFRESH_ARGS: () => REFRESH_ARGS,
36
+ main: () => main,
37
+ refreshFor: () => refreshFor,
38
+ repoRoot: () => repoRoot,
39
+ resolveCli: () => resolveCli
40
+ });
41
+ module.exports = __toCommonJS(code_graph_refresh_hook_exports);
42
+ var import_node_child_process = require("node:child_process");
43
+ var fs5 = __toESM(require("node:fs"), 1);
44
+ var path5 = __toESM(require("node:path"), 1);
45
+ var import_node_url = require("node:url");
46
+
47
+ // src/scripts/_lib/spawn_env.ts
48
+ var DENY_EXACT = /* @__PURE__ */ new Set([
49
+ // dynamic loader
50
+ "LD_PRELOAD",
51
+ "LD_LIBRARY_PATH",
52
+ "LD_AUDIT",
53
+ "DYLD_INSERT_LIBRARIES",
54
+ "DYLD_LIBRARY_PATH",
55
+ "DYLD_FRAMEWORK_PATH",
56
+ "GCONV_PATH",
57
+ // git command-injection
58
+ "GIT_EXTERNAL_DIFF",
59
+ "GIT_SSH",
60
+ "GIT_SSH_COMMAND",
61
+ "GIT_PROXY_COMMAND",
62
+ "GIT_PAGER",
63
+ "PAGER",
64
+ // git config-injection: GIT_ALTERNATE_OBJECT_DIRECTORIES can point git at
65
+ // attacker-controlled object stores; the GIT_CONFIG* family is handled by
66
+ // prefix below (it is a general arbitrary-config-injection primitive).
67
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
68
+ // git path-redirection: GIT_DIR / GIT_INDEX_FILE / GIT_NAMESPACE point a
69
+ // child's git at an attacker-controlled repo, index file, or ref namespace
70
+ // — ordinary git ops then read and write attacker state (low severity,
71
+ // same family as GIT_ALTERNATE_OBJECT_DIRECTORIES above).
72
+ "GIT_DIR",
73
+ "GIT_INDEX_FILE",
74
+ "GIT_NAMESPACE",
75
+ // resolver hijack: HOSTALIASES remaps hostnames via an attacker file,
76
+ // redirecting any network fetch the child performs (CWE-427-adjacent).
77
+ "HOSTALIASES",
78
+ // runtime auto-exec hooks
79
+ "NODE_OPTIONS",
80
+ "BASH_ENV",
81
+ "ENV",
82
+ "PYTHONPATH",
83
+ "PYTHONSTARTUP",
84
+ "PYTHONINSPECT",
85
+ "PERL5OPT",
86
+ "PERL5LIB",
87
+ "RUBYOPT",
88
+ // shell field-splitting
89
+ "IFS"
90
+ ]);
91
+ function isDeniedByFamily(name) {
92
+ if (name.startsWith("LD_") || name.startsWith("DYLD_")) return true;
93
+ if (name.startsWith("GIT_") && name.endsWith("_COMMAND")) return true;
94
+ if (name === "GIT_CONFIG" || name.startsWith("GIT_CONFIG_")) return true;
95
+ return false;
96
+ }
97
+ function hardenedSpawnEnv(overrides = {}) {
98
+ const out = {};
99
+ for (const [key, value] of Object.entries(process.env)) {
100
+ if (value === void 0) continue;
101
+ if (DENY_EXACT.has(key)) continue;
102
+ if (isDeniedByFamily(key)) continue;
103
+ out[key] = value;
104
+ }
105
+ for (const [key, value] of Object.entries(overrides)) {
106
+ out[key] = value;
107
+ }
108
+ return out;
109
+ }
110
+
111
+ // src/scripts/code_graph/refresh_cli.ts
112
+ var fs = __toESM(require("node:fs"), 1);
113
+ var path = __toESM(require("node:path"), 1);
114
+ var CAPABILITY_FILE = "src/scripts/code_graph/refresh_lock.ts";
115
+ function resolveCli(root, envPath = process.env["PATH"] ?? "") {
116
+ let realRoot;
117
+ try {
118
+ realRoot = fs.realpathSync(root);
119
+ } catch {
120
+ return null;
121
+ }
122
+ const inside = (p) => {
123
+ const rel = path.relative(realRoot, p);
124
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
125
+ };
126
+ for (const dir of envPath.split(path.delimiter)) {
127
+ if (!path.isAbsolute(dir)) continue;
128
+ const candidate = path.join(dir, "agent-config");
129
+ try {
130
+ fs.accessSync(candidate, fs.constants.X_OK);
131
+ const real = fs.realpathSync(candidate);
132
+ if (fs.statSync(real).isFile() && !inside(real) && !inside(path.resolve(dir))) return candidate;
133
+ } catch {
134
+ }
135
+ }
136
+ return null;
137
+ }
138
+ function cliPackage(cli) {
139
+ try {
140
+ for (let dir = path.dirname(fs.realpathSync(cli)); dir !== path.dirname(dir); dir = path.dirname(dir)) {
141
+ const file = path.join(dir, "package.json");
142
+ if (!fs.existsSync(file)) continue;
143
+ const pkg = JSON.parse(fs.readFileSync(file, "utf-8"));
144
+ if (pkg.name === "@event4u/agent-config") return { root: dir, version: pkg.version ?? "?" };
145
+ }
146
+ } catch {
147
+ }
148
+ return null;
149
+ }
150
+ function cliIsCapable(cli) {
151
+ const pkg = cliPackage(cli);
152
+ return pkg !== null && fs.existsSync(path.join(pkg.root, CAPABILITY_FILE));
153
+ }
154
+ function usableCli(root, envPath) {
155
+ const cli = resolveCli(root, envPath);
156
+ if (cli === null) return { reason: "no-cli" };
157
+ return cliIsCapable(cli) ? { cli } : { reason: "cli-too-old", cli };
158
+ }
159
+
160
+ // src/scripts/code_graph/graph_home.ts
161
+ var fs2 = __toESM(require("node:fs"), 1);
162
+ var path3 = __toESM(require("node:path"), 1);
163
+
164
+ // src/scripts/_lib/user_global_paths.ts
165
+ var path2 = __toESM(require("node:path"), 1);
166
+ var DEFAULT_EVENT4U_ROOT_RELATIVE = path2.join(".event4u", "agent-config");
167
+ var LEGACY_XDG_ROOT_RELATIVE = path2.join(".config", "agent-config");
168
+
169
+ // src/scripts/code_graph/graph_home.ts
170
+ var STATE_DIR_REL = path3.join("agents", "runtime", "state");
171
+ var NATIVE_CACHE_REL = path3.join(STATE_DIR_REL, "code-graph-v1.json");
172
+ var MAP_DIR_REL = path3.join("agents", "map");
173
+ var LOCK_REL = path3.join(STATE_DIR_REL, "code-graph-refresh.lock");
174
+ var AUTO_REFRESH_REL = path3.join(STATE_DIR_REL, "code-graph-auto-refresh.json");
175
+ function hasProjectHome(root) {
176
+ return fs2.existsSync(path3.join(root, "agents")) || fs2.existsSync(path3.join(root, ".agent-settings.yml"));
177
+ }
178
+ function projectHome(root) {
179
+ return {
180
+ kind: "project",
181
+ root,
182
+ dir: path3.join(root, "agents"),
183
+ stateDir: path3.join(root, STATE_DIR_REL),
184
+ cachePath: path3.join(root, NATIVE_CACHE_REL),
185
+ mapDir: path3.join(root, MAP_DIR_REL),
186
+ lockPath: path3.join(root, LOCK_REL),
187
+ autoRefreshPath: path3.join(root, AUTO_REFRESH_REL),
188
+ repoId: null,
189
+ instance: null
190
+ };
191
+ }
192
+
193
+ // src/scripts/code_graph/refresh_lock.ts
194
+ var fs3 = __toESM(require("node:fs"), 1);
195
+ var os = __toESM(require("node:os"), 1);
196
+ var path4 = __toESM(require("node:path"), 1);
197
+ var STALE_LOCK_MS = 5 * 60 * 1e3;
198
+ var MAX_LOCK_AGE_MS = 30 * 60 * 1e3;
199
+ var ownerPath = (lock) => `${lock}.owner.json`;
200
+ function recordRefreshIn(stateDir, rec) {
201
+ try {
202
+ fs3.writeFileSync(path4.join(stateDir, `code-graph-refresh.${rec.by}.json`), JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), ...rec }));
203
+ } catch {
204
+ }
205
+ }
206
+ function pidAlive(pid) {
207
+ try {
208
+ process.kill(pid, 0);
209
+ return true;
210
+ } catch (e) {
211
+ return e.code === "EPERM";
212
+ }
213
+ }
214
+ var errno = (e) => e.code;
215
+ function readOwner(lock) {
216
+ let raw;
217
+ try {
218
+ raw = fs3.readFileSync(ownerPath(lock), "utf-8");
219
+ } catch (e) {
220
+ return errno(e) === "ENOENT" ? "none" : "unreadable";
221
+ }
222
+ try {
223
+ const o = JSON.parse(raw);
224
+ if (typeof o.pid === "number" && typeof o.started_at === "number" && typeof o.nonce === "string") return o;
225
+ } catch {
226
+ }
227
+ return "none";
228
+ }
229
+ function isStale(lock, now = Date.now()) {
230
+ const owner = readOwner(lock);
231
+ if (owner === "unreadable") return false;
232
+ if (owner !== "none") {
233
+ if (owner.host !== os.hostname()) return now - owner.started_at > MAX_LOCK_AGE_MS;
234
+ return !pidAlive(owner.pid);
235
+ }
236
+ try {
237
+ return now - fs3.statSync(lock).mtimeMs > STALE_LOCK_MS;
238
+ } catch (e) {
239
+ return errno(e) === "ENOENT";
240
+ }
241
+ }
242
+
243
+ // src/scripts/hooks/exit_codes.ts
244
+ var EXIT_ALLOW = 0;
245
+ var EXIT_BLOCK = 1;
246
+ var EXIT_WARN = 2;
247
+ var EXIT_ERROR = 3;
248
+ var EXIT_CODES = Object.freeze([
249
+ Object.freeze({
250
+ code: EXIT_ALLOW,
251
+ name: "allow",
252
+ meaning: "no objection; the dispatcher passes the call through",
253
+ owner: "every concern \u2014 the default verdict",
254
+ authorizedBy: "nothing; allowing needs no authority"
255
+ }),
256
+ Object.freeze({
257
+ code: EXIT_BLOCK,
258
+ name: "block",
259
+ meaning: "refuse the call; the dispatcher lowers this onto the host deny channel",
260
+ owner: "a concern declared `severity: blocking` in hook_manifest.yaml",
261
+ authorizedBy: "the manifest entry plus its row in the BLOCKING_ALLOWLIST of tests/hooks/concern_severity.test.ts \u2014 an advisory concern emitting this is downgraded to warn by dispatch_hook._is_advisory"
262
+ }),
263
+ Object.freeze({
264
+ code: EXIT_WARN,
265
+ name: "warn",
266
+ meaning: "advisory; the dispatcher exits 0 and surfaces the reason",
267
+ owner: "any concern",
268
+ authorizedBy: "nothing; warning is the ceiling for an advisory concern and is always available to a blocking one"
269
+ }),
270
+ Object.freeze({
271
+ code: EXIT_ERROR,
272
+ name: "error",
273
+ meaning: "the concern crashed, timed out, or could not decide \u2014 any rc >= 3. The dispatcher resolves it by the concern`s declared severity, never by the number itself",
274
+ owner: "no concern emits this on purpose; the runtime does",
275
+ authorizedBy: "hook_manifest.yaml `severity` alone \u2014 blocking refuses, anything else fails open; `fail_closed` is no longer read on this branch. See docs/contracts/hook-architecture-v1.md \xA7 Exit-code semantics"
276
+ })
277
+ ]);
278
+
279
+ // src/scripts/hooks/hook_stdin.ts
280
+ var tty = __toESM(require("node:tty"), 1);
281
+
282
+ // src/scripts/_lib/stdin.ts
283
+ var fs4 = __toESM(require("node:fs"), 1);
284
+ var CHUNK = 64 * 1024;
285
+ var RETRY_SLEEP_MS = 5;
286
+ var MAX_RETRIES = 2e3;
287
+ function _sleepSync(ms) {
288
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
289
+ }
290
+ function readStdinText(fd = 0, opts = {}) {
291
+ const chunks = [];
292
+ const buf = Buffer.alloc(CHUNK);
293
+ let retries = 0;
294
+ let got_any = false;
295
+ const first_byte_deadline = opts.firstByteTimeoutMs === void 0 ? null : Date.now() + opts.firstByteTimeoutMs;
296
+ for (; ; ) {
297
+ let read;
298
+ try {
299
+ read = fs4.readSync(fd, buf, 0, CHUNK, null);
300
+ retries = 0;
301
+ } catch (exc) {
302
+ const code = exc.code;
303
+ if (code === "EAGAIN") {
304
+ if (!got_any && first_byte_deadline !== null && Date.now() >= first_byte_deadline) {
305
+ return "";
306
+ }
307
+ retries += 1;
308
+ if (retries > MAX_RETRIES) {
309
+ throw new Error(
310
+ `readStdinText: stdin stayed unreadable across ${String(MAX_RETRIES)} retries (~${String(MAX_RETRIES * RETRY_SLEEP_MS / 1e3)}s). Refusing to report an empty read as empty input.`
311
+ );
312
+ }
313
+ _sleepSync(RETRY_SLEEP_MS);
314
+ continue;
315
+ }
316
+ if (code === "EOF") break;
317
+ throw exc;
318
+ }
319
+ if (read === 0) break;
320
+ got_any = true;
321
+ chunks.push(Buffer.from(buf.subarray(0, read)));
322
+ }
323
+ return Buffer.concat(chunks).toString("utf-8");
324
+ }
325
+
326
+ // src/scripts/hooks/hook_stdin.ts
327
+ var OVERRIDE_KEY = /* @__PURE__ */ Symbol.for("agent-config.hookStdinOverride");
328
+ function host() {
329
+ return globalThis;
330
+ }
331
+ var HOOK_FIRST_BYTE_TIMEOUT_MS = 25;
332
+ function readFd0ToEnd() {
333
+ void process.stdin;
334
+ return readStdinText(0, { firstByteTimeoutMs: HOOK_FIRST_BYTE_TIMEOUT_MS });
335
+ }
336
+ function readHookStdin() {
337
+ const override = host()[OVERRIDE_KEY];
338
+ if (override !== null && override !== void 0) return override;
339
+ try {
340
+ if (tty.isatty(0)) return "";
341
+ return readFd0ToEnd();
342
+ } catch {
343
+ return "";
344
+ }
345
+ }
346
+
347
+ // src/scripts/hooks/state_io.ts
348
+ var REPLAY_ENV_VAR = "AGENT_CONFIG_REPLAY";
349
+ function is_replay_mode() {
350
+ return (process.env[REPLAY_ENV_VAR] ?? "").trim() === "1";
351
+ }
352
+
353
+ // src/scripts/hooks/code_graph_refresh_hook.ts
354
+ var REFRESH_ARGS = ["code-graph", "refresh", "--single-flight", "--map", "--budget-seconds", "60"];
355
+ function repoRoot(start) {
356
+ let dir;
357
+ try {
358
+ dir = fs5.realpathSync(start);
359
+ } catch {
360
+ return null;
361
+ }
362
+ for (; ; ) {
363
+ try {
364
+ fs5.lstatSync(path5.join(dir, ".git"));
365
+ return dir;
366
+ } catch (e) {
367
+ if (e.code !== "ENOENT") return null;
368
+ }
369
+ const up = path5.dirname(dir);
370
+ if (up === dir) return null;
371
+ dir = up;
372
+ }
373
+ }
374
+ function anyTracked(root, rels) {
375
+ try {
376
+ const out = (0, import_node_child_process.execFileSync)("git", ["-C", root, "ls-files", "--", ...rels], {
377
+ encoding: "utf-8",
378
+ stdio: ["ignore", "pipe", "ignore"],
379
+ env: hardenedSpawnEnv()
380
+ });
381
+ return out.trim() !== "";
382
+ } catch {
383
+ return true;
384
+ }
385
+ }
386
+ function refreshFor(cwd, spawnFn = import_node_child_process.spawn) {
387
+ if (process.env["AGENT_CONFIG_CODE_GRAPH_REFRESH"] === "off") return "disabled";
388
+ if (process.platform === "win32") return "unsupported";
389
+ if (is_replay_mode()) return "replay";
390
+ const root = repoRoot(cwd);
391
+ if (root === null || !hasProjectHome(root)) return "not-opted-in";
392
+ const home = projectHome(root);
393
+ if (!fs5.existsSync(home.autoRefreshPath)) return "not-opted-in";
394
+ if (anyTracked(root, [home.autoRefreshPath, home.cachePath].map((p) => path5.relative(root, p)))) return "tracked";
395
+ const done = (outcome, detail) => {
396
+ recordRefreshIn(home.stateDir, { by: "session-start", outcome, detail });
397
+ return outcome;
398
+ };
399
+ if (!fs5.existsSync(home.cachePath)) return done("no-cache");
400
+ const lock = home.lockPath;
401
+ if (fs5.existsSync(lock) && !isStale(lock)) return done("locked");
402
+ const verdict = usableCli(root);
403
+ if ("reason" in verdict) return done(verdict.reason, verdict.cli);
404
+ const child = spawnFn(verdict.cli, [...REFRESH_ARGS, "--root", root], {
405
+ cwd: root,
406
+ detached: true,
407
+ stdio: "ignore",
408
+ env: hardenedSpawnEnv()
409
+ });
410
+ child.on("error", () => {
411
+ });
412
+ child.unref();
413
+ return done("spawned", verdict.cli);
414
+ }
415
+ function main() {
416
+ try {
417
+ const raw = readHookStdin();
418
+ const envelope = raw.trim() ? JSON.parse(raw) : {};
419
+ const cwd = typeof envelope["cwd"] === "string" && envelope["cwd"] ? envelope["cwd"] : process.cwd();
420
+ refreshFor(cwd);
421
+ } catch {
422
+ }
423
+ return EXIT_ALLOW;
424
+ }
425
+ function isCliEntry() {
426
+ if (true) return false;
427
+ if (process.argv[1] === void 0) return false;
428
+ if (__acChunkMetaUrl === (0, import_node_url.pathToFileURL)(path5.resolve(process.argv[1])).href) return true;
429
+ try {
430
+ return fs5.realpathSync((0, import_node_url.fileURLToPath)(__acChunkMetaUrl)) === fs5.realpathSync(path5.resolve(process.argv[1]));
431
+ } catch {
432
+ return false;
433
+ }
434
+ }
435
+ if (isCliEntry()) process.exit(main());
436
+ // Annotate the CommonJS export names for ESM import in node:
437
+ 0 && (module.exports = {
438
+ REFRESH_ARGS,
439
+ main,
440
+ refreshFor,
441
+ repoRoot,
442
+ resolveCli
443
+ });
@@ -0,0 +1 @@
1
+ fdef0100152bef370980295f03f85f4c6ea3bab4376cecda0c83479b6c97ed4b code_graph_refresh.chunk.cjs