worktrust 0.10.33 → 0.10.34
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/README.md +12 -0
- package/commit-rules.mjs +447 -0
- package/engine-release.json +1 -1
- package/git-commits.mjs +346 -0
- package/package-release.json +1 -1
- package/package.json +3 -1
- package/worktrust.mjs +45 -5
package/README.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# worktrust
|
|
2
2
|
|
|
3
|
+
## 0.10.34: your own commits, measured on this computer (`npx worktrust git`)
|
|
4
|
+
|
|
5
|
+
GitHub shows an App that reads commits as "Read access to code", and has no narrower permission. `npx worktrust git`
|
|
6
|
+
reads your own commits HERE instead, with `git log`, only those whose author e-mail is yours (git's `user.email`, plus
|
|
7
|
+
any you add with `git emails add`), in the repositories your AI sessions ran in or that you add with `git add <folder>`.
|
|
8
|
+
It asks once, with the list; Enter and `--yes` are No, and a No is remembered. Each commit's file names are turned into
|
|
9
|
+
the same closed keys the GitHub sync makes (kinds of files, technologies, architecture and security markers, one-way
|
|
10
|
+
markers per folder and file) on this computer, and what is sent is counts, keys and markers: never a file name, a
|
|
11
|
+
message, code, the commit's id or the remote's address. A commit travels as an owner-keyed reference only WorkTrust's
|
|
12
|
+
side can match against what GitHub saw. `git list` shows what is offered and agreed, `git remove <folder>` reads nothing
|
|
13
|
+
more from it, `--dry-run` reads and sends nothing.
|
|
14
|
+
|
|
3
15
|
## 0.10.33: one line per autonomous process per day; a fair-use limit keeps the line
|
|
4
16
|
|
|
5
17
|
A finished headless or scheduled run (a run no person started) is no longer a line of its own. It waits on this
|
package/commit-rules.mjs
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
// GENERATED by scripts/build-commit-rules.mjs from packages/core/src/scoring (the sources of truth). Do not edit:
|
|
2
|
+
// `node scripts/build-commit-rules.mjs` rewrites it and `--check` refuses a copy that drifted from core.
|
|
3
|
+
/**
|
|
4
|
+
* WHAT A COMMIT'S FILE NAMES SAY, AS CLOSED KEYS (docs/GITHUB.md): the GitHub walk's own classifiers, transpiled, so a
|
|
5
|
+
* commit read on this computer carries the keys GitHub's copy of it would. The paths never leave this computer.
|
|
6
|
+
*/
|
|
7
|
+
// ── packages/core/src/scoring/stack.ts ──
|
|
8
|
+
const stack = (() => {
|
|
9
|
+
const TECHNOLOGIES = [
|
|
10
|
+
"typescript", "javascript", "python", "go", "rust", "java", "kotlin", "swift", "csharp", "ruby", "php", "cpp", "sql", "shell",
|
|
11
|
+
"react", "nextjs", "vue", "svelte", "angular", "reactNative", "expo", "tailwind", "nodejs", "django", "fastapi", "rails", "dotnet", "spring", "flutter",
|
|
12
|
+
"postgres", "supabase", "prisma", "graphql", "docker", "kubernetes", "terraform", "githubActions", "vercel", "aws", "gcp", "azure",
|
|
13
|
+
"redis", "sqlite", "vitest", "jest", "playwright", "storybook", "cloudflare", "deno", "bun", "drizzle", "vite", "webpack", "electron", "firebase", "sentry", "mcp", "claude",
|
|
14
|
+
"retrieval", "pgvector", "pinecone", "weaviate", "qdrant", "chroma", "langchain", "llamaindex",
|
|
15
|
+
];
|
|
16
|
+
function isTechnology(value) {
|
|
17
|
+
return typeof value === "string" && TECHNOLOGIES.includes(value);
|
|
18
|
+
}
|
|
19
|
+
const BY_EXTENSION = [
|
|
20
|
+
[/\.(ts|mts|cts)$/i, ["typescript"]],
|
|
21
|
+
[/\.tsx$/i, ["typescript", "react"]],
|
|
22
|
+
[/\.jsx$/i, ["javascript", "react"]],
|
|
23
|
+
[/\.(js|mjs|cjs)$/i, ["javascript"]],
|
|
24
|
+
[/\.py$/i, ["python"]],
|
|
25
|
+
[/\.go$/i, ["go"]],
|
|
26
|
+
[/\.rs$/i, ["rust"]],
|
|
27
|
+
[/\.java$/i, ["java"]],
|
|
28
|
+
[/\.kt$/i, ["kotlin"]],
|
|
29
|
+
[/\.swift$/i, ["swift"]],
|
|
30
|
+
[/\.cs$/i, ["csharp"]],
|
|
31
|
+
[/\.rb$/i, ["ruby"]],
|
|
32
|
+
[/\.php$/i, ["php"]],
|
|
33
|
+
[/\.(c|cc|cpp|h|hpp)$/i, ["cpp"]],
|
|
34
|
+
[/\.sql$/i, ["sql"]],
|
|
35
|
+
[/\.(sqlite|sqlite3)$/i, ["sqlite"]],
|
|
36
|
+
[/\.(sh|bash|zsh)$/i, ["shell"]],
|
|
37
|
+
[/\.vue$/i, ["vue"]],
|
|
38
|
+
[/\.svelte$/i, ["svelte"]],
|
|
39
|
+
[/\.dart$/i, ["flutter"]],
|
|
40
|
+
[/\.prisma$/i, ["prisma"]],
|
|
41
|
+
[/\.(graphql|gql)$/i, ["graphql"]],
|
|
42
|
+
[/\.tf$/i, ["terraform"]],
|
|
43
|
+
];
|
|
44
|
+
const BY_NAME = [
|
|
45
|
+
[/(^|\/)next\.config\.(js|mjs|ts)$/i, ["nextjs"]],
|
|
46
|
+
[/(^|\/)tailwind\.config\.(js|mjs|ts)$|(^|\/)postcss\.config\./i, ["tailwind"]],
|
|
47
|
+
[/(^|\/)package(-lock)?\.json$|(^|\/)pnpm-lock\.yaml$|(^|\/)yarn\.lock$/i, ["nodejs"]],
|
|
48
|
+
[/(^|\/)app\.json$|(^|\/)eas\.json$/i, ["expo", "reactNative"]],
|
|
49
|
+
[/(^|\/)angular\.json$/i, ["angular"]],
|
|
50
|
+
[/(^|\/)manage\.py$|(^|\/)settings\.py$/i, ["django"]],
|
|
51
|
+
[/(^|\/)(requirements\.txt|pyproject\.toml|Pipfile)$/i, ["python"]],
|
|
52
|
+
[/(^|\/)Gemfile(\.lock)?$|(^|\/)config\/routes\.rb$/i, ["rails"]],
|
|
53
|
+
[/\.csproj$|(^|\/)Program\.cs$/i, ["dotnet"]],
|
|
54
|
+
[/(^|\/)pom\.xml$|(^|\/)build\.gradle(\.kts)?$/i, ["spring"]],
|
|
55
|
+
[/(^|\/)pubspec\.yaml$/i, ["flutter"]],
|
|
56
|
+
[/(^|\/)supabase\//i, ["supabase", "postgres"]],
|
|
57
|
+
[/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml)$/i, ["docker"]],
|
|
58
|
+
[/(^|\/)(k8s|kubernetes|helm)\//i, ["kubernetes"]],
|
|
59
|
+
[/(^|\/)\.github\/workflows\//i, ["githubActions"]],
|
|
60
|
+
[/(^|\/)vercel\.json$/i, ["vercel"]],
|
|
61
|
+
[/(^|\/)(cloudformation|cdk)\/|(^|\/)serverless\.ya?ml$/i, ["aws"]],
|
|
62
|
+
[/(^|\/)app\.yaml$|(^|\/)cloudbuild\.ya?ml$/i, ["gcp"]],
|
|
63
|
+
[/(^|\/)azure-pipelines\.ya?ml$|(^|\/)host\.json$/i, ["azure"]],
|
|
64
|
+
[/(^|\/)redis\.conf$|(^|\/)redis\//i, ["redis"]],
|
|
65
|
+
[/(^|\/)vitest\.(config|workspace)\.[cm]?[jt]s$/i, ["vitest"]],
|
|
66
|
+
[/(^|\/)jest\.config\.[cm]?[jt]s$|(^|\/)jest\.setup\.[cm]?[jt]s$/i, ["jest"]],
|
|
67
|
+
[/(^|\/)playwright\.config\.[cm]?[jt]s$/i, ["playwright"]],
|
|
68
|
+
[/(^|\/)\.storybook\/|\.stories\.[jt]sx?$/i, ["storybook"]],
|
|
69
|
+
[/(^|\/)wrangler\.(toml|jsonc?)$/i, ["cloudflare"]],
|
|
70
|
+
[/(^|\/)deno\.(jsonc?|lock)$/i, ["deno"]],
|
|
71
|
+
[/(^|\/)bun\.lockb?$|(^|\/)bunfig\.toml$/i, ["bun"]],
|
|
72
|
+
[/(^|\/)drizzle\.config\.[cm]?[jt]s$|(^|\/)drizzle\//i, ["drizzle"]],
|
|
73
|
+
[/(^|\/)vite\.config\.[cm]?[jt]s$/i, ["vite"]],
|
|
74
|
+
[/(^|\/)webpack\.config\.[cm]?[jt]s$/i, ["webpack"]],
|
|
75
|
+
[/(^|\/)electron-builder\.(ya?ml|json)$|(^|\/)electron\.vite\.config\.[cm]?[jt]s$/i, ["electron"]],
|
|
76
|
+
[/(^|\/)firebase\.json$|(^|\/)\.firebaserc$/i, ["firebase"]],
|
|
77
|
+
[/(^|\/)sentry\.[a-z]+\.config\.[cm]?[jt]s$/i, ["sentry"]],
|
|
78
|
+
[/(^|\/)\.mcp\.json$|(^|\/)mcp\.json$/i, ["mcp"]],
|
|
79
|
+
[/(^|\/)\.claude\/|(^|\/)CLAUDE\.md$/i, ["claude"]],
|
|
80
|
+
[/(^|\/)(rag|retrieval|embeddings?|vector[-_]?stores?)(\/|\.)/i, ["retrieval"]],
|
|
81
|
+
[/(^|\/)pgvector(\/|\.)|(^|\/)migrations?\/[^/]*(vector|embedding)[^/]*\.sql$/i, ["pgvector", "retrieval"]],
|
|
82
|
+
[/(^|\/)pinecone[^/]*(\/|\.)/i, ["pinecone", "retrieval"]],
|
|
83
|
+
[/(^|\/)weaviate[^/]*(\/|\.)/i, ["weaviate", "retrieval"]],
|
|
84
|
+
[/(^|\/)qdrant[^/]*(\/|\.)/i, ["qdrant", "retrieval"]],
|
|
85
|
+
[/(^|\/)chroma(\/|\.sqlite3$)/i, ["chroma", "retrieval"]],
|
|
86
|
+
[/(^|\/)langchain[^/]*(\/|\.)|(^|\/)langgraph\.json$/i, ["langchain"]],
|
|
87
|
+
[/(^|\/)llama[-_]?index[^/]*(\/|\.)/i, ["llamaindex", "retrieval"]],
|
|
88
|
+
];
|
|
89
|
+
function stackOfFile(path) {
|
|
90
|
+
const found = new Set();
|
|
91
|
+
for (const [pattern, keys] of BY_NAME)
|
|
92
|
+
if (pattern.test(path))
|
|
93
|
+
for (const key of keys)
|
|
94
|
+
found.add(key);
|
|
95
|
+
for (const [pattern, keys] of BY_EXTENSION)
|
|
96
|
+
if (pattern.test(path))
|
|
97
|
+
for (const key of keys)
|
|
98
|
+
found.add(key);
|
|
99
|
+
return [...found].sort();
|
|
100
|
+
}
|
|
101
|
+
function manifestsOfFiles(paths) {
|
|
102
|
+
const out = new Set();
|
|
103
|
+
for (const path of paths)
|
|
104
|
+
for (const [pattern, techs] of BY_NAME)
|
|
105
|
+
if (pattern.test(path))
|
|
106
|
+
for (const tech of techs)
|
|
107
|
+
out.add(tech);
|
|
108
|
+
return [...out].sort();
|
|
109
|
+
}
|
|
110
|
+
function stackOfFiles(paths) {
|
|
111
|
+
const found = new Set();
|
|
112
|
+
for (const path of paths)
|
|
113
|
+
for (const key of stackOfFile(path))
|
|
114
|
+
found.add(key);
|
|
115
|
+
return [...found].sort();
|
|
116
|
+
}
|
|
117
|
+
function technologiesBlock(counts, marks = new Map()) {
|
|
118
|
+
return counts
|
|
119
|
+
.filter((count) => isTechnology(count.technology) && count.repositoryEvents + count.reportedEvents > 0)
|
|
120
|
+
.map((count) => {
|
|
121
|
+
const mark = marks.get(count.technology);
|
|
122
|
+
return { technology: count.technology, repositoryEvents: count.repositoryEvents, reportedEvents: count.reportedEvents, ...(mark ? { level: mark.level, ...(mark.state ? { state: mark.state } : {}) } : {}) };
|
|
123
|
+
})
|
|
124
|
+
.sort((a, b) => b.repositoryEvents - a.repositoryEvents || b.reportedEvents - a.reportedEvents);
|
|
125
|
+
}
|
|
126
|
+
return { TECHNOLOGIES, isTechnology, stackOfFile, manifestsOfFiles, stackOfFiles, technologiesBlock };
|
|
127
|
+
})();
|
|
128
|
+
|
|
129
|
+
// ── packages/core/src/scoring/git-classes.ts ──
|
|
130
|
+
const gitClasses = (() => {
|
|
131
|
+
const TEST = /(^|\/)(__tests__|tests?|spec)\/|\.(test|spec)\.[a-z]+$|_test\.(go|py|rb)$/i;
|
|
132
|
+
const DATABASE = /(^|\/)migrations?\/|\.sql$|(^|\/)(schema|seed)s?\.(prisma|sql|ts|rb)$/i;
|
|
133
|
+
const CICD = /(^|\/)\.github\/workflows\/[^/]+\.ya?ml$|(^|\/)\.circleci\/[^/]+\.ya?ml$|(^|\/)\.buildkite\/[^/]+\.ya?ml$|(^|\/)\.gitlab-ci\.ya?ml$|(^|\/)\.travis\.ya?ml$|(^|\/)Jenkinsfile(\.groovy)?$|(^|\/)azure-pipelines[^/]*\.ya?ml$|(^|\/)bitbucket-pipelines\.ya?ml$|(^|\/)cloudbuild\.ya?ml$|(^|\/)\.drone\.ya?ml$/i;
|
|
134
|
+
const INFRA = /(^|\/)\.github\/|(^|\/)(infra|terraform|k8s|helm|deploy|ansible)\/|\.(tf|tfvars|yaml|yml)$|(^|\/)(Dockerfile|docker-compose[^/]*|Makefile|Procfile)$/i;
|
|
135
|
+
const AGENT_CONFIG = /(^|\/)\.claude\/|(^|\/)(CLAUDE|AGENTS)\.md$|(^|\/)\.cursor(rules|\/)|(^|\/)\.github\/copilot-instructions\.md$|(^|\/)(mcp|\.mcp)\.json$|(^|\/)skills\/[^/]+\/SKILL\.md$|(^|\/)agents\/[^/]+\.md$/i;
|
|
136
|
+
const RD = /(^|\/)(experiments?|spikes?|prototypes?|research|labs?|sandbox|playground|pocs?|proof-of-concepts?|notebooks?)\/|\.ipynb$/i;
|
|
137
|
+
const CLASSIFIER_VERSION = "1.0.36";
|
|
138
|
+
const ARCHITECTURE = /(^|\/)(adrs?|rfcs?|architecture|design-docs?|decisions|proposals?)\/.*\.(md|mdx|rst|adoc|txt)$|(^|\/)(ARCHITECTURE|DESIGN)\.md$|(^|\/)adr-?\d+[^/]*\.(md|mdx)$/i;
|
|
139
|
+
const ML = /^((ml|research|experiments?)\/)?(training|checkpoints?|datasets?|fine-?tun\w*|finetun\w*|wandb|mlruns|machine-?learning|inference)\/.*\.(py|ts|js|yaml|yml|json|csv|parquet|jsonl)$|(^|\/)(train|training|finetune|fine-tune)\.py$|\.(safetensors|pt|pth|ckpt|gguf|onnx|h5|tflite)$/i;
|
|
140
|
+
const DATA = /^(data\/)?(etl|elt|dags?|airflow|dbt|warehouse|lakehouse|data-?pipelines?)\/.*\.(py|sql|ts|js|scala|r|go)$/i;
|
|
141
|
+
const SECURITY_DIRS = "auth|authn|authz|authentication|authorization|oauth|permissions?|rbac|acl|security|signing|jwt|jwks|mfa|totp|secrets?|vault|csp";
|
|
142
|
+
const SECURITY_NAMES = "auth|authn|authz|authentication|authorization|oauth|jwt|jwks|mfa|totp|rbac|acl|csp|permissions?";
|
|
143
|
+
const SECURITY_EXT = "\\.(ts|js|mjs|cjs|mts|cts|py|go|rs|java|kt|rb|php|cs|scala|ex|exs|swift|dart|prisma)$";
|
|
144
|
+
const SECURITY = new RegExp(`(^|\\/)(${SECURITY_DIRS})\\/.*${SECURITY_EXT}|(^|\\/)([^/]*[._-])?(${SECURITY_NAMES})([._-][^/]*)?${SECURITY_EXT}`, "i");
|
|
145
|
+
const MOBILE_EXT = "\\.(swift|kt|kts|java|dart|m|mm|ts|tsx|js|jsx|gradle|plist|storyboard|xib|xcconfig|pbxproj)$";
|
|
146
|
+
const MOBILE = new RegExp(`(^|\\/)(ios|android|mobile|react-native|expo)\\/.*${MOBILE_EXT}|(^|\\/)app\\/src\\/main\\/.*${MOBILE_EXT}|AndroidManifest\\.xml$|\\.(swift|dart|storyboard|xib)$|(^|\\/)eas\\.json$|(mobile|expo|native)[^/]*\\/[^/]*\\bapp\\.json$|(^|\\/)(Podfile|Podfile\\.lock|Info\\.plist|\\.xcconfig)$|\\.xcodeproj(\\/|$)`, "i");
|
|
147
|
+
const BACKEND_HOMES = /(^|\/)(app|pages|src\/app|src\/pages)\/api\/.*\.(ts|js|mjs|cjs|mts|cts)$|^(server|backend|controllers?|db)\/.*\.(ts|js|mjs|cjs|mts|cts)$|(^|\/)(server|backend|controllers?)\/.*\.(ts|js|mjs|cjs|mts|cts)$|(^|\/)(supabase|netlify|firebase)\/functions\/.*\.(ts|js|mjs|cjs|mts|cts)$|^functions\/.*\.(ts|js|mjs|cjs|mts|cts)$|(^|\/)lib\/db\/.*\.(ts|js|mjs|cjs|mts|cts)$/i;
|
|
148
|
+
const DOCS = /\.(md|mdx|rst|txt|adoc)$|(^|\/)(docs?|LICENSE|README)(\/|$)/i;
|
|
149
|
+
const FRONTEND = /\.(css|scss|sass|less|html|vue|svelte|astro|jsx|tsx)$/i;
|
|
150
|
+
const BACKEND = /\.(py|go|rs|java|kt|rb|php|cs|scala|ex|exs|clj|swift|c|cc|cpp|h|hpp)$/i;
|
|
151
|
+
const INTEGRATION = /(^|\/)(integrations?|connectors?|webhooks?|clients?|sdk)\/|\.(proto|graphql|gql)$|(^|\/)openapi\.(yaml|yml|json)$/i;
|
|
152
|
+
const CODE_EXT = "\\.(ts|tsx|js|jsx|mjs|cjs|mts|cts|py|go|rs|java|kt|rb|php|cs|scala|ex|exs|swift|dart|vue|svelte|prisma)$";
|
|
153
|
+
const PROVIDERS = "stripe|adyen|mollie|rootline|paypal|braintree|klarna";
|
|
154
|
+
const PAYMENT_HOMES = "checkout|billing|payments?|invoices?";
|
|
155
|
+
const PAYMENTS = new RegExp(`(^|\\/)[^/]*(${PROVIDERS})[^/]*${CODE_EXT}|(^|\\/)(${PROVIDERS}|${PAYMENT_HOMES})\\/.*${CODE_EXT}|(^|\\/)(${PAYMENT_HOMES})${CODE_EXT}`, "i");
|
|
156
|
+
const TENANCY = new RegExp(`(^|\\/)[^/]*(tenants?|tenancy|multi-?tenant|workspaces?)[^/]*${CODE_EXT}|(^|\\/)(tenants?|tenancy|multi-?tenant|workspaces?|organi[sz]ations?|rls|row-level-security)(\\/.*)?${CODE_EXT}`, "i");
|
|
157
|
+
const CONTAINERS = /(^|\/)(Dockerfile[^/]*|Containerfile|docker-compose[^/]*\.ya?ml|compose\.ya?ml|\.dockerignore)$|(^|\/)(docker|containers?)\/.*\.(ya?ml|Dockerfile|sh|conf|env)$/i;
|
|
158
|
+
const ORCHESTRATION = /(^|\/)(k8s|kubernetes|helm|kustomize|manifests|argocd|argo|flux)\/.*\.(ya?ml|tpl|json)$|^charts?\/.*\.(ya?ml|tpl)$|(^|\/)(Chart|kustomization|skaffold)\.ya?ml$|(^|\/)(helm|charts?)\/[^/]*values[^/]*\.ya?ml$/i;
|
|
159
|
+
const API_CODE = "\\.(ts|js|mjs|cjs|mts|cts|py|go|rs|java|kt|rb|php|cs|scala|ex|exs)$";
|
|
160
|
+
const API = new RegExp(`(^|\\/)(app|pages|src\\/app|src\\/pages)\\/api\\/.*${API_CODE}|^(api|server\\/api|backend\\/api)\\/.*${API_CODE}|(^|\\/)openapi\\.(ya?ml|json)$|(^|\\/)swagger\\.(ya?ml|json)$|\\.(proto|graphql|gql)$`, "i");
|
|
161
|
+
const OBSERVABILITY = new RegExp(`(^|\\/)(observability|telemetry|tracing|monitoring|alerts?|alerting|metrics|logging|loggers?)\\/.*${API_CODE}|(^|\\/)(otel|opentelemetry|sentry|datadog|prometheus|grafana|newrelic|honeycomb)[^/]*\\.(ts|js|mjs|py|go|ya?ml|json|toml)$|(^|\\/)([^/]*[._-])?(logger|tracing|telemetry)\\.(ts|js|mjs|py|go|rs)$`, "i");
|
|
162
|
+
const ASYNC = new RegExp(`(^|\\/)(queues?|jobs|consumers?|subscribers?|pubsub|kafka|rabbitmq|sqs|bullmq|temporal|cron|schedulers?|background)\\/.*${API_CODE}|(^|\\/)[^/]*\\.(job|consumer|queue|cron)\\.(ts|js|mjs|py|go|rs)$`, "i");
|
|
163
|
+
const GOVERNANCE = /(^|\/)(\.github\/)?(CODEOWNERS|CODE_OF_CONDUCT|CONTRIBUTING|GOVERNANCE|MAINTAINERS|RELEASING)(\.(md|mdx|rst|txt))?$|(^|\/)(\.github\/)?(CHANGELOG|CHANGES|HISTORY|SECURITY)\.(md|mdx|rst|txt)$|(^|\/)\.github\/(PULL_REQUEST_TEMPLATE|pull_request_template)(\.md)?$|(^|\/)\.github\/PULL_REQUEST_TEMPLATE\/[^/]+$|(^|\/)\.github\/(ISSUE_TEMPLATE|issue_template)\/[^/]+$|(^|\/)\.changeset\/(?!README\.md$)[^/]+\.md$/;
|
|
164
|
+
const CODE = /\.(ts|js|mjs|cjs|mts|cts)$/i;
|
|
165
|
+
const CLASS_RULES = [
|
|
166
|
+
{ id: "agentConfig", test: AGENT_CONFIG, cls: "agentConfig" },
|
|
167
|
+
{ id: "test", test: TEST, cls: "testing" },
|
|
168
|
+
{ id: "governance", test: GOVERNANCE, cls: "governance" },
|
|
169
|
+
{ id: "architecture", test: ARCHITECTURE, cls: "architecture" },
|
|
170
|
+
{ id: "rd", test: RD, cls: "rd" },
|
|
171
|
+
{ id: "ml", test: ML, cls: "ai_ml" },
|
|
172
|
+
{ id: "data", test: DATA, cls: "data" },
|
|
173
|
+
{ id: "database", test: DATABASE, cls: "database" },
|
|
174
|
+
{ id: "tenancy", test: TENANCY, cls: "tenancy" },
|
|
175
|
+
{ id: "payments", test: PAYMENTS, cls: "payments" },
|
|
176
|
+
{ id: "api", test: API, cls: "api" },
|
|
177
|
+
{ id: "cicd", test: CICD, cls: "ci_cd" },
|
|
178
|
+
{ id: "containers", test: CONTAINERS, cls: "containers" },
|
|
179
|
+
{ id: "orchestration", test: ORCHESTRATION, cls: "orchestration" },
|
|
180
|
+
{ id: "infra", test: INFRA, cls: "infrastructure" },
|
|
181
|
+
{ id: "integration", test: INTEGRATION, cls: "integration" },
|
|
182
|
+
{ id: "security", test: SECURITY, cls: "security" },
|
|
183
|
+
{ id: "observability", test: OBSERVABILITY, cls: "observability" },
|
|
184
|
+
{ id: "async", test: ASYNC, cls: "async" },
|
|
185
|
+
{ id: "docs", test: DOCS, cls: "docs" },
|
|
186
|
+
{ id: "mobile", test: MOBILE, cls: "mobile" },
|
|
187
|
+
{ id: "frontend", test: FRONTEND, cls: "frontend" },
|
|
188
|
+
{ id: "backendHomes", test: BACKEND_HOMES, cls: "backend" },
|
|
189
|
+
{ id: "backend", test: BACKEND, cls: "backend" },
|
|
190
|
+
{ id: "code", test: CODE, cls: "code" },
|
|
191
|
+
];
|
|
192
|
+
function classRuleOf(path) {
|
|
193
|
+
for (const rule of CLASS_RULES)
|
|
194
|
+
if (rule.test.test(path))
|
|
195
|
+
return { id: rule.id, cls: rule.cls };
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function classOfFile(path) {
|
|
199
|
+
return classRuleOf(path)?.cls ?? null;
|
|
200
|
+
}
|
|
201
|
+
function classesOfFiles(paths) {
|
|
202
|
+
const classes = new Set();
|
|
203
|
+
for (const path of paths) {
|
|
204
|
+
const cls = classOfFile(path);
|
|
205
|
+
if (cls)
|
|
206
|
+
classes.add(cls);
|
|
207
|
+
}
|
|
208
|
+
return [...classes].sort();
|
|
209
|
+
}
|
|
210
|
+
const isBotLogin = (login, type) => type === "Bot" || /\[bot\]$/i.test(login ?? "");
|
|
211
|
+
return { CLASSIFIER_VERSION, CLASS_RULES, classRuleOf, classOfFile, classesOfFiles, isBotLogin };
|
|
212
|
+
})();
|
|
213
|
+
|
|
214
|
+
// ── packages/core/src/scoring/architecture.ts ──
|
|
215
|
+
const architecture = (() => {
|
|
216
|
+
const ARCHITECTURE_POINTS = ["observability", "performance", "migrationDiscipline", "securityAccessControls", "operations", "architectureComplexity"];
|
|
217
|
+
const OBSERVABILITY = /(^|\/)(logging|logger|metrics|telemetry|tracing|monitoring|alerts?|observab)[^/]*(\/|\.|$)|sentry|opentelemetry|otel|prometheus|grafana|datadog/i;
|
|
218
|
+
const PERFORMANCE = /(^|\/)(perf|performance|cache|caching|benchmark|profil)[^/]*(\/|\.|$)|_index\.sql$|(^|\/)indexes?\.(sql|ts)$|explain|redis/i;
|
|
219
|
+
const MIGRATION = /(^|\/)migrations?\/[^/]+\.(sql|ts|js|rb|py)$/i;
|
|
220
|
+
const SECURITY = /(^|\/)(auth|oauth|rls|polic(y|ies)|permissions?|rbac|acl|secur|crypto|signing|signature|jwt|jwks|mfa|totp|secrets?|vault|csp|security-headers)[^/]*(\/|\.|$)/i;
|
|
221
|
+
const OPERATIONS = /(^|\/)\.github\/workflows\/|(^|\/)(infra|terraform|k8s|kubernetes|helm|deploy|ansible|ops|runbooks?|cron)\/|(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml|vercel\.json|fly\.toml|Procfile)$|\.tf$/i;
|
|
222
|
+
function archOfFile(path) {
|
|
223
|
+
const found = [];
|
|
224
|
+
if (OBSERVABILITY.test(path))
|
|
225
|
+
found.push("observability");
|
|
226
|
+
if (PERFORMANCE.test(path))
|
|
227
|
+
found.push("performance");
|
|
228
|
+
if (MIGRATION.test(path))
|
|
229
|
+
found.push("migrationDiscipline");
|
|
230
|
+
if (SECURITY.test(path))
|
|
231
|
+
found.push("securityAccessControls");
|
|
232
|
+
if (OPERATIONS.test(path))
|
|
233
|
+
found.push("operations");
|
|
234
|
+
return found;
|
|
235
|
+
}
|
|
236
|
+
const packageOf = (path) => {
|
|
237
|
+
const m = /^(apps|packages|services|libs|modules)\/([^/]+)\//.exec(path);
|
|
238
|
+
return m ? `${m[1]}/${m[2]}` : null;
|
|
239
|
+
};
|
|
240
|
+
function archOfFiles(paths) {
|
|
241
|
+
const found = new Set();
|
|
242
|
+
const packages = new Set();
|
|
243
|
+
for (const path of paths) {
|
|
244
|
+
for (const key of archOfFile(path))
|
|
245
|
+
found.add(key);
|
|
246
|
+
const pkg = packageOf(path);
|
|
247
|
+
if (pkg)
|
|
248
|
+
packages.add(pkg);
|
|
249
|
+
}
|
|
250
|
+
if (packages.size >= 2)
|
|
251
|
+
found.add("architectureComplexity");
|
|
252
|
+
return [...found].sort();
|
|
253
|
+
}
|
|
254
|
+
const ARCHITECTURE_DIMENSION = "architecture";
|
|
255
|
+
return { ARCHITECTURE_POINTS, archOfFile, archOfFiles, ARCHITECTURE_DIMENSION };
|
|
256
|
+
})();
|
|
257
|
+
|
|
258
|
+
// ── packages/core/src/scoring/security-markers.ts ──
|
|
259
|
+
const securityMarkers = (() => {
|
|
260
|
+
const SECURITY_MARKERS = [
|
|
261
|
+
"authentication", "authorization", "identityFederation", "secretsManagement", "encryption", "signing",
|
|
262
|
+
"rateLimiting", "auditLogging", "transportSecurity", "backupRecovery", "dependencyHygiene",
|
|
263
|
+
];
|
|
264
|
+
const CODE = "\\.(ts|tsx|js|jsx|mjs|cjs|mts|cts|py|go|rs|java|kt|rb|php|cs|scala|ex|exs|swift|dart|sql|prisma|ya?ml|json|toml|tf)$";
|
|
265
|
+
const dirOrName = (tokens) => new RegExp(`(^|\\/)(${tokens})\\/.*${CODE}|(^|\\/)([^/]*[._-])?(${tokens})([._-][^/]*)?${CODE}`, "i");
|
|
266
|
+
const RULES = [
|
|
267
|
+
{ marker: "authentication", test: dirOrName("auth|authn|authentication|login|oauth|oidc-client|jwt|jwks|mfa|totp|passkeys?|webauthn") },
|
|
268
|
+
{ marker: "authorization", test: dirOrName("authz|authorization|permissions?|rbac|abac|acl|(access|auth)-?polic(y|ies)|rls|guards?") },
|
|
269
|
+
{ marker: "identityFederation", test: dirOrName("sso|oidc|saml|scim|openid|federation|idp") },
|
|
270
|
+
{ marker: "secretsManagement", test: dirOrName("secrets?|vault|kms|keyvault|sops|dotenv-vault") },
|
|
271
|
+
{ marker: "encryption", test: dirOrName("encrypt(ion)?|cipher|crypto|pseudonymi[sz]|anonymi[sz]|tokeni[sz]|argon2?|bcrypt|scrypt") },
|
|
272
|
+
{ marker: "signing", test: new RegExp(`(^|\\/)(signing|cosign|sigstore|gpg|attestations?)\\/.*${CODE}|(^|\\/)(signing|crypto)\\/[^/]*signatures?[^/]*${CODE}|(^|\\/)([^/]*[._-])?(signing|cosign|sigstore|gpg|hmac|attestations?)([._-][^/]*)?${CODE}`, "i") },
|
|
273
|
+
{ marker: "rateLimiting", test: dirOrName("rate-?limit(er|ing)?|ratelimit|throttl(e|ing)|quota") },
|
|
274
|
+
{ marker: "auditLogging", test: dirOrName("audit(-?log|-?trail)?|audits") },
|
|
275
|
+
{ marker: "transportSecurity", test: dirOrName("csp|security-?headers|cors|hsts|tls|ssl|certs?|certificates?|helmet") },
|
|
276
|
+
{ marker: "backupRecovery", test: dirOrName("backups?|restore|pitr|disaster-?recovery") },
|
|
277
|
+
{ marker: "dependencyHygiene", test: /(^|\/)\.github\/dependabot\.ya?ml$|(^|\/)renovate\.json5?$|(^|\/)\.renovaterc(\.json)?$|(^|\/)\.snyk$|(^|\/)(trivy|grype|audit-ci)[^/]*\.(ya?ml|json)$|(^|\/)\.github\/workflows\/[^/]*(codeql|dependency|security|audit|scan)[^/]*\.ya?ml$/i },
|
|
278
|
+
];
|
|
279
|
+
function securityMarkersOfFile(path) {
|
|
280
|
+
return RULES.filter((rule) => rule.test.test(path)).map((rule) => rule.marker);
|
|
281
|
+
}
|
|
282
|
+
function securityMarkersOfFiles(paths) {
|
|
283
|
+
const found = new Set();
|
|
284
|
+
for (const path of paths)
|
|
285
|
+
for (const marker of securityMarkersOfFile(path))
|
|
286
|
+
found.add(marker);
|
|
287
|
+
return [...found].sort();
|
|
288
|
+
}
|
|
289
|
+
const num = (value) => (typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value)) ? Number(value) : null);
|
|
290
|
+
const isMarker = (value) => SECURITY_MARKERS.includes(String(value));
|
|
291
|
+
function securityCoverageOf(value) {
|
|
292
|
+
if (!value || typeof value !== "object")
|
|
293
|
+
return null;
|
|
294
|
+
const raw = value.markers;
|
|
295
|
+
if (!Array.isArray(raw))
|
|
296
|
+
return null;
|
|
297
|
+
const markers = [];
|
|
298
|
+
for (const row of raw) {
|
|
299
|
+
const units = num(row.units), strictUnits = num(row.strictUnits), projects = num(row.projects);
|
|
300
|
+
if (!isMarker(row.marker) || units === null || strictUnits === null || projects === null || typeof row.production !== "boolean")
|
|
301
|
+
continue;
|
|
302
|
+
markers.push({ marker: row.marker, units, strictUnits, projects, production: row.production, lastAt: typeof row.lastAt === "string" ? new Date(row.lastAt).toISOString() : null });
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
total: SECURITY_MARKERS.length,
|
|
306
|
+
covered: markers.filter((m) => m.units > 0).length,
|
|
307
|
+
inProduction: markers.filter((m) => m.units > 0 && m.production).length,
|
|
308
|
+
strictCovered: markers.filter((m) => m.strictUnits > 0).length,
|
|
309
|
+
markers: markers.sort((a, b) => b.units - a.units || a.marker.localeCompare(b.marker)),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return { SECURITY_MARKERS, securityMarkersOfFile, securityMarkersOfFiles, securityCoverageOf };
|
|
313
|
+
})();
|
|
314
|
+
|
|
315
|
+
// ── packages/core/src/scoring/agent-markers.ts ──
|
|
316
|
+
const agentMarkers = (() => {
|
|
317
|
+
const AGENT_MARKERS = [
|
|
318
|
+
"agentDefinition",
|
|
319
|
+
"skillDefinition",
|
|
320
|
+
"hookDefinition",
|
|
321
|
+
"slashCommand",
|
|
322
|
+
"assistantBrief",
|
|
323
|
+
"mcpManifest",
|
|
324
|
+
"mcpServer",
|
|
325
|
+
"promptTemplate",
|
|
326
|
+
"evalHarness",
|
|
327
|
+
];
|
|
328
|
+
const RULES = [
|
|
329
|
+
{ marker: "agentDefinition", test: /(^|\/)\.(claude|opencode|kilocode)\/agents\/[^/]+\.(md|ya?ml|json)$|(^|\/)agents\/[^/]+\.md$/i },
|
|
330
|
+
{ marker: "skillDefinition", test: /(^|\/)skills\/[^/]+\/SKILL\.(md|ya?ml)$|(^|\/)\.(claude|opencode)\/skills\//i },
|
|
331
|
+
{ marker: "hookDefinition", test: /(^|\/)\.(claude|opencode|cursor)\/hooks\/|(^|\/)hooks\/[^/]*(session|pretool|posttool|prompt|stop)[^/]*\.(m?[jt]s|py|sh)$/i },
|
|
332
|
+
{ marker: "slashCommand", test: /(^|\/)\.(claude|opencode)\/commands\/[^/]+\.(md|ya?ml)$/i },
|
|
333
|
+
{ marker: "assistantBrief", test: /(^|\/)(CLAUDE|AGENTS|GEMINI|CONVENTIONS)\.md$|(^|\/)\.cursorrules$|(^|\/)\.cursor\/rules\/|(^|\/)\.github\/copilot-instructions\.md$|(^|\/)\.windsurfrules$|(^|\/)\.aider\.conf\.ya?ml$/i },
|
|
334
|
+
{ marker: "mcpManifest", test: /(^|\/)\.?mcp\.json$|(^|\/)\.(claude|cursor|vscode)\/mcp\.json$/i },
|
|
335
|
+
{ marker: "mcpServer", test: /(^|\/)mcp(-server)?\/.*\.(m?[jt]sx?|py|go|rs|rb|java|cs)$|(^|\/)[^/]*mcp[-_]?server[^/]*\.(m?[jt]sx?|py|go|rs)$/i },
|
|
336
|
+
{ marker: "promptTemplate", test: /(^|\/)prompts?\/[^/]+\.(md|txt|ya?ml|json|jinja2?|hbs|mustache)$|(^|\/)[^/]*\.prompt\.(md|txt|ya?ml)$/i },
|
|
337
|
+
{ marker: "evalHarness", test: /(^|\/)(evals?|evaluations?|benchmarks?\/(llm|model|prompt)[^/]*)\/[^/]+\.(m?[jt]sx?|py)$|(^|\/)evals\/[^/]+\.jsonl$|(^|\/)[^/]*\.eval\.(m?[jt]s|py)$/i },
|
|
338
|
+
];
|
|
339
|
+
const MARKER_VERSION = "1.0.2";
|
|
340
|
+
function agentMarkersOfFile(path) {
|
|
341
|
+
return RULES.filter((rule) => rule.test.test(path)).map((rule) => rule.marker);
|
|
342
|
+
}
|
|
343
|
+
function agentMarkersOfFiles(paths) {
|
|
344
|
+
const found = new Set();
|
|
345
|
+
for (const path of paths)
|
|
346
|
+
for (const marker of agentMarkersOfFile(path))
|
|
347
|
+
found.add(marker);
|
|
348
|
+
return [...found].sort();
|
|
349
|
+
}
|
|
350
|
+
function isAgentMarker(value) {
|
|
351
|
+
return typeof value === "string" && AGENT_MARKERS.includes(value);
|
|
352
|
+
}
|
|
353
|
+
const AGENT_MARKER_AREA = {
|
|
354
|
+
agentDefinition: "agentsTools",
|
|
355
|
+
skillDefinition: "agentsTools",
|
|
356
|
+
hookDefinition: "agentsTools",
|
|
357
|
+
slashCommand: "agentsTools",
|
|
358
|
+
assistantBrief: "agentsTools",
|
|
359
|
+
mcpManifest: "agentsTools",
|
|
360
|
+
mcpServer: "agentsTools",
|
|
361
|
+
promptTemplate: "models",
|
|
362
|
+
evalHarness: "evaluation",
|
|
363
|
+
};
|
|
364
|
+
function decodeAgentMarkerRows(raw) {
|
|
365
|
+
if (!Array.isArray(raw))
|
|
366
|
+
return null;
|
|
367
|
+
const rows = [];
|
|
368
|
+
for (const value of raw) {
|
|
369
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
370
|
+
return null;
|
|
371
|
+
const entry = value;
|
|
372
|
+
if (!isAgentMarker(entry.marker))
|
|
373
|
+
continue;
|
|
374
|
+
if (typeof entry.units !== 'number' || !Number.isSafeInteger(entry.units) || entry.units < 0 ||
|
|
375
|
+
typeof entry.projects !== 'number' || !Number.isSafeInteger(entry.projects) || entry.projects < 0)
|
|
376
|
+
return null;
|
|
377
|
+
rows.push({ marker: entry.marker, units: entry.units, projects: entry.projects,
|
|
378
|
+
firstAt: typeof entry.firstAt === 'string' ? entry.firstAt : null,
|
|
379
|
+
lastAt: typeof entry.lastAt === 'string' ? entry.lastAt : null });
|
|
380
|
+
}
|
|
381
|
+
return rows;
|
|
382
|
+
}
|
|
383
|
+
return { AGENT_MARKERS, MARKER_VERSION, agentMarkersOfFile, agentMarkersOfFiles, isAgentMarker, AGENT_MARKER_AREA, decodeAgentMarkerRows };
|
|
384
|
+
})();
|
|
385
|
+
|
|
386
|
+
// ── packages/core/src/scoring/project-links.ts ──
|
|
387
|
+
const projectLinks = (() => {
|
|
388
|
+
const PROPOSED = { rootPrefixDepth: { value: 3 } };
|
|
389
|
+
const PROJECT_LINK_KINDS = ["repository", "provider_project", "root_directory", "deploy_target"];
|
|
390
|
+
const rootPrefixDepth = () => Math.round(PROPOSED.rootPrefixDepth.value);
|
|
391
|
+
function normaliseRootDirectory(value, depth = rootPrefixDepth()) {
|
|
392
|
+
if (typeof value !== "string")
|
|
393
|
+
return null;
|
|
394
|
+
const trimmed = value.trim().replace(/^(\.\/)+/, "").replace(/^\/+|\/+$/g, "");
|
|
395
|
+
if (trimmed === "" || trimmed === ".")
|
|
396
|
+
return null;
|
|
397
|
+
return trimmed.split("/").filter(Boolean).slice(0, Math.max(1, depth)).join("/");
|
|
398
|
+
}
|
|
399
|
+
function rootPrefixesOf(paths, depth = rootPrefixDepth()) {
|
|
400
|
+
const out = new Set();
|
|
401
|
+
for (const path of paths) {
|
|
402
|
+
const trimmed = path.trim().replace(/^(\.\/)+/, "").replace(/^\/+|\/+$/g, "");
|
|
403
|
+
const parts = trimmed === "" ? [] : trimmed.split("/").filter(Boolean);
|
|
404
|
+
for (let i = 1; i < parts.length && i <= depth; i += 1)
|
|
405
|
+
out.add(parts.slice(0, i).join("/"));
|
|
406
|
+
}
|
|
407
|
+
return [...out].sort();
|
|
408
|
+
}
|
|
409
|
+
return { PROJECT_LINK_KINDS, rootPrefixDepth, normaliseRootDirectory, rootPrefixesOf };
|
|
410
|
+
})();
|
|
411
|
+
|
|
412
|
+
// ── packages/core/src/scoring/commit-features.ts ──
|
|
413
|
+
const commitFeatures = (() => {
|
|
414
|
+
const { CLASSIFIER_VERSION, classRuleOf } = gitClasses;
|
|
415
|
+
const { manifestsOfFiles } = stack;
|
|
416
|
+
const { archOfFiles } = architecture;
|
|
417
|
+
const EXTENSION = /\.([A-Za-z0-9]{1,12})$/;
|
|
418
|
+
function extensionOf(path) {
|
|
419
|
+
const base = path.split("/").pop() ?? path;
|
|
420
|
+
if (base.startsWith(".") && base.indexOf(".", 1) < 0)
|
|
421
|
+
return "(none)";
|
|
422
|
+
const match = EXTENSION.exec(base);
|
|
423
|
+
const ext = match?.[1];
|
|
424
|
+
return ext ? ext.toLowerCase() : "(none)";
|
|
425
|
+
}
|
|
426
|
+
function featuresOfFiles(paths) {
|
|
427
|
+
const extensions = {};
|
|
428
|
+
const rules = new Set();
|
|
429
|
+
for (const path of paths) {
|
|
430
|
+
const ext = extensionOf(path);
|
|
431
|
+
extensions[ext] = (extensions[ext] ?? 0) + 1;
|
|
432
|
+
const rule = classRuleOf(path);
|
|
433
|
+
if (rule)
|
|
434
|
+
rules.add(rule.id);
|
|
435
|
+
}
|
|
436
|
+
return { files: paths.length, extensions, classRules: [...rules].sort(), manifests: manifestsOfFiles(paths), archPoints: [...archOfFiles(paths)].sort(), classifier: CLASSIFIER_VERSION };
|
|
437
|
+
}
|
|
438
|
+
return { extensionOf, featuresOfFiles };
|
|
439
|
+
})();
|
|
440
|
+
|
|
441
|
+
export const { stackOfFiles, manifestsOfFiles, TECHNOLOGIES } = stack;
|
|
442
|
+
export const { classesOfFiles, CLASSIFIER_VERSION, CLASS_RULES } = gitClasses;
|
|
443
|
+
export const { archOfFiles, ARCHITECTURE_POINTS } = architecture;
|
|
444
|
+
export const { securityMarkersOfFiles, SECURITY_MARKERS } = securityMarkers;
|
|
445
|
+
export const { agentMarkersOfFiles, MARKER_VERSION, AGENT_MARKERS } = agentMarkers;
|
|
446
|
+
export const { rootPrefixesOf } = projectLinks;
|
|
447
|
+
export const { featuresOfFiles } = commitFeatures;
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","history-outbox.mjs":"b88072a28aa1dd94d9fab880f96b711b5fbed76ca62e5de24d612c08171e5b71","log-session.mjs":"d20e20c4fa5e4dd6a48a2c3b7caf4cefb090063503f38dc4716d8daee6d3bf22","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","git-commits.mjs":"f9c084c54937a86df8fe30a0db2a58e04eeef0dbae69c54b8e368efc9964d6d8","history-outbox.mjs":"b88072a28aa1dd94d9fab880f96b711b5fbed76ca62e5de24d612c08171e5b71","log-session.mjs":"d20e20c4fa5e4dd6a48a2c3b7caf4cefb090063503f38dc4716d8daee6d3bf22","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"dd947a3de77a3db3f17c7027f16a2e5a2da1001ed954808614e20eb871691e6b"},"format":"worktrust-package/1","kind":"engine","version":"0.10.34"},"signature":"i0BO8j2ozw0p-expMu9OV86XI2WzR1OMIMdQ5ROS5-1qEZHI5OVORsz_ZbTd90jgkjcxiP424600KA-Ig1NLAA"}
|
package/git-commits.mjs
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YOUR OWN COMMITS, MEASURED ON THIS COMPUTER (`npx worktrust git`, CLI 0.10.34; option C, owner 2026-10-29;
|
|
3
|
+
* docs/GITHUB.md). GitHub shows a commit-reading App as "Read access to code", and there is no narrower permission. So
|
|
4
|
+
* the commits are read HERE, with `git log`, filtered to the person's own author e-mails; each commit's file names are
|
|
5
|
+
* turned into the GitHub walk's own closed keys on this computer (commit-rules.mjs, generated from core), and what is
|
|
6
|
+
* sent is counts, keys and markers, never a path, a message, a diff, a sha or the remote's address. A commit travels as
|
|
7
|
+
* its owner-keyed reference: HMAC-SHA256 under `worktrust-commit:<owner id>` over `uuidFrom("commit", sha)`, the bytes
|
|
8
|
+
* the server computes from GitHub's own head sha (docs/GITHUB.md §1), so a GitHub-observed check run on the same commit
|
|
9
|
+
* can corroborate it without this computer ever sending the sha.
|
|
10
|
+
*
|
|
11
|
+
* Asked once, with the list of repositories: what is not shown is not read, and Enter (or --yes) is No. The answers are
|
|
12
|
+
* kept in ~/.worktrust/git.json (0600): this computer's own paths, never sent.
|
|
13
|
+
*/
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import { createHash, createHmac } from "node:crypto";
|
|
16
|
+
import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, realpathSync, statSync, writeFileSync, mkdirSync, chmodSync } from "node:fs";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
import { join, resolve } from "node:path";
|
|
19
|
+
import * as rules from "./commit-rules.mjs";
|
|
20
|
+
|
|
21
|
+
/** The walker's id primitive (apps/worktrust/app/src/lib/scoring/ids.ts), byte for byte. */
|
|
22
|
+
export function uuidFrom(...parts) {
|
|
23
|
+
const hex = createHash("sha256").update(parts.join(" ")).digest("hex");
|
|
24
|
+
const variant = ((parseInt(hex.slice(16, 18), 16) % 64) + 128).toString(16).padStart(2, "0");
|
|
25
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-${variant}${hex.slice(18, 20)}-${hex.slice(20, 32)}`;
|
|
26
|
+
}
|
|
27
|
+
/** The commit's owner-keyed reference (docs/GITHUB.md §1). */
|
|
28
|
+
export const commitRefOf = (owner, sha) => createHmac("sha256", `worktrust-commit:${owner}`).update(uuidFrom("commit", sha)).digest("hex");
|
|
29
|
+
/** A Supabase migration's version as the walk marks it (packages/integrations/src/providers/supabase/api.ts). */
|
|
30
|
+
const migrationMarkerOf = (owner, version) => createHash("sha256").update(`supabase-migration:${owner}:${version}`).digest("hex");
|
|
31
|
+
export const migrationMarkersOf = (paths, owner) => [...new Set(paths.flatMap((path) => { const match = /(?:^|\/)supabase\/migrations\/(\d{1,30})_[^/]+\.sql$/.exec(path); return match ? [migrationMarkerOf(owner, match[1])] : []; }))].slice(0, 50);
|
|
32
|
+
|
|
33
|
+
/** GitHub's commit detail lists at most 300 files on the page the walk reads; the same paths are read here. */
|
|
34
|
+
const DETAIL_FILES = 300;
|
|
35
|
+
export const LIMITS = { perRepo: 1000, perRun: 2000, perBatch: 400, batchBytes: 1_500_000, transcripts: 2000 };
|
|
36
|
+
const HOSTS = /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:[^@/]+@)?(github\.com|gitlab\.com|bitbucket\.org)[:/]/i;
|
|
37
|
+
|
|
38
|
+
function git(cwd, ...argv) {
|
|
39
|
+
try { return execFileSync("git", ["-C", cwd, "-c", "core.quotePath=false", ...argv], { encoding: "utf8", timeout: 30_000, maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] }); }
|
|
40
|
+
catch { return ""; }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The work tree a folder sits in, or null. */
|
|
44
|
+
export function repoRootOf(dir) {
|
|
45
|
+
if (!dir || !existsSync(dir)) return null;
|
|
46
|
+
const top = git(dir, "rev-parse", "--show-toplevel").trim();
|
|
47
|
+
if (!top) return null;
|
|
48
|
+
try { return realpathSync(top); } catch { return top; }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* What a repository is called on the way out: owner/name, lowercased, for a remote on a host WorkTrust couples (what a
|
|
53
|
+
* session already names, CLI 0.8.6), so it is filed under the GitHub walk's project; otherwise a code only this
|
|
54
|
+
* computer can make (HMAC under its archive salt over the normalised remote or the root), never a name.
|
|
55
|
+
*/
|
|
56
|
+
export function repoIdentity(root, salt) {
|
|
57
|
+
const remote = git(root, "remote", "get-url", "origin").trim();
|
|
58
|
+
if (remote && HOSTS.test(remote)) {
|
|
59
|
+
const match = /[:/]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/.exec(remote);
|
|
60
|
+
const name = match ? `${match[1]}/${match[2]}`.toLowerCase() : null;
|
|
61
|
+
if (name && /^[a-z0-9_.-]{1,100}\/[a-z0-9_.-]{1,100}$/.test(name)) return { name, github: /github\.com/i.test(remote) };
|
|
62
|
+
}
|
|
63
|
+
const basis = remote ? `remote:${remote.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^[^@/]+@/, "").replace(/:(?!\d)/, "/").replace(/\.git$/, "").replace(/\/+$/, "")}` : `root:${root}`;
|
|
64
|
+
return salt ? { code: createHmac("sha256", salt).update(`worktrust-repo-code|${basis}`).digest("hex").slice(0, 16), github: false } : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The person's author e-mails: git's own setting here and globally, plus what they added. Lowercased, once each. */
|
|
68
|
+
export function authorEmails(root, extra = []) {
|
|
69
|
+
const found = [git(root, "config", "user.email"), git(root, "config", "--global", "user.email"), ...extra].map((email) => String(email).trim().toLowerCase()).filter((email) => /^[^\s@]+@[^\s@]+$/.test(email));
|
|
70
|
+
return [...new Set(found)];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A numstat path as GitHub's detail names it: a rename is its new path. */
|
|
74
|
+
export function numstatPath(text) {
|
|
75
|
+
let path = text.replace(/\{([^{}]*) => ([^{}]*)\}/g, "$2").replace(/\/{2,}/g, "/").replace(/^\//, "");
|
|
76
|
+
if (path.includes(" => ")) path = path.slice(path.lastIndexOf(" => ") + 4);
|
|
77
|
+
return path;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The person's own commits in one work tree, newest first, at most `limit`: every local branch, merges diffed against
|
|
82
|
+
* their first parent (as GitHub's detail is), only commits whose author e-mail is one of theirs. Read: the sha, the
|
|
83
|
+
* parents, two dates, the author e-mail (to filter, never kept) and per file the added and deleted lines and the path.
|
|
84
|
+
* Never the message, never the content.
|
|
85
|
+
*/
|
|
86
|
+
export function readCommits(root, { emails, since = null, limit = LIMITS.perRepo }) {
|
|
87
|
+
if (!emails.length) return [];
|
|
88
|
+
const argv = ["log", "--branches", "--no-color", "--no-ext-diff", "--numstat", "--diff-merges=first-parent", "--format=%x01%H%x09%P%x09%aI%x09%cI%x09%aE", `--max-count=${limit}`, "--fixed-strings", "--regexp-ignore-case", ...emails.map((email) => `--author=<${email}>`)];
|
|
89
|
+
if (since) argv.push(`--since=${since}`);
|
|
90
|
+
const out = git(root, ...argv);
|
|
91
|
+
const mine = new Set(emails);
|
|
92
|
+
const commits = [];
|
|
93
|
+
for (const block of out.split("\x01").slice(1)) {
|
|
94
|
+
const [head, ...rest] = block.split("\n");
|
|
95
|
+
const [sha, parents, authored, committed, email] = head.split("\t");
|
|
96
|
+
if (!/^[0-9a-f]{40}$/.test(sha ?? "") || !mine.has(String(email).toLowerCase())) continue;
|
|
97
|
+
let additions = 0, deletions = 0;
|
|
98
|
+
const paths = [];
|
|
99
|
+
for (const line of rest) {
|
|
100
|
+
const match = /^(\d+|-)\t(\d+|-)\t(.+)$/.exec(line);
|
|
101
|
+
if (!match) continue;
|
|
102
|
+
if (match[1] !== "-") additions += Number(match[1]);
|
|
103
|
+
if (match[2] !== "-") deletions += Number(match[2]);
|
|
104
|
+
paths.push(numstatPath(match[3]));
|
|
105
|
+
}
|
|
106
|
+
commits.push({ sha, parents: (parents ?? "").split(" ").filter((p) => /^[0-9a-f]{40}$/.test(p)), authored, committed, additions, deletions, paths });
|
|
107
|
+
}
|
|
108
|
+
return commits;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** When the repository began, as a day: its first commit. The walk reads GitHub's creation date for the work mode. */
|
|
112
|
+
export function repoSince(root) {
|
|
113
|
+
const days = git(root, "log", "--max-parents=0", "--format=%cI", "HEAD").split("\n").map((line) => line.trim()).filter(Boolean).map((at) => new Date(at)).filter((at) => Number.isFinite(at.getTime()));
|
|
114
|
+
return days.length ? new Date(Math.min(...days.map(Number))).toISOString().slice(0, 10) : null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* ONE COMMIT AS THE GITHUB WALK WOULD FILE IT (walk.ts processNode), computed here. The paths go in and never come
|
|
119
|
+
* out: what comes out is the reference, the counts and the closed keys. `projectRef` is the project the server filed
|
|
120
|
+
* the repository under (the walk's own for a GitHub repository); without it no path marker is made.
|
|
121
|
+
*/
|
|
122
|
+
export function commitPayload(commit, { owner, projectRef }) {
|
|
123
|
+
const paths = commit.paths.slice(0, DETAIL_FILES);
|
|
124
|
+
const features = rules.featuresOfFiles(paths);
|
|
125
|
+
const authoredMs = Date.parse(commit.authored ?? ""), committedMs = Date.parse(commit.committed);
|
|
126
|
+
return {
|
|
127
|
+
ref: commitRefOf(owner, commit.sha),
|
|
128
|
+
at: new Date(committedMs).toISOString().replace(/\.000Z$/, "Z"),
|
|
129
|
+
replayDays: Number.isFinite(authoredMs) ? Math.max(0, Math.round((committedMs - authoredMs) / 86_400_000)) : null,
|
|
130
|
+
additions: commit.additions,
|
|
131
|
+
deletions: commit.deletions,
|
|
132
|
+
files: paths.length,
|
|
133
|
+
parents: commit.parents.length,
|
|
134
|
+
parentRefs: commit.parents.slice(0, 8).map((sha) => commitRefOf(owner, sha)),
|
|
135
|
+
classes: rules.classesOfFiles(paths),
|
|
136
|
+
stack: rules.stackOfFiles(paths),
|
|
137
|
+
arch: rules.archOfFiles(paths),
|
|
138
|
+
security: rules.securityMarkersOfFiles(paths),
|
|
139
|
+
agents: rules.agentMarkersOfFiles(paths),
|
|
140
|
+
rootMarkers: rules.rootPrefixesOf(paths).map((prefix) => uuidFrom("root", owner, prefix)),
|
|
141
|
+
pathMarkers: projectRef ? [...new Set(paths)].slice(0, 40).map((path) => uuidFrom("path", owner, projectRef, path)) : [],
|
|
142
|
+
migrationMarkers: migrationMarkersOf(paths, owner),
|
|
143
|
+
extensions: features.extensions,
|
|
144
|
+
classRules: features.classRules,
|
|
145
|
+
manifests: features.manifests,
|
|
146
|
+
archPoints: features.archPoints,
|
|
147
|
+
classifier: rules.CLASSIFIER_VERSION,
|
|
148
|
+
markerVersion: rules.MARKER_VERSION,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* NOTHING THAT NAMES THE WORK LEAVES (the planted-leak test holds it). Before a batch is sent it is read as text for
|
|
154
|
+
* every path it was made from, every sha, every remote and root it came from: one found refuses the whole batch. A
|
|
155
|
+
* commit's fields are a closed set, so a field nobody wrote here is refused as well.
|
|
156
|
+
*/
|
|
157
|
+
const COMMIT_FIELDS = new Set(["ref", "at", "replayDays", "additions", "deletions", "files", "parents", "parentRefs", "classes", "stack", "arch", "security", "agents", "rootMarkers", "pathMarkers", "migrationMarkers", "extensions", "classRules", "manifests", "archPoints", "classifier", "markerVersion"]);
|
|
158
|
+
const REF = /^[0-9a-f]{64}$/, UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, VERSION = /^\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
159
|
+
const CLOSED = {
|
|
160
|
+
classes: new Set([...rules.CLASS_RULES.map((rule) => rule.cls), "code"]), classRules: new Set(rules.CLASS_RULES.map((rule) => rule.id)),
|
|
161
|
+
stack: new Set(rules.TECHNOLOGIES), manifests: new Set(rules.TECHNOLOGIES), arch: new Set(rules.ARCHITECTURE_POINTS), archPoints: new Set(rules.ARCHITECTURE_POINTS),
|
|
162
|
+
security: new Set(rules.SECURITY_MARKERS), agents: new Set(rules.AGENT_MARKERS),
|
|
163
|
+
};
|
|
164
|
+
const SHAPED = { parentRefs: REF, migrationMarkers: REF, rootMarkers: UUID, pathMarkers: UUID };
|
|
165
|
+
const isCount = (value) => value === null || (Number.isInteger(value) && value >= 0);
|
|
166
|
+
/** Why a commit is not of the closed shape the door takes, or null: every word from a list, every string a pattern. */
|
|
167
|
+
function shapeRefusal(commit) {
|
|
168
|
+
for (const key of Object.keys(commit)) if (!COMMIT_FIELDS.has(key)) return `an unknown field (${key})`;
|
|
169
|
+
if (!REF.test(commit.ref ?? "") || typeof commit.at !== "string" || !/^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/.test(commit.at)) return "a reference or an instant of the wrong shape";
|
|
170
|
+
for (const key of ["replayDays", "additions", "deletions", "files", "parents"]) if (!isCount(commit[key])) return `${key} is not a count`;
|
|
171
|
+
for (const [key, words] of Object.entries(CLOSED)) if (!Array.isArray(commit[key]) || commit[key].some((word) => !words.has(word))) return `a word outside the list in ${key}`;
|
|
172
|
+
for (const [key, shape] of Object.entries(SHAPED)) if (!Array.isArray(commit[key]) || commit[key].some((value) => typeof value !== "string" || !shape.test(value))) return `${key} is not markers`;
|
|
173
|
+
if (!commit.extensions || typeof commit.extensions !== "object" || Object.entries(commit.extensions).some(([key, n]) => !/^([A-Za-z0-9]{1,12}|\(none\))$/.test(key) || !isCount(n))) return "extensions are not counts by file type";
|
|
174
|
+
if (!VERSION.test(commit.classifier ?? "") || !VERSION.test(commit.markerVersion ?? "")) return "a version of the wrong shape";
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
export function leakIn(body, secrets) {
|
|
178
|
+
const text = JSON.stringify(body);
|
|
179
|
+
for (const repo of body.repos ?? []) for (const commit of repo.commits ?? []) { const refused = shapeRefusal(commit); if (refused) return refused; }
|
|
180
|
+
if (/(?<![0-9a-f])[0-9a-f]{40}(?![0-9a-f])/.test(text)) return "a sha";
|
|
181
|
+
for (const path of secrets.paths ?? []) if ((path.includes("/") || path.includes(".") || path.length >= 6) && text.includes(JSON.stringify(path).slice(1, -1))) return "a path";
|
|
182
|
+
for (const other of [...(secrets.remotes ?? []), ...(secrets.roots ?? [])]) if (other && text.includes(JSON.stringify(other).slice(1, -1))) return "a remote or a folder";
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** The folders the AI apps' sessions ran in, newest first: Claude Code's transcripts name their `cwd`. */
|
|
187
|
+
export function transcriptCwds(home = homedir(), limit = LIMITS.transcripts) {
|
|
188
|
+
const root = join(home, ".claude", "projects");
|
|
189
|
+
const files = [];
|
|
190
|
+
try {
|
|
191
|
+
for (const project of readdirSync(root)) {
|
|
192
|
+
const dir = join(root, project);
|
|
193
|
+
try { for (const name of readdirSync(dir)) if (name.endsWith(".jsonl")) { const file = join(dir, name); files.push([file, statSync(file).mtimeMs]); } } catch { /* not a folder */ }
|
|
194
|
+
}
|
|
195
|
+
} catch { return []; }
|
|
196
|
+
const cwds = new Set();
|
|
197
|
+
const buffer = Buffer.alloc(65_536);
|
|
198
|
+
for (const [file] of files.sort((a, b) => b[1] - a[1]).slice(0, limit)) {
|
|
199
|
+
let fd = null;
|
|
200
|
+
try { fd = openSync(file, "r"); const read = readSync(fd, buffer, 0, buffer.length, 0); const match = /"cwd":"((?:[^"\\]|\\.)+)"/.exec(buffer.toString("utf8", 0, read)); if (match) cwds.add(JSON.parse(`"${match[1]}"`)); }
|
|
201
|
+
catch { /* unreadable: skipped */ }
|
|
202
|
+
finally { if (fd !== null) closeSync(fd); }
|
|
203
|
+
}
|
|
204
|
+
return [...cwds];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The person's own exclusions (~/.worktrust-counter.json `exclude`, the counter's file): a folder under one is never read. */
|
|
208
|
+
function excluded(dir, home) {
|
|
209
|
+
try { const list = JSON.parse(readFileSync(join(home, ".worktrust-counter.json"), "utf8")).exclude; return Array.isArray(list) && list.some((prefix) => typeof prefix === "string" && prefix && resolve(dir).startsWith(resolve(prefix))); } catch { return false; }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ── this computer's answers ──
|
|
213
|
+
export function stateFile(home = homedir()) { return join(home, ".worktrust", "git.json"); }
|
|
214
|
+
export function loadState(home = homedir()) {
|
|
215
|
+
try { const state = JSON.parse(readFileSync(stateFile(home), "utf8")); if (state && typeof state === "object" && state.version === 1) return { version: 1, owner: typeof state.owner === "string" ? state.owner : null, emails: Array.isArray(state.emails) ? state.emails.filter((e) => typeof e === "string") : [], repos: state.repos && typeof state.repos === "object" ? state.repos : {} }; } catch { /* none yet */ }
|
|
216
|
+
return { version: 1, owner: null, emails: [], repos: {} };
|
|
217
|
+
}
|
|
218
|
+
export function saveState(state, home = homedir()) {
|
|
219
|
+
mkdirSync(join(home, ".worktrust"), { recursive: true });
|
|
220
|
+
writeFileSync(stateFile(home), `${JSON.stringify(state)}\n`, { mode: 0o600 });
|
|
221
|
+
try { chmodSync(stateFile(home), 0o600); } catch { /* best effort */ }
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The work trees to offer: the folders the sessions named, plus the ones the person added; none they removed. */
|
|
225
|
+
export function discoverRepos(state, home = homedir()) {
|
|
226
|
+
const roots = new Set();
|
|
227
|
+
for (const cwd of transcriptCwds(home)) { if (excluded(cwd, home)) continue; const root = repoRootOf(cwd); if (root) roots.add(root); }
|
|
228
|
+
for (const [root, entry] of Object.entries(state.repos)) if (entry?.how === "typed" && existsSync(root)) roots.add(root);
|
|
229
|
+
return [...roots].sort();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** What each of the three ways in reads: the table the consent shows (and the Sources card, in the app's words). */
|
|
233
|
+
export const READS_TABLE = [
|
|
234
|
+
" GitHub Basic GitHub Full This computer (worktrust git)",
|
|
235
|
+
" GitHub permission checks, statuses + code (contents) none",
|
|
236
|
+
" deploys, actions",
|
|
237
|
+
" Commits no yes yes, your own (author e-mail)",
|
|
238
|
+
" File names no yes, as keys yes, as keys, here only",
|
|
239
|
+
" Code, diffs, messages never never never",
|
|
240
|
+
" Sent outcomes counts and keys counts and keys, no path, no sha",
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* `npx worktrust git [add <path> | remove <path> | list | emails [add|remove <e-mail>]] [--dry-run] [--yes]`.
|
|
245
|
+
* `io` lends the CLI's own: say, ask (Enter is No here), send(body) → the receipt or null, consent, salt, home.
|
|
246
|
+
*/
|
|
247
|
+
export async function gitMain(argv, io) {
|
|
248
|
+
const home = io.home ?? homedir();
|
|
249
|
+
const state = loadState(home);
|
|
250
|
+
const [sub, value, extra] = argv;
|
|
251
|
+
if (sub === "emails") {
|
|
252
|
+
if ((value === "add" || value === "remove") && extra) {
|
|
253
|
+
const email = extra.trim().toLowerCase();
|
|
254
|
+
if (!/^[^\s@]+@[^\s@]+$/.test(email)) { io.say(" Not an e-mail address. Nothing changed."); return 1; }
|
|
255
|
+
state.emails = value === "add" ? [...new Set([...state.emails, email])] : state.emails.filter((e) => e !== email);
|
|
256
|
+
if (!io.dryRun) saveState(state, home);
|
|
257
|
+
io.say(` ${value === "add" ? "Added" : "Removed"}. Commits by these e-mails are yours here: ${state.emails.join(", ") || "(only git's own user.email)"}`);
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
io.say(` Your author e-mails beyond git's own user.email: ${state.emails.join(", ") || "none"}`);
|
|
261
|
+
io.say(" Add one: npx worktrust git emails add <e-mail>");
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
if (sub === "add" || sub === "remove") {
|
|
265
|
+
const root = repoRootOf(resolve(value ?? "."));
|
|
266
|
+
if (!root) { io.say(" Not a git work tree. Nothing changed."); return 1; }
|
|
267
|
+
if (sub === "remove") { state.repos[root] = { ...(state.repos[root] ?? {}), how: "removed", agreed: false }; if (!io.dryRun) saveState(state, home); io.say(" Removed: nothing more is read or sent from it. What was sent stays on your record until you remove it under Sources."); return 0; }
|
|
268
|
+
state.repos[root] = { ...(state.repos[root] ?? {}), how: "typed", agreed: null };
|
|
269
|
+
if (!io.dryRun) saveState(state, home);
|
|
270
|
+
io.say(" Added.");
|
|
271
|
+
}
|
|
272
|
+
const roots = discoverRepos(state, home).filter((root) => state.repos[root]?.how !== "removed");
|
|
273
|
+
if (sub === "list") {
|
|
274
|
+
io.say(" Repositories WorkTrust may read on this computer:");
|
|
275
|
+
for (const root of roots) {
|
|
276
|
+
const entry = state.repos[root], id = repoIdentity(root, io.salt);
|
|
277
|
+
const status = entry?.agreed === true ? `sending${entry.sentThrough ? `, through ${entry.sentThrough.slice(0, 10)}` : ""}` : entry?.agreed === false ? "not agreed" : "not asked yet";
|
|
278
|
+
io.say(` ${root} (${id?.name ?? "by code"}) ${status}`);
|
|
279
|
+
}
|
|
280
|
+
io.say(` Author e-mails: git's user.email${state.emails.length ? `, ${state.emails.join(", ")}` : ""}`);
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ── consent: once, with the list; what is not shown is not read ──
|
|
285
|
+
const unasked = roots.filter((root) => state.repos[root]?.agreed !== true && state.repos[root]?.agreed !== false);
|
|
286
|
+
if (unasked.length) {
|
|
287
|
+
io.say();
|
|
288
|
+
io.say(" WorkTrust can read your own commits in these repositories, on this computer:");
|
|
289
|
+
for (const root of unasked) io.say(` ${root}`);
|
|
290
|
+
io.say();
|
|
291
|
+
io.say(" What WorkTrust reads:");
|
|
292
|
+
for (const line of READS_TABLE) io.say(line);
|
|
293
|
+
io.say();
|
|
294
|
+
io.say(" Only commits whose author e-mail is yours. Sent: per commit its counts, kinds of files and markers,");
|
|
295
|
+
io.say(" never a file name, a message, code or the commit's id.");
|
|
296
|
+
const yes = await io.ask(`Send your own commits of these ${unasked.length} repositories?`, false);
|
|
297
|
+
for (const root of unasked) state.repos[root] = { ...(state.repos[root] ?? { how: "found" }), agreed: yes };
|
|
298
|
+
if (yes) io.consent?.agree("git-commits", "typed");
|
|
299
|
+
if (!io.dryRun) saveState(state, home);
|
|
300
|
+
}
|
|
301
|
+
const agreed = roots.filter((root) => state.repos[root]?.agreed === true);
|
|
302
|
+
if (!agreed.length) { io.say(" Nothing to send: no repository agreed. Add one: npx worktrust git add <folder>"); return 0; }
|
|
303
|
+
|
|
304
|
+
// ── where each repository is filed, and the owner the references are keyed with ──
|
|
305
|
+
const repos = agreed.map((root) => ({ root, identity: repoIdentity(root, io.salt) })).filter((repo) => repo.identity);
|
|
306
|
+
const label = (repo) => (repo.identity.name ? { name: repo.identity.name } : { code: repo.identity.code });
|
|
307
|
+
const where = io.dryRun ? null : await io.send({ repos: repos.map((repo) => ({ ...label(repo), commits: [] })) });
|
|
308
|
+
if (!io.dryRun && !where?.owner) { io.say(" WorkTrust could not be reached, or refused this computer. Nothing was sent."); return 1; }
|
|
309
|
+
const owner = where?.owner ?? state.owner ?? "00000000-0000-0000-0000-000000000000";
|
|
310
|
+
if (where?.owner) state.owner = where.owner;
|
|
311
|
+
let budget = LIMITS.perRun, landed = 0, already = 0, read = 0;
|
|
312
|
+
for (const repo of repos) {
|
|
313
|
+
if (budget <= 0) break;
|
|
314
|
+
const entry = state.repos[repo.root];
|
|
315
|
+
const key = repo.identity.name ?? `code:${repo.identity.code}`;
|
|
316
|
+
const projectRef = where?.projects?.[key] ?? null;
|
|
317
|
+
const emails = authorEmails(repo.root, state.emails);
|
|
318
|
+
// Incremental: from two days before the last commit sent (a late rebase), each commit once by its reference.
|
|
319
|
+
const since = entry.sentThrough ? new Date(Date.parse(entry.sentThrough) - 2 * 86_400_000).toISOString() : null;
|
|
320
|
+
const sent = new Set(entry.sent ?? []);
|
|
321
|
+
const commits = readCommits(repo.root, { emails, since, limit: Math.min(LIMITS.perRepo, budget) });
|
|
322
|
+
const fresh = commits.map((commit) => ({ commit, payload: commitPayload(commit, { owner, projectRef }) })).filter(({ payload }) => !sent.has(payload.ref.slice(0, 16)));
|
|
323
|
+
budget -= fresh.length; read += fresh.length;
|
|
324
|
+
if (io.dryRun) { io.say(` ${key}: ${fresh.length} commit(s) would be sent (nothing sent: --dry-run)`); continue; }
|
|
325
|
+
const since0 = repoSince(repo.root);
|
|
326
|
+
let through = entry.sentThrough ?? "";
|
|
327
|
+
for (let at = 0; at < fresh.length; at += LIMITS.perBatch) {
|
|
328
|
+
const part = fresh.slice(at, at + LIMITS.perBatch);
|
|
329
|
+
const body = { repos: [{ ...label(repo), ...(since0 ? { since: since0 } : {}), commits: part.map(({ payload }) => payload) }] };
|
|
330
|
+
const leak = leakIn(body, { paths: part.flatMap(({ commit }) => commit.paths), roots: [repo.root], remotes: [git(repo.root, "remote", "get-url", "origin").trim()] });
|
|
331
|
+
if (leak) { io.say(` Refused before sending: the batch would carry ${leak}. Nothing of ${key} was sent.`); return 1; }
|
|
332
|
+
const receipt = await io.send(body);
|
|
333
|
+
// Not landed, nothing lost: the mark does not move, so the next run reads and sends these commits again.
|
|
334
|
+
if (receipt?.refused) { io.say(` ${key}: not sent. ${receipt.refused.message}`); if (!io.dryRun) saveState(state, home); return 1; }
|
|
335
|
+
if (!receipt) { io.say(` ${key}: not sent (WorkTrust unreachable or refused); the next run tries again.`); if (!io.dryRun) saveState(state, home); return 1; }
|
|
336
|
+
landed += receipt.landed ?? 0; already += receipt.already ?? 0;
|
|
337
|
+
for (const { payload } of part) sent.add(payload.ref.slice(0, 16));
|
|
338
|
+
through = part.reduce((max, { payload }) => (payload.at > max ? payload.at : max), through);
|
|
339
|
+
state.repos[repo.root] = { ...state.repos[repo.root], sentThrough: through, sent: [...sent].slice(-5000) };
|
|
340
|
+
saveState(state, home);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (!io.dryRun) saveState(state, home);
|
|
344
|
+
io.say(io.dryRun ? ` ${read} commit(s) read; nothing sent.` : ` Sent: ${landed} commit(s) landed, ${already} already on your record through GitHub.`);
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"4f2ea9b41f90fbdc478fa1f461e4f34d8c67c847ec5bec983f809bd49897fdc7","SECURITY.md":"b672649c7c7bf18538dd4560d7b533498721e0be765a000796d7d18390b5cbb6","chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"613734a8d130c4dbd512faf6ee53e29f9892a2cbc92173598411ec28c8bc6ebe","git-commits.mjs":"f9c084c54937a86df8fe30a0db2a58e04eeef0dbae69c54b8e368efc9964d6d8","history-outbox.mjs":"b88072a28aa1dd94d9fab880f96b711b5fbed76ca62e5de24d612c08171e5b71","log-session.mjs":"d20e20c4fa5e4dd6a48a2c3b7caf4cefb090063503f38dc4716d8daee6d3bf22","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"427be6e3e70086bc3484bcde258447d393d11bf4088298db786a024a4ae7469b","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"dd947a3de77a3db3f17c7027f16a2e5a2da1001ed954808614e20eb871691e6b"},"format":"worktrust-package/1","kind":"npm","version":"0.10.34"},"signature":"NBifKfprOGRr5AeZSTgwwIhcyGtTuQCYYWQGAOZFZ8y3Uk700xdJlJ4x_lffCNmh-ANZZo2qliuUQrw8iO50AQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.34",
|
|
4
4
|
"description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"claude-mod.mjs",
|
|
33
33
|
"package-integrity.mjs",
|
|
34
34
|
"worktrust-launch.mjs",
|
|
35
|
+
"git-commits.mjs",
|
|
36
|
+
"commit-rules.mjs",
|
|
35
37
|
"engine-release.json",
|
|
36
38
|
"package-release.json",
|
|
37
39
|
"history-outbox.mjs",
|
package/worktrust.mjs
CHANGED
|
@@ -76,7 +76,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
76
76
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
77
77
|
const has = (name) => args.includes(`--${name}`);
|
|
78
78
|
/** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
|
|
79
|
-
const CLI_VERSION = "0.10.
|
|
79
|
+
const CLI_VERSION = "0.10.34";
|
|
80
80
|
/**
|
|
81
81
|
* HOW THIS CLI MEASURES, AS A NUMBER OF ITS OWN (0.10.31; owner, 2026-10-28: 0.10.30 offered a re-measure it had no reason
|
|
82
82
|
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|
|
@@ -101,9 +101,9 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
|
|
|
101
101
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
102
102
|
const HOME_DIR = join(homedir(), ".worktrust");
|
|
103
103
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
104
|
-
const SCRIPTS = ["credential-store.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs"];
|
|
104
|
+
const SCRIPTS = ["credential-store.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "commit-rules.mjs", "git-commits.mjs"];
|
|
105
105
|
/** The modules the scripts import by name from beside them; a download keeps that name. */
|
|
106
|
-
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs"]);
|
|
106
|
+
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
|
|
107
107
|
const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
|
|
108
108
|
const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
|
|
109
109
|
const PLACEHOLDER = `wt_${"0".repeat(43)}`;
|
|
@@ -361,7 +361,7 @@ const previousNote = {
|
|
|
361
361
|
* file; a coupling to another account starts it empty. An unreadable file counts as no agreement at all.
|
|
362
362
|
*/
|
|
363
363
|
const CONSENT_FILE = join(HOME_DIR, "consent.json");
|
|
364
|
-
const CONSENT_NAME = /^(?:door:[^\n,]{1,80}|session-hook|codex-notify|antigravity-stop)$/;
|
|
364
|
+
const CONSENT_NAME = /^(?:door:[^\n,]{1,80}|session-hook|codex-notify|antigravity-stop|git-commits)$/;
|
|
365
365
|
const CONSENT_HOW = new Set(["typed", "flag", "found"]);
|
|
366
366
|
let consentLoaded = null;
|
|
367
367
|
async function consent() {
|
|
@@ -1319,6 +1319,41 @@ async function preserve() {
|
|
|
1319
1319
|
process.exitCode = await new Promise((resolve) => child.on("exit", (code) => resolve(code ?? 1)));
|
|
1320
1320
|
}
|
|
1321
1321
|
|
|
1322
|
+
/**
|
|
1323
|
+
* YOUR OWN COMMITS, MEASURED HERE (`npx worktrust git`, 0.10.34; option C, owner 2026-10-29; docs/GITHUB.md). git-commits.mjs
|
|
1324
|
+
* reads them with git log and makes the GitHub walk's keys of them on this computer; this file lends it the key, the signed
|
|
1325
|
+
* send to the CLI's commits door, the question (Enter is No) and the consent file. Nothing is sent without a typed yes.
|
|
1326
|
+
*/
|
|
1327
|
+
function archiveSalt() {
|
|
1328
|
+
const file = join(HOME_DIR, "archive-salt");
|
|
1329
|
+
try { const kept = readPrivateFile(file)?.trim(); if (/^[0-9a-f]{64}$/.test(kept ?? "")) return kept; } catch { /* first run */ }
|
|
1330
|
+
try { ensureHome(); const made = randomBytes(32).toString("hex"); writePrivateFile(file, `${made}\n`); return made; } catch { return null; }
|
|
1331
|
+
}
|
|
1332
|
+
async function gitCommits() {
|
|
1333
|
+
if (!["git-commits.mjs", "commit-rules.mjs"].every((name) => existsSync(join(HERE, name)))) fail("worktrust git needs the complete WorkTrust npm/Python package. Nothing was read or sent.");
|
|
1334
|
+
const { gitMain } = await import("./git-commits.mjs");
|
|
1335
|
+
const sub = args.slice(args.indexOf("git") + 1).filter((arg) => !arg.startsWith("--"));
|
|
1336
|
+
const local = ["list", "emails", "remove"].includes(sub[0]) || has("dry-run");
|
|
1337
|
+
const key = local ? keyStore.load() : await freshKey();
|
|
1338
|
+
if (!key && !local) fail("this computer is not coupled. Run `npx worktrust` first.");
|
|
1339
|
+
const url = key ? `${new URL(key.url).origin}/api/cli/commits` : null;
|
|
1340
|
+
const send = async (body) => {
|
|
1341
|
+
if (!key || !url) return null;
|
|
1342
|
+
const text = JSON.stringify({ ...body, cli_version: CLI_VERSION });
|
|
1343
|
+
try {
|
|
1344
|
+
const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, "user-agent": `worktrust-cli/${CLI_VERSION}`, ...proof(key.device, url, text) }, body: text, redirect: "error", signal: AbortSignal.timeout(30_000) });
|
|
1345
|
+
if (response.status === 200) return await response.json();
|
|
1346
|
+
// A fair-use refusal (0.10.34, docs/FAIR-USE.md §2): its own sentence, said as it is; the commits stay for the next run.
|
|
1347
|
+
if (response.status === 429 || response.status === 503) {
|
|
1348
|
+
const refusal = await response.json().catch(() => null);
|
|
1349
|
+
if (typeof refusal?.message === "string") return { refused: { message: refusal.message.slice(0, 400), retryAfter: Number(response.headers.get("retry-after")) || null } };
|
|
1350
|
+
}
|
|
1351
|
+
return null;
|
|
1352
|
+
} catch { return null; }
|
|
1353
|
+
};
|
|
1354
|
+
process.exitCode = await gitMain(sub, { say, ask, send, consent: await consent(), salt: archiveSalt(), dryRun: has("dry-run") });
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1322
1357
|
function help() {
|
|
1323
1358
|
say("WorkTrust: couple this computer to your record. Metadata only.");
|
|
1324
1359
|
say();
|
|
@@ -1357,6 +1392,10 @@ function help() {
|
|
|
1357
1392
|
say(" worktrust mod the WorkTrust mod for Claude Code: what it counts, and whether it is on");
|
|
1358
1393
|
say(" install turn it on: counts permission answers, effort levels, context peaks and subagents (asks first)");
|
|
1359
1394
|
say(" remove turn it off and delete what it counted");
|
|
1395
|
+
say(" worktrust git send your own commits, measured on this computer: counts and kinds, never a file name,");
|
|
1396
|
+
say(" a message, code or the commit's id (asks once, with the list of repositories; Enter is No)");
|
|
1397
|
+
say(" add <folder> offer one more repository remove <folder> read nothing more from it");
|
|
1398
|
+
say(" list what is offered and agreed emails add <e-mail> another author e-mail of yours");
|
|
1360
1399
|
say(" worktrust preserve keep your AI history: the report, then the settings and a local archive, each on your yes");
|
|
1361
1400
|
say(" --apply keep them: asks per change, backs the file up first (--yes: no question)");
|
|
1362
1401
|
say(" --archive [dir] a local, metadata-only, hash-chained record of the measured days (~/AI-Evidence)");
|
|
@@ -1374,7 +1413,7 @@ async function main() {
|
|
|
1374
1413
|
if (!moduleArgs || !moduleExecutable || !createCredentialStore) fail("Use the complete WorkTrust package from npm/PyPI or the signed preservation kit; individual scripts cannot run.");
|
|
1375
1414
|
if (Number(process.versions.node.split(".")[0]) < 18) fail("needs Node 18 or later (fetch is built in from 18).");
|
|
1376
1415
|
const AGENT_ENV = ["CLAUDECODE", "CLAUDE_CODE_ENTRYPOINT", "CODEX_SANDBOX", "CODEX_CI", "GEMINI_CLI", "CURSOR_AGENT", "OPENCODE", "CLINE_ACTIVE", "AIDER_CHAT", "ANTIGRAVITY_AGENT", "WINDSURF_AGENT"];
|
|
1377
|
-
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import", "orchestration", "mod", "protect-key"]);
|
|
1416
|
+
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import", "orchestration", "mod", "protect-key", "git"]);
|
|
1378
1417
|
const agentShell = AGENT_ENV.find((name) => process.env[name] && process.env[name] !== "0");
|
|
1379
1418
|
if (agentShell && PERSON_ONLY.has(command)) {
|
|
1380
1419
|
say();
|
|
@@ -1431,6 +1470,7 @@ else if (command === "disconnect") await disconnect();
|
|
|
1431
1470
|
else if (command === "status") await status();
|
|
1432
1471
|
else if (command === "preserve") await preserve();
|
|
1433
1472
|
else if (command === "mod") await mod();
|
|
1473
|
+
else if (command === "git") await gitCommits();
|
|
1434
1474
|
else if (command === "orchestration") {
|
|
1435
1475
|
if (!["orchestration-report.mjs", "orchestration-evidence.mjs", "orchestration-contract.mjs"].every((name) => existsSync(join(HERE, name)))) fail("Local agent reports need the complete WorkTrust npm/Python package or preservation kit. No file was read or sent.");
|
|
1436
1476
|
const { reportFile } = await import("./orchestration-report.mjs"); reportFile(args.slice(1));
|