@kentwynn/kgraph 0.2.17 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,13 +121,14 @@ After useful AI work, assistants save durable runtime-capture notes into `.kgrap
121
121
  Normal agent flow is intentionally small:
122
122
 
123
123
  ```bash
124
- kgraph pack "topic" --budget 8000 --json
124
+ kgraph "topic"
125
125
  # work normally
126
- # if repo files changed, write an inbox note before the final refresh
127
- kgraph
126
+ kgraph "topic" --final
127
+ # if final check requires capture:
128
+ kgraph "topic" --capture "durable conclusion" --capture-file path/to/file.ts --capture-symbol SymbolName
128
129
  ```
129
130
 
130
- `kgraph "<topic>"` remains the human-readable briefing. Agents should prefer `kgraph pack "<topic>" --budget 8000 --json` because it returns the stable `ContextPack` contract with atoms, source ranges, git changes, omitted items, token estimates, and inclusion reasons.
131
+ `kgraph "<topic>"` is the smart root workflow: it refreshes maps, processes capture notes, reports memory health, and returns focused context. Agents can still use `kgraph pack "<topic>" --budget 8000 --json` when they need the stable machine-readable `ContextPack` contract with atoms, source ranges, git changes, omitted items, token estimates, and inclusion reasons.
131
132
 
132
133
  Use `kgraph doctor` after setup and before trusting a repo's saved intelligence. It checks initialization, maps, pending inbox notes, integration targets, and actionable quality problems. Use `kgraph doctor --quality` and `kgraph repair --dry-run` when stale or noisy atom references start making context harder to trust.
133
134
 
@@ -163,6 +164,18 @@ kgraph "some topic"
163
164
 
164
165
  The normal command. Scans the repo, updates durable memory, and returns focused context for the topic.
165
166
 
167
+ ```bash
168
+ kgraph "some topic" --final
169
+ ```
170
+
171
+ End-of-work check. Refreshes intelligence and fails with `capture-required` when mapped repo files changed but no recent durable atom references those files.
172
+
173
+ ```bash
174
+ kgraph "some topic" --capture "durable conclusion" --capture-file src/auth.ts --capture-symbol refreshSession
175
+ ```
176
+
177
+ Stores durable cognition through the root workflow. Use `--capture-confidence high` only with file or symbol evidence.
178
+
166
179
  ```bash
167
180
  kgraph
168
181
  ```
@@ -33,6 +33,9 @@ export function registerConcludeCommand(program) {
33
33
  console.log(`Stored ${note.kind} cognition: ${note.title}`);
34
34
  console.log(`Confidence: ${note.confidence}`);
35
35
  console.log(`Status: ${note.referencesStatus}`);
36
+ for (const warning of note.warnings) {
37
+ console.error(`Warning: ${warning}`);
38
+ }
36
39
  }));
37
40
  }
38
41
  export function normalizeKind(value) {
@@ -89,6 +89,9 @@ export function registerSessionCommand(program) {
89
89
  if (pendingConclusion) {
90
90
  const note = await concludeTopic(workspace, pendingConclusion);
91
91
  console.log(`Stored session cognition: ${note.title}`);
92
+ for (const warning of note.warnings) {
93
+ console.error(`Warning: ${warning}`);
94
+ }
92
95
  }
93
96
  }));
94
97
  session
@@ -1 +1,11 @@
1
- export declare function runDefaultWorkflow(query?: string): Promise<void>;
1
+ export interface DefaultWorkflowOptions {
2
+ final?: boolean;
3
+ capture?: string;
4
+ type?: string;
5
+ confidence?: string;
6
+ domain?: string;
7
+ tags?: string[];
8
+ files?: string[];
9
+ symbols?: string[];
10
+ }
11
+ export declare function runDefaultWorkflow(query?: string, options?: DefaultWorkflowOptions): Promise<void>;
@@ -1,13 +1,18 @@
1
1
  import { refreshCognitionReferenceStatuses, updateCognition, } from '../../cognition/cognition-updater.js';
2
+ import { concludeTopic } from '../../cognition/conclusion.js';
2
3
  import { loadConfig } from '../../config/config.js';
3
4
  import { queryContext } from '../../context/context-query.js';
5
+ import { readKnowledgeAtoms } from '../../knowledge/atom-store.js';
6
+ import { getWorkingTreeChanges } from '../../scanner/git-utils.js';
4
7
  import { scanRepository } from '../../scanner/repo-scanner.js';
8
+ import { listInboxNotes } from '../../storage/cognition-store.js';
5
9
  import { assertWorkspace, pathExists, resolveWorkspace, } from '../../storage/kgraph-paths.js';
6
10
  import { readMaps, writeMaps } from '../../storage/map-store.js';
7
- import { runCommand } from '../errors.js';
11
+ import { KGraphError, runCommand } from '../errors.js';
8
12
  import { renderRootHelp, renderWorkflowBanner } from '../help.js';
13
+ import { normalizeConfidence, normalizeKind } from './conclude.js';
9
14
  import { renderContextMarkdown } from './context.js';
10
- export async function runDefaultWorkflow(query) {
15
+ export async function runDefaultWorkflow(query, options = {}) {
11
16
  await runCommand(async () => {
12
17
  const topic = query?.trim();
13
18
  const candidateWorkspace = resolveWorkspace(process.cwd());
@@ -32,6 +37,35 @@ export async function runDefaultWorkflow(query) {
32
37
  symbols: scan.symbols,
33
38
  });
34
39
  const update = await updateCognition(workspace, { files: scan.files, symbols: scan.symbols }, false);
40
+ if (options.capture) {
41
+ if (!topic) {
42
+ throw new KGraphError('A topic is required when using --capture.');
43
+ }
44
+ const note = await concludeTopic(workspace, {
45
+ topic,
46
+ body: options.capture,
47
+ kind: normalizeKind(options.type),
48
+ confidence: normalizeConfidence(options.confidence),
49
+ domain: options.domain,
50
+ tags: options.tags ?? [],
51
+ relatedFiles: options.files ?? [],
52
+ relatedSymbols: options.symbols ?? [],
53
+ source: 'conclude',
54
+ });
55
+ console.log(`Stored ${note.kind} cognition: ${note.title}`);
56
+ console.log(`Confidence: ${note.confidence}`);
57
+ console.log(`Status: ${note.referencesStatus}`);
58
+ for (const warning of note.warnings) {
59
+ console.error(`Warning: ${warning}`);
60
+ }
61
+ }
62
+ const atoms = await readKnowledgeAtoms(workspace);
63
+ const pendingInbox = await listInboxNotes(workspace);
64
+ const activeAtoms = atoms.filter((atom) => atom.status === 'active');
65
+ const captureCheck = await buildCaptureCheck(workspace.rootPath, {
66
+ files: scan.files,
67
+ atoms,
68
+ });
35
69
  console.log(renderWorkflowBanner({
36
70
  files: scan.files.length,
37
71
  symbols: scan.symbols.length,
@@ -42,11 +76,30 @@ export async function runDefaultWorkflow(query) {
42
76
  mode: integration.mode,
43
77
  enabled: integration.enabled,
44
78
  })),
79
+ memory: {
80
+ atomsProcessed: update.processed.length,
81
+ pendingInbox: pendingInbox.length,
82
+ activeAtoms: activeAtoms.length,
83
+ needsReviewAtoms: atoms.filter((atom) => atom.status === 'needs-review')
84
+ .length,
85
+ staleAtoms: atoms.filter((atom) => atom.status === 'stale').length,
86
+ highConfidenceMissingEvidence: activeAtoms.filter((atom) => atom.confidence === 'high' && atom.evidenceRefs.length === 0).length,
87
+ captureRequired: captureCheck.required,
88
+ changedFiles: captureCheck.changedFiles.length,
89
+ },
45
90
  }));
46
91
  console.log('');
47
92
  for (const warning of [...scan.warnings, ...update.warnings]) {
48
93
  console.warn(`Warning: ${warning}`);
49
94
  }
95
+ if (options.final) {
96
+ console.log('');
97
+ renderFinalCaptureCheck(captureCheck, topic);
98
+ if (captureCheck.required) {
99
+ process.exitCode = 1;
100
+ }
101
+ return;
102
+ }
50
103
  if (!topic) {
51
104
  return;
52
105
  }
@@ -56,3 +109,53 @@ export async function runDefaultWorkflow(query) {
56
109
  console.log(renderContextMarkdown(response));
57
110
  });
58
111
  }
112
+ async function buildCaptureCheck(rootPath, input) {
113
+ const knownFiles = new Set(input.files.map((file) => file.path));
114
+ const changedFiles = (await getWorkingTreeChanges(rootPath)).filter((file) => knownFiles.has(file));
115
+ if (changedFiles.length === 0) {
116
+ return { required: false, changedFiles, coveredFiles: [] };
117
+ }
118
+ const recentCutoff = Date.now() - 24 * 60 * 60 * 1000;
119
+ const recentActiveAtoms = input.atoms.filter((atom) => {
120
+ if (atom.status !== 'active')
121
+ return false;
122
+ const createdAt = Date.parse(atom.provenance.createdAt);
123
+ return Number.isFinite(createdAt) && createdAt >= recentCutoff;
124
+ });
125
+ const covered = new Set();
126
+ for (const atom of recentActiveAtoms) {
127
+ for (const ref of atom.evidenceRefs) {
128
+ if (ref.type === 'file' && changedFiles.includes(ref.path)) {
129
+ covered.add(ref.path);
130
+ }
131
+ }
132
+ for (const file of atom.scopeRefs.files) {
133
+ if (changedFiles.includes(file)) {
134
+ covered.add(file);
135
+ }
136
+ }
137
+ }
138
+ return {
139
+ required: changedFiles.some((file) => !covered.has(file)),
140
+ changedFiles,
141
+ coveredFiles: [...covered],
142
+ };
143
+ }
144
+ function renderFinalCaptureCheck(check, topic) {
145
+ console.log('KGraph Final Check');
146
+ if (check.changedFiles.length === 0) {
147
+ console.log(' status clean');
148
+ console.log(' reason no mapped repo files changed');
149
+ return;
150
+ }
151
+ if (!check.required) {
152
+ console.log(' status captured');
153
+ console.log(` changed files ${check.changedFiles.length}`);
154
+ console.log(` covered files ${check.coveredFiles.length}`);
155
+ return;
156
+ }
157
+ console.log(' status capture-required');
158
+ console.log(` changed files ${check.changedFiles.length}`);
159
+ console.log(' conclusion missing for one or more changed files');
160
+ console.log(` next kgraph "${topic || '<topic>'}" --capture "<durable conclusion>" --capture-file <path>`);
161
+ }
@@ -5,11 +5,22 @@ interface WorkflowBannerStats {
5
5
  cognitionNotes: number;
6
6
  skippedFiles?: number;
7
7
  integrations?: WorkflowBannerIntegration[];
8
+ memory?: WorkflowBannerMemory;
8
9
  }
9
10
  interface WorkflowBannerIntegration {
10
11
  name: string;
11
12
  mode: string;
12
13
  enabled: boolean;
13
14
  }
15
+ interface WorkflowBannerMemory {
16
+ atomsProcessed: number;
17
+ pendingInbox: number;
18
+ activeAtoms: number;
19
+ needsReviewAtoms: number;
20
+ staleAtoms: number;
21
+ highConfidenceMissingEvidence: number;
22
+ changedFiles?: number;
23
+ captureRequired?: boolean;
24
+ }
14
25
  export declare function renderWorkflowBanner(stats: WorkflowBannerStats, useColor?: boolean): string;
15
26
  export {};
package/dist/cli/help.js CHANGED
@@ -25,6 +25,8 @@ export function renderRootHelp(useColor = supportsColor()) {
25
25
  sectionTitle(theme, `${accent} Daily workflow`),
26
26
  command('kgraph', 'Refresh scan maps and process pending capture notes'),
27
27
  command('kgraph "auth token refresh"', 'Refresh everything and return compact context for a topic'),
28
+ command('kgraph "auth token refresh" --final', 'End-of-work check: enforce capture when changed files need memory'),
29
+ command('kgraph "auth token refresh" --capture "..."', 'Store durable knowledge through the smart root workflow'),
28
30
  '',
29
31
  sectionTitle(theme, `${accent} Workflows`),
30
32
  command('scan', 'Optional: refresh only file, symbol, import, and relationship maps'),
@@ -60,10 +62,16 @@ export function renderRootHelp(useColor = supportsColor()) {
60
62
  sectionTitle(theme, `${accent} Options`),
61
63
  command('-V, --version', 'Show version'),
62
64
  command('-h, --help', 'Show this help'),
65
+ command('--final', 'Run final capture enforcement in the root workflow'),
66
+ command('--capture <text>', 'Store a durable conclusion in the root workflow'),
67
+ command('--capture-file <path>', 'Attach file evidence to root capture'),
68
+ command('--capture-symbol <name>', 'Attach symbol evidence to root capture'),
63
69
  '',
64
70
  sectionTitle(theme, `${accent} Examples`),
65
71
  ' kgraph init --integrations codex,copilot,cursor,claude-code,gemini,windsurf,cline',
66
72
  ' kgraph "blog admin token usage"',
73
+ ' kgraph "blog admin token usage" --final',
74
+ ' kgraph "blog admin token usage" --capture "Author filter now uses display names" --capture-file www/app/blog/page.tsx',
67
75
  ' kgraph pack "about page update" --budget 4000',
68
76
  ' kgraph doctor',
69
77
  '',
@@ -97,6 +105,21 @@ export function renderWorkflowBanner(stats, useColor = supportsColor()) {
97
105
  command('symbols', String(stats.symbols)),
98
106
  command('capture notes processed', String(stats.cognitionNotes)),
99
107
  command('integration modes', integrationLine),
108
+ ...(stats.memory
109
+ ? [
110
+ '',
111
+ sectionTitle(theme, `${accent} Memory`),
112
+ command('atoms processed', String(stats.memory.atomsProcessed)),
113
+ command('pending inbox', String(stats.memory.pendingInbox)),
114
+ command('active atoms', String(stats.memory.activeAtoms)),
115
+ command('needs review', String(stats.memory.needsReviewAtoms)),
116
+ command('stale', String(stats.memory.staleAtoms)),
117
+ command('high-confidence missing evidence', String(stats.memory.highConfidenceMissingEvidence)),
118
+ command('capture status', stats.memory.captureRequired
119
+ ? `required (${stats.memory.changedFiles ?? 0} changed file(s))`
120
+ : `ok (${stats.memory.changedFiles ?? 0} changed file(s))`),
121
+ ]
122
+ : []),
100
123
  '',
101
124
  sectionTitle(theme, `${accent} Next`),
102
125
  command('kgraph "auth token refresh"', 'Return compact context for a topic'),
package/dist/cli/index.js CHANGED
@@ -31,10 +31,27 @@ export function createProgram() {
31
31
  .name('kgraph')
32
32
  .description('Persistent repo intelligence for AI coding assistants')
33
33
  .argument('[topic...]', 'Run the default refresh workflow and optionally return context for a topic')
34
+ .option('--final', 'Run end-of-work capture enforcement after refresh')
35
+ .option('--capture <text>', 'Store a durable conclusion through the root workflow')
36
+ .option('--capture-type <type>', 'Capture type: finding, decision, gotcha, summary, or relationship', 'summary')
37
+ .option('--capture-confidence <level>', 'Capture confidence: high, medium, or low', 'medium')
38
+ .option('--capture-domain <name>', 'Capture domain name')
39
+ .option('--capture-tag <tag>', 'Capture tag; repeatable', collect, [])
40
+ .option('--capture-file <path>', 'Capture related repo file; repeatable', collect, [])
41
+ .option('--capture-symbol <name>', 'Capture related symbol; repeatable', collect, [])
34
42
  .version(version)
35
43
  .helpOption(false)
36
- .action(async (topicParts = []) => {
37
- await runDefaultWorkflow(topicParts.join(' '));
44
+ .action(async (topicParts = [], options) => {
45
+ await runDefaultWorkflow(topicParts.join(' '), {
46
+ final: options.final,
47
+ capture: options.capture,
48
+ type: options.captureType,
49
+ confidence: options.captureConfidence,
50
+ domain: options.captureDomain,
51
+ tags: options.captureTag,
52
+ files: options.captureFile,
53
+ symbols: options.captureSymbol,
54
+ });
38
55
  });
39
56
  program.option('-h, --help', 'Show this help');
40
57
  program.hook('preAction', (thisCommand) => {
@@ -63,6 +80,10 @@ export function createProgram() {
63
80
  registerUninstallCommand(program);
64
81
  return program;
65
82
  }
83
+ function collect(value, previous) {
84
+ previous.push(value);
85
+ return previous;
86
+ }
66
87
  if (isCliEntrypoint()) {
67
88
  const program = createProgram();
68
89
  const helpTarget = findExplicitHelpTarget(program, process.argv.slice(2));
@@ -15,6 +15,10 @@ export async function concludeTopic(workspace, input) {
15
15
  ? input.relatedFiles
16
16
  : await inferChangedFiles(workspace, maps);
17
17
  const relatedSymbols = input.relatedSymbols ?? [];
18
+ const hasEvidence = relatedFiles.length > 0 || relatedSymbols.length > 0;
19
+ if ((input.confidence ?? 'medium') === 'high' && !hasEvidence) {
20
+ throw new KGraphError('High-confidence cognition requires evidence. Add --file <path> or --symbol <name>, or use --confidence medium/low.');
21
+ }
18
22
  const note = {
19
23
  title,
20
24
  kind: input.kind ?? 'summary',
@@ -29,7 +33,11 @@ export async function concludeTopic(workspace, input) {
29
33
  },
30
34
  relatedFiles,
31
35
  relatedSymbols,
32
- warnings: [],
36
+ warnings: (input.confidence ?? 'medium') === 'medium' && !hasEvidence
37
+ ? [
38
+ 'Medium-confidence cognition has no file or symbol evidence; add --file or --symbol when possible.',
39
+ ]
40
+ : [],
33
41
  id: `${timestamp}-${slugify(title) || 'conclusion'}`,
34
42
  sourceInboxPath: '',
35
43
  processedPath: `.kgraph/cognition/${timestamp}-${slugify(title) || 'conclusion'}.md`,
@@ -1,12 +1,13 @@
1
+ import { numberedWorkflow } from '../workflow-steps.js';
1
2
  export const claudeCodeAdapter = {
2
3
  name: 'claude-code',
3
4
  label: 'Claude Code',
4
5
  targetPath: 'CLAUDE.md',
5
6
  instructions: `## KGraph Workflow
6
7
 
7
- {{KGRAPH_CONTEXT_POLICY}} Use /kgraph for the full automated workflow. Run \`kgraph pack "<task>" --budget 8000 --json\` for a machine-readable token-budgeted context pack, \`kgraph knowledge list\` or \`kgraph knowledge get <atom-id>\` to inspect durable atoms, \`kgraph stale\` and \`kgraph blame <atom-id>\` when lifecycle/provenance matters, \`kgraph conclude\` for durable typed engineering memory, and \`kgraph compact --dry-run\` when cognition looks duplicated or stale. Run \`kgraph doctor\` when setup or generated maps look wrong. Run \`kgraph scan\`, \`kgraph update\`, and \`kgraph context\` manually only when you need one specific step.
8
-
9
- {{KGRAPH_CAPTURE_POLICY}}
8
+ ${numberedWorkflow('claude-code', {
9
+ sessionQualifier: 'native hooks also report session activity when configured',
10
+ })}
10
11
  `,
11
12
  commandFiles: [
12
13
  {
@@ -20,7 +21,7 @@ export const claudeCodeAdapter = {
20
21
  5. Verify the change actually landed before claiming completion. Prefer a narrow read of the changed range or \`git diff -- <path>\`; if there is no diff or the expected text is missing, say the edit did not apply and fix it before summarizing.
21
22
  6. Do not run \`kgraph\` again, \`kgraph context\`, \`kgraph pack\`, \`kgraph knowledge\`, \`kgraph stale\`, \`kgraph blame\`, \`kgraph scan\`, \`kgraph update\`, \`kgraph compact\`, or \`kgraph repair\` unless the user explicitly asks for that lower-level command.
22
23
  7. Do not continue broad repository search after the target file is identified. If a path must be located, prefer \`rg --files\` and quote paths containing spaces or parentheses.
23
- 8. At the end of repository-file changes, store durable engineering memory with \`kgraph conclude "<topic>" --type <finding|decision|gotcha|summary|relationship> --confidence <high|medium|low>\` only when the work created reusable engineering knowledge.
24
+ 8. At the end of repository-file changes, run \`kgraph "<topic>" --final\`. If KGraph reports capture-required, run \`kgraph "<topic>" --capture "<durable conclusion>" --capture-file <path> --capture-symbol <name>\`, or explicitly say "No durable knowledge created" only when there is genuinely no reusable knowledge.
24
25
  `,
25
26
  },
26
27
  {
@@ -85,7 +86,7 @@ export const claudeCodeAdapter = {
85
86
  },
86
87
  {
87
88
  path: '.claude/commands/kgraph-conclude.md',
88
- content: `Use \`kgraph conclude "$ARGUMENTS"\` when the session produced reusable engineering knowledge. Choose one type from finding, decision, gotcha, summary, relationship, and one confidence from high, medium, low. Store only durable conclusions, not raw chain-of-thought, temporary reasoning, speculative exploration, or low-value observations.
89
+ content: `Prefer \`kgraph "<topic>" --capture "$ARGUMENTS" --capture-file <path> --capture-symbol <name>\` when the session produced reusable engineering knowledge. Use \`kgraph conclude "$ARGUMENTS"\` only when the user explicitly asks for the conclude command. Choose one type from finding, decision, gotcha, summary, relationship, and one confidence from high, medium, low. Add file or symbol evidence whenever possible; high-confidence conclusions require evidence. Store only durable conclusions, not raw chain-of-thought, temporary reasoning, speculative exploration, or low-value observations.
89
90
  `,
90
91
  },
91
92
  {
@@ -1,3 +1,4 @@
1
+ import { agentSkillFiles } from '../agent-skills.js';
1
2
  import { numberedWorkflow } from '../workflow-steps.js';
2
3
  export const codexAdapter = {
3
4
  name: 'codex',
@@ -5,26 +6,8 @@ export const codexAdapter = {
5
6
  targetPath: 'AGENTS.md',
6
7
  instructions: `## KGraph Workflow
7
8
 
8
- {{KGRAPH_CONTEXT_POLICY}} The /kgraph skill handles the full automated workflow. Run \`kgraph pack "<task>" --budget 8000 --json\` for a machine-readable token-budgeted context pack, \`kgraph knowledge list\` or \`kgraph knowledge get <atom-id>\` to inspect durable atoms, \`kgraph stale\` and \`kgraph blame <atom-id>\` when lifecycle/provenance matters, \`kgraph conclude\` for durable typed engineering memory, and \`kgraph compact --dry-run\` when cognition looks duplicated or stale. Run \`kgraph doctor\` when setup or generated maps look wrong. Run \`kgraph scan\`, \`kgraph update\`, and \`kgraph context\` manually only when you need one specific step.
9
- `,
10
- commandFiles: [
11
- {
12
- path: '.agents/skills/kgraph/SKILL.md',
13
- content: `---
14
- name: kgraph
15
- description: Use KGraph persistent repo intelligence according to the configured integration mode. Use when asked about repo structure, debugging context, architecture decisions, or to avoid rediscovering what is already known.
16
- ---
17
-
18
- # KGraph Skill
19
-
20
- Workflow:
21
-
22
9
  ${numberedWorkflow('codex')}
23
10
  `,
24
- },
25
- ],
26
- obsoleteCommandFiles: [
27
- '.agents/skills/kgraph-scan/SKILL.md',
28
- '.agents/skills/kgraph-update/SKILL.md',
29
- ],
11
+ commandFiles: agentSkillFiles('codex'),
12
+ obsoleteCommandFiles: [],
30
13
  };
@@ -1,3 +1,4 @@
1
+ import { agentSkillFiles } from '../agent-skills.js';
1
2
  import { numberedWorkflow } from '../workflow-steps.js';
2
3
  export const copilotAdapter = {
3
4
  name: 'copilot',
@@ -7,172 +8,6 @@ export const copilotAdapter = {
7
8
 
8
9
  ${numberedWorkflow('copilot')}
9
10
  `,
10
- commandFiles: [
11
- {
12
- path: '.github/prompts/kgraph-doctor.prompt.md',
13
- content: `---
14
- description: Check KGraph workspace health and next actions
15
- agent: agent
16
- ---
17
-
18
- Run \`kgraph doctor\` to check whether the workspace is initialized, maps exist, inbox notes are pending, and configured integrations point to real files. Use \`kgraph doctor --quality\` when the user asks about stale or noisy cognition references. Summarize any failed checks and the next command to run.
19
- `,
20
- },
21
- {
22
- path: '.github/prompts/kgraph-repair.prompt.md',
23
- content: `---
24
- description: Preview or clean stale/noisy KGraph cognition references
25
- agent: agent
26
- argument-hint: "--dry-run or apply"
27
- ---
28
-
29
- Run \`kgraph repair --dry-run\` first and summarize the proposed atom-reference cleanup. Run \`kgraph repair\` only when the user asks to apply the cleanup.
30
- `,
31
- },
32
- {
33
- path: '.github/prompts/kgraph-compact.prompt.md',
34
- content: `---
35
- description: Merge duplicate KGraph cognition and archive stale low-value entries
36
- agent: agent
37
- argument-hint: "--dry-run or apply"
38
- ---
39
-
40
- Run \`kgraph compact --dry-run\` first and summarize duplicate cognition groups and stale low-confidence notes. Run \`kgraph compact\` only when the user asks to apply compaction.
41
- `,
42
- },
43
- {
44
- path: '.github/prompts/kgraph-pack.prompt.md',
45
- content: `---
46
- description: Build a budget-aware KGraph context pack
47
- agent: agent
48
- argument-hint: "Task description"
49
- ---
50
-
51
- Run \`kgraph pack "$ARGUMENTS" --budget 8000 --json\` to build a machine-readable context pack. Summarize token use, included files, symbols, relationships, git changes, session history, atoms, and omitted items with the inclusion reasons.
52
- `,
53
- },
54
- {
55
- path: '.github/prompts/kgraph-knowledge.prompt.md',
56
- content: `---
57
- description: Inspect or manage KGraph canonical knowledge atoms
58
- agent: agent
59
- argument-hint: "list, get <atom-id>, archive <atom-id>, or supersede <old-id> <new-id>"
60
- ---
61
-
62
- Use \`kgraph knowledge list\` and \`kgraph knowledge get <atom-id>\` to inspect durable atoms, evidence, provenance, and lifecycle. Run \`kgraph knowledge archive <atom-id>\` or \`kgraph knowledge supersede <old-id> <new-id>\` only when the user explicitly asks to mutate atom lifecycle.
63
- `,
64
- },
65
- {
66
- path: '.github/prompts/kgraph-stale.prompt.md',
67
- content: `---
68
- description: Show KGraph knowledge invalidated by changed or missing refs
69
- agent: agent
70
- ---
71
-
72
- Run \`kgraph stale\` to refresh atom status against the current scan and summarize stale or needs-review atoms with invalidation reasons.
73
- `,
74
- },
75
- {
76
- path: '.github/prompts/kgraph-blame.prompt.md',
77
- content: `---
78
- description: Show KGraph atom provenance and evidence
79
- agent: agent
80
- argument-hint: "Atom id"
81
- ---
82
-
83
- Run \`kgraph blame "$ARGUMENTS"\` to show who or what created a knowledge atom, the source command/session/commit, evidence refs, and lifecycle links.
84
- `,
85
- },
86
- {
87
- path: '.github/prompts/kgraph-scan.prompt.md',
88
- content: `---
89
- description: Refresh KGraph file, symbol, import, and relationship maps
90
- agent: agent
91
- ---
92
-
93
- Run \`kgraph scan\` to refresh the repository maps, then summarize what changed.
94
- `,
95
- },
96
- {
97
- path: '.github/prompts/kgraph-update.prompt.md',
98
- content: `---
99
- description: Process KGraph inbox notes into durable cognition
100
- agent: agent
101
- ---
102
-
103
- Run \`kgraph update\` to process any pending Markdown notes in \`.kgraph/inbox/\` into durable cognition.
104
- `,
105
- },
106
- {
107
- path: '.github/prompts/kgraph-visualize.prompt.md',
108
- content: `---
109
- description: Open interactive KGraph dependency graph in browser
110
- agent: agent
111
- ---
112
-
113
- Run \`kgraph visualize\` to start the interactive dependency graph at http://localhost:4242, then summarize what nodes and connections are visible.
114
- `,
115
- },
116
- {
117
- path: '.github/prompts/kgraph-capture.prompt.md',
118
- content: `---
119
- description: Save what was just built or changed into KGraph cognition
120
- agent: agent
121
- argument-hint: "Brief description of what was done"
122
- ---
123
-
124
- Capture this session into KGraph cognition.
125
-
126
- {{KGRAPH_CAPTURE_POLICY}}
127
- `,
128
- },
129
- {
130
- path: '.github/prompts/kgraph-conclude.prompt.md',
131
- content: `---
132
- description: Store a typed durable KGraph engineering conclusion
133
- agent: agent
134
- argument-hint: "Topic plus optional type, confidence, files, and symbols"
135
- ---
136
-
137
- Use \`kgraph conclude "$ARGUMENTS"\` when the session produced reusable engineering knowledge. Choose one type from finding, decision, gotcha, summary, relationship, and one confidence from high, medium, low. Store only durable conclusions, not raw chain-of-thought, temporary reasoning, speculative exploration, or low-value observations.
138
- `,
139
- },
140
- {
141
- path: '.github/prompts/kgraph-impact.prompt.md',
142
- content: `---
143
- description: Show KGraph change impact for a file, symbol, or topic
144
- agent: agent
145
- argument-hint: "File, symbol, or topic"
146
- ---
147
-
148
- Run \`kgraph impact "$ARGUMENTS"\` to show matched files/symbols, import users, callers, callees, related knowledge atoms, and risk hints.
149
- `,
150
- },
151
- {
152
- path: '.github/prompts/kgraph-session.prompt.md',
153
- content: `---
154
- description: Track KGraph session read/write activity and token estimates
155
- agent: agent
156
- argument-hint: "start, read <path>, write <path>, end, or status"
157
- ---
158
-
159
- Use \`kgraph session\` to inspect current session activity. Record meaningful events with \`kgraph session start --agent copilot\`, \`kgraph session read <path> --agent copilot\`, \`kgraph session write <path> --agent copilot\`, and \`kgraph session end --agent copilot --conclude --topic "<topic>"\` when durable session memory is useful.
160
- `,
161
- },
162
- {
163
- path: '.github/prompts/kgraph-history.prompt.md',
164
- content: `---
165
- description: Show timeline of KGraph cognition sessions with git attribution
166
- agent: agent
167
- argument-hint: "Optional topic"
168
- ---
169
-
170
- Run \`kgraph history\` or \`kgraph history "$ARGUMENTS"\` to display processed cognition sessions. Summarize who contributed what and when. Use \`--last <n>\` to limit entries.
171
- `,
172
- },
173
- ],
174
- obsoleteCommandFiles: [
175
- '.github/prompts/kgraph.prompt.md',
176
- '.github/kgraph.agent.md',
177
- ],
11
+ commandFiles: agentSkillFiles('copilot'),
12
+ obsoleteCommandFiles: [],
178
13
  };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shared agent skill definitions used by any integration that writes
3
+ * `.agents/skills/` SKILL.md files (copilot, codex, etc.).
4
+ *
5
+ * Per-command skills are agent-name-agnostic.
6
+ * The main kgraph workflow skill is parameterised by agent name.
7
+ */
8
+ import type { IntegrationCommandFile } from './integration-registry.js';
9
+ /** Per-command skills shared across all agent-skill integrations. */
10
+ export declare const SHARED_AGENT_SKILLS: IntegrationCommandFile[];
11
+ /**
12
+ * Build the full agent skill list for an adapter: the main workflow skill
13
+ * (parameterised by agent name) plus all shared per-command skills.
14
+ */
15
+ export declare function agentSkillFiles(agentName: string): IntegrationCommandFile[];
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Shared agent skill definitions used by any integration that writes
3
+ * `.agents/skills/` SKILL.md files (copilot, codex, etc.).
4
+ *
5
+ * Per-command skills are agent-name-agnostic.
6
+ * The main kgraph workflow skill is parameterised by agent name.
7
+ */
8
+ import { numberedWorkflow } from './workflow-steps.js';
9
+ /** Per-command skills shared across all agent-skill integrations. */
10
+ export const SHARED_AGENT_SKILLS = [
11
+ {
12
+ path: '.agents/skills/kgraph-doctor/SKILL.md',
13
+ content: `---
14
+ name: kgraph-doctor
15
+ description: Check KGraph workspace health and next actions
16
+ ---
17
+
18
+ Run \`kgraph doctor\` to check whether the workspace is initialized, maps exist, inbox notes are pending, and configured integrations point to real files. Use \`kgraph doctor --quality\` when the user asks about stale or noisy cognition references. Summarize any failed checks and the next command to run.
19
+ `,
20
+ },
21
+ {
22
+ path: '.agents/skills/kgraph-repair/SKILL.md',
23
+ content: `---
24
+ name: kgraph-repair
25
+ description: Preview or clean stale/noisy KGraph cognition references
26
+ ---
27
+
28
+ Run \`kgraph repair --dry-run\` first and summarize the proposed atom-reference cleanup. Run \`kgraph repair\` only when the user asks to apply the cleanup.
29
+ `,
30
+ },
31
+ {
32
+ path: '.agents/skills/kgraph-compact/SKILL.md',
33
+ content: `---
34
+ name: kgraph-compact
35
+ description: Merge duplicate KGraph cognition and archive stale low-value entries
36
+ ---
37
+
38
+ Run \`kgraph compact --dry-run\` first and summarize duplicate cognition groups and stale low-confidence notes. Run \`kgraph compact\` only when the user asks to apply compaction.
39
+ `,
40
+ },
41
+ {
42
+ path: '.agents/skills/kgraph-pack/SKILL.md',
43
+ content: `---
44
+ name: kgraph-pack
45
+ description: Build a budget-aware KGraph context pack
46
+ ---
47
+
48
+ Run \`kgraph pack "$ARGUMENTS" --budget 8000 --json\` to build a machine-readable context pack. Summarize token use, included files, symbols, relationships, git changes, session history, atoms, and omitted items with the inclusion reasons.
49
+ `,
50
+ },
51
+ {
52
+ path: '.agents/skills/kgraph-knowledge/SKILL.md',
53
+ content: `---
54
+ name: kgraph-knowledge
55
+ description: Inspect or manage KGraph canonical knowledge atoms
56
+ ---
57
+
58
+ Use \`kgraph knowledge list\` and \`kgraph knowledge get <atom-id>\` to inspect durable atoms, evidence, provenance, and lifecycle. Run \`kgraph knowledge archive <atom-id>\` or \`kgraph knowledge supersede <old-id> <new-id>\` only when the user explicitly asks to mutate atom lifecycle.
59
+ `,
60
+ },
61
+ {
62
+ path: '.agents/skills/kgraph-stale/SKILL.md',
63
+ content: `---
64
+ name: kgraph-stale
65
+ description: Show KGraph knowledge invalidated by changed or missing refs
66
+ ---
67
+
68
+ Run \`kgraph stale\` to refresh atom status against the current scan and summarize stale or needs-review atoms with invalidation reasons.
69
+ `,
70
+ },
71
+ {
72
+ path: '.agents/skills/kgraph-blame/SKILL.md',
73
+ content: `---
74
+ name: kgraph-blame
75
+ description: Show KGraph atom provenance and evidence
76
+ ---
77
+
78
+ Run \`kgraph blame "$ARGUMENTS"\` to show who or what created a knowledge atom, the source command/session/commit, evidence refs, and lifecycle links.
79
+ `,
80
+ },
81
+ {
82
+ path: '.agents/skills/kgraph-scan/SKILL.md',
83
+ content: `---
84
+ name: kgraph-scan
85
+ description: Refresh KGraph file, symbol, import, and relationship maps
86
+ ---
87
+
88
+ Run \`kgraph scan\` to refresh the repository maps, then summarize what changed.
89
+ `,
90
+ },
91
+ {
92
+ path: '.agents/skills/kgraph-update/SKILL.md',
93
+ content: `---
94
+ name: kgraph-update
95
+ description: Process KGraph inbox notes into durable cognition
96
+ ---
97
+
98
+ Run \`kgraph update\` to process any pending Markdown notes in \`.kgraph/inbox/\` into durable cognition.
99
+ `,
100
+ },
101
+ {
102
+ path: '.agents/skills/kgraph-visualize/SKILL.md',
103
+ content: `---
104
+ name: kgraph-visualize
105
+ description: Open interactive KGraph dependency graph in browser
106
+ ---
107
+
108
+ Run \`kgraph visualize\` to start the interactive dependency graph at http://localhost:4242, then summarize what nodes and connections are visible.
109
+ `,
110
+ },
111
+ {
112
+ path: '.agents/skills/kgraph-capture/SKILL.md',
113
+ content: `---
114
+ name: kgraph-capture
115
+ description: Save what was just built or changed into KGraph cognition
116
+ ---
117
+
118
+ Capture this session into KGraph cognition.
119
+
120
+ {{KGRAPH_CAPTURE_POLICY}}
121
+ `,
122
+ },
123
+ {
124
+ path: '.agents/skills/kgraph-conclude/SKILL.md',
125
+ content: `---
126
+ name: kgraph-conclude
127
+ description: Store a typed durable KGraph engineering conclusion
128
+ ---
129
+
130
+ Prefer \`kgraph "<topic>" --capture "$ARGUMENTS" --capture-file <path> --capture-symbol <name>\` when the session produced reusable engineering knowledge. Use low-level \`kgraph conclude "$ARGUMENTS"\` only when the user explicitly asks for the conclude command. Choose one type from finding, decision, gotcha, summary, relationship, and one confidence from high, medium, low. Add file or symbol evidence whenever possible; high-confidence conclusions require evidence. Store only durable conclusions, not raw chain-of-thought, temporary reasoning, speculative exploration, or low-value observations.
131
+ `,
132
+ },
133
+ {
134
+ path: '.agents/skills/kgraph-impact/SKILL.md',
135
+ content: `---
136
+ name: kgraph-impact
137
+ description: Show KGraph change impact for a file, symbol, or topic
138
+ ---
139
+
140
+ Run \`kgraph impact "$ARGUMENTS"\` to show matched files/symbols, import users, callers, callees, related knowledge atoms, and risk hints.
141
+ `,
142
+ },
143
+ {
144
+ path: '.agents/skills/kgraph-session/SKILL.md',
145
+ content: `---
146
+ name: kgraph-session
147
+ description: Track KGraph session read/write activity and token estimates
148
+ ---
149
+
150
+ Use \`kgraph session\` to inspect current session activity. Record meaningful events with \`kgraph session start --agent $AGENT\`, \`kgraph session read <path> --agent $AGENT\`, \`kgraph session write <path> --agent $AGENT\`, and \`kgraph session end --agent $AGENT --conclude --topic "<topic>"\` when durable session memory is useful.
151
+ `,
152
+ },
153
+ {
154
+ path: '.agents/skills/kgraph-history/SKILL.md',
155
+ content: `---
156
+ name: kgraph-history
157
+ description: Show timeline of KGraph cognition sessions with git attribution
158
+ ---
159
+
160
+ Run \`kgraph history\` or \`kgraph history "$ARGUMENTS"\` to display processed cognition sessions. Summarize who contributed what and when. Use \`--last <n>\` to limit entries.
161
+ `,
162
+ },
163
+ ];
164
+ /**
165
+ * Build the full agent skill list for an adapter: the main workflow skill
166
+ * (parameterised by agent name) plus all shared per-command skills.
167
+ */
168
+ export function agentSkillFiles(agentName) {
169
+ return [
170
+ {
171
+ path: '.agents/skills/kgraph/SKILL.md',
172
+ content: `---
173
+ name: kgraph
174
+ description: Use KGraph persistent repo intelligence according to the configured integration mode. Use when asked about repo structure, debugging context, architecture decisions, or to avoid rediscovering what is already known.
175
+ ---
176
+
177
+ # KGraph Skill
178
+
179
+ Workflow:
180
+
181
+ ${numberedWorkflow(agentName)}
182
+ `,
183
+ },
184
+ ...SHARED_AGENT_SKILLS,
185
+ ];
186
+ }
@@ -51,12 +51,15 @@ export function renderContextPolicy(mode) {
51
51
  }
52
52
  export function renderCapturePolicy() {
53
53
  return `Capture policy:
54
- - At the end of any session that changed repository files, store durable engineering memory with \`kgraph conclude "<topic>" --type <finding|decision|gotcha|summary|relationship> --confidence <high|medium|low>\` or \`kgraph session end --agent <agent> --conclude --topic "<topic>"\`.
54
+ - At the end of any session that changed repository files, run \`kgraph "<topic>" --final\` before the final response so KGraph can enforce whether capture is required.
55
+ - If final check reports capture-required, run \`kgraph "<topic>" --capture "<durable conclusion>" --capture-file <path> --capture-symbol <name>\` to store durable engineering memory, or explicitly say "No durable knowledge created" only when there is genuinely no reusable knowledge.
56
+ - Low-level alternatives remain available: \`kgraph conclude "<topic>" --type <finding|decision|gotcha|summary|relationship> --confidence <high|medium|low>\` or \`kgraph session end --agent <agent> --conclude --topic "<topic>"\`.
57
+ - Add evidence when storing cognition. High-confidence conclusions must include at least one \`--file <path>\` or \`--symbol <name>\`; medium-confidence conclusions should include evidence when possible.
55
58
  - Preserve only expensive-to-rediscover findings, decisions, gotchas, summaries, and relationships. Do not store raw chain-of-thought, temporary reasoning, speculative exploration, or low-value observations.
56
59
  - Use \`.kgraph/inbox/<slug>.md\` only when a longer structured note is clearer than a single \`kgraph conclude\` command.
57
60
  - A \`.kgraph/inbox/*.md\` note is KGraph runtime capture, not project documentation. It is allowed by this workflow unless the user explicitly says not to capture to KGraph.
58
61
  - Do not skip capture for meaningful UI text, button, link, route, styling, or small file edits. Skip capture only when no reusable repository knowledge was created.
59
- - Do not run KGraph repeatedly. Run it once at the start with \`kgraph pack "<topic>" --budget 8000 --json\` for agent-readable context. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
62
+ - Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\` or \`kgraph pack "<topic>" --budget 8000 --json\` for agent-readable context. If repo files changed, run \`kgraph "<topic>" --final\` once before the final answer.
60
63
  - After the final \`kgraph\` run, mention whether durable cognition was stored or processed.
61
64
 
62
65
  When using an inbox note, use this structure:
@@ -1,4 +1,4 @@
1
- import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
1
+ import { mkdir, readdir, readFile, rm, rmdir, writeFile, } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { loadConfig, saveConfig } from '../config/config.js';
4
4
  import { pathExists } from '../storage/kgraph-paths.js';
@@ -19,6 +19,7 @@ export async function addIntegrations(workspace, names, mode = 'always') {
19
19
  const config = await loadConfig(workspace);
20
20
  const byName = new Map(config.integrations.map((integration) => [integration.name, integration]));
21
21
  const changed = [];
22
+ const writtenCommandFiles = new Set();
22
23
  for (const name of names) {
23
24
  const adapter = getIntegrationAdapter(name);
24
25
  const next = {
@@ -34,10 +35,14 @@ export async function addIntegrations(workspace, names, mode = 'always') {
34
35
  }
35
36
  else {
36
37
  await writeIntegrationInstructions(workspace.rootPath, adapter.targetPath, adapter.name, applyContextPolicy(adapter.instructions, mode));
37
- await writeIntegrationCommandFiles(workspace.rootPath, (adapter.commandFiles ?? []).map((file) => ({
38
+ const deduped = (adapter.commandFiles ?? []).filter((file) => !writtenCommandFiles.has(file.path));
39
+ await writeIntegrationCommandFiles(workspace.rootPath, deduped.map((file) => ({
38
40
  ...file,
39
41
  content: applyContextPolicy(file.content, mode),
40
42
  })));
43
+ for (const file of adapter.commandFiles ?? []) {
44
+ writtenCommandFiles.add(file.path);
45
+ }
41
46
  }
42
47
  await removeIntegrationCommandFiles(workspace.rootPath, adapter.obsoleteCommandFiles ?? []);
43
48
  changed.push(next);
@@ -53,10 +58,21 @@ export async function removeIntegrations(workspace, names) {
53
58
  const config = await loadConfig(workspace);
54
59
  const removeNames = new Set(names);
55
60
  const removed = [];
61
+ // Collect command-file paths still owned by remaining enabled integrations
62
+ const retainedPaths = new Set();
63
+ for (const integration of config.integrations) {
64
+ if (removeNames.has(integration.name) || !integration.enabled) {
65
+ continue;
66
+ }
67
+ const adapter = getIntegrationAdapter(integration.name);
68
+ for (const file of adapter.commandFiles ?? []) {
69
+ retainedPaths.add(file.path);
70
+ }
71
+ }
56
72
  for (const name of removeNames) {
57
73
  const adapter = getIntegrationAdapter(name);
58
74
  await removeIntegrationInstructions(workspace.rootPath, adapter.targetPath, adapter.name);
59
- await removeIntegrationCommandFiles(workspace.rootPath, adapter.commandFiles ?? []);
75
+ await removeIntegrationCommandFiles(workspace.rootPath, (adapter.commandFiles ?? []).filter((file) => !retainedPaths.has(file.path)));
60
76
  await removeIntegrationCommandFiles(workspace.rootPath, adapter.obsoleteCommandFiles ?? []);
61
77
  removed.push(adapter.name);
62
78
  }
@@ -96,6 +112,21 @@ async function writeIntegrationCommandFiles(rootPath, files) {
96
112
  async function removeIntegrationCommandFiles(rootPath, files) {
97
113
  for (const file of files) {
98
114
  const filePath = typeof file === 'string' ? file : file.path;
99
- await rm(path.join(rootPath, filePath), { force: true, recursive: true });
115
+ const fullPath = path.join(rootPath, filePath);
116
+ await rm(fullPath, { force: true, recursive: true });
117
+ // Remove empty parent directories up to (but not including) rootPath
118
+ let dir = path.dirname(fullPath);
119
+ while (dir !== rootPath && dir.startsWith(rootPath)) {
120
+ try {
121
+ const entries = await readdir(dir);
122
+ if (entries.length > 0)
123
+ break;
124
+ await rmdir(dir);
125
+ dir = path.dirname(dir);
126
+ }
127
+ catch {
128
+ break;
129
+ }
130
+ }
100
131
  }
101
132
  }
@@ -9,6 +9,7 @@ const COMPACT_STEP = `Run \`kgraph compact --dry-run\` when cognition looks dupl
9
9
  const HISTORY_STEP = `Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.`;
10
10
  const KNOWLEDGE_STEP = `Run \`kgraph knowledge list --topic "<topic>"\` or \`kgraph knowledge get <atom-id>\` when the user asks what KGraph remembers or atom provenance/lifecycle matters.`;
11
11
  const PACK_STEP = `Treat \`kgraph pack "<task>" --budget 8000 --json\` as the primary agent contract: use atoms, source ranges, git changes, omitted items, and inclusion reasons from the ContextPack before reading files. Use human \`kgraph "<topic>"\` output only when the user explicitly wants a briefing.`;
12
+ const SMART_ROOT_STEP = `Prefer the root workflow for normal agent work: run \`kgraph "<topic>"\` to refresh maps, process cognition, report memory health, and return context; run \`kgraph "<topic>" --final\` before the final answer when repository files changed; run \`kgraph "<topic>" --capture "<durable conclusion>" --capture-file <path> --capture-symbol <name>\` when the final check requires durable knowledge.`;
12
13
  const STALE_STEP = `Run \`kgraph stale\` when changed or deleted code may have invalidated durable knowledge. Run \`kgraph blame <atom-id>\` when provenance or evidence for a memory matters.`;
13
14
  const EXPLORATION_BOUNDARY_STEP = `Keep exploration bounded by the task. For simple edits, use KGraph to identify the likely file, then read only that file or a narrow range and make the edit. Do not keep searching after the target file is found, do not retry malformed shell commands with broader variants, and do not run broad \`find\`, recursive \`grep\`, or repeated full-file dumps after KGraph already returned candidate files. Use \`rg --files\` and quoted paths when a path must be located.`;
14
15
  const VERIFY_EDIT_STEP = `After editing, verify the change actually landed before claiming completion. Prefer a narrow read of the changed range or \`git diff -- <path>\`; if there is no diff or the expected text is missing, say the edit did not apply and fix it before summarizing.`;
@@ -26,19 +27,20 @@ export function numberedWorkflow(agentName, options = {}) {
26
27
  3. Use the returned files, symbols, relationships, and cognition before broad exploration.
27
28
  4. ${EXPLORATION_BOUNDARY_STEP}
28
29
  5. ${VERIFY_EDIT_STEP}
29
- 6. ${PACK_STEP}
30
- 7. ${KNOWLEDGE_STEP}
31
- 8. ${DOCTOR_STEP}
32
- 9. ${STALE_STEP}
33
- 10. ${sessionStep(agentName, options.sessionQualifier)}
34
- 11. ${IMPACT_STEP}
30
+ 6. ${SMART_ROOT_STEP}
31
+ 7. ${PACK_STEP}
32
+ 8. ${KNOWLEDGE_STEP}
33
+ 9. ${DOCTOR_STEP}
34
+ 10. ${STALE_STEP}
35
+ 11. ${sessionStep(agentName, options.sessionQualifier)}
36
+ 12. ${IMPACT_STEP}
35
37
 
36
38
  {{KGRAPH_CAPTURE_POLICY}}
37
39
 
38
- 12. ${REPAIR_STEP}
39
- 13. ${COMPACT_STEP}
40
- 14. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
41
- 15. ${HISTORY_STEP}`;
40
+ 13. ${REPAIR_STEP}
41
+ 14. ${COMPACT_STEP}
42
+ 15. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
43
+ 16. ${HISTORY_STEP}`;
42
44
  }
43
45
  /**
44
46
  * Returns the bullet-list workflow for rules files.
@@ -48,6 +50,7 @@ export function bulletWorkflow(agentName, options = {}) {
48
50
  return `- {{KGRAPH_CONTEXT_POLICY}}
49
51
  - ${EXPLORATION_BOUNDARY_STEP}
50
52
  - ${VERIFY_EDIT_STEP}
53
+ - ${SMART_ROOT_STEP}
51
54
  - ${PACK_STEP}
52
55
  - ${KNOWLEDGE_STEP}
53
56
  - ${DOCTOR_STEP}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kentwynn/kgraph",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "Persistent repo intelligence for AI coding assistants.",
5
5
  "type": "module",
6
6
  "bin": {