-
Notifications
You must be signed in to change notification settings - Fork 0
feat: route the capture signal to the model instead of to doctor (0.7.0) #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import { readFileSync, existsSync, realpathSync } from 'node:fs'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { join, sep } from 'node:path'; | ||
| import { join, sep, basename, dirname } from 'node:path'; | ||
| import { loadConfig, paths } from './config.js'; | ||
| import { listNotes, archiveNote, contentHash, nowIso, serializeNote } from './store.js'; | ||
| import { atomicWrite } from './atomic.js'; | ||
| import { openDb, reindex } from './index-db.js'; | ||
| import { buildDigest, buildTree, renderTree } from './digest.js'; | ||
| import { buildDigest, buildCaptureNudge, buildTree, renderTree } from './digest.js'; | ||
|
|
||
| /** | ||
| * Compaction is pure code. No model is involved, and none should be. | ||
|
|
@@ -203,9 +203,33 @@ export function writeSkillDescription(skillPath, description) { | |
| return true; | ||
| } | ||
|
|
||
| /** Regenerate everything derived: ROUTING.md and each installed skill description. */ | ||
| /** | ||
| * Which skill a registered path belongs to. | ||
| * | ||
| * Derived from the path rather than stored beside it, because `setup` is what creates | ||
| * these paths and it only ever creates the two shapes below. Keeping `skillPaths` a | ||
| * flat list of strings means no config migration and no second source of truth about | ||
| * which skill is which — the layout already answers it. | ||
| */ | ||
| export function skillNameFromPath(p) { | ||
| const file = basename(p); | ||
| if (file === 'SKILL.md') return basename(dirname(p)); | ||
| const m = file.match(/^(.+)\.prompt\.md$/); | ||
| return m ? m[1] : null; | ||
| } | ||
|
|
||
| /** | ||
| * Regenerate everything derived: ROUTING.md and each installed skill description. | ||
| * | ||
| * Two descriptions are generated, not one, and which a path receives is decided by the | ||
| * skill it belongs to. `remember` gets the capture nudge; everything else registered | ||
| * gets the digest. Before this, one text was written to every registered path, which is | ||
| * why `setup` could only ever register `recall` — handing `remember` the digest would | ||
| * have replaced a good description with a description of the wrong thing. | ||
| */ | ||
| function regenerate(db, cfg) { | ||
| const digest = buildDigest(db, { cfg }); | ||
| const nudge = buildCaptureNudge(db, { cfg }); | ||
| const tree = buildTree(db, { all: true, cfg }); | ||
|
|
||
| const routing = [ | ||
|
|
@@ -227,9 +251,18 @@ function regenerate(db, cfg) { | |
| skipped.push(p); | ||
| continue; | ||
| } | ||
| if (writeSkillDescription(p, digest)) skills.push(p); | ||
| const text = skillNameFromPath(p) === 'remember' ? nudge : digest; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect how captureGap derives and normalizes g.repo before it is interpolated
# into the model-facing nudge.
rg -n -C 10 'function captureGap|captureGap\(|g\.repo|buildCaptureNudge' src/digest.js
# Confirm the nudge-to-skill-description route and its persistent sink.
rg -n -C 8 'buildCaptureNudge|skillNameFromPath|writeSkillDescription|skillPaths' src/compact.js src/setup.jsRepository: vib795/agent-memory Length of output: 12562 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the exact repository-identity derivation and the description serialization sink.
sed -n '120,192p' src/digest.js
sed -n '185,205p' src/compact.jsRepository: vib795/agent-memory Length of output: 4486 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Read the bounded captureGap implementation and its repository source.
rg -n -C 18 'function captureGap|export function captureGap|currentRepo\(' src/digest.js src/*.jsRepository: vib795/agent-memory Length of output: 19625 LLM Security (CWE-1427) Reachability: External · Exploitability: Moderate Do not put repository-controlled text in the model-facing description.
🤖 Prompt for AI Agents |
||
| if (writeSkillDescription(p, text)) skills.push(p); | ||
| } | ||
| return { digest, digestChars: digest.length, routing: paths.routing, skills, skipped }; | ||
| return { | ||
| digest, | ||
| digestChars: digest.length, | ||
| nudge, | ||
| nudgeChars: nudge.length, | ||
| routing: paths.routing, | ||
| skills, | ||
| skipped, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the Tier 2 trigger.
skills/remember/SKILL.mdnow runsagent-memory briefbefore capture. Tier 2 therefore runs forrememberas well asrecall. Replace “only when recall fires” with wording that includes both paths.🤖 Prompt for AI Agents