@wyattjoh/rfc 0.3.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyattjoh/rfc",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Agent-facing CLI and MCP server for evidence-grounded IETF RFC research.",
5
5
  "keywords": [
6
6
  "cli",
@@ -26,7 +26,8 @@
26
26
  "main": "./src/index.ts",
27
27
  "types": "./src/index.ts",
28
28
  "exports": {
29
- ".": "./src/index.ts"
29
+ ".": "./src/index.ts",
30
+ "./agent": "./src/agent.ts"
30
31
  },
31
32
  "publishConfig": {
32
33
  "access": "public"
@@ -40,7 +41,7 @@
40
41
  "dependencies": {
41
42
  "@effect/platform-node": "4.0.0-rc.117",
42
43
  "@modelcontextprotocol/server": "2.0.0",
43
- "@wyattjoh/rfc-core": "0.1.0",
44
+ "@wyattjoh/rfc-core": "0.1.1",
44
45
  "effect": "4.0.0-rc.117"
45
46
  },
46
47
  "devDependencies": {
package/src/agent.ts ADDED
@@ -0,0 +1,13 @@
1
+ export {
2
+ datatrackerTopicSearchTermLimit,
3
+ datatrackerTopicSearchTermMaximumCharacters,
4
+ schemaVersion,
5
+ } from "@wyattjoh/rfc-core/protocol";
6
+ export { rfcAgentToolMetadata, rfcMcpInstructions } from "./agent-surface";
7
+ export {
8
+ renderAuthStatus,
9
+ renderCitationVerification,
10
+ renderEvidenceBundle,
11
+ renderSourceCacheRemove,
12
+ renderSourceCacheStatus,
13
+ } from "./renderers";
package/src/operations.ts CHANGED
@@ -26,6 +26,15 @@ import {
26
26
  } from "./credentials";
27
27
  import type { UsageRecorder } from "./usage-store";
28
28
 
29
+ export {
30
+ renderAuthStatus,
31
+ renderCitationVerification,
32
+ renderEstimatedUsd,
33
+ renderEvidenceBundle,
34
+ renderSourceCacheRemove,
35
+ renderSourceCacheStatus,
36
+ } from "./renderers";
37
+
29
38
  /**
30
39
  * Trusted process configuration applied to one RFC operation.
31
40
  */
@@ -106,17 +115,6 @@ const usageAccountingWarning = Object.freeze({
106
115
  },
107
116
  } as const satisfies RfcOperationWarning);
108
117
 
109
- const renderTokenCount = (value: number | null): string => value?.toString() ?? "unavailable";
110
-
111
- /**
112
- * Render an estimated USD value consistently across CLI output.
113
- *
114
- * @param value Estimated cost, or null when pricing is unavailable.
115
- * @returns A dollar value with fixed sub-cent precision or `unavailable`.
116
- */
117
- export const renderEstimatedUsd = (value: number | null): string =>
118
- value === null ? "unavailable" : `$${value.toFixed(9)}`;
119
-
120
118
  const credentialErrorEnvelope = (error: unknown): ErrorEnvelope | undefined => {
121
119
  if (error instanceof CredentialMissingError) {
122
120
  return {
@@ -341,89 +339,3 @@ export const executeSourceCacheRemove = (
341
339
  */
342
340
  export const executeAuthStatus = (dependencies: RfcOperationDependencies): Promise<AuthStatus> =>
343
341
  storedCredentialStatus(dependencies.credentialStore);
344
-
345
- /**
346
- * Render one evidence bundle for concise agent or human consumption.
347
- *
348
- * @param result Version-two evidence bundle.
349
- * @returns Multi-line text preserving statuses, qualifications, provenance, and cost.
350
- */
351
- export const renderEvidenceBundle = (result: EvidenceBundle): string => {
352
- const lines = [`Status: ${result.status}`, `RFC: ${result.rfc?.identifier ?? "none discovered"}`];
353
- for (const context of result.contexts ?? []) {
354
- lines.push(`Context: ${context.role} ${context.document.identifier} (${context.state})`);
355
- }
356
- for (const passage of result.evidence) {
357
- lines.push(
358
- `Evidence RFC: ${passage.provenance.identifier} (${passage.context} context)`,
359
- `Section: ${passage.provenance.section ?? "unknown"}`,
360
- `Quote: ${passage.quote}`,
361
- `Source: ${passage.provenance.sourceUrl}`,
362
- `Offsets: ${passage.provenance.startOffset}-${passage.provenance.endOffset} (${passage.provenance.offsetUnit})`,
363
- );
364
- }
365
- for (const candidate of result.reviewCandidates ?? []) {
366
- lines.push(
367
- "Review candidate: not accepted evidence",
368
- `Candidate RFC: ${candidate.provenance.identifier} (${candidate.context} context)`,
369
- `Section: ${candidate.provenance.section ?? "unknown"}`,
370
- `Quote: ${candidate.quote}`,
371
- `Source: ${candidate.provenance.sourceUrl}`,
372
- `Offsets: ${candidate.provenance.startOffset}-${candidate.provenance.endOffset} (${candidate.provenance.offsetUnit})`,
373
- );
374
- }
375
- lines.push(
376
- `Input tokens: ${renderTokenCount(result.diagnostics.usage.inputTokens)}`,
377
- `Estimated input cost (USD): ${renderEstimatedUsd(result.diagnostics.inputCost.estimatedUsd)}`,
378
- );
379
- return lines.join("\n");
380
- };
381
-
382
- /**
383
- * Render one citation-verification result for concise agent or human consumption.
384
- *
385
- * @param result Version-two citation verdict.
386
- * @returns Multi-line text preserving verdict, provenance, and cost.
387
- */
388
- export const renderCitationVerification = (result: CitationVerificationResult): string =>
389
- [
390
- `Verdict: ${result.verdict}`,
391
- `RFC: ${result.rfc.identifier}`,
392
- `Quote: ${result.quote}`,
393
- `Offsets: ${result.provenance.startOffset ?? "unknown"}-${result.provenance.endOffset ?? "unknown"}`,
394
- `Section: ${result.provenance.section ?? "unknown"}`,
395
- `Source: ${result.provenance.sourceUrl}`,
396
- `Input tokens: ${renderTokenCount(result.diagnostics.usage.inputTokens)}`,
397
- `Estimated input cost (USD): ${renderEstimatedUsd(result.diagnostics.inputCost.estimatedUsd)}`,
398
- ].join("\n");
399
-
400
- /**
401
- * Render one local source-cache status.
402
- *
403
- * @param result Version-two source-cache status.
404
- * @returns Concise multi-line status text.
405
- */
406
- export const renderSourceCacheStatus = (result: RfcSourceCacheStatus): string =>
407
- `RFC: ${result.rfc}\nCache: ${result.state}`;
408
-
409
- /**
410
- * Render one local source-cache removal result.
411
- *
412
- * @param result Version-two source-cache removal result.
413
- * @returns Concise multi-line removal text.
414
- */
415
- export const renderSourceCacheRemove = (result: RfcSourceCacheRemoveResult): string =>
416
- `RFC: ${result.rfc}\nCache: ${result.removed ? "removed" : "missing"}`;
417
-
418
- /**
419
- * Render safe credential status metadata.
420
- *
421
- * @param result Version-two credential status.
422
- * @returns Concise multi-line credential status text.
423
- */
424
- export const renderAuthStatus = (result: AuthStatus): string =>
425
- [
426
- `Credential: ${result.configured ? "configured" : "not configured"}`,
427
- `Service: ${result.service}`,
428
- `Name: ${result.name}`,
429
- ].join("\n");
@@ -0,0 +1,104 @@
1
+ import type {
2
+ CitationVerificationResult,
3
+ EvidenceBundle,
4
+ RfcSourceCacheRemoveResult,
5
+ RfcSourceCacheStatus,
6
+ } from "@wyattjoh/rfc-core";
7
+ import type { AuthStatus } from "./credentials";
8
+
9
+ const renderTokenCount = (value: number | null): string => value?.toString() ?? "unavailable";
10
+
11
+ /**
12
+ * Render an estimated USD value consistently across CLI output.
13
+ *
14
+ * @param value Estimated cost, or null when pricing is unavailable.
15
+ * @returns A dollar value with fixed sub-cent precision or `unavailable`.
16
+ */
17
+ export const renderEstimatedUsd = (value: number | null): string =>
18
+ value === null ? "unavailable" : `$${value.toFixed(9)}`;
19
+
20
+ /**
21
+ * Render one evidence bundle for concise agent or human consumption.
22
+ *
23
+ * @param result Version-two evidence bundle.
24
+ * @returns Multi-line text preserving statuses, qualifications, provenance, and cost.
25
+ */
26
+ export const renderEvidenceBundle = (result: EvidenceBundle): string => {
27
+ const lines = [`Status: ${result.status}`, `RFC: ${result.rfc?.identifier ?? "none discovered"}`];
28
+ for (const context of result.contexts ?? []) {
29
+ lines.push(`Context: ${context.role} ${context.document.identifier} (${context.state})`);
30
+ }
31
+ for (const passage of result.evidence) {
32
+ lines.push(
33
+ `Evidence RFC: ${passage.provenance.identifier} (${passage.context} context)`,
34
+ `Section: ${passage.provenance.section ?? "unknown"}`,
35
+ `Quote: ${passage.quote}`,
36
+ `Source: ${passage.provenance.sourceUrl}`,
37
+ `Offsets: ${passage.provenance.startOffset}-${passage.provenance.endOffset} (${passage.provenance.offsetUnit})`,
38
+ );
39
+ }
40
+ for (const candidate of result.reviewCandidates ?? []) {
41
+ lines.push(
42
+ "Review candidate: not accepted evidence",
43
+ `Candidate RFC: ${candidate.provenance.identifier} (${candidate.context} context)`,
44
+ `Section: ${candidate.provenance.section ?? "unknown"}`,
45
+ `Quote: ${candidate.quote}`,
46
+ `Source: ${candidate.provenance.sourceUrl}`,
47
+ `Offsets: ${candidate.provenance.startOffset}-${candidate.provenance.endOffset} (${candidate.provenance.offsetUnit})`,
48
+ );
49
+ }
50
+ lines.push(
51
+ `Input tokens: ${renderTokenCount(result.diagnostics.usage.inputTokens)}`,
52
+ `Estimated input cost (USD): ${renderEstimatedUsd(result.diagnostics.inputCost.estimatedUsd)}`,
53
+ );
54
+ return lines.join("\n");
55
+ };
56
+
57
+ /**
58
+ * Render one citation-verification result for concise agent or human consumption.
59
+ *
60
+ * @param result Version-two citation verdict.
61
+ * @returns Multi-line text preserving verdict, provenance, and cost.
62
+ */
63
+ export const renderCitationVerification = (result: CitationVerificationResult): string =>
64
+ [
65
+ `Verdict: ${result.verdict}`,
66
+ `RFC: ${result.rfc.identifier}`,
67
+ `Quote: ${result.quote}`,
68
+ `Offsets: ${result.provenance.startOffset ?? "unknown"}-${result.provenance.endOffset ?? "unknown"}`,
69
+ `Section: ${result.provenance.section ?? "unknown"}`,
70
+ `Source: ${result.provenance.sourceUrl}`,
71
+ `Input tokens: ${renderTokenCount(result.diagnostics.usage.inputTokens)}`,
72
+ `Estimated input cost (USD): ${renderEstimatedUsd(result.diagnostics.inputCost.estimatedUsd)}`,
73
+ ].join("\n");
74
+
75
+ /**
76
+ * Render one local source-cache status.
77
+ *
78
+ * @param result Version-two source-cache status.
79
+ * @returns Concise multi-line status text.
80
+ */
81
+ export const renderSourceCacheStatus = (result: RfcSourceCacheStatus): string =>
82
+ `RFC: ${result.rfc}\nCache: ${result.state}`;
83
+
84
+ /**
85
+ * Render one local source-cache removal result.
86
+ *
87
+ * @param result Version-two source-cache removal result.
88
+ * @returns Concise multi-line removal text.
89
+ */
90
+ export const renderSourceCacheRemove = (result: RfcSourceCacheRemoveResult): string =>
91
+ `RFC: ${result.rfc}\nCache: ${result.removed ? "removed" : "missing"}`;
92
+
93
+ /**
94
+ * Render safe credential status metadata.
95
+ *
96
+ * @param result Version-two credential status.
97
+ * @returns Concise multi-line credential status text.
98
+ */
99
+ export const renderAuthStatus = (result: AuthStatus): string =>
100
+ [
101
+ `Credential: ${result.configured ? "configured" : "not configured"}`,
102
+ `Service: ${result.service}`,
103
+ `Name: ${result.name}`,
104
+ ].join("\n");