@wyattjoh/rfc 0.2.1 → 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/README.md CHANGED
@@ -23,7 +23,7 @@ The model-facing tools are:
23
23
 
24
24
  Each successful tool call returns concise text plus the complete version-two result as validated structured content. Operational failures are MCP tool errors containing the same safe version-two error envelope as the CLI. Valid fail-closed research statuses and citation verdicts remain successful domain results. `rfc_source_cache_remove` requires `confirm: true` and is marked destructive and idempotent.
25
25
 
26
- Provider credentials are intentionally outside the model-facing mutation surface. The MCP can inspect safe credential status but can never accept, reveal, add, or remove a key. Configure the credential through `rfc auth add` before launching the server. The stored key is resolved separately for every semantic tool call.
26
+ Provider credentials are intentionally outside the model-facing mutation surface. The MCP can inspect safe credential status but can never accept, reveal, add, or remove a key. Configure the credential through `rfc auth login` before launching the server. The stored key is resolved separately for every semantic tool call.
27
27
 
28
28
  Trusted operators may select the same deterministic test or self-hosted boundaries at process startup:
29
29
 
@@ -98,23 +98,23 @@ The TypeSafe API key is stored by Bun's experimental `Bun.secrets` API under thi
98
98
  - service: `com.wyattjoh.rfc`
99
99
  - name: `typesafe-api-key`
100
100
 
101
- Add it interactively with a masked prompt:
101
+ Store it interactively with a masked login prompt:
102
102
 
103
103
  ```sh
104
- rfc auth add
104
+ rfc auth login
105
105
  ```
106
106
 
107
107
  For automation, explicitly pipe the key through standard input. It is never accepted as an argv value:
108
108
 
109
109
  ```sh
110
- cat /path/to/a-protected-key-input | rfc auth add --stdin
110
+ cat /path/to/a-protected-key-input | rfc auth login --stdin
111
111
  ```
112
112
 
113
- `auth status` reports only whether a key is configured and the service/name identity. `auth remove` is deterministic: its versioned JSON result reports `removed: true` when a key existed and `removed: false` when it was already absent. Human output is the default for auth commands; add `--format json` for the versioned process result. The key is not included in command output, diagnostics, snapshots, or error envelopes.
113
+ Bare `auth` reports only whether a key is configured and the service/name identity. `auth remove` is deterministic: its versioned JSON result reports `removed: true` when a key existed and `removed: false` when it was already absent. Human output is the default for auth commands; add `--format json` for the versioned process result. The key is not included in command output, diagnostics, snapshots, or error envelopes.
114
114
 
115
115
  Bun maps the store to the host credential service: macOS Keychain, Linux Secret Service (libsecret, such as GNOME Keyring or KWallet), or Windows Credential Manager. Linux requires a running and unlocked Secret Service daemon; macOS requires Keychain access; Windows requires Credential Manager. This repository pins Bun `1.4.2` in `package.json` and tests against that version because `Bun.secrets` is experimental and may change.
116
116
 
117
- To migrate an existing setup, run `rfc auth add`, verify with `rfc auth status`, then delete the obsolete plaintext, `.env`, Varlock, dotenv, or 1Password-backed TypeSafe API-key configuration. Research, citation verification, and live evaluation all resolve this same credential lazily before constructing the provider.
117
+ To migrate an existing setup, run `rfc auth login`, verify with `rfc auth`, then delete the obsolete plaintext, `.env`, Varlock, dotenv, or 1Password-backed TypeSafe API-key configuration. Research, citation verification, and live evaluation all resolve this same credential lazily before constructing the provider.
118
118
 
119
119
  ## Precision calibration
120
120
 
@@ -123,7 +123,7 @@ Automatic answering is off. `answered` requires a locally present calibration re
123
123
  Run a calibration against the live provider only through the explicit evaluator, after storing a credential. It costs money and reaches the network:
124
124
 
125
125
  ```sh
126
- rfc auth status
126
+ rfc auth
127
127
  bun run evaluate:live
128
128
  ```
129
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyattjoh/rfc",
3
- "version": "0.2.1",
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": {
@@ -18,7 +18,7 @@ Preserve research status exactly: answered, partial, unsupported, needs_review,
18
18
 
19
19
  Exact reproduction of accepted evidence needs no citation call. Verify at most two paraphrased claims once each with rfc_verify_citation, using the exact returned quote and its UTF-8 byte offset. If a direct verification verdict is fabricated, use at most one research call to locate current wording and one verification call for that replacement. Never guess wording or offsets. Unsupported, contradicted, or fabricated verdicts cannot support an unqualified claim.
20
20
 
21
- Operational tool errors are not research statuses. Preserve their typed error code and stop rather than substituting stale text, another provider, or memory. If a tool error reports a missing credential, ask the human operator to run rfc auth add; never request or accept the secret through MCP. A usage-accounting warning follows a successful paid operation and must not trigger a retry.
21
+ Operational tool errors are not research statuses. Preserve their typed error code and stop rather than substituting stale text, another provider, or memory. If a tool error reports a missing credential, ask the human operator to run rfc auth login; never request or accept the secret through MCP. A usage-accounting warning follows a successful paid operation and must not trigger a retry.
22
22
 
23
23
  Do not read the agent-workflow resource for ordinary research. Read ${rfcMcpAgentReferenceUri} only when handling a non-answer status, operational failure, citation-repair workflow, or a provenance, privacy, cost, or cache question.`;
24
24
 
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";
@@ -128,7 +128,7 @@ export interface CredentialStore {
128
128
  }
129
129
 
130
130
  /**
131
- * The public identity of the credential used by auth status and mutation
131
+ * The public identity of the credential used by auth inspection and mutation
132
132
  * results. It contains no credential value or derivative.
133
133
  */
134
134
  export interface CredentialStoreIdentity {
@@ -339,7 +339,7 @@ export const AuthAddResultSchema = Schema.Struct({
339
339
  export type AuthAddResult = Schema.Schema.Type<typeof AuthAddResultSchema>;
340
340
 
341
341
  /**
342
- * Versioned result emitted by auth status.
342
+ * Versioned result emitted by the bare auth command.
343
343
  */
344
344
  export const AuthStatusSchema = Schema.Struct({
345
345
  schemaVersion: Schema.Literal(authSchemaVersion),
package/src/main.ts CHANGED
@@ -629,8 +629,8 @@ const makeApplication = (dependencies: RfcCliDependencies) => {
629
629
  ]),
630
630
  );
631
631
 
632
- const authAddCommand = Command.make(
633
- "add",
632
+ const authLoginCommand = Command.make(
633
+ "login",
634
634
  {
635
635
  format,
636
636
  stdin: credentialFromStdin,
@@ -661,20 +661,6 @@ const makeApplication = (dependencies: RfcCliDependencies) => {
661
661
  }),
662
662
  ).pipe(Command.withDescription("Store or replace the TypeSafe API key"));
663
663
 
664
- const authStatusCommand = Command.make(
665
- "status",
666
- { format },
667
- Effect.fn(function* ({ format }) {
668
- const result = yield* Effect.tryPromise({
669
- try: () => executeAuthStatus(dependencies),
670
- catch: (error) => error,
671
- });
672
- yield* writeStdout(
673
- resolveOutputFormat(format) === "human" ? renderAuthStatus(result) : JSON.stringify(result),
674
- );
675
- }),
676
- ).pipe(Command.withDescription("Inspect TypeSafe credential configuration without revealing it"));
677
-
678
664
  const authRemoveCommand = Command.make(
679
665
  "remove",
680
666
  { format },
@@ -697,9 +683,21 @@ const makeApplication = (dependencies: RfcCliDependencies) => {
697
683
  }),
698
684
  ).pipe(Command.withDescription("Remove the stored TypeSafe API key"));
699
685
 
700
- const authCommand = Command.make("auth").pipe(
701
- Command.withDescription("Manage the TypeSafe API key in the OS credential manager"),
702
- Command.withSubcommands([authAddCommand, authStatusCommand, authRemoveCommand]),
686
+ const authCommand = Command.make(
687
+ "auth",
688
+ { format },
689
+ Effect.fn(function* ({ format }) {
690
+ const result = yield* Effect.tryPromise({
691
+ try: () => executeAuthStatus(dependencies),
692
+ catch: (error) => error,
693
+ });
694
+ yield* writeStdout(
695
+ resolveOutputFormat(format) === "human" ? renderAuthStatus(result) : JSON.stringify(result),
696
+ );
697
+ }),
698
+ ).pipe(
699
+ Command.withDescription("Inspect or manage the TypeSafe API key in the OS credential manager"),
700
+ Command.withSubcommands([authLoginCommand, authRemoveCommand]),
703
701
  );
704
702
 
705
703
  const costsCommand = Command.make(
package/src/mcp.ts CHANGED
@@ -78,7 +78,7 @@ Remove one named RFC source-cache entry without network access. This destructive
78
78
 
79
79
  ### rfc_auth_status
80
80
 
81
- Report only whether the stable TypeSafe credential identity is configured. The MCP never accepts, returns, adds, or removes credentials. If missing, ask the human operator to run \`rfc auth add\` outside MCP.
81
+ Report only whether the stable TypeSafe credential identity is configured. The MCP never accepts, returns, adds, or removes credentials. If missing, ask the human operator to run \`rfc auth login\` outside MCP.
82
82
 
83
83
  ## Research statuses
84
84
 
@@ -108,7 +108,7 @@ Preserve exact quotes, RFC identifiers, requested/current context roles, relatio
108
108
  Operational failures are returned as MCP tool errors containing the safe version-two RFC error envelope. Report the code and stop. In particular:
109
109
 
110
110
  - \`invalid_input\`: correct the bounded tool input.
111
- - \`credential_missing\`: ask the human to run \`rfc auth add\`.
111
+ - \`credential_missing\`: ask the human to run \`rfc auth login\`.
112
112
  - \`credential_store_unavailable\` or \`credential_access_denied\`: ask the human to unlock or authorize the OS credential store; never use plaintext fallback.
113
113
  - \`discovery_failed\`: report the Datatracker failure; do not invent or use stale metadata.
114
114
  - \`source_cache_failed\`, \`source_fetch_failed\`, or \`source_revalidation_failed\`: report the authoritative source failure; never serve stale text or substitute another representation.
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 {
@@ -124,7 +122,7 @@ const credentialErrorEnvelope = (error: unknown): ErrorEnvelope | undefined => {
124
122
  kind: "error",
125
123
  error: {
126
124
  code: "credential_missing",
127
- message: "No TypeSafe API key is configured; run `rfc auth add`",
125
+ message: "No TypeSafe API key is configured; run `rfc auth login`",
128
126
  },
129
127
  };
130
128
  }
@@ -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");