@letsrebase/verify 0.1.3 → 0.2.1
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/.claude/commands/rebase-verify.md +2 -1
- package/README.md +3 -3
- package/bin/rebase-verify.mjs +109 -212
- package/package.json +1 -1
- package/src/adapters/claude-code.mjs +4 -2
- package/src/adapters/codex.mjs +4 -2
- package/src/adapters/omp.mjs +2 -2
- package/src/adapters/pi.mjs +6 -5
- package/src/agents/run.mjs +2 -2
- package/src/groundedness.mjs +28 -6
- package/src/hub.mjs +31 -28
- package/src/languages.mjs +250 -0
- package/src/pipeline-client.mjs +56 -0
- package/src/pipeline-worker.mjs +96 -0
- package/src/pipeline.mjs +194 -0
- package/src/profile-llm.mjs +15 -8
- package/src/profile.mjs +80 -89
- package/src/sources.mjs +9 -7
- package/src/submit.mjs +27 -5
- package/src/wizard.mjs +40 -32
package/src/pipeline.mjs
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// The steps between the logs and the profile, as plain functions of their inputs, so the
|
|
2
|
+
// sub-commands run them in place and the wizard runs the same ones in a worker thread
|
|
3
|
+
// (src/pipeline-worker.mjs), where a long synchronous stretch cannot freeze its spinner.
|
|
4
|
+
// Nothing here prints or exits: output goes through the `ctx` callbacks and a failure is thrown.
|
|
5
|
+
//
|
|
6
|
+
// `ctx` = { tz, top, language, outDir, cmd, say, warn, step }:
|
|
7
|
+
// tz, language the profile's timezone and language
|
|
8
|
+
// top the forced number of representative projects, or null for adaptive
|
|
9
|
+
// outDir, cmd how the person's own messages name the output folder and this command
|
|
10
|
+
// say, warn progress and notes for the sub-commands' terminal output (default: silent)
|
|
11
|
+
// step a short label of the stretch about to start, for the wizard's spinner
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { readAllSources } from "./sources.mjs";
|
|
15
|
+
import { computeFingerprint } from "./fingerprint.mjs";
|
|
16
|
+
import { computeForensics } from "./forensics.mjs";
|
|
17
|
+
import { buildDigest } from "./digest.mjs";
|
|
18
|
+
import { enrichRepo, describeContextGaps } from "./enrich.mjs";
|
|
19
|
+
import { selectRepresentatives, assembleProfile, renderMarkdown, summarizeSources } from "./profile.mjs";
|
|
20
|
+
import { narrativeInputFor } from "./profile-llm.mjs";
|
|
21
|
+
import { practicesFiles } from "./practices-sample.mjs";
|
|
22
|
+
import { buildTrajectory } from "./trajectory.mjs";
|
|
23
|
+
import { computeAiRelationship } from "./ai-relationship.mjs";
|
|
24
|
+
import { computeAgenticLiteracy } from "./agentic-literacy.mjs";
|
|
25
|
+
import { computeIntensity } from "./intensity.mjs";
|
|
26
|
+
import { computeDistribution } from "./distribution.mjs";
|
|
27
|
+
import { computeTechUsage, recordedTechUsageTz } from "./tech-usage.mjs";
|
|
28
|
+
import { computeCodePractices, mergeModelPractices, practicesBlock, recordedPracticesTz } from "./practices.mjs";
|
|
29
|
+
import { assessGroundedness } from "./groundedness.mjs";
|
|
30
|
+
import { assessAgainstLogs } from "./consistency.mjs";
|
|
31
|
+
import { DEFAULT_TZ } from "./days.mjs";
|
|
32
|
+
|
|
33
|
+
const quiet = () => {};
|
|
34
|
+
|
|
35
|
+
/** The model's answers could not be used; the message says what to fix. */
|
|
36
|
+
export class PracticesAnswersError extends Error {
|
|
37
|
+
name = "PracticesAnswersError";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The output folder, created once logs were found. A `*` .gitignore inside keeps every file in it out of a commit. */
|
|
41
|
+
export function ensureOutDir(out) {
|
|
42
|
+
mkdirSync(out, { recursive: true });
|
|
43
|
+
const ignore = join(out, ".gitignore");
|
|
44
|
+
if (!existsSync(ignore)) writeFileSync(ignore, "*\n");
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Everything computed from the parsed logs; the wizard passes the sources the person chose.
|
|
49
|
+
export function deriveInputs(parsed, out, { tz, top = null, say = quiet, warn = quiet, step = quiet }) {
|
|
50
|
+
step("Fingerprinting the logs");
|
|
51
|
+
say(`[2/5] Fingerprint, manifest, consistency ...`);
|
|
52
|
+
const fingerprint = computeFingerprint(parsed, { tz });
|
|
53
|
+
const forensics = computeForensics(parsed);
|
|
54
|
+
|
|
55
|
+
step("Grouping the work into projects");
|
|
56
|
+
say(`[3/5] Deep digest + per-repo clustering (PII redacted: ${parsed.redaction.hits}) ...`);
|
|
57
|
+
const digest = buildDigest(parsed, { tz });
|
|
58
|
+
const projects = selectRepresentatives(digest.projects, top ? +top : "auto");
|
|
59
|
+
const selected = projects.filter((p) => p.selected);
|
|
60
|
+
say(` ${digest.projectCount} products, ${selected.length}${top ? "" : " (adaptive 3-5)"} representative: ${selected.map((p) => `${p.repo}[${p.type[0]}]`).join(", ")}`);
|
|
61
|
+
|
|
62
|
+
step("Reading the representative projects");
|
|
63
|
+
const enrichments = selected.map((p) => enrichRepo(p.cwdRaw));
|
|
64
|
+
const contextGap = describeContextGaps(enrichments);
|
|
65
|
+
if (contextGap) warn(` note: ${contextGap}`);
|
|
66
|
+
step("Measuring how the work changed over time");
|
|
67
|
+
const trajectory = buildTrajectory(parsed);
|
|
68
|
+
const aiRelationship = computeAiRelationship(parsed);
|
|
69
|
+
const agenticLiteracy = computeAgenticLiteracy(parsed);
|
|
70
|
+
const intensity = computeIntensity(parsed, { tz });
|
|
71
|
+
const distribution = computeDistribution(projects);
|
|
72
|
+
const techUsage = computeTechUsage(projects, { tz });
|
|
73
|
+
step("Counting the work practices");
|
|
74
|
+
const practices = practicesBlock(computeCodePractices(parsed, { tz })?.items, { tz });
|
|
75
|
+
const sources = summarizeSources(parsed);
|
|
76
|
+
return { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, out };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const narrativeOptionsOf = (i, language) => ({
|
|
80
|
+
trajectory: i.trajectory,
|
|
81
|
+
aiRelationship: i.aiRelationship,
|
|
82
|
+
agenticLiteracy: i.agenticLiteracy,
|
|
83
|
+
intensity: i.intensity,
|
|
84
|
+
distribution: i.distribution,
|
|
85
|
+
allProjects: i.projects,
|
|
86
|
+
compactionSummaries: i.parsed.compactionSummaries,
|
|
87
|
+
language,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const sharedPractices = () => JSON.parse(readFileSync(new URL("../share/practices.json", import.meta.url), "utf8"));
|
|
91
|
+
|
|
92
|
+
// The model-classified practices: written only when some are published and
|
|
93
|
+
// there is something to read. Both files stay local; the sample file maps the
|
|
94
|
+
// opaque ids back to real sessions and is never sent.
|
|
95
|
+
export function writePracticesInput(out, parsed, { tz, outDir, say = quiet }) {
|
|
96
|
+
// A stale sample from an earlier run must never be read by finalize.
|
|
97
|
+
for (const f of ["practices-input.json", "practices-sample.json", "practices-detail.json", "practices.json"]) rmSync(join(out, f), { force: true });
|
|
98
|
+
const practices = (sharedPractices().practices ?? []).filter((p) => p.method === "model");
|
|
99
|
+
const files = practicesFiles(parsed, { tz, practices });
|
|
100
|
+
if (!files) return;
|
|
101
|
+
writeFileSync(join(out, "practices-input.json"), JSON.stringify(files.input, null, 2));
|
|
102
|
+
writeFileSync(join(out, "practices-sample.json"), JSON.stringify(files.sample, null, 2));
|
|
103
|
+
say(`Wrote ${outDir}/practices-input.json (${files.sample.length} sessions of your own messages, for your model to classify) and ${outDir}/practices-sample.json (local only).`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// The model's answers, when the person's model wrote out/practices.json: checked
|
|
107
|
+
// against the sample file written at prepare (never resampled), then merged into
|
|
108
|
+
// the block, with who classified them. A bad or unreadable file stops the step;
|
|
109
|
+
// nothing is saved.
|
|
110
|
+
export function mergePracticesAnswers(out, codeBlock, classifiedBy, { tz, outDir, cmd, say = quiet }) {
|
|
111
|
+
const answersFile = join(out, "practices.json");
|
|
112
|
+
if (!existsSync(answersFile)) return codeBlock;
|
|
113
|
+
const sampleFile = join(out, "practices-sample.json");
|
|
114
|
+
const fail = (msg) => {
|
|
115
|
+
throw new PracticesAnswersError(`${msg} Fix it, or delete ${outDir}/practices.json to leave the model practices out.`);
|
|
116
|
+
};
|
|
117
|
+
const read = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return undefined; } };
|
|
118
|
+
const sample = read(sampleFile);
|
|
119
|
+
if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run ${cmd} prepare again.`);
|
|
120
|
+
const answers = read(answersFile);
|
|
121
|
+
if (answers === undefined) fail(`${answersFile} is not valid JSON.`);
|
|
122
|
+
const ids = (sharedPractices().practices ?? []).filter((p) => p.method === "model").map((p) => p.id);
|
|
123
|
+
try {
|
|
124
|
+
const { block, detail } = mergeModelPractices(codeBlock, answers, sample, ids, { tz, classifiedBy });
|
|
125
|
+
writeFileSync(join(out, "practices-detail.json"), JSON.stringify(detail, null, 2));
|
|
126
|
+
say(`Merged the model's answers for ${sample.length} sessions (per-session detail in ${outDir}/practices-detail.json, local only).`);
|
|
127
|
+
return block;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return fail(`${answersFile}: ${e.message}.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// What the agent run adds to the profile: the answers merged into the practices block, who
|
|
134
|
+
// wrote the narrative. The answers stay in practices-detail.json, so a later finalize never
|
|
135
|
+
// reads them as the slash command's.
|
|
136
|
+
export function applyAgentRun(out, codePractices, run, ctx) {
|
|
137
|
+
if (run.practicesAnswers) writeFileSync(join(out, "practices.json"), JSON.stringify(run.practicesAnswers, null, 2));
|
|
138
|
+
const practices = run.practicesAnswers ? mergePracticesAnswers(out, codePractices, run.used, ctx) : codePractices;
|
|
139
|
+
rmSync(join(out, "practices.json"), { force: true });
|
|
140
|
+
return { practices, narrative: run.narrative, generatedBy: { narrative: run.used } };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Assemble + compute groundedness on the assembled draft + re-assemble with
|
|
144
|
+
// the score embedded. Centralised so generate, finalize and the wizard share it.
|
|
145
|
+
export function assembleWithGroundedness(args, { language, warn = quiet }) {
|
|
146
|
+
// The raw vocabularyCandidates never enter the profile (they can carry
|
|
147
|
+
// client names), so a narrative that omitted its filtered pick leaves
|
|
148
|
+
// newVocabulary empty. Say so instead of failing silently.
|
|
149
|
+
if (args.narrative && args.trajectory?.vocabularyCandidates?.length && !args.narrative.trajectory?.vocabulary_adopted?.length) {
|
|
150
|
+
warn(` note: the narrative has no trajectory.vocabulary_adopted, newVocabulary stays empty (raw candidates are never used; re-run the narrative step to fill it)`);
|
|
151
|
+
}
|
|
152
|
+
const withLanguage = { language, ...args };
|
|
153
|
+
const draft = assembleProfile(withLanguage);
|
|
154
|
+
const groundedness = assessGroundedness(draft);
|
|
155
|
+
return assembleProfile({ ...withLanguage, groundedness });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Writes candidate.json and profile.md; returns the markdown. */
|
|
159
|
+
export function saveProfile(out, profile) {
|
|
160
|
+
writeFileSync(join(out, "candidate.json"), JSON.stringify(profile, null, 2));
|
|
161
|
+
const md = renderMarkdown(profile);
|
|
162
|
+
writeFileSync(join(out, "profile.md"), md);
|
|
163
|
+
return md;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The numbers the wizard shows after a run. */
|
|
167
|
+
export const profileSummary = (profile) => ({
|
|
168
|
+
sessions: profile.volume?.sessions ?? 0,
|
|
169
|
+
products: profile.volume?.products ?? 0,
|
|
170
|
+
practices: profile.practices?.items ?? [],
|
|
171
|
+
summary: profile.summary ?? null,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* submit's pre-flight against the logs as they are now: re-reads the SAME source mix the
|
|
176
|
+
* profile was generated from (see sourceFlags() in the bin for why this must never drift),
|
|
177
|
+
* then re-derives what the profile claims.
|
|
178
|
+
* @returns {{ issues: string[], excessClaims: number, warnings: string[] }}
|
|
179
|
+
*/
|
|
180
|
+
export function checkAgainstLogs(profile, { claudeRoot, sources, step = quiet, onProgress }) {
|
|
181
|
+
step("Reading your logs again");
|
|
182
|
+
const parsed = readAllSources({ claudeRoot, sources, onProgress });
|
|
183
|
+
step("Re-deriving what the profile claims");
|
|
184
|
+
// Re-derive day-based intensity and tech-usage months in the zone the
|
|
185
|
+
// profile RECORDED, never the machine zone, so the comparison measures
|
|
186
|
+
// the data, not the bucketing.
|
|
187
|
+
const techTz = recordedTechUsageTz(profile);
|
|
188
|
+
const digest = buildDigest(parsed, { tz: techTz });
|
|
189
|
+
const intensity = computeIntensity(parsed, { tz: profile.intensity?.timezone || DEFAULT_TZ });
|
|
190
|
+
const techUsage = computeTechUsage(digest.projects, { tz: techTz });
|
|
191
|
+
const practices = computeCodePractices(parsed, { tz: recordedPracticesTz(profile) });
|
|
192
|
+
const logs = assessAgainstLogs(profile, digest.projects, { intensity, techUsage, practices });
|
|
193
|
+
return { issues: logs.issues, excessClaims: logs.excessClaims || 0, warnings: logs.warnings };
|
|
194
|
+
}
|
package/src/profile-llm.mjs
CHANGED
|
@@ -9,16 +9,17 @@
|
|
|
9
9
|
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
11
|
import { firstJsonObject } from "./agents/json-answer.mjs";
|
|
12
|
+
import { DEFAULT_LANGUAGE, LANGUAGES } from "./languages.mjs";
|
|
12
13
|
|
|
13
14
|
export const MODEL = "claude-opus-4-7";
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
const NARRATIVE_PROMPT = `You write a candidate's work profile from the logs of their activity with AI development tools.
|
|
16
17
|
|
|
17
18
|
HARD RULES:
|
|
18
19
|
- NO proper names: no companies, clients, people, products, brands, or repositories. Describe each project ONLY by abstract domain and context (e.g. "talent and campaigns management platform", not the actual product name). Exception: the agent CLI names in the orchestration data (e.g. Claude Code, opencode, codex, aider) are tools, not client brands — you may name them when citing the per-CLI split.
|
|
19
20
|
- Use only the data provided. No invention, no empty praise, no hyperbolic adjectives.
|
|
20
21
|
- Concrete and evidence-based: every claim must rest on signals in the digest (areas touched, stack, landing signals, prompts, commits).
|
|
21
|
-
-
|
|
22
|
+
- Write every text in {LANGUAGE}: dry, readable by a human. Technology, product, library and method names stay as written. Write numbers as plain digits exactly as they appear in the data, with no thousands separator. The JSON keys stay as shown. No emojis, no em dashes.
|
|
22
23
|
|
|
23
24
|
You receive a JSON with the selected projects (opaque ids p1, p2, ...), each with: type, span, volumes, code areas, stack, landing signals (commits/reverts/checks), an orchestration block, web-search topics, sampled prompts, and LOCAL repo context (description, docs, dependencies, commit subjects).
|
|
24
25
|
|
|
@@ -66,6 +67,9 @@ Reply ONLY with a valid JSON in this shape:
|
|
|
66
67
|
"projects": [ { "id": "p1", "domain": "abstract domain", "did": "2-3 sentences on what they did", "why_representative": "1 sentence" } ]
|
|
67
68
|
}`;
|
|
68
69
|
|
|
70
|
+
// The narrative prompt for a language code from src/languages.mjs.
|
|
71
|
+
export const narrativeSystem = (language = DEFAULT_LANGUAGE) => NARRATIVE_PROMPT.replace("{LANGUAGE}", LANGUAGES[language].name);
|
|
72
|
+
|
|
69
73
|
// Scrub probable proper nouns from the prompt samples we hand to the model
|
|
70
74
|
// as evidence. The LLM has a hard anti-naming rule but we don't rely on
|
|
71
75
|
// soft constraints alone: replace capitalised tokens (not at sentence start)
|
|
@@ -84,8 +88,11 @@ function scrubExamples(examples) {
|
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
function narrativeInput(selected, enrichments, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects) {
|
|
91
|
+
function narrativeInput(selected, enrichments, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects, language) {
|
|
88
92
|
return {
|
|
93
|
+
// The language the prose is written in: the prompt names it, and the slash command reads it here.
|
|
94
|
+
language,
|
|
95
|
+
languageName: LANGUAGES[language].name,
|
|
89
96
|
// Compact per-product evidence across ALL products (not just the selected
|
|
90
97
|
// ones) so the model can derive the aggregate domains. Local-only input;
|
|
91
98
|
// the output side carries abstract labels and counts, never names.
|
|
@@ -172,7 +179,7 @@ async function postMessage(key, system, user, maxTokens, signal) {
|
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
async function callAnthropic(input, key) {
|
|
175
|
-
const text = await postMessage(key,
|
|
182
|
+
const text = await postMessage(key, narrativeSystem(input.language), JSON.stringify(input), 3000);
|
|
176
183
|
return firstJsonObject(text);
|
|
177
184
|
}
|
|
178
185
|
|
|
@@ -228,8 +235,8 @@ export function validateNarrative(n, ctx) {
|
|
|
228
235
|
|
|
229
236
|
// Builds the narrative input only. Never touches the network, so `prepare`
|
|
230
237
|
// can call it whatever the environment holds.
|
|
231
|
-
export function narrativeInputFor(selected, enrichments, { trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects } = {}) {
|
|
232
|
-
return narrativeInput(selected, enrichments, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects);
|
|
238
|
+
export function narrativeInputFor(selected, enrichments, { trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects, language = DEFAULT_LANGUAGE } = {}) {
|
|
239
|
+
return narrativeInput(selected, enrichments, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects, language);
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
// Returns { narrative, input, source }. narrative is null if no key and no
|
|
@@ -237,8 +244,8 @@ export function narrativeInputFor(selected, enrichments, { trajectory, compactio
|
|
|
237
244
|
// An explicit --narrative-file always wins over the env key: the API path
|
|
238
245
|
// sends the narrative input off-machine, so it must never engage silently
|
|
239
246
|
// or discard a hand-curated narrative just because a key is in the env.
|
|
240
|
-
export async function generateNarrative(selected, enrichments, { overrideFile, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects } = {}) {
|
|
241
|
-
const input = narrativeInputFor(selected, enrichments, { trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects });
|
|
247
|
+
export async function generateNarrative(selected, enrichments, { overrideFile, trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects, language } = {}) {
|
|
248
|
+
const input = narrativeInputFor(selected, enrichments, { trajectory, compactionSummaries, aiRelationship, agenticLiteracy, intensity, distribution, allProjects, language });
|
|
242
249
|
if (overrideFile) return { narrative: validateNarrative(JSON.parse(readFileSync(overrideFile, "utf8")), overrideFile), input, source: "file" };
|
|
243
250
|
const key = process.env.ANTHROPIC_API_KEY;
|
|
244
251
|
if (key) {
|
package/src/profile.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// prose fields come from the narrative step. The Markdown is just a view, so
|
|
4
4
|
// human and agent never diverge.
|
|
5
5
|
|
|
6
|
+
import { DEFAULT_LANGUAGE, codeLabel, labelsFor } from "./languages.mjs";
|
|
7
|
+
|
|
6
8
|
// --- representative selection: significance leads, diversity breaks ties -----
|
|
7
9
|
//
|
|
8
10
|
// The pick is driven by how SIGNIFICANT the work is, not by how many chat
|
|
@@ -184,7 +186,7 @@ export function summarizeSources(parsed) {
|
|
|
184
186
|
|
|
185
187
|
// --- assemble ----------------------------------------------------------------
|
|
186
188
|
|
|
187
|
-
export function assembleProfile({ contact, projects, narrative, fingerprint, forensics, manifestHash, trajectory, groundedness, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, generatedBy }) {
|
|
189
|
+
export function assembleProfile({ contact, projects, narrative, fingerprint, forensics, manifestHash, trajectory, groundedness, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, generatedBy, language = DEFAULT_LANGUAGE }) {
|
|
188
190
|
const froms = projects.map((p) => p.from).filter(Boolean).sort();
|
|
189
191
|
const tos = projects.map((p) => p.to).filter(Boolean).sort();
|
|
190
192
|
const selected = projects.filter((p) => p.selected);
|
|
@@ -193,6 +195,8 @@ export function assembleProfile({ contact, projects, narrative, fingerprint, for
|
|
|
193
195
|
|
|
194
196
|
return {
|
|
195
197
|
schema: "playnew-profile/v1",
|
|
198
|
+
// The language every prose field and the rendered profile.md are written in (a code from src/languages.mjs).
|
|
199
|
+
language,
|
|
196
200
|
generatedAt: new Date().toISOString(),
|
|
197
201
|
// Optional and nullable: the schema keeps the field for readers of older profiles, but this tool no
|
|
198
202
|
// longer asks for it (the hub's sign-in identifies the person) and `submit` never sends it.
|
|
@@ -299,42 +303,34 @@ export function assembleProfile({ contact, projects, narrative, fingerprint, for
|
|
|
299
303
|
|
|
300
304
|
// --- render -------------------------------------------------------------------
|
|
301
305
|
|
|
302
|
-
const land = (l) =>
|
|
303
|
-
`commits ${l.commits} · reverts ${l.reverts} · churn ${l.revertChurn}${l.checksRun ? " · checks passed" : ""}`;
|
|
304
|
-
|
|
305
306
|
export function renderMarkdown(p) {
|
|
307
|
+
const T = labelsFor(p.language);
|
|
308
|
+
const code = (c) => codeLabel(T, c);
|
|
309
|
+
const codes = (list) => list.map(code).join(" · ");
|
|
306
310
|
const L = [];
|
|
307
311
|
const c = p.contact || {};
|
|
308
|
-
L.push(`#
|
|
312
|
+
L.push(`# ${T.title(c.name)}`);
|
|
309
313
|
const meta = [c.email, c.city, c.status].filter(Boolean).join(" · ");
|
|
310
314
|
if (meta) L.push(meta);
|
|
311
|
-
L.push(
|
|
312
|
-
|
|
313
|
-
);
|
|
314
|
-
L.push(`Log consistency screen: ${p.authenticity.score == null ? "n/a" : `${p.authenticity.score}/100`} (${p.authenticity.note})`);
|
|
315
|
+
L.push(T.window(p));
|
|
316
|
+
L.push(T.screen(p.authenticity.score, p.authenticity.note));
|
|
315
317
|
if (p.sources?.length) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
.join(" · ");
|
|
319
|
-
L.push(`Sources: ${src}`);
|
|
320
|
-
L.push(`Window and counts are lower bounds: logs rotate and old sessions are pruned.`);
|
|
318
|
+
L.push(T.sources(p.sources.map(T.source).join(" · ")));
|
|
319
|
+
L.push(T.lowerBounds);
|
|
321
320
|
}
|
|
322
321
|
if (p.summary) L.push(`\n${p.summary}`);
|
|
323
322
|
|
|
324
323
|
if (p.domains?.length) {
|
|
325
|
-
L.push(`\n##
|
|
326
|
-
for (const d of p.domains)
|
|
327
|
-
const note = d.note ? ` — ${d.note}` : "";
|
|
328
|
-
L.push(`- **${d.label}** · ${d.products} products · ${d.sessions} sessions${note}`);
|
|
329
|
-
}
|
|
324
|
+
L.push(`\n## ${T.domains}`);
|
|
325
|
+
for (const d of p.domains) L.push(T.domainLine(d, d.note));
|
|
330
326
|
}
|
|
331
327
|
|
|
332
|
-
L.push(`\n##
|
|
328
|
+
L.push(`\n## ${T.representative}`);
|
|
333
329
|
for (const pr of p.projects) {
|
|
334
330
|
const headTail = pr.repoLabel ? ` _(${pr.id} — ${pr.repoLabel})_` : ` _(${pr.id})_`;
|
|
335
|
-
L.push(`\n### ${pr.domain ||
|
|
336
|
-
L.push(
|
|
337
|
-
if (pr.tech.length) L.push(
|
|
331
|
+
L.push(`\n### ${pr.domain || T.domainFallback} · ${codes(pr.type)}${headTail}`);
|
|
332
|
+
L.push(T.projectLine(pr, T.landing(pr.landing)));
|
|
333
|
+
if (pr.tech.length) L.push(T.stack(pr.tech.join(", ")));
|
|
338
334
|
// The orchestration data candidate.json submits, on the human review
|
|
339
335
|
// surface too. Rendered only when it says something (multi-tool, dispatch
|
|
340
336
|
// or delegation counts) — a single-tool zero line is noise, and the exact
|
|
@@ -343,131 +339,126 @@ export function renderMarkdown(p) {
|
|
|
343
339
|
if (o && (o.toolCount >= 2 || o.dispatchCommands > 0 || o.delegation > 0)) {
|
|
344
340
|
const bits = [];
|
|
345
341
|
const tools = Object.entries(o.tools ?? {}).map(([k, v]) => `${k} ${v}`).join(" + ");
|
|
346
|
-
if (o.toolCount >= 2 && tools)
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (o.delegation > 0) bits.push(`${o.delegation} sub-agent delegations`);
|
|
351
|
-
L.push(`orchestration: ${bits.join(" · ")}`);
|
|
342
|
+
if (o.toolCount >= 2 && tools) bits.push(T.sessionsByTool(tools, o.toolOverlap === false));
|
|
343
|
+
if (o.dispatchCommands > 0) bits.push(T.dispatches(o.dispatchCommands));
|
|
344
|
+
if (o.delegation > 0) bits.push(T.delegations(o.delegation));
|
|
345
|
+
L.push(T.orchestration(bits.join(" · ")));
|
|
352
346
|
}
|
|
353
347
|
if (pr.did) L.push(pr.did);
|
|
354
|
-
if (pr.whyRepresentative) L.push(`
|
|
355
|
-
L.push(
|
|
348
|
+
if (pr.whyRepresentative) L.push(`_${T.whyRepresentative}_ ${pr.whyRepresentative}`);
|
|
349
|
+
L.push(T.artifact(pr.artifact));
|
|
356
350
|
}
|
|
357
351
|
|
|
358
352
|
if (p.otherProjects.length) {
|
|
359
|
-
L.push(`\n##
|
|
353
|
+
L.push(`\n## ${T.otherProjects}`);
|
|
360
354
|
for (const o of p.otherProjects) {
|
|
361
355
|
const tag = o.repoLabel ? ` _(${o.repoLabel})_` : "";
|
|
362
|
-
L.push(
|
|
356
|
+
L.push(T.otherLine(o, codes(o.type), tag));
|
|
363
357
|
}
|
|
364
358
|
}
|
|
365
359
|
|
|
366
|
-
L.push(`\n##
|
|
367
|
-
if (p.cognitive.tags.length) L.push(
|
|
360
|
+
L.push(`\n## ${T.cognitive}`);
|
|
361
|
+
if (p.cognitive.tags.length) L.push(`${T.tags} ${codes(p.cognitive.tags)}`);
|
|
368
362
|
if (p.cognitive.narrative) L.push(p.cognitive.narrative);
|
|
369
363
|
|
|
370
364
|
if (p.aiRelationship) {
|
|
371
|
-
L.push(`\n##
|
|
372
|
-
L.push(
|
|
365
|
+
L.push(`\n## ${T.aiHeading}`);
|
|
366
|
+
L.push(T.aiLine(p.aiRelationship, code(p.aiRelationship.mode)));
|
|
373
367
|
if (p.aiRelationship.narrative) L.push(p.aiRelationship.narrative);
|
|
374
368
|
}
|
|
375
369
|
|
|
376
370
|
if (p.intensity) {
|
|
377
371
|
const i = p.intensity;
|
|
378
|
-
L.push(`\n##
|
|
379
|
-
const tzNote = i.timezone && i.timezone !== "UTC" ?
|
|
380
|
-
L.push(
|
|
381
|
-
L.push(
|
|
382
|
-
L.push(
|
|
383
|
-
L.push(
|
|
384
|
-
L.push(
|
|
385
|
-
L.push(
|
|
372
|
+
L.push(`\n## ${T.intensity}`);
|
|
373
|
+
const tzNote = i.timezone && i.timezone !== "UTC" ? T.daysNote(i.timezone) : "";
|
|
374
|
+
L.push(T.activeDays(i, tzNote));
|
|
375
|
+
L.push(T.medianSessionsPerDay(i.medianSessionsPerActiveDay));
|
|
376
|
+
L.push(T.medianDepth(i.medianSessionToolCalls));
|
|
377
|
+
L.push(T.streak(i.longestStreak));
|
|
378
|
+
L.push(T.peakDay(i.peakDayToolCalls));
|
|
379
|
+
L.push(T.cadence(code(i.cadence), code(i.sessionShape)));
|
|
386
380
|
if (i.narrative) L.push(`\n${i.narrative}`);
|
|
387
381
|
}
|
|
388
382
|
|
|
389
383
|
if (p.distribution) {
|
|
390
384
|
const d = p.distribution;
|
|
391
|
-
L.push(`\n##
|
|
392
|
-
L.push(
|
|
393
|
-
L.push(
|
|
394
|
-
L.push(
|
|
395
|
-
L.push(
|
|
385
|
+
L.push(`\n## ${T.distribution}`);
|
|
386
|
+
L.push(T.perProduct(d));
|
|
387
|
+
L.push(T.top3(d));
|
|
388
|
+
L.push(T.multiMonth(d));
|
|
389
|
+
L.push(T.shape(code(d.shape)));
|
|
396
390
|
if (d.narrative) L.push(`\n${d.narrative}`);
|
|
397
391
|
}
|
|
398
392
|
|
|
399
393
|
if (p.techUsage?.technologies?.length) {
|
|
400
394
|
const u = p.techUsage;
|
|
401
|
-
const tzNote = u.timezone && u.timezone !== "UTC" ?
|
|
402
|
-
L.push(`\n##
|
|
403
|
-
L.push(
|
|
395
|
+
const tzNote = u.timezone && u.timezone !== "UTC" ? T.monthsNote(u.timezone) : "";
|
|
396
|
+
L.push(`\n## ${T.techUsage}`);
|
|
397
|
+
L.push(T.techIntro(tzNote));
|
|
404
398
|
for (const t of u.technologies) {
|
|
405
|
-
const span = t.firstMonth === t.lastMonth ? t.firstMonth : `${t.firstMonth} to ${t.lastMonth}`;
|
|
406
|
-
L.push(
|
|
399
|
+
const span = t.firstMonth === t.lastMonth ? t.firstMonth : `${t.firstMonth} ${T.to} ${t.lastMonth}`;
|
|
400
|
+
L.push(T.techLine(t, code(t.band), span));
|
|
407
401
|
}
|
|
408
402
|
}
|
|
409
403
|
|
|
410
404
|
if (p.practices?.items?.length) {
|
|
411
405
|
const u = p.practices;
|
|
412
|
-
const tzNote = u.timezone && u.timezone !== "UTC" ?
|
|
413
|
-
L.push(`\n##
|
|
414
|
-
L.push(
|
|
415
|
-
for (const t of u.items)
|
|
416
|
-
const how = t.method === "model" ? "classified by the person's model" : "counted by code";
|
|
417
|
-
L.push(`- ${t.id}: in ${t.seen} of ${t.of} ${t.of === 1 ? "session" : "sessions"} · ${t.products} ${t.products === 1 ? "product" : "products"} · ${t.months} ${t.months === 1 ? "month" : "months"} · ${how}`);
|
|
418
|
-
}
|
|
406
|
+
const tzNote = u.timezone && u.timezone !== "UTC" ? T.monthsNote(u.timezone) : "";
|
|
407
|
+
L.push(`\n## ${T.practices}`);
|
|
408
|
+
L.push(T.practicesIntro(tzNote));
|
|
409
|
+
for (const t of u.items) L.push(T.practiceLine(t, code(t.id), t.method === "model" ? T.byModel : T.byCode));
|
|
419
410
|
}
|
|
420
411
|
|
|
421
412
|
if (p.agenticLiteracy) {
|
|
422
413
|
const a = p.agenticLiteracy;
|
|
423
|
-
L.push(`\n##
|
|
424
|
-
L.push(
|
|
425
|
-
L.push(
|
|
426
|
-
L.push(
|
|
427
|
-
L.push(
|
|
428
|
-
L.push(
|
|
429
|
-
L.push(
|
|
430
|
-
L.push(
|
|
431
|
-
L.push(`\
|
|
432
|
-
L.push(
|
|
433
|
-
L.push(
|
|
434
|
-
L.push(
|
|
435
|
-
L.push(
|
|
436
|
-
L.push(
|
|
437
|
-
L.push(`\
|
|
438
|
-
L.push(
|
|
439
|
-
L.push(
|
|
440
|
-
L.push(
|
|
414
|
+
L.push(`\n## ${T.literacy}`);
|
|
415
|
+
L.push(T.uses);
|
|
416
|
+
L.push(T.subagentDelegations(a.uses.subagentDelegations));
|
|
417
|
+
L.push(T.taskTracking(a.uses.taskTrackingEvents));
|
|
418
|
+
L.push(T.builtinSlash(a.uses.builtinSlashInvocations));
|
|
419
|
+
L.push(T.customSkills(a.uses.customSkillsCommands));
|
|
420
|
+
L.push(T.publicMcp(a.uses.publicMcp));
|
|
421
|
+
L.push(T.customMcp(a.uses.customMcp));
|
|
422
|
+
L.push(`\n${T.builds}`);
|
|
423
|
+
L.push(T.skillsAuthored(a.builds.skillsAuthored));
|
|
424
|
+
L.push(T.commandsAuthored(a.builds.commandsAuthored));
|
|
425
|
+
L.push(T.agentsAuthored(a.builds.agentsAuthored));
|
|
426
|
+
L.push(T.hooksEdited(a.builds.hooksEdited));
|
|
427
|
+
L.push(T.memoryFiles(a.builds.projectMemoryFiles));
|
|
428
|
+
L.push(`\n${T.designs}`);
|
|
429
|
+
L.push(T.plansFirst(a.designs.plansFirst));
|
|
430
|
+
L.push(T.subtaskTracking(a.designs.subtaskTracking));
|
|
431
|
+
L.push(T.clarifies(a.designs.clarifies));
|
|
441
432
|
if (a.narrative) L.push(`\n${a.narrative}`);
|
|
442
433
|
}
|
|
443
434
|
|
|
444
435
|
// Trajectory: what changed strategically over the window. Numbers first, then
|
|
445
436
|
// the LLM narrative, then the principles the candidate codified for themselves.
|
|
446
437
|
if (p.trajectory) {
|
|
447
|
-
L.push(`\n##
|
|
438
|
+
L.push(`\n## ${T.trajectory}`);
|
|
448
439
|
if (p.trajectory.narrative) L.push(p.trajectory.narrative);
|
|
449
440
|
|
|
450
441
|
if (p.trajectory.shifts && p.trajectory.shifts.deltas) {
|
|
451
|
-
L.push(`\
|
|
442
|
+
L.push(`\n${T.shifts(p.trajectory.shifts.midpoint)}`);
|
|
452
443
|
for (const d of p.trajectory.shifts.deltas) {
|
|
453
444
|
const arrow = d.dir === "up" ? "↑" : d.dir === "down" ? "↓" : d.dir === "stable" ? "·" : "";
|
|
454
|
-
L.push(`- ${d.metric}: ${formatVal(d.early, d.format)} → ${formatVal(d.late, d.format)} ${arrow}`);
|
|
445
|
+
L.push(`- ${code(d.metric)}: ${formatVal(d.early, d.format)} → ${formatVal(d.late, d.format)} ${arrow}`);
|
|
455
446
|
}
|
|
456
447
|
}
|
|
457
448
|
|
|
458
449
|
if (p.trajectory.topics?.length) {
|
|
459
|
-
L.push(`\
|
|
450
|
+
L.push(`\n${T.topics}`);
|
|
460
451
|
for (const q of p.trajectory.topics) {
|
|
461
|
-
L.push(`- ${q.quarter}: ${q.themes.map((t) => `${t.name} (${t.count})`).join(", ")}`);
|
|
452
|
+
L.push(`- ${q.quarter}: ${q.themes.map((t) => `${code(t.name)} (${t.count})`).join(", ")}`);
|
|
462
453
|
}
|
|
463
454
|
}
|
|
464
455
|
|
|
465
456
|
if (p.trajectory.newVocabulary?.length) {
|
|
466
|
-
L.push(`\
|
|
457
|
+
L.push(`\n${T.vocabulary(p.trajectory.newVocabulary.join(", "))}`);
|
|
467
458
|
}
|
|
468
459
|
|
|
469
460
|
if (p.trajectory.principlesAdopted?.length) {
|
|
470
|
-
L.push(`\
|
|
461
|
+
L.push(`\n${T.principles}`);
|
|
471
462
|
for (const pr of p.trajectory.principlesAdopted) {
|
|
472
463
|
const when = pr.when ? `_${pr.when}_ — ` : "";
|
|
473
464
|
L.push(`- ${when}${pr.text}`);
|
|
@@ -476,14 +467,14 @@ export function renderMarkdown(p) {
|
|
|
476
467
|
}
|
|
477
468
|
|
|
478
469
|
if (p.stackAdopted?.length) {
|
|
479
|
-
L.push(`\n##
|
|
470
|
+
L.push(`\n## ${T.stackAdopted}`);
|
|
480
471
|
L.push(p.stackAdopted.join(", "));
|
|
481
472
|
// Disclosed boundaries — detection reads package.json + touched files, never
|
|
482
473
|
// .env: (1) deps reflect the repo as it stands now, not at session time;
|
|
483
474
|
// (2) npm manifests only — no pyproject/requirements; (3) deps are absent if
|
|
484
475
|
// the project folder no longer exists; (4) REST-only services (an API key,
|
|
485
476
|
// no package) are not auto-detected.
|
|
486
|
-
L.push(
|
|
477
|
+
L.push(T.stackNote);
|
|
487
478
|
}
|
|
488
479
|
|
|
489
480
|
return L.join("\n") + "\n";
|
package/src/sources.mjs
CHANGED
|
@@ -53,9 +53,11 @@ export const SOURCES = [
|
|
|
53
53
|
/**
|
|
54
54
|
* Read one source by its id (see SOURCES) with agent-run transcripts dropped,
|
|
55
55
|
* or null when `sources.<id>.disabled`. Same roots and flags as readAllSources.
|
|
56
|
+
* `onProgress({ done, total })` is called as the files of the source are read, for the
|
|
57
|
+
* sources that are files (the sqlite ones are read in one query).
|
|
56
58
|
*/
|
|
57
|
-
export function readSource(id, { claudeRoot, sources }) {
|
|
58
|
-
if (id === "claude-code") return dropAgentRuns(readClaudeCode(claudeRoot));
|
|
59
|
+
export function readSource(id, { claudeRoot, sources, onProgress }) {
|
|
60
|
+
if (id === "claude-code") return dropAgentRuns(readClaudeCode(claudeRoot, { onProgress }));
|
|
59
61
|
const o = sources?.[id] ?? {};
|
|
60
62
|
if (o.disabled) return null;
|
|
61
63
|
switch (id) {
|
|
@@ -66,9 +68,9 @@ export function readSource(id, { claudeRoot, sources }) {
|
|
|
66
68
|
const root = o.root ?? defaultOpencodeRoot();
|
|
67
69
|
return dropAgentRuns(o.json ? readOpencodeJson(root) : readOpencode(root));
|
|
68
70
|
}
|
|
69
|
-
case "codex": return dropAgentRuns(readCodex(o.root ?? defaultCodexRoot()));
|
|
70
|
-
case "pi": return dropAgentRuns(readPi(o.root ?? defaultPiRoot()));
|
|
71
|
-
case "omp": return dropAgentRuns(readOmp(o.root ?? defaultOmpRoot()));
|
|
71
|
+
case "codex": return dropAgentRuns(readCodex(o.root ?? defaultCodexRoot(), { onProgress }));
|
|
72
|
+
case "pi": return dropAgentRuns(readPi(o.root ?? defaultPiRoot(), { onProgress }));
|
|
73
|
+
case "omp": return dropAgentRuns(readOmp(o.root ?? defaultOmpRoot(), { onProgress }));
|
|
72
74
|
case "cursor": return dropAgentRuns(readCursor(o.root ?? defaultCursorRoot()));
|
|
73
75
|
case "kimi": return dropAgentRuns(readKimi(o.root ?? defaultKimiRoot()));
|
|
74
76
|
default: throw new Error(`unknown source: ${id}`);
|
|
@@ -80,10 +82,10 @@ export function combineSources(bundles) {
|
|
|
80
82
|
return bundles.length > 1 ? mergeSources(...bundles) : bundles[0];
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
export function readAllSources({ claudeRoot, sources }) {
|
|
85
|
+
export function readAllSources({ claudeRoot, sources, onProgress }) {
|
|
84
86
|
const bundles = [];
|
|
85
87
|
for (const { id } of SOURCES) {
|
|
86
|
-
const b = readSource(id, { claudeRoot, sources });
|
|
88
|
+
const b = readSource(id, { claudeRoot, sources, onProgress: onProgress && ((p) => onProgress({ ...p, source: id })) });
|
|
87
89
|
// claude-code is always part of the result; the others only when they have sessions.
|
|
88
90
|
if (b && (id === "claude-code" || b.sessions.length)) bundles.push(b);
|
|
89
91
|
}
|