@mmerterden/multi-agent-pipeline 23.3.0 → 23.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.
- package/CHANGELOG.md +44 -0
- package/README.md +25 -6
- package/README.tr.md +26 -7
- package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
- package/docs/adr/0010-own-code-graph.md +299 -8
- package/docs/architecture.md +3 -3
- package/docs/ecosystem.md +10 -10
- package/docs/engineering.md +4 -4
- package/docs/facts.json +8 -8
- package/docs/features.md +5 -5
- package/docs/performance.md +17 -17
- package/install/_dev-only-files.mjs +9 -0
- package/install/claude.mjs +28 -2
- package/install/templates/claude-hooks.json +32 -1
- package/manifest.json +223 -155
- package/package.json +11 -3
- package/pipeline/commands/multi-agent/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
- package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
- package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
- package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
- package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
- package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/contract/CHANGELOG.md +49 -0
- package/pipeline/contract/build.mjs +13 -1
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +4 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
- package/pipeline/contract/fixtures/runs-running.json +4 -1
- package/pipeline/contract/manifest.json +28 -15
- package/pipeline/contract/types/index.d.ts +55 -3
- package/pipeline/lib/detach-self.mjs +95 -0
- package/pipeline/lib/public-mcp-servers.mjs +33 -0
- package/pipeline/lib/rotated-log.mjs +93 -0
- package/pipeline/lib/tls-trust.mjs +29 -0
- package/pipeline/lib/usage-lifecycle.mjs +9 -11
- package/pipeline/lib/usage-names.generated.mjs +614 -0
- package/pipeline/lib/usage-run-key.mjs +235 -0
- package/pipeline/lib/usage-vocab.mjs +210 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
- package/pipeline/multi-agent-refs/analysis/render.md +1 -1
- package/pipeline/multi-agent-refs/channels/generator.md +4 -5
- package/pipeline/multi-agent-refs/cross-cli-contract.md +3 -3
- package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
- package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
- package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
- package/pipeline/multi-agent-refs/features/model-fallback.md +6 -4
- package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
- package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
- package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
- package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
- package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
- package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
- package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
- package/pipeline/multi-agent-refs/help/en.md +3 -2
- package/pipeline/multi-agent-refs/help/tr.md +3 -2
- package/pipeline/multi-agent-refs/knowledge.md +1 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
- package/pipeline/multi-agent-refs/phases/operations.md +2 -2
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -0
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
- package/pipeline/multi-agent-refs/platform-parity.md +2 -2
- package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
- package/pipeline/office/index.html +1207 -233
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/activity.schema.json +23 -0
- package/pipeline/schemas/agent-state.schema.json +6 -1
- package/pipeline/schemas/code-graph-calls.schema.json +254 -0
- package/pipeline/schemas/code-graph-docs.schema.json +223 -0
- package/pipeline/schemas/code-graph-infra.schema.json +227 -0
- package/pipeline/schemas/code-graph.schema.json +2 -2
- package/pipeline/schemas/examples/design-check-config.json +27 -0
- package/pipeline/schemas/learning-curve.schema.json +67 -0
- package/pipeline/schemas/office-jobs.json +69 -2
- package/pipeline/schemas/office-jobs.schema.json +8 -1
- package/pipeline/schemas/phases.json +5 -0
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +46 -12
- package/pipeline/schemas/runs-index.schema.json +17 -0
- package/pipeline/schemas/toolkit-path-params.json +84 -8
- package/pipeline/scripts/README.md +1 -0
- package/pipeline/scripts/_code-graph.mjs +184 -103
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/_contract-routes-office.mjs +21 -0
- package/pipeline/scripts/_diff-impact.mjs +21 -2
- package/pipeline/scripts/_graph-sidecars.mjs +372 -0
- package/pipeline/scripts/_http-post.mjs +103 -115
- package/pipeline/scripts/_safe-read.mjs +57 -0
- package/pipeline/scripts/_skill-practices.mjs +26 -0
- package/pipeline/scripts/_strip-code.mjs +380 -0
- package/pipeline/scripts/activity-snapshot.mjs +13 -1
- package/pipeline/scripts/aggregate-metrics.mjs +3 -5
- package/pipeline/scripts/call-graph/index.mjs +78 -0
- package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
- package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
- package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
- package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
- package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
- package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
- package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
- package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
- package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
- package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
- package/pipeline/scripts/call-graph/lex.mjs +396 -0
- package/pipeline/scripts/call-graph/platform.mjs +86 -0
- package/pipeline/scripts/call-graph/profiles.mjs +89 -0
- package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
- package/pipeline/scripts/call-graph/scan.mjs +267 -0
- package/pipeline/scripts/code-graph-rules/android.json +7 -2
- package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
- package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
- package/pipeline/scripts/code-graph-rules/go.json +2 -1
- package/pipeline/scripts/code-graph-rules/ios.json +3 -1
- package/pipeline/scripts/code-graph-rules/java.json +76 -0
- package/pipeline/scripts/code-graph-rules/node.json +7 -2
- package/pipeline/scripts/code-graph-rules/python.json +6 -2
- package/pipeline/scripts/code-graph-rules/rust.json +105 -0
- package/pipeline/scripts/contract-server.mjs +1 -0
- package/pipeline/scripts/feedback-send.mjs +26 -26
- package/pipeline/scripts/gate-ledger.mjs +2 -1
- package/pipeline/scripts/gen-usage-names.mjs +124 -0
- package/pipeline/scripts/graph-affected.mjs +109 -20
- package/pipeline/scripts/graph-build.mjs +95 -15
- package/pipeline/scripts/graph-export.mjs +272 -0
- package/pipeline/scripts/graph-hint.mjs +15 -2
- package/pipeline/scripts/graph-query.mjs +305 -26
- package/pipeline/scripts/graph-report.mjs +187 -1
- package/pipeline/scripts/health-report.mjs +3 -4
- package/pipeline/scripts/infra/docs.mjs +317 -0
- package/pipeline/scripts/infra/extract.mjs +998 -0
- package/pipeline/scripts/infra/graph.mjs +245 -0
- package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
- package/pipeline/scripts/job-launch.mjs +67 -2
- package/pipeline/scripts/learning-curve.mjs +288 -178
- package/pipeline/scripts/log-metric.sh +10 -1
- package/pipeline/scripts/note-agent-event.mjs +3 -4
- package/pipeline/scripts/note-command-use.mjs +333 -0
- package/pipeline/scripts/note-command-use.sh +126 -0
- package/pipeline/scripts/note-mcp-call.sh +89 -0
- package/pipeline/scripts/note-mcp-failure.mjs +272 -1
- package/pipeline/scripts/note-session.sh +62 -3
- package/pipeline/scripts/note-skill-use.mjs +58 -2
- package/pipeline/scripts/office-build.mjs +115 -1
- package/pipeline/scripts/office-memory.mjs +14 -5
- package/pipeline/scripts/pair.mjs +333 -0
- package/pipeline/scripts/pre-push-check.sh +1 -1
- package/pipeline/scripts/remote/cbor.mjs +128 -0
- package/pipeline/scripts/remote/contract.mjs +98 -0
- package/pipeline/scripts/remote/handler.mjs +317 -0
- package/pipeline/scripts/remote/handles.mjs +57 -0
- package/pipeline/scripts/remote/lifecycle.mjs +186 -0
- package/pipeline/scripts/remote/listener.mjs +204 -0
- package/pipeline/scripts/remote/lockout.mjs +103 -0
- package/pipeline/scripts/remote/nonces.mjs +61 -0
- package/pipeline/scripts/remote/pairing.mjs +519 -0
- package/pipeline/scripts/remote/qr-encode.mjs +459 -0
- package/pipeline/scripts/remote/store.mjs +188 -0
- package/pipeline/scripts/remote/transport.mjs +211 -0
- package/pipeline/scripts/remote/verbs.json +70 -0
- package/pipeline/scripts/remote/verbs.mjs +217 -0
- package/pipeline/scripts/remote/webauthn.mjs +169 -0
- package/pipeline/scripts/remote/wire.mjs +364 -0
- package/pipeline/scripts/remote-listener.mjs +83 -0
- package/pipeline/scripts/route-learn.mjs +4 -4
- package/pipeline/scripts/run-kill.mjs +1 -1
- package/pipeline/scripts/run-write.mjs +13 -2
- package/pipeline/scripts/runs-index.mjs +30 -3
- package/pipeline/scripts/search-logs.sh +9 -0
- package/pipeline/scripts/session-brief.mjs +458 -0
- package/pipeline/scripts/session-brief.sh +130 -0
- package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
- package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
- package/pipeline/scripts/test-gap-rules/java.json +20 -0
- package/pipeline/scripts/test-gap-rules/rust.json +14 -0
- package/pipeline/scripts/token-budget-report.mjs +3 -2
- package/pipeline/scripts/uninstall.mjs +29 -0
- package/pipeline/scripts/usage-access.mjs +16 -31
- package/pipeline/scripts/usage-health.mjs +31 -62
- package/pipeline/scripts/usage-register-beacon.mjs +11 -22
- package/pipeline/scripts/usage-register.mjs +39 -29
- package/pipeline/scripts/usage-report.mjs +579 -178
- package/pipeline/scripts/validate-code-graph.mjs +361 -111
- package/pipeline/scripts/write-state.mjs +39 -0
- package/pipeline/skills/.skill-manifest.json +21 -17
- package/pipeline/skills/.skills-index.json +13 -2
- package/pipeline/skills/shared/README.md +5 -4
- package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
- package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
- package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
- package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
- package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
- package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
- package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
- package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
- package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
- package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
- package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
- package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
- package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
- package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
- package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
- package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
- package/pipeline/skills/skills-index.md +3 -2
- package/docs/FIGMA_PIPELINE.md +0 -137
- package/pipeline/lib/identifier-scan.mjs +0 -156
- package/pipeline/scripts/publish-staged.mjs +0 -324
- package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usage-run-key.mjs - the per-install key behind the run id a usage event sends.
|
|
3
|
+
*
|
|
4
|
+
* A run id is a ticket key in practice, which is low entropy: a plain hash of
|
|
5
|
+
* it can be reversed by hashing every plausible key. The id that leaves the
|
|
6
|
+
* machine is therefore an HMAC under a random secret that never leaves it.
|
|
7
|
+
* The same machine and the same run id always give the same digest, so the
|
|
8
|
+
* events of one run still join; another machine, or another secret, gives a
|
|
9
|
+
* different one.
|
|
10
|
+
*
|
|
11
|
+
* The secret is 32 random bytes in a 0600 file beside the other usage state
|
|
12
|
+
* files. It is created on first use with an exclusive link, so two processes
|
|
13
|
+
* starting together end up with one value. A file that is damaged, loose or
|
|
14
|
+
* not this user's is replaced (see loadRunKey). When it cannot be read or created
|
|
15
|
+
* there is no digest at all: callers skip the send and never fall back to an
|
|
16
|
+
* unkeyed form.
|
|
17
|
+
*
|
|
18
|
+
* @module pipeline/lib/usage-run-key
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
22
|
+
import {
|
|
23
|
+
linkSync,
|
|
24
|
+
lstatSync,
|
|
25
|
+
mkdirSync,
|
|
26
|
+
readFileSync,
|
|
27
|
+
renameSync,
|
|
28
|
+
unlinkSync,
|
|
29
|
+
writeFileSync,
|
|
30
|
+
} from "node:fs";
|
|
31
|
+
import { homedir } from "node:os";
|
|
32
|
+
import { dirname, join } from "node:path";
|
|
33
|
+
|
|
34
|
+
export const RUN_KEY_FILE = "usage-run-key";
|
|
35
|
+
const KEY_HEX = /^[0-9a-f]{64}$/;
|
|
36
|
+
|
|
37
|
+
/** Where the secret lives; MULTI_AGENT_USAGE_RUN_KEY_FILE overrides it (tests, sandboxes). */
|
|
38
|
+
export function runKeyPath(env = process.env) {
|
|
39
|
+
return (
|
|
40
|
+
env.MULTI_AGENT_USAGE_RUN_KEY_FILE ||
|
|
41
|
+
join(homedir(), ".claude", "logs", "multi-agent", RUN_KEY_FILE)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The key when the file is a regular file this user owns, owner-only, holding 64 hex characters; else null. */
|
|
46
|
+
function readKey(path, uid) {
|
|
47
|
+
try {
|
|
48
|
+
const st = lstatSync(path);
|
|
49
|
+
if (!st.isFile()) return null;
|
|
50
|
+
if (uid !== null && st.uid !== uid) return null;
|
|
51
|
+
if ((st.mode & 0o077) !== 0) return null;
|
|
52
|
+
const text = readFileSync(path, "utf8").trim();
|
|
53
|
+
return KEY_HEX.test(text) ? text : null;
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const LOCK_WAIT_MS = 3000;
|
|
60
|
+
const LOCK_STALE_MS = 10_000;
|
|
61
|
+
const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
62
|
+
|
|
63
|
+
const readText = (path) => {
|
|
64
|
+
try {
|
|
65
|
+
return readFileSync(path, "utf8");
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Move a lock that has outlived LOCK_STALE_MS out of the way. The move is a
|
|
73
|
+
* rename, which succeeds for exactly one waiter; the moved file is read to make
|
|
74
|
+
* sure it is the stale lock that was judged (a fresh lock taken in between is
|
|
75
|
+
* put back), so two waiters never both take over and a live holder is not
|
|
76
|
+
* displaced.
|
|
77
|
+
*/
|
|
78
|
+
function clearStale(lock, token) {
|
|
79
|
+
let st;
|
|
80
|
+
try {
|
|
81
|
+
st = lstatSync(lock);
|
|
82
|
+
} catch {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (Date.now() - st.mtimeMs <= LOCK_STALE_MS) return;
|
|
86
|
+
const seen = readText(lock);
|
|
87
|
+
const moved = `${lock}.stale.${token}`;
|
|
88
|
+
try {
|
|
89
|
+
renameSync(lock, moved);
|
|
90
|
+
} catch {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (readText(moved) !== seen) {
|
|
94
|
+
try {
|
|
95
|
+
linkSync(moved, lock);
|
|
96
|
+
} catch {
|
|
97
|
+
/* another lock already stands */
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
unlinkSync(moved);
|
|
102
|
+
} catch {
|
|
103
|
+
/* gone */
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Take `<path>.lock` (create-exclusive, holding a random token that names this
|
|
109
|
+
* holder). Returns the token, or null when the lock could not be had in time.
|
|
110
|
+
*/
|
|
111
|
+
function takeLock(lock) {
|
|
112
|
+
const token = randomBytes(8).toString("hex");
|
|
113
|
+
const end = Date.now() + LOCK_WAIT_MS;
|
|
114
|
+
for (;;) {
|
|
115
|
+
try {
|
|
116
|
+
writeFileSync(lock, token, { mode: 0o600, flag: "wx" });
|
|
117
|
+
return token;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (e?.code !== "EEXIST") return null;
|
|
120
|
+
clearStale(lock, token);
|
|
121
|
+
}
|
|
122
|
+
if (Date.now() > end) return null;
|
|
123
|
+
pause(10);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Remove the lock only while it still holds this holder's token, so a slow holder never deletes its successor's. */
|
|
128
|
+
function releaseLock(lock, token) {
|
|
129
|
+
if (readText(lock) !== token) return;
|
|
130
|
+
try {
|
|
131
|
+
unlinkSync(lock);
|
|
132
|
+
} catch {
|
|
133
|
+
/* already gone */
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The install's secret as hex, or null when it cannot be read or created.
|
|
139
|
+
*
|
|
140
|
+
* A file that fails the checks (not a regular file of this user's, readable by
|
|
141
|
+
* others, short or damaged) is replaced by a new key through a rename, which
|
|
142
|
+
* swaps a link for a file without writing through it. A key others could read
|
|
143
|
+
* may have been seen, so it is never repaired in place. Replacing changes the
|
|
144
|
+
* run id of runs in flight: their next event joins as a new run, once.
|
|
145
|
+
*
|
|
146
|
+
* Creating and replacing happen under `<path>.lock`, and the key is checked
|
|
147
|
+
* again once the lock is held, so processes that find the same bad file
|
|
148
|
+
* together end with one replacement and every one of them returns the key that
|
|
149
|
+
* is in the file. A directory at the name cannot be replaced and gives null.
|
|
150
|
+
* With `create: false` nothing is created or repaired.
|
|
151
|
+
*
|
|
152
|
+
* @param {{path?: string, create?: boolean, uid?: number | null}} [opts]
|
|
153
|
+
*/
|
|
154
|
+
export function loadRunKey({
|
|
155
|
+
path = runKeyPath(),
|
|
156
|
+
create = true,
|
|
157
|
+
uid = typeof process.getuid === "function" ? process.getuid() : null,
|
|
158
|
+
} = {}) {
|
|
159
|
+
const existing = readKey(path, uid);
|
|
160
|
+
if (existing) return existing;
|
|
161
|
+
if (!create) return null;
|
|
162
|
+
try {
|
|
163
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const lock = `${path}.lock`;
|
|
168
|
+
const token = takeLock(lock);
|
|
169
|
+
if (!token) return readKey(path, uid);
|
|
170
|
+
const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
171
|
+
try {
|
|
172
|
+
const again = readKey(path, uid);
|
|
173
|
+
if (again) return again;
|
|
174
|
+
let present = false;
|
|
175
|
+
try {
|
|
176
|
+
lstatSync(path);
|
|
177
|
+
present = true;
|
|
178
|
+
} catch {
|
|
179
|
+
/* absent */
|
|
180
|
+
}
|
|
181
|
+
const key = randomBytes(32).toString("hex");
|
|
182
|
+
writeFileSync(tmp, `${key}\n`, { mode: 0o600, flag: "wx" });
|
|
183
|
+
if (present) renameSync(tmp, path);
|
|
184
|
+
else linkSync(tmp, path);
|
|
185
|
+
return readKey(path, uid);
|
|
186
|
+
} catch {
|
|
187
|
+
return null;
|
|
188
|
+
} finally {
|
|
189
|
+
try {
|
|
190
|
+
unlinkSync(tmp);
|
|
191
|
+
} catch {
|
|
192
|
+
/* already gone or renamed */
|
|
193
|
+
}
|
|
194
|
+
releaseLock(lock, token);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* A keyed digest in a domain of its own: `prefix` plus the first `hex`
|
|
200
|
+
* characters of HMAC-SHA256(key, label + NUL + value). The label keeps the
|
|
201
|
+
* digests of one value in two roles (a run id and a repository of the same
|
|
202
|
+
* text) apart. Null when there is no value or no key.
|
|
203
|
+
*
|
|
204
|
+
* @param {string} label domain label
|
|
205
|
+
* @param {unknown} value
|
|
206
|
+
* @param {string | null} key hex secret from loadRunKey
|
|
207
|
+
* @param {string} prefix
|
|
208
|
+
* @param {number} [hex]
|
|
209
|
+
*/
|
|
210
|
+
export function keyedDigest(label, value, key, prefix, hex = 16) {
|
|
211
|
+
if (value == null || value === "" || !key) return null;
|
|
212
|
+
const mac = createHmac("sha256", Buffer.from(key, "hex")).update(`${label}\0${value}`);
|
|
213
|
+
return `${prefix}${mac.digest("hex").slice(0, hex)}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* `r` plus the first 16 hex characters of HMAC-SHA256(key, "run-id" NUL id).
|
|
218
|
+
* Null when there is no id or no key.
|
|
219
|
+
*
|
|
220
|
+
* @param {unknown} id
|
|
221
|
+
* @param {string | null} key hex secret from loadRunKey
|
|
222
|
+
*/
|
|
223
|
+
export function runIdDigest(id, key) {
|
|
224
|
+
return keyedDigest("run-id", id, key, "r", 16);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** `p` plus 16 hex characters: the repository, keyed, in its own domain. */
|
|
228
|
+
export function repoDigest(name, key) {
|
|
229
|
+
return keyedDigest("repo", typeof name === "string" ? name.trim() : null, key, "p", 16);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** `m` plus 10 hex characters: this machine's short host name, keyed, in its own domain. */
|
|
233
|
+
export function hostDigest(name, key) {
|
|
234
|
+
return keyedDigest("host", typeof name === "string" ? name.trim() : null, key, "m", 10);
|
|
235
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usage-vocab.mjs - the closed lists and shape checks behind a usage record.
|
|
3
|
+
*
|
|
4
|
+
* Every field of the record that leaves the machine is one of: a number or a
|
|
5
|
+
* boolean, a value from a closed list shipped in the code, a keyed digest
|
|
6
|
+
* (usage-run-key.mjs), or an opt-in field reduced to a summary. Whatever the run
|
|
7
|
+
* state, the preferences or the machine configuration hold, a value that is not
|
|
8
|
+
* on its list is dropped or replaced by a constant; nothing is sent because it
|
|
9
|
+
* merely looked harmless. The lists that mirror a schema are checked against
|
|
10
|
+
* that schema by a test, so they cannot drift from it.
|
|
11
|
+
*
|
|
12
|
+
* @module pipeline/lib/usage-vocab
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** agent-state.schema.json `taskType`. */
|
|
16
|
+
export const TASK_TYPES = ["component", "bugfix", "feature", "refactor", "chore"];
|
|
17
|
+
/** prefs.schema.json `outputLanguage`. */
|
|
18
|
+
export const LANGUAGES = ["en", "tr"];
|
|
19
|
+
/** The hosts the pipeline runs in (detectCli). */
|
|
20
|
+
export const CLIS = ["claude", "codex", "copilot"];
|
|
21
|
+
/** Operating systems the package targets, plus the constant for any other. */
|
|
22
|
+
export const OPERATING_SYSTEMS = ["macos", "linux", "windows", "other"];
|
|
23
|
+
/** phase-tracker.sh statuses, plus `done`, the agent-state spelling of completed. */
|
|
24
|
+
export const PHASE_STATUSES = ["pending", "in_progress", "completed", "done", "failed", "skipped"];
|
|
25
|
+
/** Where a run came from (inputType). */
|
|
26
|
+
export const INPUT_TYPES = ["jira", "github-issue", "free-text"];
|
|
27
|
+
/** A repository host the record may name; any other remote is a company's own. */
|
|
28
|
+
export const REMOTE_KINDS = ["github", "gitlab", "bitbucket", "azure", "azure-devops", "gitea"];
|
|
29
|
+
|
|
30
|
+
const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
31
|
+
const VERSION = /^\d{1,3}\.\d{1,3}\.\d{1,3}(?:-(?:rc|beta|alpha)\.\d{1,3})?$/;
|
|
32
|
+
|
|
33
|
+
/** The earliest and latest instant a record may carry. */
|
|
34
|
+
export const MIN_TIME_MS = Date.UTC(2020, 0, 1);
|
|
35
|
+
export const MAX_TIME_MS = Date.UTC(2100, 0, 1);
|
|
36
|
+
/** The longest run or phase duration a record may carry, in seconds (30 days). */
|
|
37
|
+
export const MAX_DURATION_SEC = 30 * 24 * 3600;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Milliseconds since the epoch for a complete ISO 8601 timestamp that parses
|
|
41
|
+
* and falls between 2020 and 2100, else null. Date.parse alone accepts text such
|
|
42
|
+
* as `acme-4711`.
|
|
43
|
+
*/
|
|
44
|
+
export function isoMs(value) {
|
|
45
|
+
if (typeof value !== "string") return null;
|
|
46
|
+
const s = value.trim();
|
|
47
|
+
if (!ISO.test(s)) return null;
|
|
48
|
+
const ms = Date.parse(s);
|
|
49
|
+
return Number.isNaN(ms) || ms < MIN_TIME_MS || ms >= MAX_TIME_MS ? null : ms;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** An instant as UTC ISO text, rounded down to the minute. */
|
|
53
|
+
export function floorMinute(ms) {
|
|
54
|
+
return new Date(Math.floor(ms / 60000) * 60000).toISOString();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The current minute as UTC ISO text. */
|
|
58
|
+
export function nowMinute(now = Date.now()) {
|
|
59
|
+
return floorMinute(now);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A complete, plausible ISO 8601 timestamp as UTC text rounded down to the
|
|
64
|
+
* minute, else null. The user's UTC offset and the seconds never leave the
|
|
65
|
+
* machine: a second-level start time can be joined against public activity.
|
|
66
|
+
* Compare timestamps with isoMs, never as text.
|
|
67
|
+
*/
|
|
68
|
+
export function isoTimestamp(value) {
|
|
69
|
+
const ms = isoMs(value);
|
|
70
|
+
return ms === null ? null : floorMinute(ms);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Seconds between two ISO timestamps, rounded, or null when either is not one,
|
|
75
|
+
* the end precedes the start, or the span exceeds MAX_DURATION_SEC.
|
|
76
|
+
*/
|
|
77
|
+
export function spanSec(start, end) {
|
|
78
|
+
const s = isoMs(start);
|
|
79
|
+
const f = isoMs(end);
|
|
80
|
+
return s === null || f === null ? null : spanMs(s, f);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Seconds between two instants in milliseconds, or null when reversed or over MAX_DURATION_SEC. */
|
|
84
|
+
export function spanMs(startMs, endMs) {
|
|
85
|
+
if (endMs < startMs) return null;
|
|
86
|
+
const sec = Math.round((endMs - startMs) / 1000);
|
|
87
|
+
return sec <= MAX_DURATION_SEC ? sec : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A duration in seconds when it is a finite number within bounds, else null. */
|
|
91
|
+
export function boundedSec(value) {
|
|
92
|
+
return typeof value === "number" &&
|
|
93
|
+
Number.isFinite(value) &&
|
|
94
|
+
value >= 0 &&
|
|
95
|
+
value <= MAX_DURATION_SEC
|
|
96
|
+
? Math.round(value)
|
|
97
|
+
: null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The one validator for a version number anywhere a record carries one: three
|
|
102
|
+
* numbers, and a prerelease only of the shape `-rc.N`, `-beta.N` or `-alpha.N`.
|
|
103
|
+
* Anything else, including a leading `v`, is not a version.
|
|
104
|
+
*/
|
|
105
|
+
export function releaseVersion(value) {
|
|
106
|
+
if (typeof value !== "string") return null;
|
|
107
|
+
const s = value.trim();
|
|
108
|
+
return VERSION.test(s) ? s : null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** `releaseVersion`, or the constant `unknown`. */
|
|
112
|
+
export function versionOrUnknown(value) {
|
|
113
|
+
return releaseVersion(value) ?? "unknown";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The code hosts whose pull request URL the opt-in may send. */
|
|
117
|
+
export const PR_URL_HOSTS = ["github.com", "gitlab.com", "bitbucket.org", "dev.azure.com"];
|
|
118
|
+
|
|
119
|
+
/** Common words by language, for the title summary's language tag. Shipped, never learned. */
|
|
120
|
+
export const TITLE_WORDS = {
|
|
121
|
+
en: [
|
|
122
|
+
"a",
|
|
123
|
+
"add",
|
|
124
|
+
"and",
|
|
125
|
+
"app",
|
|
126
|
+
"for",
|
|
127
|
+
"fix",
|
|
128
|
+
"in",
|
|
129
|
+
"of",
|
|
130
|
+
"on",
|
|
131
|
+
"the",
|
|
132
|
+
"to",
|
|
133
|
+
"with",
|
|
134
|
+
"when",
|
|
135
|
+
"from",
|
|
136
|
+
"is",
|
|
137
|
+
"not",
|
|
138
|
+
"screen",
|
|
139
|
+
"error",
|
|
140
|
+
"update",
|
|
141
|
+
"remove",
|
|
142
|
+
"button",
|
|
143
|
+
"page",
|
|
144
|
+
"crash",
|
|
145
|
+
"after",
|
|
146
|
+
"before",
|
|
147
|
+
"new",
|
|
148
|
+
"bug",
|
|
149
|
+
"user",
|
|
150
|
+
"login",
|
|
151
|
+
"list",
|
|
152
|
+
"show",
|
|
153
|
+
"wrong",
|
|
154
|
+
"missing",
|
|
155
|
+
"support",
|
|
156
|
+
"make",
|
|
157
|
+
"use",
|
|
158
|
+
],
|
|
159
|
+
tr: [
|
|
160
|
+
"ve",
|
|
161
|
+
"ile",
|
|
162
|
+
"bir",
|
|
163
|
+
"bu",
|
|
164
|
+
"icin",
|
|
165
|
+
"için",
|
|
166
|
+
"hata",
|
|
167
|
+
"ekran",
|
|
168
|
+
"sayfa",
|
|
169
|
+
"giris",
|
|
170
|
+
"giriş",
|
|
171
|
+
"buton",
|
|
172
|
+
"duzelt",
|
|
173
|
+
"düzelt",
|
|
174
|
+
"ekle",
|
|
175
|
+
"kaldir",
|
|
176
|
+
"kaldır",
|
|
177
|
+
"olarak",
|
|
178
|
+
"gore",
|
|
179
|
+
"göre",
|
|
180
|
+
"sonra",
|
|
181
|
+
"once",
|
|
182
|
+
"önce",
|
|
183
|
+
"yeni",
|
|
184
|
+
"kullanici",
|
|
185
|
+
"kullanıcı",
|
|
186
|
+
"liste",
|
|
187
|
+
"goster",
|
|
188
|
+
"göster",
|
|
189
|
+
"yanlis",
|
|
190
|
+
"yanlış",
|
|
191
|
+
"eksik",
|
|
192
|
+
"sorun",
|
|
193
|
+
"acilmiyor",
|
|
194
|
+
"açılmıyor",
|
|
195
|
+
"calismiyor",
|
|
196
|
+
"çalışmıyor",
|
|
197
|
+
"guncelle",
|
|
198
|
+
"güncelle",
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/** The value when it is one of `list` (compared as written), else null. */
|
|
203
|
+
export function oneOf(value, list) {
|
|
204
|
+
return typeof value === "string" && list.includes(value) ? value : null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** A finite number or null. */
|
|
208
|
+
export function finite(value) {
|
|
209
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
210
|
+
}
|
|
@@ -280,6 +280,6 @@ on no other run (Locked 36).
|
|
|
280
280
|
|
|
281
281
|
Runs after Step 5a submits and before Phase 1 begins. Reads from `state.analysisSpec.repos[]`. For each repo, walks the platform whitelist and produces a 13-bucket evidence catalogue. No user interaction. Output: `state.analysisSpec.evidence.repoEvidence[<repo>]`. See Phase 1b for the bucket list and tagging rules.
|
|
282
282
|
|
|
283
|
-
####
|
|
283
|
+
#### Output destination (not asked here)
|
|
284
284
|
|
|
285
|
-
The output-destination picker
|
|
285
|
+
Intake does not ask where the document goes. The output-destination picker is **Phase 3.5** in `render.md`, which runs once Phase 3 has written the per-platform draft buffers, so the person chooses with the drafts in front of them.
|
|
@@ -157,7 +157,7 @@ mkdir -p "$(dirname "$STATE")"
|
|
|
157
157
|
STATUS=complete # or failed when the run could not emit its document
|
|
158
158
|
printf '%s' "{\"taskId\":\"$TASK_ID\",\"command\":\"/multi-agent:analysis\",\"mode\":\"analysis\",\"project\":${PROJECT_JSON:-null},\"status\":\"$STATUS\",\"currentPhase\":5,\"finishedAt\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" \
|
|
159
159
|
| node "$HOME/.claude/scripts/write-state.mjs" "$STATE" >/dev/null 2>&1 || true
|
|
160
|
-
node "$HOME/.claude/scripts/usage-report.mjs" --state "$STATE" >/dev/null 2>&1 || true
|
|
160
|
+
node "$HOME/.claude/scripts/usage-report.mjs" --state "$STATE" --detach >/dev/null 2>&1 || true
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
`mode` is `analysis`, one of the modes `schemas/phases.json` declares; the reporter sends only those, and anything else as `unknown`. `status` is `complete` or `failed` (agent-state.schema.json), which the reporter turns into the completed or failed run status. `project` is digested by the reporter before it leaves the machine, and is `null` on a stack-optional run - there is no repository to name. A failure here never affects the run: the reporter is best-effort.
|
|
@@ -148,11 +148,10 @@ Emitted only when `reportContent.costSummary === true` and tracker data is avail
|
|
|
148
148
|
### Cost Summary
|
|
149
149
|
| Phase | Model | Tokens in | Tokens out | Est. USD |
|
|
150
150
|
|-------|-------|-----------|------------|----------|
|
|
151
|
-
| 1.
|
|
152
|
-
| 2.
|
|
153
|
-
| 3.
|
|
154
|
-
|
|
|
155
|
-
| **Total** | | **94,744** | **22,930** | **$2.04** |
|
|
151
|
+
| 1. Plan | opus | 31,384 | 8,330 | $1.08 |
|
|
152
|
+
| 2. Dev | sonnet | 42,310 | 9,880 | $0.27 |
|
|
153
|
+
| 3. Review | opus | 21,050 | 4,720 | $0.66 |
|
|
154
|
+
| **Total** | | **94,744** | **22,930** | **$2.01** |
|
|
156
155
|
```
|
|
157
156
|
|
|
158
157
|
Generated by `$HOME/.claude/scripts/render-cost-summary.sh <task-id>` using prices from `$HOME/.claude/scripts/cost-table.json`. The channels adapter shells out to this renderer - doc table is illustrative only, runtime is authoritative.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Cross-CLI Contract (Claude Code · Copilot CLI · Codex CLI)
|
|
2
2
|
|
|
3
3
|
<!-- toc -->
|
|
4
|
-
- [1. Command Inventory (
|
|
4
|
+
- [1. Command Inventory (80 commands)](#1-command-inventory-80-commands)
|
|
5
5
|
- [2. Canonical Placeholder Vocabulary](#2-canonical-placeholder-vocabulary)
|
|
6
6
|
- [2.6 Intentional structural divergence - two entry files over one set of refs](#26-intentional-structural-divergence---two-entry-files-over-one-set-of-refs)
|
|
7
7
|
- [2.7 One switch, three different meanings: `fable-on` / `fable-off`](#27-one-switch-three-different-meanings-fable-on-fable-off)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
## 1. Command Inventory (
|
|
23
|
+
## 1. Command Inventory (80 commands)
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
address-review, analysis, analysis-jira, analysis-resolve, autopilot-off,
|
|
@@ -28,7 +28,7 @@ autopilot-on, autopilot-status, bug-bash, build-optimize, channels, clean-disk,
|
|
|
28
28
|
create-jira, design-check, diff-explain, doctor, estimate, fable-off, fable-on,
|
|
29
29
|
fable-status, feedback, forget,
|
|
30
30
|
garbage-collect, graph, health, help, ios-coding-standard, issue, jira, kill,
|
|
31
|
-
language, log, manual-test, office-off, office-on, office-status,
|
|
31
|
+
language, log, manual-test, office-off, office-on, office-status, pair,
|
|
32
32
|
postmortem, prune-logs,
|
|
33
33
|
prune-prompts, purge, refactor, research, resume, review,
|
|
34
34
|
review-analysis, review-issue, review-jira, review-priority, route-off, route-on,
|
|
@@ -61,4 +61,4 @@ The coverage gate is a last line of defence, not the plan. If it fires, Phase 3
|
|
|
61
61
|
- **The inventory is the contract**: Phase 0 step 5 decides what "done" means. An audit that visits the linear happy path and lists the rest as "not visited" is the failure mode this command exists to prevent; the gate makes it visible instead of polite.
|
|
62
62
|
- **Chunk with scope, not with silence**: a 50-target module is a legitimate multi-run job. Scope it, finish each run's gate cleanly, and let `--resume` carry the remainder.
|
|
63
63
|
- **"Pixel perfect" is perceptual + geometric**: scale normalized, chrome cropped; findings carry px / pt / hex deltas and a tolerance.
|
|
64
|
-
- The `design_*` engine is project-agnostic; project specifics (mock keys, launch args / targets, node overrides, status-bar crop, coverage floor, Confluence toggle) come from `design-check-config.json` / prefs, never hardcoded.
|
|
64
|
+
- The `design_*` engine is project-agnostic; project specifics (mock keys, launch args / targets, node overrides, status-bar crop, coverage floor, Confluence toggle) come from `design-check-config.json` / prefs, never hardcoded. The file's shape is `$HOME/.claude/schemas/design-check-config.schema.json`; `$HOME/.claude/schemas/examples/design-check-config.json` is a complete example.
|