agentleFS
huberphuberp/agentloop/.github/copilot-instructions.md

agentloop

Copilot instructions1 starsChanged 6 months agoMITView on GitHub

  • Reads credentials

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read runtime configuration from dotenv-backed settings in src/config.ts.

    line 4
  2. Very specific:

    Do not read process.env directly in business logic files when a value exists in appConfig.

    line 5
  3. Very specific:

    Keep .env.example in sync whenever new configuration keys are introduced.

    line 6
  4. Very specific:

    Do not reintroduce backward compatibility hacks for missing bindTools unless explicitly required.

    line 15
  5. Very specific:

    Use the shared logger from src/logger.ts.

    line 49
  6. Distinctive:

    Keep logger output machine-readable and avoid ad hoc string-only logs.

    line 53
  7. Distinctive:

    Default destination is stdout.

    line 54
  8. Very specific:

    Avoid eval in production tool implementations.

    line 57
  9. Distinctive:

    When adding external API tools, validate input and handle failures explicitly.

    line 58
  10. Distinctive:

    Prefer deterministic outputs for tests and mocked tool responses.

    line 59
  11. Very specific:

    Run tests with npx jest; use --testPathPatterns (not --testPathPattern) for filtering in Jest v30+.

    line 62
  12. Very specific:

    Keep src/__tests__/index.test.ts compatible with current runtime behavior, including bindTools mocking.

    line 63
  13. Distinctive:

    When tool execution behavior changes, add or update tests for:

    line 64
  14. Distinctive:

    Update README.md after changing dependencies, runtime architecture, config keys, or logging behavior.

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Copilot Instructions

Runtime Configuration

  • Read runtime configuration from dotenv-backed settings in src/config.ts.
  • Do not read process.env directly in business logic files when a value exists in appConfig.
  • Keep .env.example in sync whenever new configuration keys are introduced.

Tooling Architecture

  • Each tool lives in its own file under src/tools/ and exports a toolDefinition: ToolDefinition object.
  • ToolRegistry.loadFromDirectory() in src/tools/registry.ts auto-discovers all .ts files that export toolDefinition. Adding a new tool file requires no other edits.
  • Tools are bound to the LLM in src/index.ts via llm.bindTools(toolRegistry.toLangChainTools()) during the lazy ensureInitialized() call.
  • Preserve the two-step tool flow:
    1. Model requests tool calls.
    2. Runtime executes tools and appends ToolMessage entries before final model response.
  • Do not reintroduce backward compatibility hacks for missing bindTools unless explicitly required.

MCP Integration

  • MCP client is in src/mcp/client.ts (McpClient class) and src/mcp/bridge.ts (registerMcpTools).
  • Configure servers via MCP_SERVERS env var (JSON array of { name, transport, command?, args?, url? }).
  • MCP tools are registered into the ToolRegistry during ensureInitialized() alongside built-in tools.

Security Layer

  • ToolPermissionManager in src/security.ts enforces blocklist/allowlist and per-tool permission levels ("safe"/"cautious"/"dangerous") before every tool execution.
  • ToolBlockedError from src/errors.ts is thrown on rejection and injected as a ToolMessage by src/index.ts so the LLM can reason about it.
  • Configure via AUTO_APPROVE_ALL, TOOL_ALLOWLIST, TOOL_BLOCKLIST env vars.

Agent Profiles and Skills

  • Agent profiles are JSON files under src/agents/builtin/ (and optionally AGENT_PROFILES_DIR).
  • Skills are Markdown files under src/skills/builtin/ (and optionally SKILLS_DIR).
  • Both are auto-loaded during ensureInitialized(). Profiles can restrict which tools are active, override model/temperature, and set iteration limits.
  • activateProfile() in src/agents/activator.ts converts a profile into an AgentRuntimeConfig.

Orchestrator and Subagents

  • executePlan() in src/orchestrator.ts runs multi-step plans: simple steps via runSubagent() directly, complex steps via SubagentManager.
  • Supports resumeFrom (1-based), onStepFailure (retry/skip/abort), and a pluggable CheckpointStore.
  • Subagent runner is in src/subagents/runner.ts; planner is in src/subagents/planner.ts.

Streaming Support

  • streamWithTools() in src/streaming.ts is the streaming-capable agent loop.
  • agentExecutor.stream in src/index.ts is the public API; it delegates to streamWithTools.
  • Enable via STREAMING_ENABLED=true; the CLI prints tokens as they arrive.

Observability

  • Tracer interface and FileTracer/NoopTracer implementations are in src/observability.ts.
  • Inject a custom tracer in tests with setTracer() exported from src/index.ts.
  • Configure via TRACING_ENABLED, TRACE_OUTPUT_DIR, TRACING_COST_PER_INPUT_TOKEN_USD, TRACING_COST_PER_OUTPUT_TOKEN_USD.

Logging Guidelines

  • Use the shared logger from src/logger.ts.
  • Log tool lifecycle events with structured fields:
    • invocation: tool name, call id, arguments
    • completion: tool name, call id, response
  • Keep logger output machine-readable and avoid ad hoc string-only logs.
  • Default destination is stdout; destination and verbosity must stay configurable via dotenv values.

Security and Reliability

  • Avoid eval in production tool implementations.
  • When adding external API tools, validate input and handle failures explicitly.
  • Prefer deterministic outputs for tests and mocked tool responses.

Testing

  • Run tests with npx jest; use --testPathPatterns (not --testPathPattern) for filtering in Jest v30+.
  • Keep src/__tests__/index.test.ts compatible with current runtime behavior, including bindTools mocking.
  • When tool execution behavior changes, add or update tests for:
    • no-tool response path
    • tool-called path
    • tool response re-injection path
  • ts-jest with isolatedModules: true in tsconfig.json is required to prevent OOM during tests.
  • ESM-only transitive deps are shimmed via moduleNameMapper in package.json (see tests/jest-shims/).

Documentation

  • Update README.md after changing dependencies, runtime architecture, config keys, or logging behavior.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.