@kentwynn/kgraph 0.2.3 → 0.2.4

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
@@ -267,7 +267,7 @@ kgraph integrate list
267
267
  kgraph integrate remove cursor
268
268
  ```
269
269
 
270
- New integrations default to `always` mode because coding agents often under-classify small UI, route, button, and link changes as not needing repo context.
270
+ New integrations default to `smart` mode. Use `--mode always` to force KGraph on every chat, or `--mode manual` to run only when explicitly asked.
271
271
 
272
272
  | Mode | Behavior |
273
273
  | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -14,7 +14,7 @@ export function registerInitCommand(program) {
14
14
  .description('Initialize a .kgraph workspace')
15
15
  .option('--integration <name>', 'Configure an AI tool integration', collectOption, [])
16
16
  .option('--integrations <names>', 'Configure comma-separated AI tool integrations')
17
- .option('--mode <mode>', 'Integration mode: always, smart, manual, or off', 'always')
17
+ .option('--mode <mode>', 'Integration mode: always, smart, manual, or off', 'smart')
18
18
  .action((options) => runCommand(async () => {
19
19
  const workspace = await ensureWorkspace(process.cwd());
20
20
  const wroteConfig = await writeDefaultConfig(workspace);
@@ -53,7 +53,7 @@ export function registerInitCommand(program) {
53
53
  })) {
54
54
  const selected = await promptForInitIntegrations(recommendedIntegrations);
55
55
  if (selected.length > 0) {
56
- const changed = await addIntegrations(workspace, selected, 'always');
56
+ const changed = await addIntegrations(workspace, selected, 'smart');
57
57
  console.log(`Configured integrations: ${changed.map((item) => `${item.name}:${item.mode}`).join(', ')}`);
58
58
  config = await loadConfig(workspace);
59
59
  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', 'always')
28
+ .option('--mode <mode>', 'always, smart, manual, or off', 'smart')
29
29
  .action((names, options) => runCommand(async () => {
30
30
  const workspace = await assertWorkspace(process.cwd());
31
31
  const normalized = normalizeIntegrationNames(names);
@@ -1,3 +1,4 @@
1
+ import { numberedWorkflow } from '../workflow-steps.js';
1
2
  export const claudeCodeAdapter = {
2
3
  name: 'claude-code',
3
4
  label: 'Claude Code',
@@ -11,18 +12,7 @@ export const claudeCodeAdapter = {
11
12
  path: '.claude/commands/kgraph.md',
12
13
  content: `Use KGraph persistent repo intelligence for the current request.
13
14
 
14
- 1. Infer the topic from the user's request.
15
- 2. {{KGRAPH_CONTEXT_POLICY}}
16
- 3. Use the returned files, symbols, relationships, and cognition before broad exploration.
17
- 4. Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
18
- 5. Track meaningful session activity with \`kgraph session start --agent claude-code\`, \`kgraph session read <path> --agent claude-code\`, \`kgraph session write <path> --agent claude-code\`, and \`kgraph session end --agent claude-code\` when native hooks are unavailable.
19
- 6. Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
20
-
21
- {{KGRAPH_CAPTURE_POLICY}}
22
-
23
- 7. Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
24
- 8. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
25
- 9. Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
15
+ ${numberedWorkflow('claude-code', { sessionQualifier: 'when native hooks are unavailable' })}
26
16
  `,
27
17
  },
28
18
  {
@@ -1,16 +1,10 @@
1
+ import { bulletWorkflow } from '../workflow-steps.js';
1
2
  export const clineAdapter = {
2
3
  name: 'cline',
3
4
  label: 'Cline',
4
5
  targetPath: '.clinerules/kgraph.md',
5
6
  instructions: `# KGraph Workflow
6
7
 
7
- - {{KGRAPH_CONTEXT_POLICY}}
8
- - Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
9
- - Track meaningful session activity with \`kgraph session start --agent cline\`, \`kgraph session read <path> --agent cline\`, \`kgraph session write <path> --agent cline\`, and \`kgraph session end --agent cline\`.
10
- - Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
11
- {{KGRAPH_CAPTURE_POLICY}}
12
- - Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
13
- - Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
14
- - Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
8
+ ${bulletWorkflow('cline')}
15
9
  `,
16
10
  };
@@ -1,3 +1,4 @@
1
+ import { numberedWorkflow } from '../workflow-steps.js';
1
2
  export const codexAdapter = {
2
3
  name: 'codex',
3
4
  label: 'Codex',
@@ -18,23 +19,12 @@ description: Use KGraph persistent repo intelligence according to the configured
18
19
 
19
20
  Workflow:
20
21
 
21
- 1. Infer the current topic from the user request.
22
- 2. {{KGRAPH_CONTEXT_POLICY}}
23
- 3. Use KGraph's returned files, symbols, relationships, and cognition as navigation hints.
24
- 4. Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
25
- 5. Track meaningful session activity with \`kgraph session start --agent codex\`, \`kgraph session read <path> --agent codex\`, \`kgraph session write <path> --agent codex\`, and \`kgraph session end --agent codex\`.
26
- 6. Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
27
-
28
- {{KGRAPH_CAPTURE_POLICY}}
29
-
30
- 7. Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
31
- 8. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
32
- 9. Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
22
+ ${numberedWorkflow('codex')}
33
23
  `,
34
24
  },
35
25
  ],
36
26
  obsoleteCommandFiles: [
37
- '.agents/skills/kgraph-update',
38
- '.agents/skills/kgraph-scan',
27
+ '.agents/skills/kgraph-scan/SKILL.md',
28
+ '.agents/skills/kgraph-update/SKILL.md',
39
29
  ],
40
30
  };
@@ -1,19 +1,33 @@
1
+ import { numberedWorkflow } from '../workflow-steps.js';
1
2
  export const copilotAdapter = {
2
3
  name: 'copilot',
3
4
  label: 'GitHub Copilot',
4
5
  targetPath: '.github/copilot-instructions.md',
5
6
  instructions: `## KGraph Workflow
6
7
 
7
- 1. {{KGRAPH_CONTEXT_POLICY}}
8
- 2. Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
9
- 3. Track meaningful session activity with \`kgraph session start --agent copilot\`, \`kgraph session read <path> --agent copilot\`, \`kgraph session write <path> --agent copilot\`, and \`kgraph session end --agent copilot\`.
10
- 4. Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
8
+ ${numberedWorkflow('copilot')}
9
+ `,
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, scan, update, 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
+ ---
11
23
 
12
- {{KGRAPH_CAPTURE_POLICY}}
24
+ ## KGraph Agent
25
+
26
+ You are a KGraph-powered agent. Before exploring the repository freely, always:
13
27
 
14
- 5. Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
28
+ ${numberedWorkflow('copilot')}
15
29
  `,
16
- commandFiles: [
30
+ },
17
31
  {
18
32
  path: '.github/prompts/kgraph-doctor.prompt.md',
19
33
  content: `---
@@ -112,5 +126,8 @@ Run \`kgraph history\` or \`kgraph history "$ARGUMENTS"\` to display processed c
112
126
  `,
113
127
  },
114
128
  ],
115
- obsoleteCommandFiles: ['.github/prompts/kgraph.prompt.md'],
129
+ obsoleteCommandFiles: [
130
+ '.github/prompts/kgraph.prompt.md',
131
+ '.github/kgraph.agent.md',
132
+ ],
116
133
  };
@@ -1,3 +1,4 @@
1
+ import { bulletWorkflow } from '../workflow-steps.js';
1
2
  export const cursorAdapter = {
2
3
  name: 'cursor',
3
4
  label: 'Cursor',
@@ -9,14 +10,7 @@ alwaysApply: true
9
10
 
10
11
  ## KGraph Workflow
11
12
 
12
- - {{KGRAPH_CONTEXT_POLICY}}
13
- - Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
14
- - Track meaningful session activity with \`kgraph session start --agent cursor\`, \`kgraph session read <path> --agent cursor\`, \`kgraph session write <path> --agent cursor\`, and \`kgraph session end --agent cursor\`.
15
- - Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
16
- {{KGRAPH_CAPTURE_POLICY}}
17
- - Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
18
- - Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
19
- - Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
13
+ ${bulletWorkflow('cursor')}
20
14
  `,
21
15
  obsoleteCommandFiles: ['.cursor/rules/kgraph-commands.mdc'],
22
16
  };
@@ -1,16 +1,10 @@
1
+ import { bulletWorkflow } from '../workflow-steps.js';
1
2
  export const geminiAdapter = {
2
3
  name: 'gemini',
3
4
  label: 'Gemini CLI',
4
5
  targetPath: 'GEMINI.md',
5
6
  instructions: `## KGraph Workflow
6
7
 
7
- - {{KGRAPH_CONTEXT_POLICY}}
8
- - Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
9
- - Track meaningful session activity with \`kgraph session start --agent gemini\`, \`kgraph session read <path> --agent gemini\`, \`kgraph session write <path> --agent gemini\`, and \`kgraph session end --agent gemini\`.
10
- - Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
11
- {{KGRAPH_CAPTURE_POLICY}}
12
- - Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
13
- - Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
14
- - Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
8
+ ${bulletWorkflow('gemini')}
15
9
  `,
16
10
  };
@@ -1,16 +1,10 @@
1
+ import { bulletWorkflow } from '../workflow-steps.js';
1
2
  export const windsurfAdapter = {
2
3
  name: 'windsurf',
3
4
  label: 'Windsurf',
4
5
  targetPath: '.windsurf/rules/kgraph.md',
5
6
  instructions: `# KGraph Workflow
6
7
 
7
- - {{KGRAPH_CONTEXT_POLICY}}
8
- - Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.
9
- - Track meaningful session activity with \`kgraph session start --agent windsurf\`, \`kgraph session read <path> --agent windsurf\`, \`kgraph session write <path> --agent windsurf\`, and \`kgraph session end --agent windsurf\`.
10
- - Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.
11
- {{KGRAPH_CAPTURE_POLICY}}
12
- - Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.
13
- - Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
14
- - Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
8
+ ${bulletWorkflow('windsurf')}
15
9
  `,
16
10
  };
@@ -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 = 'always') {
18
+ export async function addIntegrations(workspace, names, mode = 'smart') {
19
19
  const config = await loadConfig(workspace);
20
20
  const byName = new Map(config.integrations.map((integration) => [integration.name, integration]));
21
21
  const changed = [];
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared KGraph workflow step strings used across all AI tool adapters.
3
+ * Update here once instead of in each adapter file.
4
+ */
5
+ export interface WorkflowOptions {
6
+ /** Qualifier appended to the session step, e.g. "when native hooks are unavailable" */
7
+ sessionQualifier?: string;
8
+ }
9
+ /**
10
+ * Returns the 9-step numbered workflow for skill/agent/command files.
11
+ * Used by: copilot (agent file), codex (skill file), claude-code (command file).
12
+ */
13
+ export declare function numberedWorkflow(agentName: string, options?: WorkflowOptions): string;
14
+ /**
15
+ * Returns the bullet-list workflow for rules files.
16
+ * Used by: cursor, cline, windsurf, gemini.
17
+ */
18
+ export declare function bulletWorkflow(agentName: string, options?: WorkflowOptions): string;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared KGraph workflow step strings used across all AI tool adapters.
3
+ * Update here once instead of in each adapter file.
4
+ */
5
+ const DOCTOR_STEP = `Run \`kgraph doctor\` when setup, maps, inbox processing, or integrations look wrong. Run \`kgraph doctor --quality\` when context shows stale/noisy cognition references.`;
6
+ const IMPACT_STEP = `Run \`kgraph impact "<file-or-symbol>"\` when the user asks what a change may affect. Run \`kgraph history "<topic>"\` when prior work or decisions matter.`;
7
+ const REPAIR_STEP = `Run \`kgraph repair --dry-run\` before cleanup when stale/noisy cognition needs fixing. Run \`kgraph repair\` only when the user asks to apply that cleanup.`;
8
+ const HISTORY_STEP = `Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.`;
9
+ function sessionStep(agentName, qualifier) {
10
+ 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}\``;
11
+ return qualifier ? `${base} ${qualifier}.` : `${base}.`;
12
+ }
13
+ /**
14
+ * Returns the 9-step numbered workflow for skill/agent/command files.
15
+ * Used by: copilot (agent file), codex (skill file), claude-code (command file).
16
+ */
17
+ export function numberedWorkflow(agentName, options = {}) {
18
+ return `1. Infer the topic from the user's request.
19
+ 2. {{KGRAPH_CONTEXT_POLICY}}
20
+ 3. Use the returned files, symbols, relationships, and cognition before broad exploration.
21
+ 4. ${DOCTOR_STEP}
22
+ 5. ${sessionStep(agentName, options.sessionQualifier)}
23
+ 6. ${IMPACT_STEP}
24
+
25
+ {{KGRAPH_CAPTURE_POLICY}}
26
+
27
+ 7. ${REPAIR_STEP}
28
+ 8. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
29
+ 9. ${HISTORY_STEP}`;
30
+ }
31
+ /**
32
+ * Returns the bullet-list workflow for rules files.
33
+ * Used by: cursor, cline, windsurf, gemini.
34
+ */
35
+ export function bulletWorkflow(agentName, options = {}) {
36
+ return `- {{KGRAPH_CONTEXT_POLICY}}
37
+ - ${DOCTOR_STEP}
38
+ - ${sessionStep(agentName, options.sessionQualifier)}
39
+ - ${IMPACT_STEP}
40
+ {{KGRAPH_CAPTURE_POLICY}}
41
+ - ${REPAIR_STEP}
42
+ - Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
43
+ - ${HISTORY_STEP}`;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kentwynn/kgraph",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Persistent repo intelligence for AI coding assistants.",
5
5
  "type": "module",
6
6
  "bin": {