@wyattjoh/rfc-pi 0.3.0 → 0.4.0
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 +5 -1
- package/extensions/rfc.ts +43 -3
- package/package.json +3 -3
- package/skills/rfc-lookup/SKILL.md +19 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@wyattjoh/rfc-pi`
|
|
2
2
|
|
|
3
|
-
Native [Pi](https://pi.dev) integration for the RFC Evidence Engine. The package registers the `rfc_research` and `
|
|
3
|
+
Native [Pi](https://pi.dev) integration for the RFC Evidence Engine. The package registers the `rfc_research`, `rfc_verify_citation`, and `rfc_source_text` tools, adds the RFC lookup workflow to the system prompt, and includes the `/rfc-lookup` skill.
|
|
4
4
|
|
|
5
5
|
Tool results reach the model as compact JSON: per question, `found`, and ranked hits with RFC, title, role, relevance, verdict, and passages (`section`, `verdict`, exact `quote`, and UTF-8 `bytes` range). The complete version-three result, including diagnostics and provenance, stays in the tool result details.
|
|
6
6
|
|
|
@@ -21,6 +21,10 @@ bunx @wyattjoh/rfc@latest auth
|
|
|
21
21
|
|
|
22
22
|
Each tool call runs the CLI through `bunx`, pinned to the exact `@wyattjoh/rfc` version this package depends on rather than a dist-tag, so a call never re-resolves against the registry and never runs a CLI this package was not tested against. Credentials remain in the OS credential manager and are never exposed to Pi or accepted through tool input.
|
|
23
23
|
|
|
24
|
+
## Full RFC source text
|
|
25
|
+
|
|
26
|
+
Use `rfc_source_text` only when the full RFC text is explicitly required or requested; prefer the research and citation tools for ordinary questions. With just `rfc`, it returns the source hash, total UTF-8 byte length, and parsed headings with half-open byte ranges, not the text. Give both `startOffset` and `endOffset` to retrieve that exact, untruncated slice (citation ranges use the same offsets). Pass `expectedSourceHash` on later reads so a revalidated source change fails rather than mixing snapshots.
|
|
27
|
+
|
|
24
28
|
## Local cache and credential tools
|
|
25
29
|
|
|
26
30
|
`rfc_source_cache_status`, `rfc_source_cache_remove`, and `rfc_auth_status` are not registered by default, because research never needs them and every registered tool is resent to the model on each request. Set `RFC_PI_LOCAL_TOOLS=1` before starting Pi to register them:
|
package/extensions/rfc.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
ResearchResult,
|
|
6
6
|
RfcSourceCacheRemoveResult,
|
|
7
7
|
RfcSourceCacheStatus,
|
|
8
|
+
RfcSourceTextResult,
|
|
8
9
|
} from "@wyattjoh/rfc-core";
|
|
9
10
|
import type { AuthStatus } from "@wyattjoh/rfc";
|
|
10
11
|
import {
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
rfcPiInstructions,
|
|
18
19
|
schemaVersion,
|
|
19
20
|
} from "@wyattjoh/rfc/agent";
|
|
20
|
-
import { retrievalPolicy } from "@wyattjoh/rfc-core";
|
|
21
|
+
import { retrievalPolicy } from "@wyattjoh/rfc-core/policy";
|
|
21
22
|
import { Type } from "typebox";
|
|
22
23
|
import rfcPiPackage from "../package.json" with { type: "json" };
|
|
23
24
|
|
|
@@ -31,7 +32,8 @@ import rfcPiPackage from "../package.json" with { type: "json" };
|
|
|
31
32
|
*/
|
|
32
33
|
const rfcPackageSpec = `@wyattjoh/rfc@${rfcPiPackage.dependencies["@wyattjoh/rfc"]}`;
|
|
33
34
|
const commandTimeoutMilliseconds = 180_000;
|
|
34
|
-
|
|
35
|
+
// An 8 MiB RFC source may expand when JSON escapes control characters.
|
|
36
|
+
const commandOutputMaximumBytes = 64 * 1024 * 1024;
|
|
35
37
|
const commandStderrMaximumCharacters = 2_000;
|
|
36
38
|
const commandFailureRetentionLimit = 32;
|
|
37
39
|
|
|
@@ -116,6 +118,16 @@ const citationParameters = Type.Object(
|
|
|
116
118
|
{ additionalProperties: false },
|
|
117
119
|
);
|
|
118
120
|
|
|
121
|
+
const sourceTextParameters = Type.Object(
|
|
122
|
+
{
|
|
123
|
+
rfc: nonEmptyString(descriptions.sourceRfc),
|
|
124
|
+
startOffset: Type.Optional(Type.Integer({ description: descriptions.sourceStart, minimum: 0 })),
|
|
125
|
+
endOffset: Type.Optional(Type.Integer({ description: descriptions.sourceEnd, minimum: 0 })),
|
|
126
|
+
expectedSourceHash: Type.Optional(nonEmptyString(descriptions.expectedSourceHash)),
|
|
127
|
+
},
|
|
128
|
+
{ additionalProperties: false },
|
|
129
|
+
);
|
|
130
|
+
|
|
119
131
|
const rfcParameters = Type.Object(
|
|
120
132
|
{
|
|
121
133
|
rfc: nonEmptyString(descriptions.cacheRfc),
|
|
@@ -273,7 +285,7 @@ const runRfcCommand = <A extends object>(
|
|
|
273
285
|
const capture = (chunks: Array<Buffer>) => (chunk: Buffer) => {
|
|
274
286
|
outputBytes += chunk.byteLength;
|
|
275
287
|
if (outputBytes > commandOutputMaximumBytes) {
|
|
276
|
-
outputError = new Error(
|
|
288
|
+
outputError = new Error(`RFC tool output exceeded ${commandOutputMaximumBytes} bytes`);
|
|
277
289
|
child.kill("SIGTERM");
|
|
278
290
|
return;
|
|
279
291
|
}
|
|
@@ -422,6 +434,34 @@ export default function rfcExtension(pi: ExtensionAPI): void {
|
|
|
422
434
|
},
|
|
423
435
|
});
|
|
424
436
|
|
|
437
|
+
pi.registerTool({
|
|
438
|
+
name: rfcAgentToolMetadata.sourceText.name,
|
|
439
|
+
label: rfcAgentToolMetadata.sourceText.title,
|
|
440
|
+
description: rfcAgentToolMetadata.sourceText.description,
|
|
441
|
+
promptSnippet: rfcAgentToolMetadata.sourceText.title,
|
|
442
|
+
parameters: sourceTextParameters,
|
|
443
|
+
async execute(toolCallId, { rfc, startOffset, endOffset, expectedSourceHash }, signal) {
|
|
444
|
+
const result = await runToolCommand<RfcSourceTextResult>(
|
|
445
|
+
toolCallId,
|
|
446
|
+
[
|
|
447
|
+
"source-text",
|
|
448
|
+
"--rfc",
|
|
449
|
+
rfc,
|
|
450
|
+
"--format",
|
|
451
|
+
"json",
|
|
452
|
+
...(startOffset === undefined ? [] : ["--start-offset", String(startOffset)]),
|
|
453
|
+
...(endOffset === undefined ? [] : ["--end-offset", String(endOffset)]),
|
|
454
|
+
...(expectedSourceHash === undefined
|
|
455
|
+
? []
|
|
456
|
+
: ["--expected-source-hash", expectedSourceHash]),
|
|
457
|
+
],
|
|
458
|
+
undefined,
|
|
459
|
+
signal,
|
|
460
|
+
);
|
|
461
|
+
return successResult(result.value, JSON.stringify(result.value), result.warnings);
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
|
|
425
465
|
if (process.env[rfcLocalToolsVariable] !== "1") return;
|
|
426
466
|
|
|
427
467
|
pi.registerTool({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyattjoh/rfc-pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Native Pi extension and lookup skill for evidence-grounded IETF RFC research.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ietf",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@wyattjoh/rfc": "0.
|
|
32
|
-
"@wyattjoh/rfc-core": "0.
|
|
31
|
+
"@wyattjoh/rfc": "0.5.0",
|
|
32
|
+
"@wyattjoh/rfc-core": "0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/bun": "1.4.2",
|
|
@@ -18,7 +18,7 @@ from memory or a second provider.
|
|
|
18
18
|
Launch the local stdio server with `rfc mcp`. A model connected through MCP does
|
|
19
19
|
not need this skill or direct CLI access: initialization instructions contain the
|
|
20
20
|
workflow, and `rfc://docs/agent-workflow` contains the complete agent reference.
|
|
21
|
-
The typed tools are `rfc_research`, `rfc_verify_citation`,
|
|
21
|
+
The typed tools are `rfc_research`, `rfc_verify_citation`, `rfc_source_text`,
|
|
22
22
|
`rfc_source_cache_status`, `rfc_source_cache_remove`, and `rfc_auth_status`.
|
|
23
23
|
|
|
24
24
|
Successful calls return concise text plus complete version-three structured
|
|
@@ -213,6 +213,24 @@ locate current wording and at most one verification call for the replacement.
|
|
|
213
213
|
Remove or qualify claims whose verdict is `unsupported`, `contradicted`, or
|
|
214
214
|
`fabricated`; never repair quote wording or replace a gap with recall.
|
|
215
215
|
|
|
216
|
+
## Exact RFC source text
|
|
217
|
+
|
|
218
|
+
Use `rfc_source_text` or `rfc source-text` only when the full RFC text is explicitly
|
|
219
|
+
required or requested; otherwise prefer `rfc_research` and `rfc_verify_citation`.
|
|
220
|
+
An identifier-only call returns the authoritative source hash, total UTF-8 bytes,
|
|
221
|
+
and parsed headings with half-open byte ranges, but no text. Request the exact
|
|
222
|
+
untruncated text with both `startOffset` (inclusive) and `endOffset` (exclusive),
|
|
223
|
+
using citation ranges or heading ranges directly. On later calls provide the
|
|
224
|
+
`expectedSourceHash` from the initial response; if the cached source is
|
|
225
|
+
revalidated and changes, start again from fresh metadata instead of mixing
|
|
226
|
+
snapshots. A full RFC can be read with the range `[0,totalBytes)`, although
|
|
227
|
+
large results consume substantial context.
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
rfc source-text RFC9110 --format json
|
|
231
|
+
rfc source-text RFC9110 --start-offset 0 --end-offset 2048 --expected-source-hash <hash>
|
|
232
|
+
```
|
|
233
|
+
|
|
216
234
|
## RFC source-cache operations
|
|
217
235
|
|
|
218
236
|
Canonical RFC Editor text is cached only after that RFC is requested. Inspect or
|