npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flavor-code/read-external

v0.1.0

Published

Agent无法访问工作区之外的文件

Downloads

110

Readme

read-external

flavor-code 项目插件:提供只读工具 read_external,用于访问工作区之外的文件。 内置 Read 受工作区边界限制读不到目标文件时(例如另一个仓库、临时目录、系统配置),用本工具读取。

注册能力

  • 斜杠命令 /read-external <文件路径> [起始行] [结束行](用户手动调用)
    • 相对路径按当前工作区解析;成功输出文件元信息 + 内容,失败输出「读取失败: …」提示(不抛错)
    • 安全边界与工具完全一致(共用 read-external.mjs 核心逻辑)
  • 工具 read_external(readOnly: true,与 Read/Glob/Grep 同级免审批;agent 自动调用)
    • path(必填):绝对路径,或相对当前工作目录的路径
    • maxBytes(可选):读取上限,默认 1 MiB,硬上限 10 MiB
    • startLine / endLine(可选):1 基闭区间行号(作用于已读入的内容)
    • 返回:{ path, sizeBytes, readBytes, truncated, firstLine, lastLine, content }

安全边界(内置拒绝名单,不可配置)

读取前对 realpath 解析后的路径做检查,命中即拒绝:

  • 路径段位于凭据目录:.ssh/、.aws/、.gnupg/、.azure/
  • .env* 环境密钥文件(豁免 .env.example)
  • SSH 私钥:id_rsa / id_ed25519 / id_ecdsa / id_dsa 及其 -/_ 后缀变体(豁免 .pub)
  • 凭据文件:.netrc、_netrc、.npmrc、.pgpass、git-credentials、credentials
  • 私钥/证书扩展名:.pem、.key、.p12、.pfx、.kdbx
  • 二进制防护:内容含 NUL 字节或非 UTF-8 一律拒绝(截断切断多字节尾部的情况会自动回退最多 3 字节重试)
  • 只读:仅 stat/open("r"),无任何写路径;目录与非普通文件拒绝

开发与验证

node scripts/check.mjs

零依赖离线检查:清单结构、输入校验、拒绝名单命中/豁免、真实临时文件的读取/行区间/截断/二进制用例、activate 冒烟与 ToolDefinition 契约。

说明

  • 插件依赖宿主默认的 in-process 加载(production.ts 中 sandbox 缺省关闭),因此可直接使用 node:fs,与 astgraph 同模式;若未来开启 Worker/vm 沙箱需改为宿主中介的 filesystem 服务。
  • .flavor/ 整目录被 git 忽略,本插件为工作区本地能力,不随仓库分发。
  • 曾以 RegisterTool 创建的旧 managed 工具 read_external 已删除,避免同名注册冲突。