@mmerterden/multi-agent-pipeline 23.3.0 → 23.5.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 (239) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +27 -8
  3. package/README.tr.md +28 -9
  4. package/SECURITY.md +16 -0
  5. package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
  6. package/docs/adr/0010-own-code-graph.md +299 -8
  7. package/docs/architecture.md +3 -3
  8. package/docs/ecosystem.md +10 -10
  9. package/docs/engineering.md +4 -4
  10. package/docs/facts.json +8 -8
  11. package/docs/features.md +5 -5
  12. package/docs/performance.md +17 -17
  13. package/install/_dev-only-files.mjs +9 -0
  14. package/install/_platform-filter.mjs +2 -55
  15. package/install/claude.mjs +28 -2
  16. package/install/codex.mjs +1 -3
  17. package/install/copilot.mjs +4 -8
  18. package/install/templates/claude-hooks.json +32 -1
  19. package/manifest.json +236 -167
  20. package/package.json +11 -3
  21. package/pipeline/commands/multi-agent/SKILL.md +1 -1
  22. package/pipeline/commands/multi-agent/design-check/SKILL.md +3 -2
  23. package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
  24. package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
  25. package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
  26. package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
  27. package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
  28. package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
  29. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  30. package/pipeline/contract/CHANGELOG.md +63 -0
  31. package/pipeline/contract/README.md +1 -0
  32. package/pipeline/contract/build.mjs +13 -1
  33. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  34. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  35. package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
  36. package/pipeline/contract/fixtures/runs-empty.json +1 -1
  37. package/pipeline/contract/fixtures/runs-failed.json +4 -1
  38. package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
  39. package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
  40. package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
  41. package/pipeline/contract/fixtures/runs-running.json +4 -1
  42. package/pipeline/contract/manifest.json +41 -15
  43. package/pipeline/contract/types/index.d.ts +81 -3
  44. package/pipeline/lib/detach-self.mjs +95 -0
  45. package/pipeline/lib/public-mcp-servers.mjs +33 -0
  46. package/pipeline/lib/rotated-log.mjs +93 -0
  47. package/pipeline/lib/stack-detect.sh +1 -1
  48. package/pipeline/lib/tls-trust.mjs +29 -0
  49. package/pipeline/lib/usage-lifecycle.mjs +9 -11
  50. package/pipeline/lib/usage-names.generated.mjs +613 -0
  51. package/pipeline/lib/usage-run-key.mjs +235 -0
  52. package/pipeline/lib/usage-vocab.mjs +210 -0
  53. package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
  54. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  55. package/pipeline/multi-agent-refs/channels/generator.md +4 -5
  56. package/pipeline/multi-agent-refs/cross-cli-contract.md +3 -3
  57. package/pipeline/multi-agent-refs/design-check/init-inventory.md +11 -1
  58. package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
  59. package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
  60. package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
  61. package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
  62. package/pipeline/multi-agent-refs/features/model-fallback.md +6 -4
  63. package/pipeline/multi-agent-refs/features/remote-control.md +253 -0
  64. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  65. package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
  66. package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
  67. package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
  68. package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
  69. package/pipeline/multi-agent-refs/features/usage-reporting.md +255 -27
  70. package/pipeline/multi-agent-refs/help/en.md +3 -2
  71. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  72. package/pipeline/multi-agent-refs/knowledge.md +1 -1
  73. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -2
  74. package/pipeline/multi-agent-refs/phases/operations.md +2 -2
  75. package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
  76. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  77. package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -0
  78. package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
  79. package/pipeline/multi-agent-refs/platform-parity.md +2 -2
  80. package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
  81. package/pipeline/office/index.html +1309 -236
  82. package/pipeline/office/toolkit.json +1 -1
  83. package/pipeline/rules/outside-the-pipeline.md +1 -1
  84. package/pipeline/schemas/activity.schema.json +23 -0
  85. package/pipeline/schemas/agent-state.schema.json +6 -1
  86. package/pipeline/schemas/code-graph-calls.schema.json +254 -0
  87. package/pipeline/schemas/code-graph-docs.schema.json +223 -0
  88. package/pipeline/schemas/code-graph-infra.schema.json +227 -0
  89. package/pipeline/schemas/code-graph.schema.json +2 -2
  90. package/pipeline/schemas/examples/design-check-config.json +27 -0
  91. package/pipeline/schemas/learning-curve.schema.json +67 -0
  92. package/pipeline/schemas/mcp-health.schema.json +96 -0
  93. package/pipeline/schemas/office-jobs.json +69 -2
  94. package/pipeline/schemas/office-jobs.schema.json +8 -1
  95. package/pipeline/schemas/phases.json +5 -0
  96. package/pipeline/schemas/phases.schema.json +8 -0
  97. package/pipeline/schemas/prefs.schema.json +46 -12
  98. package/pipeline/schemas/runs-index.schema.json +17 -0
  99. package/pipeline/schemas/toolkit-path-params.json +78 -8
  100. package/pipeline/scripts/README.md +1 -0
  101. package/pipeline/scripts/_code-graph.mjs +184 -103
  102. package/pipeline/scripts/_contract-core.mjs +1 -1
  103. package/pipeline/scripts/_contract-routes-office.mjs +33 -0
  104. package/pipeline/scripts/_diff-impact.mjs +21 -2
  105. package/pipeline/scripts/_graph-sidecars.mjs +372 -0
  106. package/pipeline/scripts/_http-post.mjs +103 -115
  107. package/pipeline/scripts/_safe-read.mjs +57 -0
  108. package/pipeline/scripts/_skill-practices.mjs +26 -0
  109. package/pipeline/scripts/_strip-code.mjs +380 -0
  110. package/pipeline/scripts/activity-snapshot.mjs +13 -1
  111. package/pipeline/scripts/aggregate-metrics.mjs +3 -5
  112. package/pipeline/scripts/build-stack-plugins.mjs +1 -47
  113. package/pipeline/scripts/call-graph/index.mjs +78 -0
  114. package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
  115. package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
  116. package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
  117. package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
  118. package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
  119. package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
  120. package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
  121. package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
  122. package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
  123. package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
  124. package/pipeline/scripts/call-graph/lex.mjs +396 -0
  125. package/pipeline/scripts/call-graph/platform.mjs +86 -0
  126. package/pipeline/scripts/call-graph/profiles.mjs +89 -0
  127. package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
  128. package/pipeline/scripts/call-graph/scan.mjs +267 -0
  129. package/pipeline/scripts/code-graph-rules/android.json +7 -2
  130. package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
  131. package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
  132. package/pipeline/scripts/code-graph-rules/go.json +2 -1
  133. package/pipeline/scripts/code-graph-rules/ios.json +3 -1
  134. package/pipeline/scripts/code-graph-rules/java.json +76 -0
  135. package/pipeline/scripts/code-graph-rules/node.json +7 -2
  136. package/pipeline/scripts/code-graph-rules/python.json +6 -2
  137. package/pipeline/scripts/code-graph-rules/rust.json +105 -0
  138. package/pipeline/scripts/contract-server.mjs +3 -0
  139. package/pipeline/scripts/design-check-config.mjs +205 -0
  140. package/pipeline/scripts/feedback-send.mjs +26 -26
  141. package/pipeline/scripts/gate-ledger.mjs +2 -1
  142. package/pipeline/scripts/gen-facts.mjs +1 -2
  143. package/pipeline/scripts/gen-usage-names.mjs +124 -0
  144. package/pipeline/scripts/graph-affected.mjs +109 -20
  145. package/pipeline/scripts/graph-build.mjs +95 -15
  146. package/pipeline/scripts/graph-export.mjs +272 -0
  147. package/pipeline/scripts/graph-hint.mjs +15 -2
  148. package/pipeline/scripts/graph-query.mjs +305 -26
  149. package/pipeline/scripts/graph-report.mjs +187 -1
  150. package/pipeline/scripts/health-report.mjs +3 -4
  151. package/pipeline/scripts/infra/docs.mjs +317 -0
  152. package/pipeline/scripts/infra/extract.mjs +998 -0
  153. package/pipeline/scripts/infra/graph.mjs +245 -0
  154. package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
  155. package/pipeline/scripts/job-launch.mjs +67 -2
  156. package/pipeline/scripts/learning-curve.mjs +288 -178
  157. package/pipeline/scripts/log-metric.sh +10 -1
  158. package/pipeline/scripts/mcp-health.mjs +309 -0
  159. package/pipeline/scripts/note-agent-event.mjs +3 -4
  160. package/pipeline/scripts/note-command-use.mjs +333 -0
  161. package/pipeline/scripts/note-command-use.sh +126 -0
  162. package/pipeline/scripts/note-mcp-call.sh +89 -0
  163. package/pipeline/scripts/note-mcp-failure.mjs +272 -1
  164. package/pipeline/scripts/note-session.sh +62 -3
  165. package/pipeline/scripts/note-skill-use.mjs +58 -2
  166. package/pipeline/scripts/office-build.mjs +115 -1
  167. package/pipeline/scripts/office-memory.mjs +14 -5
  168. package/pipeline/scripts/pair.mjs +333 -0
  169. package/pipeline/scripts/pre-push-check.sh +1 -1
  170. package/pipeline/scripts/remote/cbor.mjs +128 -0
  171. package/pipeline/scripts/remote/contract.mjs +98 -0
  172. package/pipeline/scripts/remote/handler.mjs +330 -0
  173. package/pipeline/scripts/remote/handles.mjs +57 -0
  174. package/pipeline/scripts/remote/lifecycle.mjs +186 -0
  175. package/pipeline/scripts/remote/listener.mjs +204 -0
  176. package/pipeline/scripts/remote/lockout.mjs +103 -0
  177. package/pipeline/scripts/remote/nonces.mjs +61 -0
  178. package/pipeline/scripts/remote/pairing.mjs +519 -0
  179. package/pipeline/scripts/remote/qr-encode.mjs +459 -0
  180. package/pipeline/scripts/remote/store.mjs +191 -0
  181. package/pipeline/scripts/remote/transport.mjs +211 -0
  182. package/pipeline/scripts/remote/verbs.json +70 -0
  183. package/pipeline/scripts/remote/verbs.mjs +217 -0
  184. package/pipeline/scripts/remote/webauthn.mjs +169 -0
  185. package/pipeline/scripts/remote/wire.mjs +364 -0
  186. package/pipeline/scripts/remote-listener.mjs +83 -0
  187. package/pipeline/scripts/route-learn.mjs +4 -4
  188. package/pipeline/scripts/run-kill.mjs +1 -1
  189. package/pipeline/scripts/run-write.mjs +13 -2
  190. package/pipeline/scripts/runs-index.mjs +30 -3
  191. package/pipeline/scripts/search-logs.sh +9 -0
  192. package/pipeline/scripts/session-brief.mjs +458 -0
  193. package/pipeline/scripts/session-brief.sh +130 -0
  194. package/pipeline/scripts/skill-usage.mjs +16 -5
  195. package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
  196. package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
  197. package/pipeline/scripts/test-gap-rules/java.json +20 -0
  198. package/pipeline/scripts/test-gap-rules/rust.json +14 -0
  199. package/pipeline/scripts/token-budget-report.mjs +3 -2
  200. package/pipeline/scripts/uninstall.mjs +29 -0
  201. package/pipeline/scripts/usage-access.mjs +16 -31
  202. package/pipeline/scripts/usage-health.mjs +31 -62
  203. package/pipeline/scripts/usage-register-beacon.mjs +11 -22
  204. package/pipeline/scripts/usage-register.mjs +39 -29
  205. package/pipeline/scripts/usage-report.mjs +579 -178
  206. package/pipeline/scripts/validate-code-graph.mjs +361 -111
  207. package/pipeline/scripts/write-state.mjs +39 -0
  208. package/pipeline/skills/.skill-manifest.json +21 -17
  209. package/pipeline/skills/.skills-index.json +13 -2
  210. package/pipeline/skills/shared/README.md +5 -4
  211. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
  212. package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
  213. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
  214. package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
  215. package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
  216. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  217. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
  218. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
  219. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
  220. package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
  221. package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
  222. package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
  223. package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
  224. package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
  225. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
  226. package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
  227. package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
  228. package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
  229. package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
  230. package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
  231. package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
  232. package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
  233. package/pipeline/skills/skills-index.md +3 -2
  234. package/docs/FIGMA_PIPELINE.md +0 -137
  235. package/pipeline/lib/identifier-scan.mjs +0 -156
  236. package/pipeline/scripts/_renamed-skills.mjs +0 -164
  237. package/pipeline/scripts/publish-staged.mjs +0 -324
  238. package/pipeline/skills/renamed.json +0 -30
  239. package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
@@ -0,0 +1,105 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "rust",
4
+ "description": "Rust code-graph rules. Adds what the graph needs on top of test-gap-rules/rust.json, which owns sourceExtensions, excludePathGlobs and the test-path predicates. Types and traits are the symbols; functions and methods come from the call analysis, which reads impl blocks.",
5
+ "comments": {
6
+ "line": ["//"],
7
+ "block": [["/*", "*/"]],
8
+ "string": ["\""],
9
+ "dialect": "rust",
10
+ "nested": true
11
+ },
12
+ "definitionPatterns": [
13
+ {
14
+ "id": "struct",
15
+ "kind": "struct",
16
+ "regex": "\\bstruct\\s+([A-Z][A-Za-z0-9_]*)"
17
+ },
18
+ {
19
+ "id": "enum",
20
+ "kind": "enum",
21
+ "regex": "\\benum\\s+([A-Z][A-Za-z0-9_]*)"
22
+ },
23
+ {
24
+ "id": "trait",
25
+ "kind": "trait",
26
+ "regex": "\\btrait\\s+([A-Z][A-Za-z0-9_]*)"
27
+ },
28
+ {
29
+ "id": "type",
30
+ "kind": "type",
31
+ "regex": "\\btype\\s+([A-Z][A-Za-z0-9_]*)\\s*(?:<[^>]*>)?\\s*="
32
+ },
33
+ {
34
+ "id": "fn",
35
+ "kind": "fn",
36
+ "regex": "^[ \\t]*(?:pub(?:\\([^)]*\\))?\\s+)?(?:async\\s+|const\\s+|unsafe\\s+)*fn\\s+([a-z_][A-Za-z0-9_]*)"
37
+ }
38
+ ],
39
+ "importPatterns": [
40
+ {
41
+ "id": "use",
42
+ "regex": "^\\s*(?:pub(?:\\([^)]*\\))?\\s+)?use\\s+(?:[A-Za-z_][A-Za-z0-9_]*::)*([A-Za-z_][A-Za-z0-9_]*)"
43
+ }
44
+ ],
45
+ "referenceKinds": ["struct", "enum", "trait", "type"],
46
+ "supertypes": {
47
+ "syntax": "colon",
48
+ "kinds": ["trait"]
49
+ },
50
+ "referenceKindsNote": "fn is absent for the reason the other stacks record: a bare lowercase name matched across files is rarely a call to that exact declaration. Call edges come from the call analysis instead.",
51
+ "ignoredIdentifiers": [
52
+ "self",
53
+ "Self",
54
+ "super",
55
+ "crate",
56
+ "fn",
57
+ "let",
58
+ "mut",
59
+ "pub",
60
+ "use",
61
+ "mod",
62
+ "impl",
63
+ "trait",
64
+ "struct",
65
+ "enum",
66
+ "type",
67
+ "where",
68
+ "match",
69
+ "if",
70
+ "else",
71
+ "for",
72
+ "while",
73
+ "loop",
74
+ "in",
75
+ "return",
76
+ "break",
77
+ "continue",
78
+ "as",
79
+ "ref",
80
+ "move",
81
+ "static",
82
+ "const",
83
+ "unsafe",
84
+ "async",
85
+ "await",
86
+ "dyn",
87
+ "true",
88
+ "false",
89
+ "Some",
90
+ "None",
91
+ "Ok",
92
+ "Err",
93
+ "Option",
94
+ "Result",
95
+ "Vec",
96
+ "String",
97
+ "Box",
98
+ "Rc",
99
+ "Arc",
100
+ "Default",
101
+ "Debug",
102
+ "Clone",
103
+ "Copy"
104
+ ]
105
+ }
@@ -47,6 +47,7 @@
47
47
  * GET /v1/credentials office-credentials.mjs --json [--probe]
48
48
  * GET /v1/memory office-memory.mjs --json
49
49
  * GET /v1/server-room office-server-room.mjs --json
50
+ * GET /v1/mcp-health mcp-health.mjs --json
50
51
  * GET /v1/archive office-archive.mjs --json
51
52
  * GET /v1/runs/{id}/results run-results.mjs: diff, findings, tests, evidence, analysis
52
53
  * GET /v1/runs/{id}/evidence/{name} run-results.mjs --evidence: one screenshot
@@ -361,10 +362,12 @@ export const ROUTES = [
361
362
  office.activityStream,
362
363
  office.chat,
363
364
  office.ledger,
365
+ office.learning,
364
366
  office.system,
365
367
  office.credentials,
366
368
  office.memory,
367
369
  office.serverRoom,
370
+ office.mcpHealth,
368
371
  office.archive,
369
372
  runs.results,
370
373
  runs.evidence,
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @file design-check-config.mjs - hold the user's design-check config to its
4
+ * schema before /multi-agent:design-check uses it.
5
+ *
6
+ * The config is optional and lives at
7
+ * ~/.claude/projects/<project slug>/design-check-config.json, written by the
8
+ * user. A misspelled key or a value of the wrong type would otherwise be
9
+ * ignored or misread deep inside a run, after the build. This checks the file
10
+ * against schemas/design-check-config.schema.json and prints every problem with
11
+ * the dotted path of the key it is about, so the fix is one edit.
12
+ *
13
+ * The check covers the schema keywords that file uses (type, enum, const,
14
+ * required, properties, additionalProperties, items, minimum, maximum) and
15
+ * runs without a validator package. A value is never echoed back, only the key
16
+ * name, the expected shape and the found type. The file is read through the
17
+ * bounded regular-file reader: at most MAX_BYTES, never through a link.
18
+ *
19
+ * Usage:
20
+ * design-check-config.mjs [--repo <dir>] the project folder of that checkout
21
+ * design-check-config.mjs --file <path> one config file
22
+ *
23
+ * Exit: 0 valid, or no file (the defaults apply); 1 the file is invalid, not
24
+ * JSON or unreadable; 2 usage: an unknown flag, a missing value, a --repo
25
+ * path that does not resolve or a --file that does not exist.
26
+ *
27
+ * @module pipeline/scripts/design-check-config
28
+ */
29
+
30
+ import { readFileSync, realpathSync } from "node:fs";
31
+ import { homedir } from "node:os";
32
+ import { join, resolve } from "node:path";
33
+
34
+ import { parseArgs } from "../lib/args.mjs";
35
+ import { exitOnHelp } from "../lib/cli-help.mjs";
36
+ import { invokedDirectly } from "../lib/invoked-directly.mjs";
37
+ import { mainRepoRoot } from "../lib/repo-profile-root.mjs";
38
+ import { readRegularFile } from "../lib/regular-file.mjs";
39
+ import { projectSlug } from "../lib/slug.mjs";
40
+
41
+ exitOnHelp(import.meta.url);
42
+
43
+ export const CONFIG_FILE = "design-check-config.json";
44
+ const MAX_BYTES = 256 * 1024;
45
+ const MAX_PROBLEMS = 40;
46
+ const KEY_SHOWN = 60;
47
+
48
+ const SCHEMA = JSON.parse(
49
+ readFileSync(new URL("../schemas/design-check-config.schema.json", import.meta.url), "utf8"),
50
+ );
51
+
52
+ const kindOf = (v) => (v === null ? "null" : Array.isArray(v) ? "array" : typeof v);
53
+ const keyName = (k) =>
54
+ String(k)
55
+ .replace(/[^\x20-\x7e]/g, "?")
56
+ .slice(0, KEY_SHOWN);
57
+ const at = (path, key) => (path === "(root)" ? keyName(key) : `${path}.${keyName(key)}`);
58
+
59
+ function typeMatches(type, v) {
60
+ if (type === "integer") return Number.isInteger(v);
61
+ if (type === "number") return typeof v === "number" && Number.isFinite(v);
62
+ return kindOf(v) === type;
63
+ }
64
+
65
+ function report(out, message) {
66
+ if (out.length < MAX_PROBLEMS) out.push(message);
67
+ else out.dropped = (out.dropped ?? 0) + 1;
68
+ }
69
+
70
+ function walk(schema, value, path, out) {
71
+ if (!schema || typeof schema !== "object") return;
72
+ if (schema.type !== undefined) {
73
+ const types = [].concat(schema.type);
74
+ if (!types.some((t) => typeMatches(t, value))) {
75
+ const found = kindOf(value) === "number" ? "number" : kindOf(value);
76
+ report(out, `${path}: expected ${types.join(" or ")}, got ${found}`);
77
+ return;
78
+ }
79
+ }
80
+ if (Object.hasOwn(schema, "const") && value !== schema.const) {
81
+ report(out, `${path}: must be ${JSON.stringify(schema.const)}`);
82
+ return;
83
+ }
84
+ if (Array.isArray(schema.enum) && !schema.enum.includes(value)) {
85
+ report(out, `${path}: must be one of ${schema.enum.join(", ")}`);
86
+ return;
87
+ }
88
+ if (typeof value === "number") {
89
+ if (typeof schema.minimum === "number" && value < schema.minimum)
90
+ report(out, `${path}: must be at least ${schema.minimum}`);
91
+ if (typeof schema.maximum === "number" && value > schema.maximum)
92
+ report(out, `${path}: must be at most ${schema.maximum}`);
93
+ }
94
+ if (Array.isArray(value) && schema.items) {
95
+ value.forEach((item, i) => walk(schema.items, item, `${path}[${i}]`, out));
96
+ }
97
+ if (kindOf(value) === "object") {
98
+ const props = schema.properties ?? {};
99
+ for (const key of schema.required ?? []) {
100
+ if (!Object.hasOwn(value, key)) report(out, `${at(path, key)}: required key is missing`);
101
+ }
102
+ for (const key of Object.keys(value)) {
103
+ if (Object.hasOwn(props, key)) walk(props[key], value[key], at(path, key), out);
104
+ else if (schema.additionalProperties === false) {
105
+ report(out, `${at(path, key)}: unknown key (allowed: ${Object.keys(props).join(", ")})`);
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Every way a parsed config departs from the schema, one line each, naming the
113
+ * key by its dotted path. An empty list means it is valid.
114
+ * @param {unknown} config
115
+ * @returns {string[]}
116
+ */
117
+ export function validateConfig(config) {
118
+ const out = [];
119
+ walk(SCHEMA, config, "(root)", out);
120
+ if (out.dropped) out.push(`and ${out.dropped} more`);
121
+ return out;
122
+ }
123
+
124
+ /**
125
+ * Where the config of the project `repo` belongs to lives: under the host's
126
+ * project folder, named by the main checkout's path.
127
+ * @param {string} repo
128
+ * @param {NodeJS.ProcessEnv} [env]
129
+ */
130
+ export function configPathFor(repo, env = process.env) {
131
+ let root;
132
+ try {
133
+ root = mainRepoRoot(repo);
134
+ } catch {
135
+ root = realpathSync(resolve(repo));
136
+ }
137
+ return join(env.HOME || homedir(), ".claude", "projects", projectSlug(root), CONFIG_FILE);
138
+ }
139
+
140
+ function main(argv) {
141
+ let flags;
142
+ try {
143
+ ({ flags } = parseArgs(argv, {
144
+ strings: ["file", "repo"],
145
+ unknown: "error",
146
+ positionals: false,
147
+ emptyIsValue: false,
148
+ equals: false,
149
+ }));
150
+ } catch {
151
+ return usage();
152
+ }
153
+ const file = flags.file === undefined ? null : resolve(flags.file);
154
+ const repo = flags.repo ?? null;
155
+ if (file && repo) return usage();
156
+ let path;
157
+ try {
158
+ path = file ?? configPathFor(repo ?? process.cwd());
159
+ } catch {
160
+ console.error("design-check config: the --repo path does not resolve");
161
+ return 2;
162
+ }
163
+ let text;
164
+ try {
165
+ text = readRegularFile(path, { maxBytes: MAX_BYTES, noFollow: true });
166
+ } catch (e) {
167
+ if (/ENOENT/.test(e?.message ?? "")) {
168
+ if (file) {
169
+ console.error(`design-check config: --file ${path} does not exist`);
170
+ return 2;
171
+ }
172
+ console.log(`no design-check config at ${path}; the defaults apply`);
173
+ return 0;
174
+ }
175
+ console.log(
176
+ `design-check config ${path} cannot be read: it must be a regular file under ${MAX_BYTES / 1024} KiB, not a link`,
177
+ );
178
+ return 1;
179
+ }
180
+ let config;
181
+ try {
182
+ config = JSON.parse(text);
183
+ } catch {
184
+ console.log(`design-check config ${path} is not valid JSON`);
185
+ return 1;
186
+ }
187
+ const problems = validateConfig(config);
188
+ if (problems.length === 0) {
189
+ console.log(`design-check config ${path} is valid`);
190
+ return 0;
191
+ }
192
+ console.log(`design-check config ${path} has ${problems.length} problem(s):`);
193
+ for (const p of problems) console.log(` ${p}`);
194
+ console.log(
195
+ `fix the keys above in ${CONFIG_FILE}; the schema is schemas/design-check-config.schema.json`,
196
+ );
197
+ return 1;
198
+ }
199
+
200
+ function usage() {
201
+ console.error("usage: design-check-config.mjs [--repo <dir> | --file <path>]");
202
+ return 2;
203
+ }
204
+
205
+ if (invokedDirectly(import.meta.url)) process.exit(main(process.argv.slice(2)));
@@ -32,7 +32,10 @@ import { join } from "node:path";
32
32
  import { hostCommand } from "../lib/user-facing.mjs";
33
33
  import { loadGlobalPrefs, prefsFileIn } from "../lib/prefs-value.mjs";
34
34
  import { exitOnHelp } from "../lib/cli-help.mjs";
35
- import { endpointAllowed, resolveUsageToken } from "../lib/usage-token.mjs";
35
+ import { nowMinute, releaseVersion } from "../lib/usage-vocab.mjs";
36
+ import { postJson } from "./_http-post.mjs";
37
+ import { registerUrlAllowed } from "../lib/usage-endpoint.mjs";
38
+ import { resolveUsageToken } from "../lib/usage-token.mjs";
36
39
 
37
40
  exitOnHelp(import.meta.url);
38
41
 
@@ -57,7 +60,7 @@ function packageVersion() {
57
60
  join(homedir(), ".codex", ".pipeline-version"),
58
61
  ]) {
59
62
  try {
60
- const v = readFileSync(p, "utf-8").trim();
63
+ const v = releaseVersion(readFileSync(p, "utf-8"));
61
64
  if (v) return v;
62
65
  } catch {
63
66
  /* try the next host */
@@ -101,7 +104,7 @@ async function main() {
101
104
  kind,
102
105
  v: packageVersion(),
103
106
  host: host(),
104
- at: new Date().toISOString(),
107
+ at: nowMinute(),
105
108
  };
106
109
 
107
110
  if (process.argv.includes("--dry-run")) {
@@ -111,8 +114,10 @@ async function main() {
111
114
  return;
112
115
  }
113
116
 
114
- if (!endpointAllowed(endpoint)) {
115
- process.stderr.write(`ERROR: refusing to send over a non-TLS endpoint: ${endpoint}\n`);
117
+ if (!registerUrlAllowed(endpoint, readPrefs().usageLog?.trustedHosts)) {
118
+ process.stderr.write(
119
+ `ERROR: refusing to send: the endpoint is not https on a trusted host (usageLog.trustedHosts): ${endpoint}\n`,
120
+ );
116
121
  process.exit(1);
117
122
  }
118
123
 
@@ -124,29 +129,24 @@ async function main() {
124
129
  process.exit(1);
125
130
  }
126
131
 
127
- const ctrl = new AbortController();
128
- const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
129
- try {
130
- const res = await fetch(endpoint, {
131
- method: "POST",
132
- headers: { "Content-Type": "application/json", "X-Usage-Token": token },
133
- body: JSON.stringify(payload),
134
- signal: ctrl.signal,
135
- });
136
- if (!res.ok) {
137
- // Unlike telemetry, this failure is reported: the person is standing there
138
- // waiting to hear whether their message went. Swallowing it would leave
139
- // them believing they had been heard.
140
- process.stderr.write(`ERROR: the endpoint answered ${res.status}\n`);
141
- process.exit(1);
142
- }
143
- process.stdout.write("feedback sent\n");
144
- } catch (err) {
145
- process.stderr.write(`ERROR: could not reach the endpoint (${err.name})\n`);
132
+ const res = await postJson({
133
+ url: endpoint,
134
+ headers: { "X-Usage-Token": token },
135
+ body: JSON.stringify(payload),
136
+ timeoutMs: TIMEOUT_MS,
137
+ });
138
+ if (res.failure) {
139
+ process.stderr.write(`ERROR: could not reach the endpoint (${res.failure})\n`);
140
+ process.exit(1);
141
+ }
142
+ if (res.status < 200 || res.status >= 300) {
143
+ // Unlike telemetry, this failure is reported: the person is standing there
144
+ // waiting to hear whether their message went. Swallowing it would leave
145
+ // them believing they had been heard.
146
+ process.stderr.write(`ERROR: the endpoint answered ${res.status}\n`);
146
147
  process.exit(1);
147
- } finally {
148
- clearTimeout(timer);
149
148
  }
149
+ process.stdout.write("feedback sent\n");
150
150
  }
151
151
 
152
152
  // `main()` is async, and calling it bare leaves any rejection it does not
@@ -83,7 +83,7 @@ import { globalPref } from "../lib/prefs-value.mjs";
83
83
  import { modeEntry } from "../lib/run-completion.mjs";
84
84
  import { attendedVerdict, gatesActive } from "../lib/unattended.mjs";
85
85
  import { listRuns, resolveRunFile } from "./_run-paths.mjs";
86
- import { acquireLock, releaseLock, stillOurs } from "./write-state.mjs";
86
+ import { acquireLock, releaseLock, stampWaitingSince, stillOurs } from "./write-state.mjs";
87
87
  import { ArgsError, parseArgs } from "../lib/args.mjs";
88
88
  import { exitOnHelp } from "../lib/cli-help.mjs";
89
89
 
@@ -501,6 +501,7 @@ export async function updateState(path, mutate) {
501
501
  }
502
502
  const next = mutate(current);
503
503
  if (next === current) return current;
504
+ stampWaitingSince(next, current);
504
505
  next.rev = (Number.isInteger(current.rev) ? current.rev : 0) + 1;
505
506
  if (!stillOurs(path, ino)) {
506
507
  throw new LedgerError("io", `the lock on ${path} was taken mid-write; nothing written`);
@@ -41,7 +41,6 @@ import { join, dirname } from "node:path";
41
41
  import { fileURLToPath } from "node:url";
42
42
  import { spawnSync } from "node:child_process";
43
43
  import { siblingsParent } from "./_sibling-root.mjs";
44
- import { isAliasSkill } from "./_renamed-skills.mjs";
45
44
  import { exitOnHelp } from "../lib/cli-help.mjs";
46
45
  import { SERVER_CHECKOUT_DIRS } from "../lib/mcp-rename.mjs";
47
46
 
@@ -198,7 +197,7 @@ if (existsSync(pluginsDir)) {
198
197
  const walk = (d) => {
199
198
  for (const e of readdirSync(d, { withFileTypes: true })) {
200
199
  if (e.isDirectory()) walk(join(d, e.name));
201
- else if (e.name === "SKILL.md" && !isAliasSkill(join(d, e.name))) n += 1;
200
+ else if (e.name === "SKILL.md") n += 1;
202
201
  }
203
202
  };
204
203
  try {
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * gen-usage-names.mjs - write lib/usage-names.generated.mjs, the names a usage
4
+ * record may carry.
5
+ *
6
+ * A record names a command, a skill or an MCP tool only when the package
7
+ * itself ships it. The lists are built here, when the package is packed, from
8
+ * the package's own trees, and travel inside it; nothing found on the machine
9
+ * that runs the pipeline (saved routines, local wrappers, a marketplace cache,
10
+ * a registered server) can extend them.
11
+ *
12
+ * SHIPPED_COMMANDS the tracked directories of pipeline/commands/multi-agent
13
+ * SHIPPED_SKILLS the tracked directories of pipeline/skills/shared/{core,external}
14
+ * TOOLKIT_TOOLS the tools of this product's MCP server, from
15
+ * pipeline/schemas/toolkit-path-params.json (itself
16
+ * generated from the server's tool manifest)
17
+ *
18
+ * The trees are read from the tracked file set (git ls-files), not from the
19
+ * disk, so a directory that is only present locally never enters a list.
20
+ * `prepack` runs the generator, so a published package carries the lists of the
21
+ * tree it was packed from; `npm test` runs it with --check.
22
+ *
23
+ * Usage: gen-usage-names.mjs [--check]
24
+ * Exit: 0 written / current, 1 --check found the file stale.
25
+ *
26
+ * @module pipeline/scripts/gen-usage-names
27
+ */
28
+
29
+ import { execFileSync } from "node:child_process";
30
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
31
+ import { dirname, join, resolve } from "node:path";
32
+ import { fileURLToPath } from "node:url";
33
+ import { invokedDirectly } from "../lib/invoked-directly.mjs";
34
+ import { exitOnHelp } from "../lib/cli-help.mjs";
35
+
36
+ exitOnHelp(import.meta.url);
37
+
38
+ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
39
+ const OUT = join(ROOT, "pipeline", "lib", "usage-names.generated.mjs");
40
+
41
+ /**
42
+ * The directories directly under `prefix` that hold at least one tracked file.
43
+ * The tracked file set is the package's; a directory that exists on this disk
44
+ * but is not in git (a routine, a scratch copy) is not.
45
+ */
46
+ function trackedDirsUnder(root, prefix) {
47
+ const out = execFileSync("git", ["ls-files", "-z", "--", prefix], {
48
+ cwd: root,
49
+ encoding: "utf8",
50
+ maxBuffer: 64 * 1024 * 1024,
51
+ });
52
+ const names = new Set();
53
+ for (const file of out.split("\0")) {
54
+ if (!file.startsWith(`${prefix}/`)) continue;
55
+ const [name, ...rest] = file.slice(prefix.length + 1).split("/");
56
+ if (rest.length && name && !name.startsWith(".")) names.add(name);
57
+ }
58
+ return [...names].sort();
59
+ }
60
+
61
+ /** The three lists, read from the package's trees. */
62
+ export function collect(root = ROOT) {
63
+ const commands = trackedDirsUnder(root, "pipeline/commands/multi-agent");
64
+ const skills = [
65
+ ...new Set(
66
+ ["core", "external"].flatMap((g) => trackedDirsUnder(root, `pipeline/skills/shared/${g}`)),
67
+ ),
68
+ ].sort();
69
+ const params = JSON.parse(
70
+ readFileSync(join(root, "pipeline", "schemas", "toolkit-path-params.json"), "utf8"),
71
+ );
72
+ const tools = Object.keys(params.tools ?? {}).sort();
73
+ return { commands, skills, tools };
74
+ }
75
+
76
+ export function render({ commands, skills, tools }) {
77
+ const list = (name, doc, names) => [
78
+ `/** ${doc} */`,
79
+ `export const ${name} = Object.freeze([`,
80
+ ...names.map((n) => ` ${JSON.stringify(n)},`),
81
+ "]);",
82
+ "",
83
+ ];
84
+ return [
85
+ "/**",
86
+ " * Generated by pipeline/scripts/gen-usage-names.mjs from the package's own",
87
+ " * command, skill and tool trees. Regenerate after any of them changes; npm",
88
+ " * test runs it with --check.",
89
+ " *",
90
+ " * @module pipeline/lib/usage-names.generated",
91
+ " */",
92
+ "",
93
+ ...list(
94
+ "SHIPPED_COMMANDS",
95
+ "The commands under commands/multi-agent that the package ships.",
96
+ commands,
97
+ ),
98
+ ...list("SHIPPED_SKILLS", "The skills the package ships (core and external).", skills),
99
+ ...list("TOOLKIT_TOOLS", "The tools this product's MCP server serves.", tools),
100
+ ].join("\n");
101
+ }
102
+
103
+ function main() {
104
+ const check = process.argv.includes("--check");
105
+ const want = render(collect());
106
+ const have = existsSync(OUT) ? readFileSync(OUT, "utf8") : null;
107
+ if (check) {
108
+ if (want !== have) {
109
+ process.stderr.write(
110
+ "gen-usage-names: pipeline/lib/usage-names.generated.mjs is stale\n" +
111
+ " run: node pipeline/scripts/gen-usage-names.mjs\n",
112
+ );
113
+ process.exitCode = 1;
114
+ return;
115
+ }
116
+ process.stdout.write("gen-usage-names: current\n");
117
+ return;
118
+ }
119
+ if (want !== have) writeFileSync(OUT, want);
120
+ // stderr: this runs as `prepack`, whose stdout lands inside `npm pack --json`.
121
+ process.stderr.write(`gen-usage-names: ${want === have ? "current" : "written"}\n`);
122
+ }
123
+
124
+ if (invokedDirectly(import.meta.url)) main();