agentera 3.0.0-dev.72 → 3.0.0-dev.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +111 -0
  2. package/bundle/.agentera-build-source.json +8 -0
  3. package/bundle/CHANGELOG.md +17 -17
  4. package/bundle/extract-corpus-parity.json +1 -1
  5. package/bundle/references/adapters/package-publication.json +49 -53
  6. package/bundle/references/adapters/package-registry.yaml +5 -1
  7. package/bundle/references/adapters/package-surface-characterization.md +6 -4
  8. package/bundle/references/analysis/evidence-tier-authority.yaml +45 -4
  9. package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
  10. package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
  11. package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -0
  12. package/bundle/references/artifacts/glossary-entry-contract.yaml +1533 -35
  13. package/bundle/references/cli/update-channels.yaml +2 -2
  14. package/bundle/references/cli/vocabulary.md +1 -1
  15. package/bundle/references/meta/retained-reference-authority.yaml +15 -0
  16. package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +11 -7
  17. package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +6 -3
  18. package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +13 -7
  19. package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +5 -0
  20. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +7 -0
  21. package/dist/.agentera-build-source.json +8 -0
  22. package/dist/analytics/extractCorpus/copilotSessions.js +13 -4
  23. package/dist/analytics/extractCorpus/core.js +223 -3
  24. package/dist/analytics/extractCorpus/corpus.js +18 -1
  25. package/dist/analytics/extractCorpus/cursorSessions.js +22 -4
  26. package/dist/analytics/extractCorpus/evidenceTiers.js +123 -17
  27. package/dist/analytics/extractCorpus/filesystemSources.js +4 -0
  28. package/dist/analytics/extractCorpus/index.js +2 -2
  29. package/dist/analytics/extractCorpus/jsonlSessions.js +52 -3
  30. package/dist/analytics/extractCorpus/sqliteSessions.js +12 -3
  31. package/dist/analytics/personalGlossaryAdmission.js +26 -46
  32. package/dist/analytics/personalGlossaryCandidateProjection.js +692 -0
  33. package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
  34. package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
  35. package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
  36. package/dist/analytics/personalGlossaryDecision.js +203 -0
  37. package/dist/analytics/personalGlossaryExplicit.js +788 -0
  38. package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
  39. package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
  40. package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
  41. package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
  42. package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
  43. package/dist/analytics/personalGlossaryProfile.js +13 -3
  44. package/dist/analytics/personalGlossaryRecurrence.js +618 -0
  45. package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
  46. package/dist/analytics/personalGlossaryReviewRecords.js +332 -0
  47. package/dist/capabilities/index.js +5 -1
  48. package/dist/capabilities/profile/instructions.js +50 -15
  49. package/dist/cli/commands/personalGlossaryCandidateReads.js +744 -0
  50. package/dist/cli/commands/personalGlossaryDecision.js +349 -0
  51. package/dist/cli/commands/personalGlossaryPublish.js +484 -0
  52. package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
  53. package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
  54. package/dist/cli/commands/prime/briefOrientation.js +118 -19
  55. package/dist/cli/commands/report.js +18 -2
  56. package/dist/cli/commands/schema.js +179 -0
  57. package/dist/cli/commands/verify.js +51 -9
  58. package/dist/cli/dispatch/lifecycle.js +51 -6
  59. package/dist/cli/help.js +48 -2
  60. package/dist/cli/migrationRequired.js +4 -1
  61. package/dist/core/atomicWriter.js +4 -1
  62. package/dist/core/developmentInvocation.js +4 -1
  63. package/dist/core/yaml.js +53 -1
  64. package/dist/eval/glossaryEvaluation.js +751 -0
  65. package/dist/eval/glossaryEvaluationProcess.js +29 -0
  66. package/dist/eval/glossaryEvaluationRunner.js +571 -0
  67. package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
  68. package/dist/registries/activationTuples.js +31 -3
  69. package/dist/registries/evidenceTierContract.js +4 -0
  70. package/dist/registries/explicitSegmentGrammarContract.js +619 -0
  71. package/dist/registries/glossaryCandidateContractPaths.js +6 -0
  72. package/dist/registries/glossaryCandidateContracts.js +820 -0
  73. package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
  74. package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
  75. package/dist/registries/glossaryCandidateProjectionAuthority.js +197 -0
  76. package/dist/registries/glossaryCandidateProjectionContract.js +104 -0
  77. package/dist/registries/glossaryEntryContract.js +105 -103
  78. package/dist/registries/glossaryEntryTemporal.js +12 -0
  79. package/dist/registries/glossaryMiningAuthority.js +764 -0
  80. package/dist/registries/glossaryProfileFullContract.js +24 -0
  81. package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
  82. package/dist/registries/glossaryReviewRecordsContract.js +129 -0
  83. package/dist/registries/glossaryTermIdentity.js +122 -0
  84. package/dist/registries/packagePublication.js +3 -3
  85. package/dist/registries/personalGlossaryContracts.js +1 -0
  86. package/dist/release/releaseMetadata.js +14 -7
  87. package/dist/upgrade/npxPlatformStatus.js +2 -1
  88. package/dist/upgrade/projectIntegration.js +7 -1
  89. package/dist/validate/activationArtifactEvidence.js +18 -4
  90. package/dist/validate/activationEvidenceManifest.js +101 -22
  91. package/package.json +2 -4
  92. package/dist/cli/commands/personalGlossary.js +0 -176
@@ -1,176 +0,0 @@
1
- import fs from "node:fs";
2
- import { updatePersonalGlossaryProfile } from "../../analytics/personalGlossaryProfile.js";
3
- import { loadYamlMapping } from "../../core/yaml.js";
4
- import { personalGlossaryOutputContract } from "../../registries/glossaryEntryContract.js";
5
- import { emitInvalidInput } from "../errors.js";
6
- import { emitStructured } from "../structured.js";
7
- const REQUEST_FIELDS = ["schema_version", "profile_path", "as_of", "fresh_entries", "retained_history"];
8
- const HISTORY_FIELDS = ["source_id", "evidence_anchor", "source_kind", "signal_type"];
9
- const RECOVERY = "Correct the request and retry the same command; no profile bytes were changed.";
10
- function mapping(value) {
11
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
12
- }
13
- function calendarDate(value) {
14
- if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value))
15
- return false;
16
- const date = new Date(`${value}T00:00:00.000Z`);
17
- return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === value;
18
- }
19
- function invalid(io, body) {
20
- return emitInvalidInput(io, { format: "json", body: { ...body, recovery: body.recovery ?? RECOVERY } });
21
- }
22
- function parseArgs(argv) {
23
- let input;
24
- let dryRun = false;
25
- for (let index = 0; index < argv.length; index += 1) {
26
- const argument = argv[index];
27
- const [name, inline] = argument.split("=", 2);
28
- if (name === "--dry-run") {
29
- if (inline !== undefined)
30
- return { class: "unrecognized_argument", message: "--dry-run does not accept a value" };
31
- dryRun = true;
32
- continue;
33
- }
34
- if (name === "--input" || name === "--format") {
35
- const value = inline ?? argv[++index];
36
- if (!value || value.startsWith("--"))
37
- return { class: "missing_argument", message: `${name} requires a value`, syntax: `${name} VALUE` };
38
- if (name === "--format") {
39
- if (value !== "json")
40
- return { class: "invalid_choice", message: `argument --format: invalid choice: '${value}' (choose from 'json')`, valid_values: ["json"] };
41
- }
42
- else {
43
- if (input !== undefined)
44
- return { class: "mutually_exclusive", message: "--input may only be supplied once" };
45
- input = value;
46
- }
47
- continue;
48
- }
49
- return { class: "unrecognized_argument", message: `unrecognized arguments: ${argument}`, syntax: "agentera report profile-glossary --input <file|-> [--dry-run] --format json" };
50
- }
51
- if (!input)
52
- return { class: "missing_argument", message: "--input is required", syntax: "agentera report profile-glossary --input <file|-> [--dry-run] --format json" };
53
- return { input, dryRun };
54
- }
55
- function readRequest(source, io) {
56
- let bytes;
57
- if (source === "-")
58
- bytes = Buffer.from(io.stdin ? io.stdin() : fs.readFileSync(0));
59
- else
60
- bytes = fs.readFileSync(source);
61
- const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
62
- const parsed = mapping(loadYamlMapping(text));
63
- if (!parsed)
64
- throw new Error("request is not a mapping");
65
- return parsed;
66
- }
67
- function validateRequest(value) {
68
- const contract = personalGlossaryOutputContract();
69
- const keys = Object.keys(value);
70
- const unsupported = keys.filter((key) => !REQUEST_FIELDS.includes(key));
71
- const missing = REQUEST_FIELDS.filter((key) => !(key in value));
72
- if (unsupported.length > 0 || missing.length > 0) {
73
- return { class: "schema_violation", message: `request fields are invalid${missing.length ? `; missing: ${missing.join(", ")}` : ""}${unsupported.length ? `; unsupported: ${unsupported.join(", ")}` : ""}`, valid_values: REQUEST_FIELDS };
74
- }
75
- if (value.schema_version !== contract.requestSchemaVersion) {
76
- return { class: "schema_violation", message: `schema_version must be ${contract.requestSchemaVersion}`, valid_values: [contract.requestSchemaVersion] };
77
- }
78
- if (typeof value.profile_path !== "string" || value.profile_path.trim() === "") {
79
- return { class: "invalid_request", message: "profile_path must be the exact non-empty path returned by prime profile context", valid_values: ["profile_context.profile.path"] };
80
- }
81
- if (!calendarDate(value.as_of)) {
82
- return { class: "invalid_request", message: "as_of must be an ISO calendar date", valid_values: ["YYYY-MM-DD"] };
83
- }
84
- if (!Array.isArray(value.fresh_entries) || value.fresh_entries.some((entry) => !mapping(entry))) {
85
- return { class: "invalid_request", message: "fresh_entries must be a list of shared personal glossary entries", valid_values: ["fresh_entries: []"] };
86
- }
87
- for (const [index, raw] of value.fresh_entries.entries()) {
88
- const entry = mapping(raw);
89
- const temporal = mapping(entry.temporal);
90
- if (!temporal || !calendarDate(temporal.observed_at) || !calendarDate(temporal.last_confirmed_at)) {
91
- return { class: "invalid_request", message: `fresh_entries[${index}].temporal requires observed_at and last_confirmed_at ISO calendar dates`, valid_values: ["YYYY-MM-DD"] };
92
- }
93
- if (!["stable", "durable", "situational"].includes(entry.permanence)) {
94
- return { class: "invalid_request", message: `fresh_entries[${index}].permanence is invalid`, valid_values: ["stable", "durable", "situational"] };
95
- }
96
- const provenance = mapping(entry.provenance);
97
- if (!provenance || !["personal_explicit_definition", "personal_inferred_usage"].includes(String(provenance.kind))) {
98
- return { class: "invalid_request", message: `fresh_entries[${index}].provenance.kind is invalid`, valid_values: ["personal_explicit_definition", "personal_inferred_usage"] };
99
- }
100
- }
101
- if (!Array.isArray(value.retained_history) || value.retained_history.some((row) => !mapping(row))) {
102
- return { class: "invalid_request", message: "retained_history must be a list", valid_values: ["retained_history: []"] };
103
- }
104
- for (const [index, raw] of value.retained_history.entries()) {
105
- const row = mapping(raw);
106
- if (JSON.stringify(Object.keys(row).sort()) !== JSON.stringify([...HISTORY_FIELDS].sort()) || HISTORY_FIELDS.some((field) => typeof row[field] !== "string" || String(row[field]).trim() === "")) {
107
- return { class: "invalid_request", message: `retained_history[${index}] must contain exactly ${HISTORY_FIELDS.join(", ")}`, valid_values: HISTORY_FIELDS };
108
- }
109
- }
110
- return null;
111
- }
112
- function admissionContext(rows) {
113
- const retainedHistory = new Map();
114
- for (const raw of rows) {
115
- const row = mapping(raw);
116
- const anchor = String(row.evidence_anchor);
117
- if (retainedHistory.has(anchor))
118
- return { class: "conflict", message: `retained_history contains duplicate evidence_anchor '${anchor}'`, valid_values: ["one row per evidence_anchor"] };
119
- retainedHistory.set(anchor, { sourceId: String(row.source_id), sourceKind: String(row.source_kind), signalType: String(row.signal_type) });
120
- }
121
- return { retainedHistory };
122
- }
123
- export function runPersonalGlossaryCommand(argv, io) {
124
- const parsed = parseArgs(argv);
125
- if ("class" in parsed)
126
- return invalid(io, parsed);
127
- let request;
128
- try {
129
- request = readRequest(parsed.input, io);
130
- }
131
- catch {
132
- return invalid(io, { class: "invalid_format", message: "--input must be a readable UTF-8 YAML or JSON mapping", valid_values: ["YAML mapping", "JSON object"] });
133
- }
134
- const requestError = validateRequest(request);
135
- if (requestError)
136
- return invalid(io, requestError);
137
- const profilePath = String(request.profile_path);
138
- try {
139
- if (!fs.statSync(profilePath).isFile())
140
- throw new Error("not a regular file");
141
- }
142
- catch {
143
- return invalid(io, { class: "invalid_request", message: `profile_path is not an existing readable PROFILE.md file: ${profilePath}`, valid_values: ["existing PROFILE.md path from profile_context.profile.path"] });
144
- }
145
- const context = admissionContext(request.retained_history);
146
- if ("class" in context)
147
- return invalid(io, context);
148
- try {
149
- const result = updatePersonalGlossaryProfile({
150
- profilePath,
151
- asOf: String(request.as_of),
152
- freshEntries: request.fresh_entries,
153
- retainedHistory: context,
154
- dryRun: parsed.dryRun,
155
- });
156
- const candidateStatus = result.changed ? "changed" : "unchanged";
157
- emitStructured({
158
- schemaVersion: "agentera.personalGlossaryUpdate.v1",
159
- command: "report profile-glossary",
160
- status: parsed.dryRun ? "dry_run_candidate" : result.changed ? "changed" : "unchanged_replay",
161
- dry_run: parsed.dryRun,
162
- candidate_status: candidateStatus,
163
- profile_path: profilePath,
164
- entry_count: result.entries.length,
165
- }, "json", io.out ?? ((text) => process.stdout.write(text)));
166
- return 0;
167
- }
168
- catch (error) {
169
- const message = error.message;
170
- return invalid(io, {
171
- class: /conflict|duplicate|ambiguous/i.test(message) ? "conflict" : "invalid_request",
172
- message,
173
- valid_values: ["stable", "durable", "situational", "personal_explicit_definition", "personal_inferred_usage"],
174
- });
175
- }
176
- }