@kentwynn/kgraph 0.2.12 → 0.2.13

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
@@ -308,13 +308,13 @@ KGraph integrations are local files. They do not start background agents, call A
308
308
 
309
309
  ```bash
310
310
  kgraph integrate add codex copilot cursor claude-code gemini windsurf cline
311
- kgraph integrate add copilot --mode always
311
+ kgraph integrate add copilot --mode smart
312
312
  kgraph integrate set copilot --mode manual
313
313
  kgraph integrate list
314
314
  kgraph integrate remove cursor
315
315
  ```
316
316
 
317
- New integrations default to `smart` mode. Use `--mode always` to force KGraph on every chat, or `--mode manual` to run only when explicitly asked.
317
+ New integrations default to `always` mode, so every chat in the repository starts with `kgraph "<topic>"`. Use `--mode smart` to run KGraph only for repo-specific work, or `--mode manual` to run only when explicitly asked.
318
318
 
319
319
  | Mode | Behavior |
320
320
  | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -15,7 +15,7 @@ export function registerInitCommand(program) {
15
15
  .description('Initialize a .kgraph workspace')
16
16
  .option('--integration <name>', 'Configure an AI tool integration', collectOption, [])
17
17
  .option('--integrations <names>', 'Configure comma-separated AI tool integrations')
18
- .option('--mode <mode>', 'Integration mode: always, smart, manual, or off', 'smart')
18
+ .option('--mode <mode>', 'Integration mode: always, smart, manual, or off', 'always')
19
19
  .action((options) => runCommand(async () => {
20
20
  const workspace = await ensureWorkspace(process.cwd());
21
21
  await ensureKnowledgeStore(workspace);
@@ -55,7 +55,7 @@ export function registerInitCommand(program) {
55
55
  })) {
56
56
  const selected = await promptForInitIntegrations(recommendedIntegrations);
57
57
  if (selected.length > 0) {
58
- const changed = await addIntegrations(workspace, selected, 'smart');
58
+ const changed = await addIntegrations(workspace, selected, 'always');
59
59
  console.log(`Configured integrations: ${changed.map((item) => `${item.name}:${item.mode}`).join(', ')}`);
60
60
  config = await loadConfig(workspace);
61
61
  recommendedIntegrations = recommendedIntegrationsForInit({
@@ -25,7 +25,7 @@ export function registerIntegrateCommand(program) {
25
25
  .command('add')
26
26
  .description('Add AI tool integrations')
27
27
  .argument('<names...>')
28
- .option('--mode <mode>', 'always, smart, manual, or off', 'smart')
28
+ .option('--mode <mode>', 'always, smart, manual, or off', 'always')
29
29
  .action((names, options) => runCommand(async () => {
30
30
  const workspace = await assertWorkspace(process.cwd());
31
31
  const normalized = normalizeIntegrationNames(names);
@@ -1,8 +1,13 @@
1
1
  import { rm } from 'node:fs/promises';
2
+ import path from 'node:path';
2
3
  import { loadConfig } from '../../config/config.js';
3
4
  import { removeIntegrations } from '../../integrations/integration-store.js';
4
5
  import { pathExists, resolveWorkspace } from '../../storage/kgraph-paths.js';
5
6
  import { runCommand } from '../errors.js';
7
+ const LEGACY_GENERATED_FILES = [
8
+ '.github/agents/kgraph.agent.md',
9
+ '.github/kgraph.agent.md',
10
+ ];
6
11
  export function registerUninstallCommand(program) {
7
12
  program
8
13
  .command('uninstall')
@@ -28,6 +33,7 @@ export function registerUninstallCommand(program) {
28
33
  !options.keepIntegrations &&
29
34
  configuredIntegrations.length > 0) {
30
35
  await removeIntegrations(workspace, configuredIntegrations);
36
+ await removeLegacyGeneratedFiles(workspace.rootPath);
31
37
  }
32
38
  if (initialized) {
33
39
  await rm(workspace.kgraphPath, { recursive: true, force: true });
@@ -37,6 +43,9 @@ export function registerUninstallCommand(program) {
37
43
  console.log('Run `kgraph init` to set up this repository again.');
38
44
  }));
39
45
  }
46
+ async function removeLegacyGeneratedFiles(rootPath) {
47
+ await Promise.all(LEGACY_GENERATED_FILES.map((filePath) => rm(path.join(rootPath, filePath), { force: true })));
48
+ }
40
49
  function printUninstallPreview(input) {
41
50
  console.log('KGraph Uninstall Preview');
42
51
  console.log('');
package/dist/cli/help.js CHANGED
@@ -50,8 +50,8 @@ export function renderRootHelp(useColor = supportsColor()) {
50
50
  '',
51
51
  theme.bold('Integrations'),
52
52
  command('integrate list', 'Show configured AI tool integrations'),
53
- command('integrate add gemini windsurf cline', 'Write KGraph instructions using smart mode by default'),
54
- command('integrate add copilot --mode always', 'Every Copilot chat starts with kgraph "<topic>"'),
53
+ command('integrate add gemini windsurf cline', 'Write KGraph instructions using always mode by default'),
54
+ command('integrate add copilot --mode smart', 'Run KGraph for repo-specific Copilot work only'),
55
55
  command('integrate set copilot --mode manual', 'Only run KGraph when explicitly requested'),
56
56
  command('integrate remove cursor', 'Remove KGraph-managed instruction blocks'),
57
57
  command('--mode smart|always|manual|off', 'Control automatic KGraph involvement per integration'),
@@ -157,7 +157,7 @@ function normalizeIntegrations(value) {
157
157
  return integrations;
158
158
  }
159
159
  function normalizeIntegrationMode(value) {
160
- return value === 'always' || value === 'manual' || value === 'off'
160
+ return value === 'smart' || value === 'manual' || value === 'off'
161
161
  ? value
162
- : 'smart';
162
+ : 'always';
163
163
  }
@@ -1,4 +1,3 @@
1
- import { numberedWorkflow } from '../workflow-steps.js';
2
1
  export const claudeCodeAdapter = {
3
2
  name: 'claude-code',
4
3
  label: 'Claude Code',
@@ -6,13 +5,22 @@ export const claudeCodeAdapter = {
6
5
  instructions: `## KGraph Workflow
7
6
 
8
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}}
9
10
  `,
10
11
  commandFiles: [
11
12
  {
12
13
  path: '.claude/commands/kgraph.md',
13
- content: `Use KGraph persistent repo intelligence for the current request.
14
+ content: `Use KGraph persistent repo intelligence through the single normal \`kgraph "<topic>"\` entry point.
14
15
 
15
- ${numberedWorkflow('claude-code', { sessionQualifier: 'when native hooks are unavailable' })}
16
+ 1. Infer a concise topic from the user's request.
17
+ 2. Run exactly one command from the repository root: \`kgraph "<topic>"\`.
18
+ 3. Treat the returned files, symbols, relationships, atoms, and warnings as the first-pass source of truth.
19
+ 4. If the user asked for an edit, inspect only the returned candidate file or the smallest necessary range, then make the edit.
20
+ 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
+ 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
+ 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.
16
24
  `,
17
25
  },
18
26
  {
@@ -8,26 +8,6 @@ export const copilotAdapter = {
8
8
  ${numberedWorkflow('copilot')}
9
9
  `,
10
10
  commandFiles: [
11
- {
12
- path: '.github/agents/kgraph.agent.md',
13
- content: `---
14
- name: kgraph
15
- description: Use KGraph persistent repo intelligence to answer questions about this codebase. Runs kgraph context, pack, knowledge, stale, blame, scan, update, conclude, compact, impact, history, and session commands to ground responses in durable local knowledge.
16
- tools:
17
- - run_in_terminal
18
- - read_file
19
- - file_search
20
- - grep_search
21
- - semantic_search
22
- ---
23
-
24
- ## KGraph Agent
25
-
26
- You are a KGraph-powered agent. Before exploring the repository freely, always:
27
-
28
- ${numberedWorkflow('copilot')}
29
- `,
30
- },
31
11
  {
32
12
  path: '.github/prompts/kgraph-doctor.prompt.md',
33
13
  content: `---
@@ -36,16 +36,17 @@ export function applyContextPolicy(content, mode) {
36
36
  .replaceAll(KGRAPH_CAPTURE_POLICY_PLACEHOLDER, renderCapturePolicy());
37
37
  }
38
38
  export function renderContextPolicy(mode) {
39
+ const useResultBoundary = 'Use the returned KGraph candidate files as the first-pass source of truth. Do not rerun the same KGraph query just to tail or reformat output, do not continue broad repository search after the target file is identified, do not retry malformed shell commands with broader variants, and do not run broad `find`, recursive `grep`, or repeated full-file dumps after KGraph has narrowed the target.';
39
40
  switch (mode) {
40
41
  case 'always':
41
- return 'Every chat in this repository must start by running `kgraph "<topic>"` before answering or exploring files. Infer the topic from the user\'s message; no exceptions, including simple or conversational requests.';
42
+ return `Every chat in this repository must start by running \`kgraph "<topic>"\` before answering or exploring files. Infer the topic from the user's message; no exceptions, including simple or conversational requests. ${useResultBoundary}`;
42
43
  case 'manual':
43
44
  return 'Do not run KGraph automatically. Run `kgraph "<topic>"` only when the user explicitly asks for KGraph context or invokes the KGraph command.';
44
45
  case 'off':
45
46
  return 'KGraph is disabled for this integration.';
46
47
  case 'smart':
47
48
  default:
48
- return 'For repo-specific coding, debugging, architecture, refactor, review, or file-exploration requests, run `kgraph "<topic>"` before broad repository exploration. Infer the topic from the user\'s message. Skip KGraph for simple conversational requests that do not depend on repo knowledge.';
49
+ return `For repo-specific coding, debugging, architecture, refactor, review, or file-exploration requests, run \`kgraph "<topic>"\` before broad repository exploration. Infer the topic from the user's message. Skip KGraph for simple conversational requests that do not depend on repo knowledge. ${useResultBoundary}`;
49
50
  }
50
51
  }
51
52
  export function renderCapturePolicy() {
@@ -15,7 +15,7 @@ export async function listIntegrations(workspace) {
15
15
  })));
16
16
  return statuses.sort((left, right) => left.name.localeCompare(right.name));
17
17
  }
18
- export async function addIntegrations(workspace, names, mode = 'smart') {
18
+ 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 = [];
@@ -10,6 +10,8 @@ const HISTORY_STEP = `Run \`kgraph history\` or \`kgraph history "<topic>"\` to
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 = `Run \`kgraph pack "<task>" --budget 8000 --json\` when an agent needs a machine-readable, token-budgeted context pack instead of human Markdown context.`;
12
12
  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
+ 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
+ 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.`;
13
15
  function sessionStep(agentName, qualifier) {
14
16
  const base = `Track meaningful session activity with \`kgraph session start --agent ${agentName}\`, \`kgraph session read <path> --agent ${agentName}\`, \`kgraph session write <path> --agent ${agentName}\`, and \`kgraph session end --agent ${agentName} --conclude --topic "<topic>"\` when durable session memory is useful`;
15
17
  return qualifier ? `${base} ${qualifier}.` : `${base}.`;
@@ -22,19 +24,21 @@ export function numberedWorkflow(agentName, options = {}) {
22
24
  return `1. Infer the topic from the user's request.
23
25
  2. {{KGRAPH_CONTEXT_POLICY}}
24
26
  3. Use the returned files, symbols, relationships, and cognition before broad exploration.
25
- 4. ${PACK_STEP}
26
- 5. ${KNOWLEDGE_STEP}
27
- 6. ${DOCTOR_STEP}
28
- 7. ${STALE_STEP}
29
- 8. ${sessionStep(agentName, options.sessionQualifier)}
30
- 9. ${IMPACT_STEP}
27
+ 4. ${EXPLORATION_BOUNDARY_STEP}
28
+ 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}
31
35
 
32
36
  {{KGRAPH_CAPTURE_POLICY}}
33
37
 
34
- 10. ${REPAIR_STEP}
35
- 11. ${COMPACT_STEP}
36
- 12. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
37
- 13. ${HISTORY_STEP}`;
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}`;
38
42
  }
39
43
  /**
40
44
  * Returns the bullet-list workflow for rules files.
@@ -42,6 +46,8 @@ export function numberedWorkflow(agentName, options = {}) {
42
46
  */
43
47
  export function bulletWorkflow(agentName, options = {}) {
44
48
  return `- {{KGRAPH_CONTEXT_POLICY}}
49
+ - ${EXPLORATION_BOUNDARY_STEP}
50
+ - ${VERIFY_EDIT_STEP}
45
51
  - ${PACK_STEP}
46
52
  - ${KNOWLEDGE_STEP}
47
53
  - ${DOCTOR_STEP}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kentwynn/kgraph",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Persistent repo intelligence for AI coding assistants.",
5
5
  "type": "module",
6
6
  "bin": {