fix(local-rest-api): replace hardcoded Create-Target-If-Missing with agent-controlled option#72
Open
grimlor wants to merge 13 commits intojacksteamdev:mainfrom
Open
Conversation
Replace hardcoded "Create-Target-If-Missing": "true" header with a conditional based on the new optional createTargetIfMissing parameter in ApiPatchParameters. This gives agents explicit control over whether missing targets are created during patch operations.
… function Extract duplicated header-building logic from patch_active_file and patch_vault_file into buildPatchHeaders(). Add BDD test coverage for required fields, optional fields, and createTargetIfMissing behavior.
…arameters Update test templates from tp.user.promptArg to tp.mcpTools.prompt to match the current implementation renamed in 111297e. Remove unnecessary /g flag from TEMPLATER_END_TAG regex which caused .test() to advance lastIndex across loop iterations, skipping matches in multi-parameter content.
✅ Deploy Preview for superb-starlight-b5acb5 canceled.
|
…idiom bun:test's expect() does not accept diagnostic message arguments like Jest. Move comments from inside expect() calls to above the assertions where they serve as readable context without being silently ignored.
…TCH endpoints The header was referenced in prose examples but missing from the formal parameters section. Add it to all three PATCH endpoints (active file, periodic note, vault file) with default "false" matching the new agent-controlled behavior.
9c453a7 to
27f0f02
Compare
…onse and ApiPatchParameters
…onse and ApiPatchParameters to include URL-encoding requirements for special characters
5f10d80 to
9cc116c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Replace the hardcoded
"Create-Target-If-Missing": "true"header in bothpatch_active_fileandpatch_vault_filehandlers with logic driven by a new optionalcreateTargetIfMissingboolean parameter onApiPatchParameters. This gives agents explicit control over whether missing targets (headings, blocks, frontmatter fields) are created during patch operations, rather than always creating them unconditionally.Additionally extracts the duplicated header-building logic into a pure
buildPatchHeadersfunction with BDD test coverage, fixes pre-existing test failures inparseTemplateParameters, and addsCreate-Target-If-Missingas a formal parameter in the OpenAPI spec.Fixes #71
Type of Change
Testing
How has this been tested?
9 new BDD tests for
buildPatchHeaderscovering required fields, optional fields, andcreateTargetIfMissingbehavior. All 22 tests across themcp-serverpackage pass (including 4 previously brokenparseTemplateParameterstests).Architecture Compliance
/docs/project-architecture.md).clinerulesChecklist
Security Considerations
Additional Context
Commits:
feat(local-rest-api): add createTargetIfMissing option to patch handlers— add optional boolean toApiPatchParameters, wire into both handlersrefactor(local-rest-api): extract buildPatchHeaders as pure, testable function— deduplicate header logic, add 9 BDD testsfix(templates): update tests and fix stateful regex in parseTemplateParameters— update test templates fromtp.user.promptArgtotp.mcpTools.prompt, remove/gflag fromTEMPLATER_END_TAGregex that causedlastIndexto skip matches across loop iterationsstyle(tests): move diagnostic comments above assertions for bun:test idiom— reformat test diagnostics for bun:test conventionsdocs(openapi): add Create-Target-If-Missing as formal parameter to PATCH endpoints— header was referenced in prose examples but missing from the formal parameters section across all three PATCH endpoints