@kentwynn/kgraph 0.1.23 → 0.1.24
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 +2 -2
- package/dist/integrations/adapters/claude-code.js +4 -22
- package/dist/integrations/adapters/cline.js +1 -4
- package/dist/integrations/adapters/codex.js +4 -22
- package/dist/integrations/adapters/copilot.js +3 -41
- package/dist/integrations/adapters/cursor.js +1 -4
- package/dist/integrations/adapters/gemini.js +1 -4
- package/dist/integrations/adapters/windsurf.js +1 -4
- package/dist/integrations/instruction-blocks.d.ts +2 -0
- package/dist/integrations/instruction-blocks.js +29 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,14 +107,14 @@ kgraph "auth token refresh"
|
|
|
107
107
|
kgraph doctor
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
After useful AI work, assistants
|
|
110
|
+
After useful AI work, assistants save durable runtime-capture notes into `.kgraph/inbox/`. These notes are not project documentation; they are KGraph input files that the next `kgraph` run processes automatically. You can also process them directly with `kgraph update`.
|
|
111
111
|
|
|
112
112
|
Normal agent flow is intentionally small:
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
115
|
kgraph "topic"
|
|
116
116
|
# work normally
|
|
117
|
-
# if repo files changed, write an inbox note
|
|
117
|
+
# if repo files changed, write an inbox note before the final refresh
|
|
118
118
|
kgraph
|
|
119
119
|
```
|
|
120
120
|
|
|
@@ -17,30 +17,12 @@ export const claudeCodeAdapter = {
|
|
|
17
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
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
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
|
-
7. At the end of any session that changed repository files, write one concise Markdown note to \`.kgraph/inbox/<slug>.md\` before finishing.
|
|
21
|
-
8. Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
22
|
-
9. Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
23
|
-
10. After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
24
|
-
11. 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.
|
|
25
|
-
12. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
|
|
26
|
-
13. Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
\`\`\`markdown
|
|
30
|
-
# <Short Title>
|
|
21
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Key Files
|
|
36
|
-
- \`path/to/file.ts\` — what changed or why it matters
|
|
37
|
-
|
|
38
|
-
## Key Symbols
|
|
39
|
-
- \`FunctionName\` — what changed or why it matters
|
|
40
|
-
|
|
41
|
-
## Decisions
|
|
42
|
-
Any implementation or product decision future sessions should know.
|
|
43
|
-
\`\`\`
|
|
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.
|
|
44
26
|
`,
|
|
45
27
|
},
|
|
46
28
|
{
|
|
@@ -8,10 +8,7 @@ export const clineAdapter = {
|
|
|
8
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
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
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
|
-
|
|
12
|
-
- Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
13
|
-
- Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
14
|
-
- After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
11
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
15
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.
|
|
16
13
|
- Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
|
|
17
14
|
- Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
@@ -24,30 +24,12 @@ Workflow:
|
|
|
24
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
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
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
|
-
7. At the end of any session that changed repository files, write one concise Markdown note to \`.kgraph/inbox/<slug>.md\` before finishing.
|
|
28
|
-
8. Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
29
|
-
9. Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
30
|
-
10. After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
31
|
-
11. 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.
|
|
32
|
-
12. Run \`kgraph visualize\` when the user wants to inspect the dependency graph — opens an interactive graph at http://localhost:4242 with PNG export.
|
|
33
|
-
13. Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
\`\`\`markdown
|
|
37
|
-
# <Short Title>
|
|
28
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## Key Files
|
|
43
|
-
- \`path/to/file.ts\` — what changed or why it matters
|
|
44
|
-
|
|
45
|
-
## Key Symbols
|
|
46
|
-
- \`FunctionName\` — what changed or why it matters
|
|
47
|
-
|
|
48
|
-
## Decisions
|
|
49
|
-
Any implementation or product decision future sessions should know.
|
|
50
|
-
\`\`\`
|
|
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.
|
|
51
33
|
`,
|
|
52
34
|
},
|
|
53
35
|
],
|
|
@@ -8,28 +8,10 @@ export const copilotAdapter = {
|
|
|
8
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
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
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.
|
|
11
|
-
5. At the end of any session that changed repository files, write one concise Markdown note to \`.kgraph/inbox/<slug>.md\` before finishing.
|
|
12
|
-
6. Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
13
|
-
7. Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
14
|
-
8. After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
15
|
-
9. 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.
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
\`\`\`markdown
|
|
19
|
-
# <Short Title>
|
|
12
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
One or two sentences describing what was done.
|
|
23
|
-
|
|
24
|
-
## Key Files
|
|
25
|
-
- \`path/to/file.ts\` — what it does
|
|
26
|
-
|
|
27
|
-
## Key Symbols
|
|
28
|
-
- \`FunctionName\` — what it does
|
|
29
|
-
|
|
30
|
-
## Decisions
|
|
31
|
-
Any architectural or implementation decisions made.
|
|
32
|
-
\`\`\`
|
|
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.
|
|
33
15
|
`,
|
|
34
16
|
commandFiles: [
|
|
35
17
|
{
|
|
@@ -93,27 +75,7 @@ argument-hint: "Brief description of what was done"
|
|
|
93
75
|
|
|
94
76
|
Capture this session into KGraph cognition.
|
|
95
77
|
|
|
96
|
-
|
|
97
|
-
2. Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
98
|
-
3. Use the user's message as context, but keep the note factual and concise.
|
|
99
|
-
4. Run \`kgraph\` once to process the note and refresh maps. Use \`kgraph update\` only when you intentionally want inbox processing without a scan.
|
|
100
|
-
|
|
101
|
-
Note structure:
|
|
102
|
-
\`\`\`markdown
|
|
103
|
-
# <Short Title>
|
|
104
|
-
|
|
105
|
-
## Summary
|
|
106
|
-
One or two sentences describing what was done.
|
|
107
|
-
|
|
108
|
-
## Key Files
|
|
109
|
-
- \`path/to/file.ts\` — what it does
|
|
110
|
-
|
|
111
|
-
## Key Symbols
|
|
112
|
-
- \`FunctionName\` — what it does
|
|
113
|
-
|
|
114
|
-
## Decisions
|
|
115
|
-
Any architectural or implementation decisions made.
|
|
116
|
-
\`\`\`
|
|
78
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
117
79
|
`,
|
|
118
80
|
},
|
|
119
81
|
{
|
|
@@ -13,10 +13,7 @@ alwaysApply: true
|
|
|
13
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
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
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
|
-
|
|
17
|
-
- Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
18
|
-
- Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
19
|
-
- After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
16
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
20
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.
|
|
21
18
|
- Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
|
|
22
19
|
- Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
@@ -8,10 +8,7 @@ export const geminiAdapter = {
|
|
|
8
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
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
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
|
-
|
|
12
|
-
- Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
13
|
-
- Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
14
|
-
- After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
11
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
15
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.
|
|
16
13
|
- Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
|
|
17
14
|
- Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
@@ -8,10 +8,7 @@ export const windsurfAdapter = {
|
|
|
8
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
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
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
|
-
|
|
12
|
-
- Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
13
|
-
- Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
14
|
-
- After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
11
|
+
{{KGRAPH_CAPTURE_POLICY}}
|
|
15
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.
|
|
16
13
|
- Run \`kgraph visualize\` to open the interactive dependency graph at http://localhost:4242 with PNG export.
|
|
17
14
|
- Run \`kgraph history\` or \`kgraph history "<topic>"\` to review past cognition sessions with git author attribution.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { IntegrationMode } from "../types/config.js";
|
|
2
2
|
export declare const KGRAPH_CONTEXT_POLICY_PLACEHOLDER = "{{KGRAPH_CONTEXT_POLICY}}";
|
|
3
|
+
export declare const KGRAPH_CAPTURE_POLICY_PLACEHOLDER = "{{KGRAPH_CAPTURE_POLICY}}";
|
|
3
4
|
export declare function upsertManagedBlock(content: string, integrationName: string, instructions: string): string;
|
|
4
5
|
export declare function removeManagedBlock(content: string, integrationName: string): string;
|
|
5
6
|
export declare function applyContextPolicy(content: string, mode: IntegrationMode): string;
|
|
6
7
|
export declare function renderContextPolicy(mode: IntegrationMode): string;
|
|
8
|
+
export declare function renderCapturePolicy(): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const MARKER_PREFIX = "<!--";
|
|
2
2
|
const MARKER_SUFFIX = "-->";
|
|
3
3
|
export const KGRAPH_CONTEXT_POLICY_PLACEHOLDER = "{{KGRAPH_CONTEXT_POLICY}}";
|
|
4
|
+
export const KGRAPH_CAPTURE_POLICY_PLACEHOLDER = "{{KGRAPH_CAPTURE_POLICY}}";
|
|
4
5
|
export function upsertManagedBlock(content, integrationName, instructions) {
|
|
5
6
|
const normalized = content.trimEnd();
|
|
6
7
|
const block = renderManagedBlock(integrationName, instructions);
|
|
@@ -27,7 +28,9 @@ function escapeRegExp(value) {
|
|
|
27
28
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
29
|
}
|
|
29
30
|
export function applyContextPolicy(content, mode) {
|
|
30
|
-
return content
|
|
31
|
+
return content
|
|
32
|
+
.replaceAll(KGRAPH_CONTEXT_POLICY_PLACEHOLDER, renderContextPolicy(mode))
|
|
33
|
+
.replaceAll(KGRAPH_CAPTURE_POLICY_PLACEHOLDER, renderCapturePolicy());
|
|
31
34
|
}
|
|
32
35
|
export function renderContextPolicy(mode) {
|
|
33
36
|
switch (mode) {
|
|
@@ -42,3 +45,28 @@ export function renderContextPolicy(mode) {
|
|
|
42
45
|
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.';
|
|
43
46
|
}
|
|
44
47
|
}
|
|
48
|
+
export function renderCapturePolicy() {
|
|
49
|
+
return `Capture policy:
|
|
50
|
+
- At the end of any session that changed repository files, write one concise Markdown note to \`.kgraph/inbox/<slug>.md\` before finishing.
|
|
51
|
+
- A \`.kgraph/inbox/*.md\` note is KGraph runtime capture, not project documentation. It is allowed and required by this workflow unless the user explicitly says not to capture to KGraph.
|
|
52
|
+
- Do not skip capture for UI text, button, link, route, styling, or small file edits. Skip capture only when no repository files changed.
|
|
53
|
+
- Do not run KGraph repeatedly. Run it once at the start with \`kgraph "<topic>"\`. If repo files changed, write the inbox note first, then run \`kgraph\` once at the end.
|
|
54
|
+
- After the final \`kgraph\` run, mention whether the inbox note was processed.
|
|
55
|
+
|
|
56
|
+
The inbox note must use this structure:
|
|
57
|
+
\`\`\`markdown
|
|
58
|
+
# <Short Title>
|
|
59
|
+
|
|
60
|
+
## Summary
|
|
61
|
+
One or two sentences describing what was done.
|
|
62
|
+
|
|
63
|
+
## Key Files
|
|
64
|
+
- \`path/to/file.ts\` - what changed or why it matters
|
|
65
|
+
|
|
66
|
+
## Key Symbols
|
|
67
|
+
- \`FunctionName\` - what changed or why it matters
|
|
68
|
+
|
|
69
|
+
## Decisions
|
|
70
|
+
Any implementation or product decision future sessions should know.
|
|
71
|
+
\`\`\``;
|
|
72
|
+
}
|