feat!: simplify feature-knowledge system (write-through + dedicated MDS module)#247
Open
dean0x wants to merge 5 commits into
Open
feat!: simplify feature-knowledge system (write-through + dedicated MDS module)#247dean0x wants to merge 5 commits into
dean0x wants to merge 5 commits into
Conversation
…of 3) WORKSTREAM 3: Add shared/knowledge/_knowledge.mds with knowledge_load() and knowledge_writeback() partials — pure file-I/O, no subprocess/git calls, no .cjs engine. knowledge_load reads index.md cache (falls back to globbing frontmatter); knowledge_writeback conditionally spawns Knowledge agent to write KNOWLEDGE.md + index.md line directly. WORKSTREAM 1: Port all 9 command .md files to shared/knowledge/*.mds host files that import and call the two partials. Asymmetry preserved: explore and debug get writeback-only; the other 7 load up-front; implement/resolve/ self-review additionally write back. All prose braces escaped; code fences use raw braces. DELIVERABLE 3: scripts/build-knowledge.ts — explicit 9-entry source→plugin map (not a glob), per-file clean (never wipes a whole dir), hard-fail on any mds:: error, disjoint from build-recipes.ts. DELIVERABLE 4: package.json wires build:knowledge after build:recipes in the main build chain; .gitignore adds 9 per-file entries for generated commands; git rm --cached untracks the now-generated .md files. Old machinery (feature-knowledge.cjs, index.json, .create-result.json, subprocess calls) remains untouched — this phase is purely additive. Tree builds green; all 1880 tests pass. TASK_ID: feat/simplify-feature-knowledge
…ls/agent (2/3)
WS2: delete eval-knowledge hook, feature-knowledge.cjs CJS library, dream-knowledge
skill, knowledge-agent.ts, agent-result.ts (sever references first, then delete).
Update session-start-context to drop _SC2_KNOW_EN; drop KNOWLEDGE_ENABLED arg from
dream_collect_tasks; make knowledge.* case unconditionally delete stale markers;
remove index.json bootstrap from ensure-devflow-init and init.ts. Add
devflow:dream-knowledge to LEGACY_SKILLS_V2X for cleanup on upgrade.
WS5: update apply-feature-knowledge skill to drop [STALE] handling and strengthen
verify-against-code as the freshness mechanism. Update feature-knowledge skill to
remove referencedFiles from frontmatter template and Result Output section; replace
with direct index.md write instructions (line format: - **{slug}** — {areas} — desc).
Rewrite knowledge agent to write KNOWLEDGE.md + index.md directly without any
intermediate .create-result.json or external scripts.
Test cleanup: delete tests/feature-knowledge/* (5 files, 1072 lines). Remove
knowledge assertions from shell-hooks.test.ts (throttle, sentinel, dream-evaluate
knowledge block, runCollectTasks knowEnabled param). Update project-paths.test.ts
to drop the 4 deleted helper assertions. All 1777 tests pass.
TASK_ID: feat/simplify-feature-knowledge
WS4: Two new migrations in MIGRATIONS registry: - purge-knowledge-hooks-global-v1 (global): removes orphaned ~/.devflow/scripts/hooks/eval-knowledge and ~/.devflow/scripts/hooks/lib/feature-knowledge.cjs left by the additive installer after Phase 2 deleted them from source - purge-feature-knowledge-pipeline-v1 (per-project): removes dream knowledge.* markers, .knowledge.lock/, .knowledge-last-refresh, .knowledge-refresh.lock, .disabled sentinel; renames index.json to index.json.deprecated; preserves knowledge gate in dream config WS6 docs: CLAUDE.md fully updated to write-through model — Feature Knowledge Bases paragraph rewritten; eval-knowledge removed from hooks list and dream-evaluate description; dream-collect-tasks updated to note knowledge.* deletion; Model Strategy drops knowledge=sonnet Dream note; Migrations paragraph adds both new migrations; Project Structure removes stale files (.disabled, .knowledge.lock, .knowledge-last-refresh, index.json → index.md); build:knowledge added to build commands. WS6 tests: 38 new tests across 2 files — - tests/migrations.test.ts: 4 new entries in MIGRATIONS describe + idempotency/cleanup suites for both new migrations (30 new tests) - tests/build-knowledge.test.ts: new file — SOURCE_TO_PLUGIN_MAP lock (9-entry explicit mapping), MDS compiler happy path, script subprocess contract (exits 0), compiled-output assertions (no stale call sites); 8 tests Dogfood: .devflow/features/feature-knowledge-system/KNOWLEDGE.md rewritten to document the new write-through architecture; index.json renamed to index.json.deprecated; index.md created with new line format. Final state: npm run build exits 0 (all 9 knowledge commands compiled); npm test 1815/1815 passing (up from 1777 in Phase 2). Co-Authored-By: Claude <noreply@anthropic.com>
…lish comments Update Phase 1b of /release to load feature knowledge using the write-through model: read index.md cache first, fall back to globbing KNOWLEDGE.md frontmatter on absence, and load full KBs for relevant areas. Removes the deprecated index.json load and feature-knowledge.cjs subprocess call. Polish plugins.ts legacy-sweep comment to correctly mark dream-knowledge as removed (not still-active) and clarify dream-decisions/dream-curation are the active pair. Update init.ts knowledge feature description to describe the write-through model accurately.
Phase 1 over-escaped braces inside column-0 fenced code blocks in the
.mds source files. MDS leaves fenced content untouched, so \{ passed
through literally into 9 generated commands (269 total leaked \{ across
implement 83, resolve 50, bug-analysis 33, debug 31, plan 25,
code-review 23, self-review 12, explore 9, research 3).
Un-escape \{ → { and \} → } inside column-0 fenced regions only.
Prose escapes (outside fences) are left intact — MDS compiles those
correctly. Build confirms no prose brace was wrongly un-escaped (a green
build is the safety net: wrong un-escape → MDS undefined-variable error).
Before: 269 leaked \{ across 9 generated commands
After: 0 leaked \{ (all 9 commands clean)
Tests: 1815/1815 passing
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.
Summary
Replaces the feature-knowledge detect-drift-then-background-repair machine with a write-through model and moves the two reusable command-level blocks into native MDS partials compiled by a dedicated build module. Net: a large deletion, far fewer runtime parts, and freshness that tracks usage.
Before: a ~650-line
feature-knowledge.cjsengine + a SessionEnd hook (eval-knowledge) + a Dream refresh task (dream-knowledge) + an mkdir lock + per-session markers + three throttles + anindex.jsonregistry + a.create-result.jsonhandoff — all to serve one weak git-mtime heuristic, and it produced ~zero real updates on this repo (empty index → every run found nothing stale and just advanced the throttle).After: the workflow that does the work updates
KNOWLEDGE.mdnow, in-context; readers verify against code on load. Loading/saving are direct agent file-I/O. Freshness = write-through + verify-on-read.What changed (6 workstreams)
{knowledge_load()}/{knowledge_writeback()}) across the 9 host commands, preserving the load/writeback asymmetry (explore/debug write-back only; the other 7 load up-front; implement/resolve/self-review also write back).eval-knowledge,feature-knowledge.cjs, thedream-knowledgeskill,knowledge-agent.ts,agent-result.ts, and the heavy CLI CRUD. Dream no longer has a knowledge task;dream-collect-tasksnow sweeps staleknowledge.*markers (same pattern asmemory.*/learning.*).shared/knowledge/source dir (_knowledge.mdspartials + 9 host.mds) compiled by a standalonescripts/build-knowledge.ts(explicit 9-entry source→plugin map, per-file clean, hard-fail). The 9plugins/*/commands/*.mdare now generated (gitignored).build:recipesis untouched.devflow init):purge-knowledge-hooks-global-v1(removes installedeval-knowledge+feature-knowledge.cjs) andpurge-feature-knowledge-pipeline-v1(removes dreamknowledge.*markers, lock dirs/sentinels, renamesindex.json→index.json.deprecated). Both ENOENT-tolerant + idempotent; the dream-configknowledgegate is preserved.dream-knowledge; slimmedapply-feature-knowledge(verify-against-code is now the freshness mechanism; dropped[STALE]handling); updatedfeature-knowledgeauthor skill (agent writes theindex.mdline itself; droppedreferencedFiles); simplified the Knowledge agent to dual direct writes (KNOWLEDGE.md+index.mdline; no.create-result.json).tests/feature-knowledge/*; added abuild-knowledgesmoke test + migration idempotency tests.devflow knowledge create | check | refresh | removeare removed.devflow knowledge listand--enable/--disable/--statusremain.knowledge: true|falsedream-config key (default true; gates write-back only — load is ungated). Existing KBs remain loadable via frontmatter fallback afterindex.jsonis deprecated.2.0.0); per repo convention the bump is CI-derived from thefeat!:commits, not done in this PR.Testing
npm run buildgreen (full chain incl. the newbuild:knowledgestep — all 9 commands compile, 0 errors/warnings).npm test: 1815 passing / 61 files (+38 new).Deploy note
The new commands/hooks/agents/migrations activate only after
node dist/cli.js init(a global reinstall) — intentionally not run during implementation to avoid self-modifying the in-flight workflow.🤖 Generated with Claude Code