agentera 3.0.0-dev.32 → 3.0.0-dev.39
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/bundle/CHANGELOG.md +75 -5
- package/bundle/references/adapters/package-publication.json +43 -0
- package/bundle/references/adapters/package-surface-characterization.md +12 -0
- package/bundle/references/analysis/evidence-tier-authority.yaml +23 -21
- package/bundle/references/analysis/verification-policy.yaml +1 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +11 -2
- package/bundle/references/artifacts/glossary-entry-contract.yaml +1241 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +149 -80
- package/bundle/references/cli/agent-ready-state-contract.yaml +84 -2
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +12 -1
- package/bundle/references/cli/prime-consumer-compatibility.yaml +7 -1
- package/bundle/skills/agentera/SKILL.md +26 -26
- package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +26 -8
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +21 -4
- package/bundle/skills/agentera/capabilities/build/schemas/exit.yaml +5 -4
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +67 -3
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +3 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +64 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +4 -1
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +30 -0
- package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +5 -2
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +3 -2
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +30 -0
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +82 -0
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +19 -4
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +92 -0
- package/dist/analytics/extractCorpus/evidenceTiers.js +46 -3
- package/dist/analytics/extractCorpus/evidenceTiers.js.map +1 -1
- package/dist/analytics/extractCorpus/tierReader.js +1 -1
- package/dist/analytics/extractCorpus/tierReader.js.map +1 -1
- package/dist/analytics/glossaryAdviceResolution.js +167 -0
- package/dist/analytics/glossaryAdviceResolution.js.map +1 -0
- package/dist/analytics/glossaryInputAcquisition.js +320 -0
- package/dist/analytics/glossaryInputAcquisition.js.map +1 -0
- package/dist/analytics/personalGlossaryAdmission.js +134 -0
- package/dist/analytics/personalGlossaryAdmission.js.map +1 -0
- package/dist/analytics/personalGlossaryProfile.js +219 -0
- package/dist/analytics/personalGlossaryProfile.js.map +1 -0
- package/dist/audit/terminologyDrift.js +282 -0
- package/dist/audit/terminologyDrift.js.map +1 -0
- package/dist/capabilities/audit/instructions.js +2 -1
- package/dist/capabilities/audit/instructions.js.map +1 -1
- package/dist/capabilities/build/instructions.js +41 -2
- package/dist/capabilities/build/instructions.js.map +1 -1
- package/dist/capabilities/discuss/instructions.js +14 -1
- package/dist/capabilities/discuss/instructions.js.map +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/orchestrate/instructions.js +2 -2
- package/dist/capabilities/plan/instructions.js +19 -2
- package/dist/capabilities/plan/instructions.js.map +1 -1
- package/dist/capabilities/profile/instructions.js +67 -1
- package/dist/capabilities/profile/instructions.js.map +1 -1
- package/dist/cli/capabilityContext/bespoke.js +4 -3
- package/dist/cli/capabilityContext/bespoke.js.map +1 -1
- package/dist/cli/capabilityContext/build.js +77 -24
- package/dist/cli/capabilityContext/build.js.map +1 -1
- package/dist/cli/capabilityContext/closeout.js +2 -2
- package/dist/cli/capabilityContext/closeout.js.map +1 -1
- package/dist/cli/capabilityContext/evidence.js +2 -6
- package/dist/cli/capabilityContext/evidence.js.map +1 -1
- package/dist/cli/capabilityContext/planState.js +59 -78
- package/dist/cli/capabilityContext/planState.js.map +1 -1
- package/dist/cli/capabilityContext/projectVerification.js +410 -0
- package/dist/cli/capabilityContext/projectVerification.js.map +1 -0
- package/dist/cli/capabilityContext/startup.js +21 -4
- package/dist/cli/capabilityContext/startup.js.map +1 -1
- package/dist/cli/commands/glossaryAdvice.js +139 -0
- package/dist/cli/commands/glossaryAdvice.js.map +1 -0
- package/dist/cli/commands/personalGlossary.js +177 -0
- package/dist/cli/commands/personalGlossary.js.map +1 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js.map +1 -0
- package/dist/cli/commands/prime/collectEntityOrientation.js +18 -2
- package/dist/cli/commands/prime/collectEntityOrientation.js.map +1 -1
- package/dist/cli/commands/prime/collectOrientationState.js +7 -1
- package/dist/cli/commands/prime/collectOrientationState.js.map +1 -1
- package/dist/cli/commands/prime/orientationOutput.js +12 -2
- package/dist/cli/commands/prime/orientationOutput.js.map +1 -1
- package/dist/cli/commands/prime.js +37 -2
- package/dist/cli/commands/prime.js.map +1 -1
- package/dist/cli/commands/profileGrounding.js +77 -0
- package/dist/cli/commands/profileGrounding.js.map +1 -0
- package/dist/cli/commands/query.js +14 -4
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/schema.js +10 -0
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/state/write.js +4 -1
- package/dist/cli/commands/state/write.js.map +1 -1
- package/dist/cli/dispatch/lifecycle.js +45 -0
- package/dist/cli/dispatch/lifecycle.js.map +1 -1
- package/dist/cli/dispatch/prime.js +22 -1
- package/dist/cli/dispatch/prime.js.map +1 -1
- package/dist/cli/dispatch/shared.js +1 -1
- package/dist/cli/dispatch/shared.js.map +1 -1
- package/dist/cli/help.js +23 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/migrationRequired.js +2 -0
- package/dist/cli/migrationRequired.js.map +1 -1
- package/dist/cli/orientation/attention.js +3 -1
- package/dist/cli/orientation/attention.js.map +1 -1
- package/dist/cli/orientation.js +2 -2
- package/dist/cli/orientation.js.map +1 -1
- package/dist/registries/artifactProtocolIds.js +2 -0
- package/dist/registries/artifactProtocolIds.js.map +1 -1
- package/dist/registries/artifactRegistry.js +2 -0
- package/dist/registries/artifactRegistry.js.map +1 -1
- package/dist/registries/evidenceTierContract.js +26 -16
- package/dist/registries/evidenceTierContract.js.map +1 -1
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryAdviceContract.js.map +1 -0
- package/dist/registries/glossaryCaveatContract.js +68 -0
- package/dist/registries/glossaryCaveatContract.js.map +1 -0
- package/dist/registries/glossaryConsumerContractValidation.js +792 -0
- package/dist/registries/glossaryConsumerContractValidation.js.map +1 -0
- package/dist/registries/glossaryEntryContract.js +747 -0
- package/dist/registries/glossaryEntryContract.js.map +1 -0
- package/dist/registries/glossaryTermIdentity.js +18 -0
- package/dist/registries/glossaryTermIdentity.js.map +1 -0
- package/dist/registries/glossaryTermOccurrence.js +21 -0
- package/dist/registries/glossaryTermOccurrence.js.map +1 -0
- package/dist/state/changelog.js +222 -0
- package/dist/state/changelog.js.map +1 -0
- package/dist/state/decisionEntities.js +18 -11
- package/dist/state/decisionEntities.js.map +1 -1
- package/dist/state/decisionMigrationProvenance.js +84 -1
- package/dist/state/decisionMigrationProvenance.js.map +1 -1
- package/dist/state/decisionOverlay.js +9 -32
- package/dist/state/decisionOverlay.js.map +1 -1
- package/dist/state/decisionRevision.js +69 -444
- package/dist/state/decisionRevision.js.map +1 -1
- package/dist/state/decisionRevisionMigration.js +90 -0
- package/dist/state/decisionRevisionMigration.js.map +1 -0
- package/dist/state/directRetrieval.js +3 -52
- package/dist/state/directRetrieval.js.map +1 -1
- package/dist/state/entityCutover.js +6 -6
- package/dist/state/entityCutover.js.map +1 -1
- package/dist/state/entityGlossaryAuthority.js +14 -0
- package/dist/state/entityGlossaryAuthority.js.map +1 -0
- package/dist/state/entityMigrationIdentity.js +6 -0
- package/dist/state/entityMigrationIdentity.js.map +1 -0
- package/dist/state/entityMigrationPreview.js +14 -23
- package/dist/state/entityMigrationPreview.js.map +1 -1
- package/dist/state/entityPublicationContext.js +374 -71
- package/dist/state/entityPublicationContext.js.map +1 -1
- package/dist/state/entityStorage.js +45 -29
- package/dist/state/entityStorage.js.map +1 -1
- package/dist/state/healthEntities.js +2 -4
- package/dist/state/healthEntities.js.map +1 -1
- package/dist/state/listRetrieval.js +7 -38
- package/dist/state/listRetrieval.js.map +1 -1
- package/dist/state/migrationSourceBinding.js +1 -1
- package/dist/state/migrationSourceBinding.js.map +1 -1
- package/dist/state/objectiveExperimentEntities.js +9 -9
- package/dist/state/objectiveExperimentEntities.js.map +1 -1
- package/dist/state/planEntities.js +57 -16
- package/dist/state/planEntities.js.map +1 -1
- package/dist/state/progressEntities.js +177 -39
- package/dist/state/progressEntities.js.map +1 -1
- package/dist/state/progressGlossaryCaveat.js +169 -0
- package/dist/state/progressGlossaryCaveat.js.map +1 -0
- package/dist/state/progressPublicationOrder.js +20 -0
- package/dist/state/progressPublicationOrder.js.map +1 -0
- package/dist/state/safeProjectFile.js +4 -1
- package/dist/state/safeProjectFile.js.map +1 -1
- package/dist/state/startupProjection.js +2 -70
- package/dist/state/startupProjection.js.map +1 -1
- package/dist/state/stateStorageAuthority.js +48 -0
- package/dist/state/stateStorageAuthority.js.map +1 -0
- package/dist/state/summarySourceRowAuthority.js +1 -1
- package/dist/state/summarySourceRowAuthority.js.map +1 -1
- package/dist/state/todoDocsEntities.js +8 -9
- package/dist/state/todoDocsEntities.js.map +1 -1
- package/dist/state/write/explain.js +101 -92
- package/dist/state/write/explain.js.map +1 -1
- package/dist/state/write/glossaryPublication.js +264 -0
- package/dist/state/write/glossaryPublication.js.map +1 -0
- package/dist/state/write/index.js +1 -0
- package/dist/state/write/index.js.map +1 -1
- package/dist/state/write/operations.js +25 -27
- package/dist/state/write/operations.js.map +1 -1
- package/dist/state/write/planEvaluation.js +6 -2
- package/dist/state/write/planEvaluation.js.map +1 -1
- package/dist/state/write/transaction.js +7 -4
- package/dist/state/write/transaction.js.map +1 -1
- package/dist/upgrade/upgradeOrchestrator.js +15 -10
- package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
- package/dist/validate/crossCapability.js +3 -0
- package/dist/validate/crossCapability.js.map +1 -1
- package/dist/validate/v1LegacyCruft.js +141 -0
- package/dist/validate/v1LegacyCruft.js.map +1 -0
- package/dist/validate/vocabularyAuthority.js +2 -0
- package/dist/validate/vocabularyAuthority.js.map +1 -1
- package/package.json +4 -3
- package/dist/state/decisionRevisionPublication.js +0 -532
- package/dist/state/decisionRevisionPublication.js.map +0 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { loadProfileDecayParameters } from "../capabilities/profile/instructions.js";
|
|
3
|
+
import { writeFileAtomic } from "../core/atomicWriter.js";
|
|
4
|
+
import { GlossaryEntryBoundError, validateGlossaryEntry, } from "../registries/glossaryEntryContract.js";
|
|
5
|
+
import { unicodeCaselessExact } from "../registries/glossaryTermIdentity.js";
|
|
6
|
+
const START = "<!-- agentera:personal-glossary:start -->";
|
|
7
|
+
const END = "<!-- agentera:personal-glossary:end -->";
|
|
8
|
+
const HEADING = "## Glossary";
|
|
9
|
+
const SCHEMA_VERSION = "agentera.personalGlossarySection.v1";
|
|
10
|
+
const DECAY = loadProfileDecayParameters();
|
|
11
|
+
function compareText(left, right) {
|
|
12
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
13
|
+
}
|
|
14
|
+
function calendarDate(value) {
|
|
15
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
16
|
+
throw new Error(`expected ISO calendar date, received '${value}'`);
|
|
17
|
+
const date = new Date(`${value}T00:00:00.000Z`);
|
|
18
|
+
if (Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value) {
|
|
19
|
+
throw new Error(`expected ISO calendar date, received '${value}'`);
|
|
20
|
+
}
|
|
21
|
+
return date;
|
|
22
|
+
}
|
|
23
|
+
function daysBetween(from, to) {
|
|
24
|
+
const days = (calendarDate(to).getTime() - calendarDate(from).getTime()) / 86_400_000;
|
|
25
|
+
if (days < 0)
|
|
26
|
+
throw new Error(`as_of ${to} precedes last_confirmed_at ${from}`);
|
|
27
|
+
return days;
|
|
28
|
+
}
|
|
29
|
+
function count(text, token) {
|
|
30
|
+
return text.split(token).length - 1;
|
|
31
|
+
}
|
|
32
|
+
function persistedContext(entry) {
|
|
33
|
+
const retained = new Map();
|
|
34
|
+
for (const evidence of entry.provenance.evidence) {
|
|
35
|
+
retained.set(evidence.evidence_anchor, {
|
|
36
|
+
sourceId: evidence.source_id,
|
|
37
|
+
sourceKind: "source_kind" in evidence ? evidence.source_kind : "conversation_turn",
|
|
38
|
+
signalType: "signal_type" in evidence ? evidence.signal_type : "instruction",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return { retainedHistory: retained };
|
|
42
|
+
}
|
|
43
|
+
function validateEntry(entry, context) {
|
|
44
|
+
const errors = validateGlossaryEntry(entry, "personal", context);
|
|
45
|
+
if (errors.length > 0)
|
|
46
|
+
throw new Error(`invalid personal glossary entry '${String(entry.term)}': ${errors.join("; ")}`);
|
|
47
|
+
}
|
|
48
|
+
function validateUnique(entries, label) {
|
|
49
|
+
for (const [index, entry] of entries.entries()) {
|
|
50
|
+
if (entries.slice(0, index).some((candidate) => unicodeCaselessExact(candidate.term, entry.term))) {
|
|
51
|
+
throw new Error(`${label} contains duplicate Unicode caseless-exact term '${entry.term}'`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function matchingIndex(entries, term) {
|
|
56
|
+
return entries.findIndex((entry) => unicodeCaselessExact(entry.term, term));
|
|
57
|
+
}
|
|
58
|
+
function confidenceBasisFor(document, term) {
|
|
59
|
+
const key = Object.keys(document.confidence_basis).find((candidate) => unicodeCaselessExact(candidate, term));
|
|
60
|
+
return key === undefined ? Number.NaN : document.confidence_basis[key];
|
|
61
|
+
}
|
|
62
|
+
function parseSection(profile, maxEntries = Number.POSITIVE_INFINITY) {
|
|
63
|
+
const starts = count(profile, START);
|
|
64
|
+
const ends = count(profile, END);
|
|
65
|
+
const headings = [...profile.matchAll(/^## Glossary\s*$/gm)].length;
|
|
66
|
+
if (starts === 0 && ends === 0 && headings === 0)
|
|
67
|
+
return { document: null, start: -1, end: -1 };
|
|
68
|
+
if (starts > 1 || ends > 1 || headings > 1 || (headings > 0 && starts === 0 && ends === 0))
|
|
69
|
+
throw new PersonalGlossaryBoundaryError("ambiguous");
|
|
70
|
+
if (starts !== 1 || ends !== 1 || headings !== 1)
|
|
71
|
+
throw new PersonalGlossaryBoundaryError("malformed");
|
|
72
|
+
const start = profile.indexOf(START);
|
|
73
|
+
const end = profile.indexOf(END, start) + END.length;
|
|
74
|
+
if (start < 0 || end < END.length || end <= start)
|
|
75
|
+
throw new Error("PROFILE.md Glossary section has malformed or ambiguous owned boundaries");
|
|
76
|
+
const owned = profile.slice(start, end);
|
|
77
|
+
const match = new RegExp(`^${START}\n${HEADING}\n\n\`\`\`json\n([\\s\\S]+)\n\`\`\`\n${END}$`).exec(owned);
|
|
78
|
+
if (!match)
|
|
79
|
+
throw new Error("PROFILE.md Glossary section is malformed");
|
|
80
|
+
let value;
|
|
81
|
+
try {
|
|
82
|
+
value = JSON.parse(match[1]);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
throw new Error("PROFILE.md Glossary section contains invalid JSON");
|
|
86
|
+
}
|
|
87
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
88
|
+
throw new Error("PROFILE.md Glossary section document is malformed");
|
|
89
|
+
const document = value;
|
|
90
|
+
if (JSON.stringify(Object.keys(document)) !== JSON.stringify(["schema_version", "as_of", "confidence_basis", "entries"]) || document.schema_version !== SCHEMA_VERSION || !Array.isArray(document.entries) || !document.confidence_basis || typeof document.confidence_basis !== "object" || Array.isArray(document.confidence_basis)) {
|
|
91
|
+
throw new Error("PROFILE.md Glossary section document is malformed");
|
|
92
|
+
}
|
|
93
|
+
if (document.entries.length > maxEntries)
|
|
94
|
+
throw new GlossaryEntryBoundError("personal glossary exceeds the consumer entry bound");
|
|
95
|
+
calendarDate(document.as_of);
|
|
96
|
+
validateUnique(document.entries, "existing personal glossary");
|
|
97
|
+
const basisKeys = Object.keys(document.confidence_basis);
|
|
98
|
+
if (basisKeys.length !== document.entries.length || basisKeys.some((key, index) => basisKeys.slice(0, index).some((candidate) => unicodeCaselessExact(candidate, key)) || matchingIndex(document.entries, key) < 0)) {
|
|
99
|
+
throw new Error("PROFILE.md Glossary section confidence basis is malformed");
|
|
100
|
+
}
|
|
101
|
+
for (const entry of document.entries) {
|
|
102
|
+
validateEntry(entry, persistedContext(entry));
|
|
103
|
+
const basis = confidenceBasisFor(document, entry.term);
|
|
104
|
+
if (!Number.isInteger(basis) || basis < 0 || basis > 100)
|
|
105
|
+
throw new Error("PROFILE.md Glossary section confidence basis is malformed");
|
|
106
|
+
daysBetween(entry.temporal.last_confirmed_at, document.as_of);
|
|
107
|
+
}
|
|
108
|
+
return { document, start, end };
|
|
109
|
+
}
|
|
110
|
+
export class PersonalGlossaryBoundaryError extends Error {
|
|
111
|
+
availability;
|
|
112
|
+
constructor(availability) {
|
|
113
|
+
super("PROFILE.md Glossary section has malformed or ambiguous owned boundaries");
|
|
114
|
+
this.availability = availability;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Parse only the owned glossary range and project only consumer-safe fields. */
|
|
118
|
+
export function personalGlossaryConsumerEntries(profile, maxEntries) {
|
|
119
|
+
const document = parseSection(profile, maxEntries).document;
|
|
120
|
+
return document?.entries.map(({ term, meaning }) => ({ term, meaning })) ?? null;
|
|
121
|
+
}
|
|
122
|
+
/** Return profile grounding with the validated owned glossary range excluded byte-for-byte. */
|
|
123
|
+
export function personalProfileGrounding(profile) {
|
|
124
|
+
const section = parseSection(profile);
|
|
125
|
+
return section.document === null
|
|
126
|
+
? profile
|
|
127
|
+
: `${profile.slice(0, section.start)}${profile.slice(section.end)}`;
|
|
128
|
+
}
|
|
129
|
+
function orderedEntry(entry) {
|
|
130
|
+
return {
|
|
131
|
+
term: entry.term,
|
|
132
|
+
meaning: entry.meaning,
|
|
133
|
+
confidence: entry.confidence,
|
|
134
|
+
permanence: entry.permanence,
|
|
135
|
+
temporal: {
|
|
136
|
+
observed_at: entry.temporal.observed_at,
|
|
137
|
+
last_confirmed_at: entry.temporal.last_confirmed_at,
|
|
138
|
+
},
|
|
139
|
+
provenance: {
|
|
140
|
+
kind: entry.provenance.kind,
|
|
141
|
+
evidence: entry.provenance.evidence.map((item) => ({ ...item })),
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function render(document) {
|
|
146
|
+
return `${START}\n${HEADING}\n\n\`\`\`json\n${JSON.stringify(document, null, 2)}\n\`\`\`\n${END}`;
|
|
147
|
+
}
|
|
148
|
+
export function updatePersonalGlossaryProfile(input) {
|
|
149
|
+
calendarDate(input.asOf);
|
|
150
|
+
const original = fs.readFileSync(input.profilePath, "utf8");
|
|
151
|
+
const section = parseSection(original);
|
|
152
|
+
if (section.document && calendarDate(input.asOf).getTime() < calendarDate(section.document.as_of).getTime()) {
|
|
153
|
+
throw new Error("personal glossary as_of cannot move backward");
|
|
154
|
+
}
|
|
155
|
+
validateUnique(input.freshEntries, "fresh personal glossary evidence");
|
|
156
|
+
for (const entry of input.freshEntries)
|
|
157
|
+
validateEntry(entry, input.retainedHistory);
|
|
158
|
+
const fresh = input.freshEntries;
|
|
159
|
+
const established = section.document?.entries ?? [];
|
|
160
|
+
const merged = [];
|
|
161
|
+
const confidenceBasis = new Map();
|
|
162
|
+
const usedFresh = new Set();
|
|
163
|
+
for (const previous of established) {
|
|
164
|
+
const freshIndex = matchingIndex(fresh, previous.term);
|
|
165
|
+
const current = freshIndex >= 0 ? fresh[freshIndex] : undefined;
|
|
166
|
+
if (freshIndex >= 0)
|
|
167
|
+
usedFresh.add(freshIndex);
|
|
168
|
+
let entry;
|
|
169
|
+
let entryBasis;
|
|
170
|
+
if (current) {
|
|
171
|
+
if (previous.meaning !== current.meaning || previous.provenance.kind !== current.provenance.kind) {
|
|
172
|
+
throw new Error(`personal glossary conflict for established term '${previous.term}'`);
|
|
173
|
+
}
|
|
174
|
+
daysBetween(previous.temporal.last_confirmed_at, input.asOf);
|
|
175
|
+
entryBasis = current.confidence;
|
|
176
|
+
entry = orderedEntry({
|
|
177
|
+
...current,
|
|
178
|
+
term: previous.term,
|
|
179
|
+
permanence: previous.permanence,
|
|
180
|
+
temporal: { observed_at: previous.temporal.observed_at, last_confirmed_at: input.asOf },
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
entryBasis = confidenceBasisFor(section.document, previous.term);
|
|
185
|
+
const days = daysBetween(previous.temporal.last_confirmed_at, input.asOf);
|
|
186
|
+
entry = orderedEntry({
|
|
187
|
+
...previous,
|
|
188
|
+
confidence: Math.max(DECAY.floor, Math.round(entryBasis * Math.exp(-DECAY.lambdas[previous.permanence] * days))),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
merged.push(entry);
|
|
192
|
+
confidenceBasis.set(entry.term, entryBasis);
|
|
193
|
+
}
|
|
194
|
+
for (const [index, current] of fresh.entries()) {
|
|
195
|
+
if (usedFresh.has(index))
|
|
196
|
+
continue;
|
|
197
|
+
const entryBasis = current.confidence;
|
|
198
|
+
if (calendarDate(current.temporal.observed_at).getTime() > calendarDate(input.asOf).getTime())
|
|
199
|
+
throw new Error(`observed_at for '${current.term}' is after as_of`);
|
|
200
|
+
const entry = orderedEntry({
|
|
201
|
+
...current,
|
|
202
|
+
temporal: { observed_at: current.temporal.observed_at, last_confirmed_at: input.asOf },
|
|
203
|
+
});
|
|
204
|
+
merged.push(entry);
|
|
205
|
+
confidenceBasis.set(entry.term, entryBasis);
|
|
206
|
+
}
|
|
207
|
+
merged.sort((left, right) => compareText(left.term, right.term));
|
|
208
|
+
const orderedBasis = Object.fromEntries(merged.map((entry) => [entry.term, confidenceBasis.get(entry.term)]));
|
|
209
|
+
const document = { schema_version: SCHEMA_VERSION, as_of: input.asOf, confidence_basis: orderedBasis, entries: merged };
|
|
210
|
+
const rendered = render(document);
|
|
211
|
+
const candidate = section.document
|
|
212
|
+
? `${original.slice(0, section.start)}${rendered}${original.slice(section.end)}`
|
|
213
|
+
: `${original}${original.endsWith("\n") ? "\n" : "\n\n"}${rendered}\n`;
|
|
214
|
+
const changed = candidate !== original;
|
|
215
|
+
if (changed && !input.dryRun)
|
|
216
|
+
writeFileAtomic(input.profilePath, candidate);
|
|
217
|
+
return { changed, profilePath: input.profilePath, entries: merged };
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=personalGlossaryProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personalGlossaryProfile.js","sourceRoot":"","sources":["../../../../../home/jgabor/git/agentera/packages/cli/src/analytics/personalGlossaryProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAC1D,MAAM,GAAG,GAAG,yCAAyC,CAAC;AACtD,MAAM,OAAO,GAAG,aAAa,CAAC;AAC9B,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAC7D,MAAM,KAAK,GAAG,0BAA0B,EAAE,CAAC;AAsC3C,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,YAA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E,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { resolveSourceRoot } from "../core/sourceRoot.js";
|
|
5
|
+
import { loadYamlMappingFile } from "../core/yaml.js";
|
|
6
|
+
import { isSafeProjectSourcePath } from "../registries/glossaryEntryContract.js";
|
|
7
|
+
import { unicodeCaselessExact } from "../registries/glossaryTermIdentity.js";
|
|
8
|
+
import { containsGlossaryTerm } from "../registries/glossaryTermOccurrence.js";
|
|
9
|
+
function compareText(left, right) {
|
|
10
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
11
|
+
}
|
|
12
|
+
/** Deterministic variant ordering only; never use this key for term identity. */
|
|
13
|
+
function variantSortKey(term) {
|
|
14
|
+
return term.toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
function orderedEvidence(evidence) {
|
|
17
|
+
return [...evidence].sort((left, right) => compareText(left.source_path, right.source_path)
|
|
18
|
+
|| left.line - right.line
|
|
19
|
+
|| compareText(left.source_record_sha256, right.source_record_sha256));
|
|
20
|
+
}
|
|
21
|
+
function evidenceIdentity(item) {
|
|
22
|
+
return `${item.source_path}:${item.line}`;
|
|
23
|
+
}
|
|
24
|
+
function proposalWithoutDigest(proposal) {
|
|
25
|
+
const { proposal_digest: _digest, ...finding } = proposal;
|
|
26
|
+
return {
|
|
27
|
+
...finding,
|
|
28
|
+
canonical_evidence: orderedEvidence(finding.canonical_evidence),
|
|
29
|
+
variants: finding.variants
|
|
30
|
+
.map((variant) => ({ ...variant, evidence: orderedEvidence(variant.evidence) }))
|
|
31
|
+
.sort((left, right) => compareText(variantSortKey(left.term), variantSortKey(right.term))
|
|
32
|
+
|| compareText(left.term, right.term)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function canonicalTerminologyJson(value) {
|
|
36
|
+
if (Array.isArray(value))
|
|
37
|
+
return `[${value.map(canonicalTerminologyJson).join(",")}]`;
|
|
38
|
+
if (value !== null && typeof value === "object") {
|
|
39
|
+
return `{${Object.entries(value)
|
|
40
|
+
.filter(([, item]) => item !== undefined)
|
|
41
|
+
.sort(([left], [right]) => compareText(left, right))
|
|
42
|
+
.map(([key, item]) => `${JSON.stringify(key)}:${canonicalTerminologyJson(item)}`)
|
|
43
|
+
.join(",")}}`;
|
|
44
|
+
}
|
|
45
|
+
return JSON.stringify(value);
|
|
46
|
+
}
|
|
47
|
+
/** Digest one complete finding while ignoring semantically irrelevant array order. */
|
|
48
|
+
export function terminologyProposalDigest(proposal) {
|
|
49
|
+
return crypto
|
|
50
|
+
.createHash("sha256")
|
|
51
|
+
.update(canonicalTerminologyJson(proposalWithoutDigest(proposal)))
|
|
52
|
+
.digest("hex");
|
|
53
|
+
}
|
|
54
|
+
function canonicalProposal(seed) {
|
|
55
|
+
const ordered = seed.terms
|
|
56
|
+
.map((term) => ({ term: term.term, evidence: orderedEvidence(term.evidence) }))
|
|
57
|
+
.sort((left, right) => right.evidence.length - left.evidence.length || compareText(left.term, right.term));
|
|
58
|
+
const [canonical, ...variants] = ordered;
|
|
59
|
+
const finding = {
|
|
60
|
+
family: "terminology_drift",
|
|
61
|
+
concept: seed.concept,
|
|
62
|
+
proposed_canonical_term: canonical.term,
|
|
63
|
+
canonical_evidence: canonical.evidence,
|
|
64
|
+
variants: variants.sort((left, right) => compareText(variantSortKey(left.term), variantSortKey(right.term))
|
|
65
|
+
|| compareText(left.term, right.term)),
|
|
66
|
+
severity: seed.confidence < 70 ? "info" : seed.severity,
|
|
67
|
+
confidence: seed.confidence,
|
|
68
|
+
...(seed.personal_divergence ? { personal_divergence: seed.personal_divergence } : {}),
|
|
69
|
+
};
|
|
70
|
+
return { ...finding, proposal_digest: terminologyProposalDigest(finding) };
|
|
71
|
+
}
|
|
72
|
+
function mapping(value) {
|
|
73
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
74
|
+
}
|
|
75
|
+
function exactFields(value, allowed) {
|
|
76
|
+
return Object.keys(value).every((field) => allowed.includes(field));
|
|
77
|
+
}
|
|
78
|
+
function proposalEvidence(value, label, violations) {
|
|
79
|
+
if (!mapping(value) || !exactFields(value, ["source_path", "line", "source_record_sha256"])) {
|
|
80
|
+
violations.push(`${label} must contain only source_path, line, and source_record_sha256`);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (!isSafeProjectSourcePath(value.source_path)
|
|
84
|
+
|| !Number.isInteger(value.line)
|
|
85
|
+
|| Number(value.line) < 1
|
|
86
|
+
|| typeof value.source_record_sha256 !== "string"
|
|
87
|
+
|| !/^[a-f0-9]{64}$/.test(value.source_record_sha256)) {
|
|
88
|
+
violations.push(`${label} must identify one safe project-relative source line with a lowercase SHA-256`);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
/** Validate and normalize the complete finding shape that Audit itself can emit. */
|
|
94
|
+
export function validateTerminologyProposal(value) {
|
|
95
|
+
const violations = [];
|
|
96
|
+
const fields = ["family", "concept", "proposed_canonical_term", "canonical_evidence", "variants", "severity", "confidence", "personal_divergence", "proposal_digest"];
|
|
97
|
+
if (!mapping(value) || !exactFields(value, fields)) {
|
|
98
|
+
return { proposal: null, violations: ["proposal must be one complete terminology_drift finding with no undeclared fields"] };
|
|
99
|
+
}
|
|
100
|
+
if (value.family !== "terminology_drift")
|
|
101
|
+
violations.push("proposal family must be terminology_drift");
|
|
102
|
+
if (typeof value.concept !== "string" || value.concept.trim() === "")
|
|
103
|
+
violations.push("proposal concept must be non-empty");
|
|
104
|
+
if (typeof value.proposed_canonical_term !== "string" || value.proposed_canonical_term.trim() === "")
|
|
105
|
+
violations.push("proposed canonical term must be non-empty");
|
|
106
|
+
if (!["critical", "warning", "info"].includes(String(value.severity)))
|
|
107
|
+
violations.push("proposal severity is invalid");
|
|
108
|
+
const minimumConfidence = confidenceFloor();
|
|
109
|
+
if (!Number.isInteger(value.confidence) || Number(value.confidence) < minimumConfidence || Number(value.confidence) > 100) {
|
|
110
|
+
violations.push(`proposal confidence must be an integer from ${minimumConfidence} through 100`);
|
|
111
|
+
}
|
|
112
|
+
if (Number.isInteger(value.confidence) && Number(value.confidence) < 70 && value.severity !== "info") {
|
|
113
|
+
violations.push("confidence below 70 requires info severity");
|
|
114
|
+
}
|
|
115
|
+
if (typeof value.proposal_digest !== "string" || !/^[a-f0-9]{64}$/.test(value.proposal_digest))
|
|
116
|
+
violations.push("proposal_digest must be a lowercase SHA-256");
|
|
117
|
+
const terms = [];
|
|
118
|
+
const readTerm = (term, records, label) => {
|
|
119
|
+
if (typeof term !== "string" || term.trim() === "") {
|
|
120
|
+
violations.push(`${label} term must be non-empty`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!Array.isArray(records) || records.length === 0) {
|
|
124
|
+
violations.push(`${label} evidence must be non-empty`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const parsed = records
|
|
128
|
+
.map((record, index) => proposalEvidence(record, `${label}[${index}]`, violations))
|
|
129
|
+
.filter((record) => record !== null);
|
|
130
|
+
if (new Set(parsed.map(evidenceIdentity)).size !== parsed.length) {
|
|
131
|
+
violations.push(`${label} identities must be distinct`);
|
|
132
|
+
}
|
|
133
|
+
terms.push({ term, evidence: parsed });
|
|
134
|
+
};
|
|
135
|
+
readTerm(value.proposed_canonical_term, value.canonical_evidence, "canonical_evidence");
|
|
136
|
+
if (!Array.isArray(value.variants) || value.variants.length === 0) {
|
|
137
|
+
violations.push("proposal variants must be non-empty");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
value.variants.forEach((variant, index) => {
|
|
141
|
+
if (!mapping(variant) || !exactFields(variant, ["term", "evidence"])) {
|
|
142
|
+
violations.push(`variants[${index}] must contain only term and evidence`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
readTerm(variant.term, variant.evidence, `variants[${index}].evidence`);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (terms.some((term, index) => terms.slice(0, index).some((candidate) => unicodeCaselessExact(candidate.term, term.term)))) {
|
|
149
|
+
violations.push("proposal term identities must be Unicode caseless-exact unique");
|
|
150
|
+
}
|
|
151
|
+
let divergence;
|
|
152
|
+
if (value.personal_divergence !== undefined) {
|
|
153
|
+
if (!mapping(value.personal_divergence)
|
|
154
|
+
|| !exactFields(value.personal_divergence, ["personal_term", "project_term"])
|
|
155
|
+
|| typeof value.personal_divergence.personal_term !== "string"
|
|
156
|
+
|| value.personal_divergence.personal_term.trim() === ""
|
|
157
|
+
|| value.personal_divergence.project_term !== value.proposed_canonical_term)
|
|
158
|
+
violations.push("personal_divergence must bind a non-empty personal term to the proposed project term");
|
|
159
|
+
else
|
|
160
|
+
divergence = value.personal_divergence;
|
|
161
|
+
}
|
|
162
|
+
if (violations.length > 0 || terms.length < 2)
|
|
163
|
+
return { proposal: null, violations };
|
|
164
|
+
const expected = canonicalProposal({
|
|
165
|
+
family: "terminology_drift",
|
|
166
|
+
concept: value.concept,
|
|
167
|
+
terms,
|
|
168
|
+
severity: value.severity,
|
|
169
|
+
confidence: value.confidence,
|
|
170
|
+
...(divergence ? { personal_divergence: divergence } : {}),
|
|
171
|
+
});
|
|
172
|
+
if (expected.proposed_canonical_term !== value.proposed_canonical_term)
|
|
173
|
+
violations.push("proposed canonical term is not the best-supported term under the Audit tie-break");
|
|
174
|
+
if (canonicalTerminologyJson(proposalWithoutDigest(expected)) !== canonicalTerminologyJson(proposalWithoutDigest(value))) {
|
|
175
|
+
violations.push("proposal shape or ordering is not the canonical Audit output");
|
|
176
|
+
}
|
|
177
|
+
if (expected.proposal_digest !== value.proposal_digest)
|
|
178
|
+
violations.push("proposal_digest does not match the canonical Audit output");
|
|
179
|
+
return { proposal: violations.length === 0 ? expected : null, violations };
|
|
180
|
+
}
|
|
181
|
+
function confidenceFloor() {
|
|
182
|
+
const protocol = loadYamlMappingFile(path.join(resolveSourceRoot(), "skills", "agentera", "protocol.yaml"));
|
|
183
|
+
const scale = protocol.CONFIDENCE_SCALE;
|
|
184
|
+
const range = scale?.["3"]?.range;
|
|
185
|
+
if (!Array.isArray(range) || !Number.isInteger(range[0])) {
|
|
186
|
+
throw new Error("protocol CONFIDENCE_SCALE CS3 lower bound is unavailable");
|
|
187
|
+
}
|
|
188
|
+
return Number(range[0]);
|
|
189
|
+
}
|
|
190
|
+
function verifiedEvidence(projectRoot, term, evidence) {
|
|
191
|
+
const root = fs.realpathSync(projectRoot);
|
|
192
|
+
const verified = [];
|
|
193
|
+
const identities = new Set();
|
|
194
|
+
for (const item of evidence) {
|
|
195
|
+
if (!Number.isInteger(item.line) || item.line < 1 || !isSafeProjectSourcePath(item.source_path))
|
|
196
|
+
return null;
|
|
197
|
+
const pathname = path.resolve(root, item.source_path);
|
|
198
|
+
if (pathname !== root && !pathname.startsWith(`${root}${path.sep}`))
|
|
199
|
+
return null;
|
|
200
|
+
let realPath;
|
|
201
|
+
try {
|
|
202
|
+
realPath = fs.realpathSync(pathname);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
if (!realPath.startsWith(`${root}${path.sep}`) || !fs.statSync(realPath).isFile())
|
|
208
|
+
return null;
|
|
209
|
+
const line = fs.readFileSync(realPath, "utf8").split(/\r?\n/)[item.line - 1];
|
|
210
|
+
if (line === undefined || !containsGlossaryTerm(line, term))
|
|
211
|
+
return null;
|
|
212
|
+
const sourcePath = path.relative(root, realPath).split(path.sep).join(path.posix.sep);
|
|
213
|
+
const identity = `${sourcePath}:${item.line}`;
|
|
214
|
+
if (identities.has(identity))
|
|
215
|
+
continue;
|
|
216
|
+
identities.add(identity);
|
|
217
|
+
verified.push({
|
|
218
|
+
source_path: sourcePath,
|
|
219
|
+
line: item.line,
|
|
220
|
+
source_record_sha256: crypto.createHash("sha256").update(line).digest("hex"),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return verified.length > 0 ? verified : null;
|
|
224
|
+
}
|
|
225
|
+
/** Generate findings from assessed concepts without writing project or personal state. */
|
|
226
|
+
export function assessTerminologyDrift(input) {
|
|
227
|
+
const minimumConfidence = confidenceFloor();
|
|
228
|
+
const findings = [];
|
|
229
|
+
for (const concept of input.concepts) {
|
|
230
|
+
if (concept.confidence < minimumConfidence ||
|
|
231
|
+
concept.confidence > 100 ||
|
|
232
|
+
!Number.isInteger(concept.confidence) ||
|
|
233
|
+
input.deliberateDecisionConcepts.has(concept.concept) ||
|
|
234
|
+
input.trackedIssueConcepts.has(concept.concept))
|
|
235
|
+
continue;
|
|
236
|
+
const consolidated = [];
|
|
237
|
+
let invalidEvidence = false;
|
|
238
|
+
for (const candidate of concept.terms) {
|
|
239
|
+
const term = candidate.term.trim();
|
|
240
|
+
const evidence = term ? verifiedEvidence(input.projectRoot, term, candidate.evidence) : null;
|
|
241
|
+
if (!evidence) {
|
|
242
|
+
invalidEvidence = true;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
const group = consolidated.find((item) => unicodeCaselessExact(item.term, term)) ?? { term, evidence: new Map() };
|
|
246
|
+
for (const item of evidence)
|
|
247
|
+
group.evidence.set(`${item.source_path}:${item.line}`, item);
|
|
248
|
+
if (!consolidated.includes(group))
|
|
249
|
+
consolidated.push(group);
|
|
250
|
+
}
|
|
251
|
+
if (invalidEvidence || consolidated.length < 2)
|
|
252
|
+
continue;
|
|
253
|
+
const terms = consolidated.map((term) => ({
|
|
254
|
+
term: term.term,
|
|
255
|
+
evidence: orderedEvidence([...term.evidence.values()]),
|
|
256
|
+
}));
|
|
257
|
+
const seed = {
|
|
258
|
+
family: "terminology_drift",
|
|
259
|
+
concept: concept.concept,
|
|
260
|
+
terms,
|
|
261
|
+
severity: concept.severity,
|
|
262
|
+
confidence: concept.confidence,
|
|
263
|
+
};
|
|
264
|
+
let finding = canonicalProposal(seed);
|
|
265
|
+
const personalTerm = input.personalTerms?.get(concept.concept)?.trim();
|
|
266
|
+
if (personalTerm && !unicodeCaselessExact(personalTerm, finding.proposed_canonical_term)) {
|
|
267
|
+
finding = canonicalProposal({
|
|
268
|
+
...seed,
|
|
269
|
+
personal_divergence: {
|
|
270
|
+
personal_term: personalTerm,
|
|
271
|
+
project_term: finding.proposed_canonical_term,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const validated = validateTerminologyProposal(finding);
|
|
276
|
+
if (!validated.proposal)
|
|
277
|
+
throw new Error(`Audit produced an invalid terminology proposal: ${validated.violations.join("; ")}`);
|
|
278
|
+
findings.push(validated.proposal);
|
|
279
|
+
}
|
|
280
|
+
return findings;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=terminologyDrift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminologyDrift.js","sourceRoot":"","sources":["../../../../../home/jgabor/git/agentera/packages/cli/src/audit/terminologyDrift.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAoD/E,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAA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,EAAE,OAAO,CAAC,uBAAuB;iBAC9C;aACF,CAAC,CAAC;QACL,CAAC;QACD,MAAM,SAAS,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/H,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -12,5 +12,6 @@ Publish a completed audit with \`agentera state health append --input PATH --for
|
|
|
12
12
|
.replaceAll("`.agentera/progress.yaml`", "the progress entity view")
|
|
13
13
|
.replaceAll("`.agentera/health.yaml`", "the health entity view")
|
|
14
14
|
.replaceAll("`.agentera/plan.yaml`", "the plan entity view")
|
|
15
|
-
.replace("The writer assigns the audit number, validates the candidate and final compacted bytes, and applies shared retention before publishing.", "The writer assigns a bare ID, validates the entity, and publishes one canonical file.")
|
|
15
|
+
.replace("The writer assigns the audit number, validates the candidate and final compacted bytes, and applies shared retention before publishing.", "The writer assigns a bare ID, validates the entity, and publishes one canonical file.")
|
|
16
|
+
.replace("Lean on `evidence_context.source_contract` from `agentera prime --context audit --format json` for evaluation startup. Do not re-encode its machine-readable rules in prose.", "Lean on `evidence_context.source_contract` from `agentera prime --context audit --format json` for evaluation startup. Do not re-encode its machine-readable rules in prose.\n\n## Terminology-drift findings\n\nAudit implements one mutation-free, read-only terminology-drift finding family. Assess cited project-file terms for one concept, propose the best-supported canonical term, retain project-file evidence for every drift variant, and emit the deterministic proposal digest consumed by the typed publication path. Compare optional personal PROFILE usage without writing profile state. Apply the existing confidence, deliberate-decision, and tracked-TODO filters; weak, known, tracked, and no-drift evidence yields no finding. A proposal is not approval: Build project-glossary publication is active and requires proposal-specific user confirmation. Audit never performs consumer lookup or mutation; Discuss, Plan, and Build use the separate active read-only advice path. Personal-profile mutation and docs-mapping mutation remain outside both paths.");
|
|
16
17
|
//# sourceMappingURL=instructions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../../../home/jgabor/git/agentera/packages/cli/src/capabilities/audit/instructions.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAW,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAA,uymBAAuymB,CAAC,CAAC;AACl2mB,eAAe,YAAY;KACxB,OAAO,CAAC,8CAA8C,EAAE;;;;;;mBAMxC,CAAC;KACjB,UAAU,CAAC,4BAA4B,EAAE,2BAA2B,CAAC;KACrE,UAAU,CAAC,2BAA2B,EAAE,0BAA0B,CAAC;KACnE,UAAU,CAAC,yBAAyB,EAAE,wBAAwB,CAAC;KAC/D,UAAU,CAAC,uBAAuB,EAAE,sBAAsB,CAAC;KAC3D,OAAO,CAAC,yIAAyI,EAAE,uFAAuF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../../../home/jgabor/git/agentera/packages/cli/src/capabilities/audit/instructions.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAW,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAA,uymBAAuymB,CAAC,CAAC;AACl2mB,eAAe,YAAY;KACxB,OAAO,CAAC,8CAA8C,EAAE;;;;;;mBAMxC,CAAC;KACjB,UAAU,CAAC,4BAA4B,EAAE,2BAA2B,CAAC;KACrE,UAAU,CAAC,2BAA2B,EAAE,0BAA0B,CAAC;KACnE,UAAU,CAAC,yBAAyB,EAAE,wBAAwB,CAAC;KAC/D,UAAU,CAAC,uBAAuB,EAAE,sBAAsB,CAAC;KAC3D,OAAO,CAAC,yIAAyI,EAAE,uFAAuF,CAAC;KAC3O,OAAO,CAAC,8KAA8K,EAAE,+hCAA+hC,CAAC,CAAC"}
|
|
@@ -6,13 +6,52 @@ export default instructions
|
|
|
6
6
|
|
|
7
7
|
Progress, plans, health audits, and decisions use entity authority: each record has \`id\` and \`artifact\`, lives in one writer-owned entity file, and is read through exact, list, or bounded CLI commands. Use \`agentera state <artifact> explain --format json\` before every supported mutation; never edit entity paths directly. Vision, docs policy, changelog, design, and profile remain intentional singletons.
|
|
8
8
|
|
|
9
|
-
Build appends progress with \`agentera state progress append\`, advances a plan task with its bare ID through \`agentera state plan set-status --id ID\`, and reads context from \`agentera prime --context build --format json\` plus declared fallback commands. Root \`TODO.md\` and \`CHANGELOG.md\` remain capability-owned editorial files.
|
|
9
|
+
Build appends progress with \`agentera state progress append\`, advances a plan task with its bare ID through \`agentera state plan set-status --id ID\`, and is the sole owner of explicitly confirmed project terminology publication through \`agentera state glossary publish --input REQUEST\`. Glossary publication records the approval and shared entry atomically; it does not authorize glossary lookup, personal-profile mutation, or docs-mapping mutation. Build reads context from \`agentera prime --context build --format json\` plus declared fallback commands. When no current executable plan exists, explicit transient work may instead start through \`agentera prime --context build --input <file|-> --format json\` with an \`agentera.buildExecutionRequest.v1\` mapping containing exactly \`schema_version\`, \`scope\`, and \`acceptance\`. This input is bounded, read-only, never persists or creates plan state, and conflicts with current plan-owned execution. Read profile grounding only from the \`content\` returned by \`agentera report profile-grounding --format json\`; never direct-read the profile path. The grounding command excludes the owned personal Glossary section and fails closed when its boundaries are malformed. Root \`TODO.md\` and \`CHANGELOG.md\` remain capability-owned editorial files.
|
|
10
10
|
|
|
11
11
|
## Workflow phases: The cycle`)
|
|
12
12
|
.replaceAll("--number N", "--id ID")
|
|
13
13
|
.replaceAll("--task N", "--id ID")
|
|
14
|
+
.replace("Use `status.profile` for profile summary; stale or missing profile is a caveat, not approval to refresh profile state.", `Use \`status.profile\` for profile summary; stale or missing profile is a caveat, not approval to refresh profile state.
|
|
15
|
+
|
|
16
|
+
#### Governed terminology advice
|
|
17
|
+
|
|
18
|
+
At initial meaning-sensitive cycle intent, request acquisition and advice with the structured, headless interface declared by \`agentera report glossary-advice --help\` and the vocabulary authority. Repeat only when a later user-authored requirement, intent, acceptance change, cycle-intent change, or clarification answer can alter the affected meaning. Do not refresh for unchanged replay, unrelated turns, background rereads, rendering, or tool output.
|
|
19
|
+
|
|
20
|
+
Use only \`advice.applicable_meaning\` with \`advice.applicable_owner\`: an exact project entry governs, including an exact divergent collision, while a personal entry applies only after the CLI proves a valid project gap. Invalid or unavailable acquisition abstains; never fabricate fallback. Preserve bounded tension without changing authority.
|
|
21
|
+
|
|
22
|
+
When \`review\` requires acknowledgment before disputed reliance and interaction is available, ask one focused clarification before meaning-sensitive execution. Re-run advice only for that affected meaning using the clarification answer and an authority-declared host review when applicable. Clarification is not approval or publication consent.
|
|
23
|
+
|
|
24
|
+
When autonomous or no-pause execution cannot resolve required review, do not use the disputed meaning. Continue only conservatively safe work and append one Build-owned \`glossary_caveat\` current event through \`agentera state progress append\`; discover its exact flags with \`agentera state progress explain --verb append --format json\`. The writer assigns an opaque caveat identity, suppresses duplicate current events, and supports explicit resolved or superseded lifecycle events after a governed refresh. Never put a term, meaning, definition, anchor, path, raw section, provenance, or clock expiry in the caveat.
|
|
25
|
+
|
|
26
|
+
Advice, tension, clarification, and caveat lifecycle never call \`agentera state glossary publish\`, create or reuse an approval, replace proposal-digest confirmation, satisfy decisions or plan state, or grant Discuss or Audit publication authority. Explicit project publication remains the separate Build-owned digest-confirmed operation.`)
|
|
14
27
|
.replaceAll("progress.yaml aggregate cycle entry", "progress entity record")
|
|
28
|
+
.replace("Every cycle runs the effective profile.", "Every cycle uses only the sanitized non-glossary profile content returned by `agentera report profile-grounding --format json`.")
|
|
15
29
|
.replaceAll("**Dual-write**: build maintains `.agentera/progress.yaml` and root `CHANGELOG.md`.", "Build records entity progress through the typed writer and maintains root `CHANGELOG.md` separately.")
|
|
16
30
|
.replaceAll("`.agentera/health.yaml` findings", "Health findings returned by `agentera state health list --format json`")
|
|
17
|
-
.replace("If `.agentera/plan.yaml` has `header.status: complete` and every task is complete", "If the selected plan entity is complete and every related task entity is complete")
|
|
31
|
+
.replace("If `.agentera/plan.yaml` has `header.status: complete` and every task is complete", "If the selected plan entity is complete and every related task entity is complete")
|
|
32
|
+
.replace("orient through log, exit signal reported", "orient through commit, exit signal reported")
|
|
33
|
+
.replace("Steps: orient, select, research, plan, dispatch, verify, commit, log.", "Steps: orient, select, research, plan, dispatch, verify, log, commit.")
|
|
34
|
+
.replace("implemented, verified, committed, artifacts updated", "implemented, verified, artifacts updated, committed")
|
|
35
|
+
.replace(/### Step 7: Commit[\s\S]*?Then stop\. One cycle complete\./, `### Step 7: Log
|
|
36
|
+
|
|
37
|
+
**Before writing**, run \`agentera check lint --artifact <artifact> --text "<draft>"\` (or \`--file <path>\`) on the draft entry to check verbosity overruns, abstraction creep, and filler accumulation. Max 3 revision attempts. Flag with \`[post-audit-flagged]\` if still failing.
|
|
38
|
+
|
|
39
|
+
Build records entity progress through the typed writer and maintains root \`CHANGELOG.md\` separately. Complete every required artifact update before committing so implementation, tests, and cycle state land together.
|
|
40
|
+
|
|
41
|
+
- **TODO.md**: add newly discovered open issues in severity bands with \`- [ ]\`. Move completed work to \`## ✓ Resolved\` as \`- [x]\` with a resolution summary.
|
|
42
|
+
- **progress**: run \`agentera state progress append --type TYPE --phase build --what TEXT --intent TEXT --verified TEXT --format json\`. The writer assigns \`id\`, \`artifact\`, and \`publication_order\`, validates the record, atomically publishes one entity, and returns post-write state.
|
|
43
|
+
- **CHANGELOG.md**: append a one-line entry under \`## [Unreleased]\`.
|
|
44
|
+
- **plan**: when a plan task closes, run \`agentera state plan set-status --id ID --status complete --format json\` rather than editing the plan directly.
|
|
45
|
+
|
|
46
|
+
TODO.md Resolved compaction follows the 10/40/50 cap via the validate-artifact hook or \`agentera check compact --mode fix\`.
|
|
47
|
+
|
|
48
|
+
### Step 8: Commit
|
|
49
|
+
|
|
50
|
+
Commit once with a conventional commit message: \`type(scope): summary\`.
|
|
51
|
+
|
|
52
|
+
Types: \`feat\`, \`fix\`, \`docs\`, \`refactor\`, \`chore\`, \`test\`. Include implementation, tests, and all required artifact updates. MUST NOT commit partial or broken work.
|
|
53
|
+
|
|
54
|
+
If the current task is a version bump: read \`.agentera/docs.yaml\` for the \`versioning\` section. Update every file in \`version_files\` before committing.
|
|
55
|
+
|
|
56
|
+
Then stop. One cycle complete.`);
|
|
18
57
|
//# sourceMappingURL=instructions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../../../home/jgabor/git/agentera/packages/cli/src/capabilities/build/instructions.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mFAAmF;AACnF,MAAM,CAAC,MAAM,YAAY,GAAW,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAA,26gBAA26gB,CAAC,CAAC;AACt+gB,eAAe,YAAY;KACxB,OAAO,CAAC,yDAAyD,EAAE;;;;;;8BAMxC,CAAC;KAC5B,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC;KACnC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC;KACjC,UAAU,CAAC,qCAAqC,EAAE,wBAAwB,CAAC;KAC3E,UAAU,CAAC,oFAAoF,EAAE,sGAAsG,CAAC;KACxM,UAAU,CAAC,kCAAkC,EAAE,wEAAwE,CAAC;KACxH,OAAO,CAAC,mFAAmF,EAAE,mFAAmF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../../../home/jgabor/git/agentera/packages/cli/src/capabilities/build/instructions.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,mFAAmF;AACnF,MAAM,CAAC,MAAM,YAAY,GAAW,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAA,26gBAA26gB,CAAC,CAAC;AACt+gB,eAAe,YAAY;KACxB,OAAO,CAAC,yDAAyD,EAAE;;;;;;8BAMxC,CAAC;KAC5B,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC;KACnC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC;KACjC,OAAO,CAAC,wHAAwH,EAAE;;;;;;;;;;;;oVAY+M,CAAC;KAClV,UAAU,CAAC,qCAAqC,EAAE,wBAAwB,CAAC;KAC3E,OAAO,CAAC,yCAAyC,EAAE,iIAAiI,CAAC;KACrL,UAAU,CAAC,oFAAoF,EAAE,sGAAsG,CAAC;KACxM,UAAU,CAAC,kCAAkC,EAAE,wEAAwE,CAAC;KACxH,OAAO,CAAC,mFAAmF,EAAE,mFAAmF,CAAC;KACjL,OAAO,CAAC,0CAA0C,EAAE,6CAA6C,CAAC;KAClG,OAAO,CAAC,uEAAuE,EAAE,uEAAuE,CAAC;KACzJ,OAAO,CAAC,qDAAqD,EAAE,qDAAqD,CAAC;KACrH,OAAO,CAAC,4DAA4D,EAAE;;;;;;;;;;;;;;;;;;;;;+BAqB1C,CAAC,CAAC"}
|