Skip to content

fix: make file-producing tools config-driven via memory/toolsDir - #1459

Merged
avoidwork merged 5 commits into
mainfrom
fix/config-driven-tool-outputs
Oct 22, 2026
Merged

avoidwork merged 5 commits into
mainfrom
fix/config-driven-tool-outputs

Conversation

@avoidwork

@avoidwork avoidwork commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Description

Make the file-producing tools (clarify, generatePptx, generatePdf, spreadsheet, tts) config-driven via config.memory.toolsDir (read through loadConfig()), matching the pattern used by screenshotWeb, cron, sampling, memory, and webhook. Adds a SYSTEM_PROMPT.md fallback directive for future tools.

  • src/tools/clarify/index.js — default clarifications file now reads config.memory.toolsDir (default memory/tools/), removing clarifications.md from the loadContext() system-prompt concatenation.
  • src/tools/pptx/index.js — outputPath is now optional and defaults to config.memory.toolsDir; validateOutputPath traversal guard preserved.
  • src/tools/pdf/index.js — outputPath defaults to config.memory.toolsDir when omitted.
  • src/tools/spreadsheet/spreadsheet.js — outputPath defaults to config.memory.toolsDir in generate/modify/export.
  • src/tools/tts/index.js — replaces hardcoded ~/voice-memos/ with config.memory.toolsDir.
  • prompts/SYSTEM_PROMPT.md — adds a fallback directive to save tool outputs to memory/tools/.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)
  • Performance improvement
  • CI / build / tooling

Testing

  • Unit tests: verify each tool defaults its output path to config.memory.toolsDir (or memory/tools/ fallback).
  • Regression test: verify loadContext() no longer includes clarifications.md.
  • npm run test (4211 pass), npm run lint (clean), npm run coverage (91.49% line coverage maintained).

Coverage

  • Line coverage maintained

Checklist

  • npm run lint passes
  • Tests pass with maintained line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

Closes #1458

Add OpenSpec proposal, design, tasks, and spec deltas for config-driven
tool outputs. The clarify, generatePptx, generatePdf, spreadsheet, and
tts tools will read config.memory.toolsDir via loadConfig() and default
their output paths there. Adds a SYSTEM_PROMPT.md fallback directive.

Closes #1458
@avoidwork avoidwork added the bug Something isn't working label Oct 22, 2026
@avoidwork avoidwork self-assigned this Oct 22, 2026
Make clarify, generatePptx, generatePdf, spreadsheet, and tts read
config.memory.toolsDir via loadConfig() and default their output paths
there, matching the pattern used by screenshotWeb, cron, sampling,
memory, and webhook. Add a SYSTEM_PROMPT.md fallback directive for
future tools. Update tests and add regression coverage.

Closes #1458
Archive the OpenSpec change and sync the spec deltas into
openspec/specs/ for clarify-tool, config-driven-tool-outputs, and
system-prompt.
@avoidwork

Copy link
Copy Markdown
Owner Author

Implementation Audit Results: config-driven-tool-outputs

Goal Fulfillment

All 7 goals from the feature goals file are implemented and verified:

  1. clarify config-driven via toolsDir — src/tools/clarify/index.js now reads config.memory.toolsDir via loadConfig() when options.clarificationsFile is not provided. Default path is join(config.cwd, toolsDir, "clarifications.md"). Description updated to reference memory/tools/. ✅
  2. generatePptx outputPath optional with toolsDir default — generatePptxSchema.outputPath is now .optional(). createPptx defaults to join(config.cwd, toolsDir, "presentation-<timestamp>.pptx"). validateOutputPath traversal guard preserved. ✅
  3. generatePdf outputPath default to toolsDir — generatePdf injects a default outputPath (join(config.cwd, toolsDir, "document-<timestamp>.pdf")) when omitted and not base64 output. splitPdf (uses outputPattern) is left untouched. ✅
  4. spreadsheet outputPath default to toolsDir — resolveOutputPath() helper defaults to join(config.cwd, toolsDir, "spreadsheet-<timestamp>.<ext>") in generate/modify/exportData. ✅
  5. tts config-driven via toolsDir — textToSpeechImpl now writes to join(config.cwd, config.memory.toolsDir) instead of join(homedir(), "voice-memos"). homedir import removed. Description updated to reference memory/tools/. ✅
  6. SYSTEM_PROMPT.md fallback directive — Added rule 11.1 in prompts/SYSTEM_PROMPT.md stating tool outputs should be saved to memory/tools/ when a tool does not handle the concern itself. ✅
  7. Tests — Updated tools_clarify.test.js (default path regression), tools_pptx.test.js + tools/pptx.test.js (outputPath optional), tools_pdf_generate.test.js (default outputPath), tools_tts.test.js (default path), spreadsheet.test.js (default outputPath), context.test.js (loadContext excludes clarifications.md). ✅

Spec Compliance

  • config-driven-tool-outputs/spec.md: All requirements met.
  • clarify-tool/spec.md: Description references memory/tools/. ✅
  • system-prompt/spec.md: Fallback directive present. ✅

Task Completion

All 17 tasks in tasks.md are marked [x].

Quality Check

  • npm run test: 4211 tests pass, 0 fail.
  • npm run lint: 0 warnings, 0 errors, all files formatted.
  • npm run coverage: 91.49% line coverage maintained. All modified tools have ≥97% line coverage.
  • npm start: Fails only due to non-TTY environment (Ink raw mode on stdin) — not related to changes. All changed modules load correctly.

Deviations

  • The generatePdf default is applied in the generatePdf dispatcher (not per-handler) to avoid duplicating logic across 7 action handlers. splitPdf is excluded since it uses outputPattern.
  • The spreadsheet generate action returns a workbook object (not written to disk); outputPath is still defaulted for consistency with the issue's requirement.
  • Two pptx test files exist (tests/unit/tools_pptx.test.js and tests/unit/tools/pptx.test.js); both were updated.

The SYSTEM_PROMPT.md directive was placed as rule 11.1 under the Delivery
section (rule 11 is a delivery/tone rule). It belongs in the Tool Call
Discipline section as rule 29, since it governs tool output handling.
Renumbered rules 30-44 and fixed the cross-reference in rule 17.
readImage now returns a formatted ToolMessage containing an image_url
content block, so the LLM can see the image directly rather than just
receiving base64-encoded data.
@avoidwork
avoidwork enabled auto-merge (squash) October 22, 2026 13:02
@avoidwork
avoidwork merged commit 1eb35a2 into main Oct 22, 2026
2 checks passed
@avoidwork
avoidwork deleted the fix/config-driven-tool-outputs branch October 22, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: make file-producing tools config-driven via memory/toolsDir

1 participant