agent-knowledge-cli 0.1.2__py3-none-any.whl

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.
Files changed (88) hide show
  1. agent_knowledge/__init__.py +3 -0
  2. agent_knowledge/__main__.py +3 -0
  3. agent_knowledge/assets/__init__.py +0 -0
  4. agent_knowledge/assets/claude/global.md +44 -0
  5. agent_knowledge/assets/claude/project-template.md +46 -0
  6. agent_knowledge/assets/claude/scripts/install.sh +85 -0
  7. agent_knowledge/assets/commands/doctor.md +21 -0
  8. agent_knowledge/assets/commands/global-knowledge-sync.md +27 -0
  9. agent_knowledge/assets/commands/graphify-sync.md +26 -0
  10. agent_knowledge/assets/commands/knowledge-sync.md +26 -0
  11. agent_knowledge/assets/commands/ship.md +29 -0
  12. agent_knowledge/assets/rules/generate-architecture-doc.mdc +87 -0
  13. agent_knowledge/assets/rules/history-backfill.mdc +67 -0
  14. agent_knowledge/assets/rules/memory-bootstrap.mdc +53 -0
  15. agent_knowledge/assets/rules/memory-writeback.mdc +90 -0
  16. agent_knowledge/assets/rules/shared-memory.mdc +102 -0
  17. agent_knowledge/assets/rules/workflow-orchestration.mdc +93 -0
  18. agent_knowledge/assets/rules-global/action-first.mdc +26 -0
  19. agent_knowledge/assets/rules-global/no-icons-emojis.mdc +16 -0
  20. agent_knowledge/assets/rules-global/no-unsolicited-docs.mdc +20 -0
  21. agent_knowledge/assets/scripts/bootstrap-memory-tree.sh +389 -0
  22. agent_knowledge/assets/scripts/compact-memory.sh +191 -0
  23. agent_knowledge/assets/scripts/doctor.sh +137 -0
  24. agent_knowledge/assets/scripts/global-knowledge-sync.sh +372 -0
  25. agent_knowledge/assets/scripts/graphify-sync.sh +397 -0
  26. agent_knowledge/assets/scripts/import-agent-history.sh +706 -0
  27. agent_knowledge/assets/scripts/install-project-links.sh +258 -0
  28. agent_knowledge/assets/scripts/lib/knowledge-common.sh +875 -0
  29. agent_knowledge/assets/scripts/measure-token-savings.py +540 -0
  30. agent_knowledge/assets/scripts/ship.sh +256 -0
  31. agent_knowledge/assets/scripts/update-knowledge.sh +341 -0
  32. agent_knowledge/assets/scripts/validate-knowledge.sh +265 -0
  33. agent_knowledge/assets/skills/decision-recording/SKILL.md +124 -0
  34. agent_knowledge/assets/skills/history-backfill/SKILL.md +115 -0
  35. agent_knowledge/assets/skills/memory-compaction/SKILL.md +115 -0
  36. agent_knowledge/assets/skills/memory-management/SKILL.md +134 -0
  37. agent_knowledge/assets/skills/project-ontology-bootstrap/SKILL.md +173 -0
  38. agent_knowledge/assets/skills/session-management/SKILL.md +116 -0
  39. agent_knowledge/assets/skills-cursor/create-rule/SKILL.md +164 -0
  40. agent_knowledge/assets/skills-cursor/create-skill/SKILL.md +498 -0
  41. agent_knowledge/assets/skills-cursor/create-subagent/SKILL.md +225 -0
  42. agent_knowledge/assets/skills-cursor/migrate-to-skills/SKILL.md +134 -0
  43. agent_knowledge/assets/skills-cursor/shell/SKILL.md +24 -0
  44. agent_knowledge/assets/skills-cursor/update-cursor-settings/SKILL.md +122 -0
  45. agent_knowledge/assets/templates/dashboards/project-overview.template.md +24 -0
  46. agent_knowledge/assets/templates/dashboards/session-rollup.template.md +23 -0
  47. agent_knowledge/assets/templates/hooks/hooks.json.template +11 -0
  48. agent_knowledge/assets/templates/integrations/claude/CLAUDE.md +7 -0
  49. agent_knowledge/assets/templates/integrations/codex/AGENTS.md +7 -0
  50. agent_knowledge/assets/templates/integrations/cursor/agent-knowledge.mdc +11 -0
  51. agent_knowledge/assets/templates/integrations/cursor/hooks.json +11 -0
  52. agent_knowledge/assets/templates/memory/MEMORY.root.template.md +36 -0
  53. agent_knowledge/assets/templates/memory/branch.template.md +33 -0
  54. agent_knowledge/assets/templates/memory/decision.template.md +33 -0
  55. agent_knowledge/assets/templates/memory/profile.hybrid.yaml +16 -0
  56. agent_knowledge/assets/templates/memory/profile.ml-platform.yaml +18 -0
  57. agent_knowledge/assets/templates/memory/profile.robotics.yaml +19 -0
  58. agent_knowledge/assets/templates/memory/profile.web-app.yaml +16 -0
  59. agent_knowledge/assets/templates/portfolio/.obsidian/README.md +21 -0
  60. agent_knowledge/assets/templates/portfolio/.obsidian/app.json +5 -0
  61. agent_knowledge/assets/templates/portfolio/.obsidian/core-plugins.json +7 -0
  62. agent_knowledge/assets/templates/project/.agent-project.yaml +36 -0
  63. agent_knowledge/assets/templates/project/.agentknowledgeignore +10 -0
  64. agent_knowledge/assets/templates/project/AGENTS.md +87 -0
  65. agent_knowledge/assets/templates/project/agent-knowledge/.obsidian/README.md +23 -0
  66. agent_knowledge/assets/templates/project/agent-knowledge/.obsidian/app.json +5 -0
  67. agent_knowledge/assets/templates/project/agent-knowledge/.obsidian/core-plugins.json +7 -0
  68. agent_knowledge/assets/templates/project/agent-knowledge/Evidence/README.md +34 -0
  69. agent_knowledge/assets/templates/project/agent-knowledge/Evidence/imports/README.md +29 -0
  70. agent_knowledge/assets/templates/project/agent-knowledge/Evidence/raw/README.md +25 -0
  71. agent_knowledge/assets/templates/project/agent-knowledge/Memory/MEMORY.md +37 -0
  72. agent_knowledge/assets/templates/project/agent-knowledge/Memory/decisions/decisions.md +31 -0
  73. agent_knowledge/assets/templates/project/agent-knowledge/Outputs/README.md +24 -0
  74. agent_knowledge/assets/templates/project/agent-knowledge/STATUS.md +43 -0
  75. agent_knowledge/assets/templates/project/agent-knowledge/Sessions/README.md +21 -0
  76. agent_knowledge/assets/templates/project/agent-knowledge/Templates/README.md +19 -0
  77. agent_knowledge/assets/templates/project/gitignore.agent-knowledge +13 -0
  78. agent_knowledge/cli.py +457 -0
  79. agent_knowledge/runtime/__init__.py +0 -0
  80. agent_knowledge/runtime/integrations.py +154 -0
  81. agent_knowledge/runtime/paths.py +46 -0
  82. agent_knowledge/runtime/shell.py +22 -0
  83. agent_knowledge/runtime/sync.py +255 -0
  84. agent_knowledge_cli-0.1.2.dist-info/METADATA +155 -0
  85. agent_knowledge_cli-0.1.2.dist-info/RECORD +88 -0
  86. agent_knowledge_cli-0.1.2.dist-info/WHEEL +4 -0
  87. agent_knowledge_cli-0.1.2.dist-info/entry_points.txt +2 -0
  88. agent_knowledge_cli-0.1.2.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,3 @@
1
+ """agent-knowledge: adaptive, file-based project knowledge for AI coding agents."""
2
+
3
+ __version__ = "0.1.2"
@@ -0,0 +1,3 @@
1
+ from agent_knowledge.cli import main
2
+
3
+ main()
File without changes
@@ -0,0 +1,44 @@
1
+ # AI Assistant Global Rules
2
+
3
+ ## Communication Style
4
+
5
+ Think deeply, act decisively, speak briefly.
6
+
7
+ - Execute over explain — let code and results speak
8
+ - Lead with the action or answer, not the reasoning
9
+ - No preambles, filler text, or summaries of what was just done
10
+ - Only detailed explanations when explicitly requested
11
+ - Short, direct sentences over long explanations
12
+
13
+ ## Prohibitions
14
+
15
+ - No emojis or icons in code, logs, or responses — plain text only
16
+ - Never create .md, README, CHANGELOG, or documentation files unless explicitly asked
17
+ - Exception: internal memory/session files are fine to create and update freely
18
+
19
+ ## Workflow
20
+
21
+ - Plan before any non-trivial task (3+ steps or architectural decisions)
22
+ - Use subagents liberally to keep the main context window clean and for parallel work
23
+ - After any user correction: record the pattern to prevent repeating it
24
+ - Never mark a task complete without proving it works
25
+ - For non-trivial changes: ask "is there a more elegant way?" before presenting
26
+ - When given a bug report: fix it autonomously — no hand-holding needed
27
+ - When the user describes a constraint or says something won't work: stop and accept it. One confirmation attempt max — do not re-discover what the user already knows
28
+
29
+ ## Code Quality
30
+
31
+ - Simplicity first: make every change as simple as possible, impact minimal code
32
+ - No laziness: find root causes, no temporary fixes, senior developer standards
33
+ - Minimal impact: only touch what is necessary, avoid introducing bugs
34
+ - No ORMs unless the project already uses one
35
+ - No new dependencies without asking first
36
+
37
+ ## Memory
38
+
39
+ - Save stable patterns, preferences, and architectural decisions to memory files
40
+ - Keep the Memory/MEMORY.md note concise (truncated after ~200 lines); put detail in branch files
41
+ - Update or remove memories that turn out to be wrong or outdated
42
+ - Never save session-specific, in-progress, or speculative information
43
+ - When the user asks to remember something: save it immediately
44
+ - When the user asks to forget something: remove it immediately
@@ -0,0 +1,46 @@
1
+ # Project: <Name>
2
+
3
+ <!-- Drop this file at the project root as CLAUDE.md -->
4
+ <!-- It is read automatically by Claude Code at the start of every session -->
5
+ <!-- Global rules in ~/.claude/CLAUDE.md are also loaded — no need to repeat them here -->
6
+
7
+ ## Stack
8
+
9
+ - <language/runtime>
10
+ - <framework>
11
+ - <database>
12
+ - <key libraries>
13
+
14
+ ## Key Directories
15
+
16
+ - `src/` — <description>
17
+ - `tests/` — <description>
18
+
19
+ ## Conventions
20
+
21
+ - <naming conventions>
22
+ - <patterns to follow>
23
+ - <patterns to avoid>
24
+
25
+ ## What NOT to do
26
+
27
+ - Do not install <X> — we use <Y> instead
28
+ - Do not restructure <X> without asking
29
+ - Do not commit secrets — use .env.template as reference
30
+
31
+ ## When unsure
32
+
33
+ - Search the codebase first. Reuse existing patterns.
34
+ - Ask before creating new packages or major abstractions.
35
+ - Read docs in `docs/` or `agent-knowledge/` before implementing.
36
+
37
+ ## Shared Memory
38
+
39
+ Persistent project memory lives at `agent-knowledge/Memory/MEMORY.md`.
40
+ The local `agent-knowledge/` path should point to the real dedicated knowledge folder.
41
+ Read it at the start of each session. Write back after meaningful changes.
42
+
43
+ - If `agent-knowledge/Memory/MEMORY.md` is missing: run `scripts/bootstrap-memory-tree.sh .`
44
+ - After any architectural decision: use the `decision-recording` skill
45
+ - After any meaningful state change: follow the `memory-writeback` rule
46
+ - To backfill from git/docs history: run `scripts/import-agent-history.sh .`
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+ #
3
+ # Install Claude Code global rules into ~/.claude/CLAUDE.md
4
+ #
5
+ # Usage:
6
+ # ./install.sh # install global rules
7
+ # ./install.sh /path/to/project # also install project template into project root
8
+ #
9
+ # The global rules are appended under a managed section marker so re-running
10
+ # this script is safe (it replaces the section, not appends again).
11
+ #
12
+
13
+ set -euo pipefail
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
16
+ CLAUDE_DIR="$HOME/.claude"
17
+ GLOBAL_SOURCE="$SCRIPT_DIR/../global.md"
18
+ GLOBAL_TARGET="$CLAUDE_DIR/CLAUDE.md"
19
+ PROJECT="${1:-}"
20
+
21
+ MARKER_START="<!-- agents-rules:global:start -->"
22
+ MARKER_END="<!-- agents-rules:global:end -->"
23
+
24
+ mkdir -p "$CLAUDE_DIR"
25
+
26
+ install_global() {
27
+ local content
28
+ content="$(cat "$GLOBAL_SOURCE")"
29
+
30
+ if [ -f "$GLOBAL_TARGET" ]; then
31
+ # Remove existing managed section if present
32
+ if grep -q "$MARKER_START" "$GLOBAL_TARGET" 2>/dev/null; then
33
+ # Strip from marker-start to marker-end inclusive
34
+ local tmp
35
+ tmp="$(mktemp)"
36
+ awk "/$MARKER_START/{flag=1} !flag{print} /$MARKER_END/{flag=0}" "$GLOBAL_TARGET" > "$tmp"
37
+ mv "$tmp" "$GLOBAL_TARGET"
38
+ echo " updated existing section in $GLOBAL_TARGET"
39
+ else
40
+ echo " appending to existing $GLOBAL_TARGET"
41
+ echo "" >> "$GLOBAL_TARGET"
42
+ fi
43
+ else
44
+ echo " creating $GLOBAL_TARGET"
45
+ fi
46
+
47
+ {
48
+ echo "$MARKER_START"
49
+ echo "$content"
50
+ echo "$MARKER_END"
51
+ } >> "$GLOBAL_TARGET"
52
+
53
+ echo " global rules installed -> $GLOBAL_TARGET"
54
+ }
55
+
56
+ install_project_template() {
57
+ local project_dir
58
+ project_dir="$(cd "$1" && pwd)"
59
+ local target="$project_dir/CLAUDE.md"
60
+ local source="$SCRIPT_DIR/../project-template.md"
61
+
62
+ if [ -f "$target" ]; then
63
+ echo " $target already exists — skipping (edit manually)"
64
+ else
65
+ cp "$source" "$target"
66
+ echo " project template installed -> $target"
67
+ echo " Edit CLAUDE.md with your project-specific rules"
68
+ fi
69
+ }
70
+
71
+ echo "Installing Claude Code rules..."
72
+ echo ""
73
+
74
+ install_global
75
+
76
+ if [ -n "$PROJECT" ]; then
77
+ install_project_template "$PROJECT"
78
+ fi
79
+
80
+ echo ""
81
+ echo "Done."
82
+ echo ""
83
+ echo "Claude Code reads:"
84
+ echo " ~/.claude/CLAUDE.md <- global rules (all projects)"
85
+ echo " <project>/CLAUDE.md <- project rules (this project only)"
@@ -0,0 +1,21 @@
1
+ # Doctor
2
+
3
+ Doctor is the quick troubleshooting entrypoint for a connected project knowledge setup.
4
+
5
+ ## Behavior
6
+
7
+ - run knowledge validation
8
+ - verify the local `./agent-knowledge` pointer and external source-of-truth path
9
+ - check project setup files such as `.agent-project.yaml`, `AGENTS.md`, and optional repo-local hooks
10
+ - summarize health warnings and the current operational state
11
+
12
+ ## Safety
13
+
14
+ - read-mostly command
15
+ - may refresh `agent-knowledge/STATUS.md` unless `--dry-run` is used
16
+
17
+ ## Expected Script Entry Point
18
+
19
+ ```bash
20
+ scripts/doctor.sh --project /path/to/project
21
+ ```
@@ -0,0 +1,27 @@
1
+ # Global Knowledge Sync
2
+
3
+ Global knowledge sync builds a project-scoped tooling knowledge view from safe,
4
+ allowlisted user-level tool surfaces. It still writes through `./agent-knowledge`,
5
+ which should resolve to the external project knowledge folder.
6
+
7
+ ## Behavior
8
+
9
+ - scan allowlisted local configuration sources such as `~/.claude/`, `~/.codex/`, and optional safe Cursor customizations
10
+ - skip opaque caches, auth/session surfaces, and suspicious secret-bearing files
11
+ - redact sensitive lines before writing evidence
12
+ - write redacted imports under `agent-knowledge/Evidence/tooling/`
13
+ - write curated summaries under `agent-knowledge/Memory/tooling/`
14
+ - update `agent-knowledge/STATUS.md`
15
+
16
+ ## Safety
17
+
18
+ - use `--dry-run` to preview writes
19
+ - reruns should be idempotent
20
+ - summaries must report both scanned sources and safety skips
21
+
22
+ ## Expected Script Entry Point
23
+
24
+ ```bash
25
+ scripts/global-knowledge-sync.sh --project /path/to/project
26
+ scripts/global-knowledge-sync.sh --project /path/to/project --dry-run
27
+ ```
@@ -0,0 +1,26 @@
1
+ # Graphify Sync
2
+
3
+ Graphify sync is the optional structural-discovery import flow for graph-style project exports.
4
+ It writes through `./agent-knowledge`, but keeps imported graph structure in `Evidence/` and `Outputs/`, not in durable memory.
5
+
6
+ ## Behavior
7
+
8
+ - detect whether `graphify` or equivalent structural export artifacts are available
9
+ - import safe graph/report/json artifacts into `agent-knowledge/Evidence/imports/graphify/`
10
+ - generate concise structural summaries under `agent-knowledge/Outputs/graphify/`
11
+ - tag imported material with confidence metadata such as `EXTRACTED` or `INFERRED`
12
+ - summarize what was imported, what was cached, and what was skipped
13
+
14
+ ## Safety
15
+
16
+ - optional only; missing graph tooling must not fail the project knowledge system
17
+ - use `--dry-run` to preview all writes
18
+ - imported graph outputs are evidence first and are not promoted into `Memory/` automatically
19
+
20
+ ## Expected Script Entry Point
21
+
22
+ ```bash
23
+ scripts/graphify-sync.sh --project /path/to/project
24
+ scripts/graphify-sync.sh --project /path/to/project --source /path/to/graphify-export
25
+ scripts/graphify-sync.sh --project /path/to/project --dry-run
26
+ ```
@@ -0,0 +1,26 @@
1
+ # Knowledge Sync
2
+
3
+ Knowledge sync is the connected-project maintenance flow for the adaptive memory system. It writes through `./agent-knowledge`, which should resolve to the external project knowledge folder.
4
+
5
+ ## Behavior
6
+
7
+ - inspect current repo changes
8
+ - classify touched files into the relevant `agent-knowledge/Memory/` branch notes
9
+ - append durable recent-change entries when knowledge meaningfully changed
10
+ - optionally record a decision note when explicitly requested
11
+ - refresh raw and imported evidence without treating it as curated truth
12
+ - update `agent-knowledge/STATUS.md`
13
+
14
+ ## Safety
15
+
16
+ - use `--dry-run` to preview all file writes
17
+ - idempotent reruns should not duplicate recent-change bullets
18
+ - sessions and evidence stay separate from durable memory
19
+
20
+ ## Expected Script Entry Point
21
+
22
+ ```bash
23
+ scripts/update-knowledge.sh --project /path/to/project
24
+ scripts/update-knowledge.sh --project /path/to/project --decision-title "Adopt X"
25
+ scripts/update-knowledge.sh --project /path/to/project --dry-run
26
+ ```
@@ -0,0 +1,29 @@
1
+ # Ship
2
+
3
+ Ship is the operational release-prep flow for a connected project repo.
4
+
5
+ ## Behavior
6
+
7
+ - inspect git status and current branch
8
+ - refuse to continue on detached HEAD or merge conflicts
9
+ - run detected validation commands for the repo
10
+ - run knowledge sync and compaction before commit
11
+ - stage repo-local changes
12
+ - generate or accept a concise commit message
13
+ - commit and push when possible
14
+ - optionally open a PR when requested
15
+
16
+ ## Safety
17
+
18
+ - use `--dry-run` to preview validations, git actions, and knowledge updates
19
+ - knowledge updates still run through `./agent-knowledge`; the script does not convert the system into repo-local storage
20
+ - if the real knowledge vault lives outside the repo, the script reports that instead of pretending to stage it
21
+ - reruns are no-op when nothing changed
22
+
23
+ ## Expected Script Entry Point
24
+
25
+ ```bash
26
+ scripts/ship.sh --project /path/to/project
27
+ scripts/ship.sh --project /path/to/project --message "chore: ship update"
28
+ scripts/ship.sh --project /path/to/project --open-pr --dry-run
29
+ ```
@@ -0,0 +1,87 @@
1
+ ---
2
+ description: Generate an architecture HTML document for a Cramim ROS2 package. Use when asked to create architecture docs, explain a package, or document a node's behavior.
3
+ globs:
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Generate Architecture HTML Document
8
+
9
+ When asked to create an architecture document for a Cramim package, produce a self-contained HTML file in `architecture_docs/` following this process.
10
+
11
+ ## 1. Research the Package
12
+
13
+ Before writing anything, thoroughly investigate the target package:
14
+
15
+ - Read all `.hpp` and `.cpp` files in the package
16
+ - Read `package.xml` and `CMakeLists.txt` for dependencies
17
+ - Read any config/YAML files referenced by launch files
18
+ - Grep for `create_publisher`, `create_subscription`, `create_service`, `create_client` to find all ROS interfaces
19
+ - Grep for state definitions (`State::createStateSharedPtr`, enums, or equivalent patterns)
20
+ - Trace the full data flow from inputs to outputs
21
+ - Identify all inter-node communication patterns
22
+ - Read launch files to understand how the node is started and configured
23
+
24
+ ## 2. Required Content Sections
25
+
26
+ Every architecture doc must include:
27
+
28
+ 1. **Executive summary** — what the component does, 2-3 sentences, with role badges for related components
29
+ 2. **Table of contents** with anchor links
30
+ 3. **Architecture diagram** — where this component fits in the overall Cramim system (Mermaid flowchart)
31
+ 4. **State machine** (if applicable) — Mermaid `stateDiagram-v2` with all states and transitions
32
+ 5. **State details** — `on_enter`, `in_state`, `on_exit` callbacks for each state (table per state)
33
+ 6. **Transition table** — every transition with From, To, Condition, Side Effect columns
34
+ 7. **End-to-end flow** — Mermaid `sequenceDiagram` showing the main operational flow
35
+ 8. **Topics & services** — tables for published topics, subscribed topics, provided services, called services (columns: name, type, description)
36
+ 9. **Interactions with other nodes** — summary cards showing who talks to whom
37
+ 10. **Key design decisions** — bullet list of architectural choices and why
38
+ 11. **File structure** — annotated directory tree in a `<pre>` block
39
+
40
+ ## 3. Visual Style
41
+
42
+ Use the exact dark-theme style from the reference file `architecture_docs/dc_behavior_tree_workplan.html`:
43
+
44
+ - **Mermaid**: CDN `mermaid@10.6.1`, dark theme with custom `themeVariables`
45
+ - **Font**: `JetBrains Mono`, `Fira Code`, `Consolas`, monospace
46
+ - **Background**: `#0a0e14` → `#151d28` gradient
47
+ - **CSS variables**: `--accent-cyan: #39c5cf`, `--accent-green: #7fdb57`, `--accent-yellow: #ffcc66`, `--accent-orange: #ff8f40`, `--accent-red: #ff6b6b`, `--accent-purple: #c792ea`, `--accent-blue: #82aaff`
48
+ - **Cards**: `.description` boxes with `.highlight-{color}` left borders
49
+ - **Grids**: `.summary-grid` / `.summary-card` for card layouts
50
+ - **Flows**: `.flow-box` with numbered circles for sequential steps
51
+ - **Tables**: gradient header (`cyan → purple`), hover highlight, uppercase headers
52
+ - **Section headers**: centered `h2` with emoji prefix
53
+ - **Responsive**: `@media (max-width: 768px)` breakpoint
54
+
55
+ ## 4. Mermaid Configuration
56
+
57
+ Always include this exact mermaid init block at the bottom of the HTML:
58
+
59
+ ```javascript
60
+ mermaid.initialize({
61
+ startOnLoad: true,
62
+ theme: 'dark',
63
+ themeVariables: {
64
+ primaryColor: '#39c5cf',
65
+ primaryTextColor: '#e6edf3',
66
+ primaryBorderColor: '#39c5cf',
67
+ lineColor: '#82aaff',
68
+ secondaryColor: '#2d3a4a',
69
+ tertiaryColor: '#1a2433',
70
+ background: '#1a2433',
71
+ mainBkg: '#1a2433',
72
+ nodeBorder: '#2d3a4a',
73
+ clusterBkg: '#151d28',
74
+ clusterBorder: '#2d3a4a',
75
+ titleColor: '#39c5cf',
76
+ edgeLabelBackground: '#1a2433'
77
+ },
78
+ flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'basis', padding: 15 },
79
+ sequence: { useMaxWidth: true, mirrorActors: false, bottomMarginAdj: 1 }
80
+ });
81
+ ```
82
+
83
+ ## 5. Output
84
+
85
+ - Save to `architecture_docs/{package_name}_architecture.html`
86
+ - File must be fully self-contained (no external CSS, only CDN JS for mermaid)
87
+ - Open in any browser without a server
@@ -0,0 +1,67 @@
1
+ ---
2
+ description: When onboarding an existing project, perform history backfill before normal steady-state memory maintenance.
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # History Backfill
7
+
8
+ After bootstrapping memory on a project with existing history, backfill the memory tree
9
+ from evidence before proceeding with steady-state work.
10
+
11
+ Apply this rule once per project. It is not needed on every session.
12
+
13
+ ---
14
+
15
+ ## When to apply
16
+
17
+ Apply after `memory-bootstrap` when the project:
18
+ - Has a git history with more than ~10 commits
19
+ - Has existing documentation (README, CLAUDE.md, AGENTS.md, `.agent-project.yaml`, `agent-knowledge/`)
20
+ - Has existing task files (`tasks/todo.md`, `tasks/lessons.md`)
21
+ - Was previously worked on by another agent or developer
22
+
23
+ Do NOT apply on every session — only when onboarding or when memory is newly empty.
24
+
25
+ ---
26
+
27
+ ## Steps (summary — full detail in skill)
28
+
29
+ 1. Read the `history-backfill` skill.
30
+ 2. Run `scripts/import-agent-history.sh .` to collect raw evidence.
31
+ 3. Read evidence files in priority order (docs first, then manifests/configs/tests/workflows, then git and sessions).
32
+ 4. Distill stable facts into memory branch notes (Current State section).
33
+ 5. Record any architectural decisions found in `decisions/`.
34
+ 6. Update `Memory/MEMORY.md` branch summaries to reflect real content.
35
+ 7. Leave Open Questions for anything evidence hints at but doesn't resolve.
36
+
37
+ ---
38
+
39
+ ## Evidence sources (priority order)
40
+
41
+ 1. `agent-knowledge/Evidence/imports/existing-docs.txt` — README, CLAUDE.md, AGENTS.md, `.agent-project.yaml`
42
+ 2. `agent-knowledge/Evidence/raw/manifests.txt` — authoritative for stack
43
+ 3. `agent-knowledge/Evidence/raw/config-files.txt` — strong signal for conventions
44
+ 4. `agent-knowledge/Evidence/raw/tests.txt` and `raw/ci-workflows.txt` — verification and deploy signal
45
+ 5. `agent-knowledge/Evidence/raw/structure.txt` — actual architecture shape
46
+ 6. `agent-knowledge/Evidence/imports/tasks.txt` and `imports/session-files.txt` — context and recurring work areas
47
+ 7. `agent-knowledge/Evidence/raw/git-log-detail.txt` and `raw/git-log.txt` — why and what changed over time
48
+ 8. `agent-knowledge/Evidence/imports/trace-index.txt` — supporting traces only, never canonical truth
49
+
50
+ ---
51
+
52
+ ## Separation principle
53
+
54
+ Evidence (`agent-knowledge/Evidence/raw/` and `agent-knowledge/Evidence/imports/`) is input — overwritten or refreshed on each import run.
55
+ Memory (`agent-knowledge/Memory/`) is curated output — maintained by the writeback rule.
56
+
57
+ Never write evidence files into memory. Never treat a single evidence source as truth
58
+ without corroboration.
59
+
60
+ ---
61
+
62
+ ## After backfill
63
+
64
+ Switch to normal steady-state operation:
65
+ - Apply `memory-writeback` rule after each meaningful task
66
+ - Apply `memory-compaction` skill when files grow large
67
+ - Do NOT re-run history backfill unless memory is reset or significantly corrupted
@@ -0,0 +1,53 @@
1
+ ---
2
+ description: If the project memory tree is missing or obviously generic, bootstrap it before starting heavy work.
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Memory Bootstrap
7
+
8
+ Check for a valid memory tree at the start of any session that involves real project work.
9
+ If missing, overly generic, or obviously stale, bootstrap it first.
10
+
11
+ ---
12
+
13
+ ## Check condition
14
+
15
+ Look for `agent-knowledge/Memory/MEMORY.md` in the project root.
16
+ The local `./agent-knowledge` path is the project entrypoint and should point to the real dedicated knowledge folder.
17
+
18
+ | State | Action |
19
+ |-------|--------|
20
+ | File exists and has real content (not just template placeholders) | Skip -- proceed with the task |
21
+ | File exists but contains only bootstrap placeholders or generic text | Re-bootstrap or backfill: read `project-ontology-bootstrap` skill |
22
+ | File is missing, empty, or the `agent-knowledge` pointer is broken | Bootstrap: read `project-ontology-bootstrap` skill |
23
+
24
+ "Real content" means the memory root has frontmatter and at least one branch note contains verified facts in **Current State**.
25
+
26
+ ---
27
+
28
+ ## Bootstrap steps (summary -- full detail in skill)
29
+
30
+ 1. Read the `project-ontology-bootstrap` skill.
31
+ 2. Ensure the local `./agent-knowledge` pointer exists and resolves to the external knowledge folder. If it does not, run `scripts/install-project-links.sh` first.
32
+ 3. Run `scripts/bootstrap-memory-tree.sh .` to create the minimal scaffold.
33
+ 4. Inspect repo structure, manifests, docs, configs, tests, and workflows.
34
+ 5. Infer the project ontology and create 2-4 initial branch notes using the project's own terminology.
35
+ 6. Use the same-name branch convention: `<topic>.md` for flat notes, `<topic>/<topic>.md` for branches with subtopics.
36
+ 7. Collect evidence with `scripts/import-agent-history.sh .`
37
+ 8. If the project already has history, apply `history-backfill`.
38
+ 9. Confirm the tree is in place before proceeding with the user's task.
39
+
40
+ ---
41
+
42
+ ## When to skip
43
+
44
+ - Memory tree exists with real content -- always skip, do not re-bootstrap
45
+ - User explicitly asked to skip bootstrap -- skip for this session only
46
+ - The task is purely read-only exploration -- bootstrap is optional (do it anyway if convenient)
47
+
48
+ ---
49
+
50
+ ## After bootstrap
51
+
52
+ Apply the `history-backfill` rule if the project has existing history (git log, docs, sessions).
53
+ Then proceed with the user's task, applying the `memory-writeback` rule as work proceeds.
@@ -0,0 +1,90 @@
1
+ ---
2
+ description: After meaningful project state changes, update the correct memory branch -- or explicitly state no update is needed.
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Memory Writeback
7
+
8
+ After any meaningful project change, evaluate whether durable project understanding changed.
9
+ If yes, update the correct memory branch before ending the session.
10
+ If no, say so explicitly.
11
+
12
+ ---
13
+
14
+ ## Evaluation -- ask after every meaningful task
15
+
16
+ > "Did this session change what future sessions should understand about this project?"
17
+
18
+ Write to memory if the answer is yes for any of:
19
+ - An architectural decision was made or reversed
20
+ - A new pattern or convention was confirmed
21
+ - A critical gotcha was discovered (build, DB, API, environment, path)
22
+ - A feature area was substantially completed or its design changed
23
+ - A recurring mistake was corrected (record the lesson)
24
+ - A dependency or external constraint changed
25
+
26
+ Skip writeback if:
27
+ - The session was read-only exploration with no new conclusions
28
+ - The change is already captured in git or inline documentation
29
+ - The fact is session-specific and won't matter in a future session
30
+ - The fact is speculative and not yet confirmed
31
+ - The work changed code but not project understanding
32
+
33
+ When skipping, state it: **Memory writeback: none needed.**
34
+
35
+ ---
36
+
37
+ ## What to write and where
38
+
39
+ | Fact type | Target |
40
+ |-----------|--------|
41
+ | Architectural decision | `Memory/decisions/YYYY-MM-DD-slug.md` + link from the relevant branch |
42
+ | New pattern or convention | relevant branch note -> Current State |
43
+ | Gotcha or constraint | relevant branch note -> Current State |
44
+ | Stack change | relevant branch note -> Current State + Recent Changes |
45
+ | Completed feature area | relevant branch note -> Current State |
46
+ | Lesson from a mistake | relevant branch note -> Current State, with **Why:** and **How to apply:** |
47
+
48
+ If no existing branch fits the fact, create a new branch note using the same-name convention.
49
+ Use the project's own terminology for branch names.
50
+
51
+ ---
52
+
53
+ ## How to write
54
+
55
+ 1. Identify the target branch note.
56
+ 2. Read its current content.
57
+ 3. Preserve YAML frontmatter and add or update the fact in the correct section.
58
+ - **Current State**: what is true now (replace stale entries, don't append duplicates)
59
+ - **Recent Changes**: YYYY-MM-DD -- what changed (prune entries older than ~4 weeks)
60
+ - **Decisions**: link to decision file
61
+ - **Open Questions**: add unresolved items only if they remain open after verification
62
+ 4. If the branch now exceeds ~150 lines, follow the `memory-compaction` skill.
63
+ 5. If branch summaries changed, update `agent-knowledge/Memory/MEMORY.md`.
64
+
65
+ For architectural decisions, use the `decision-recording` skill -- do not inline them.
66
+
67
+ ---
68
+
69
+ ## Format
70
+
71
+ Lead with the fact:
72
+ ```
73
+ Raw SQL + pgtyped types for all DB access. No ORM.
74
+ ```
75
+
76
+ For lessons, add context:
77
+ ```
78
+ Yarn is not in PATH on this machine -- use node .yarn/releases/yarn-4.x.cjs directly.
79
+ Why: the repo uses Yarn 4 via Corepack, not the global yarn binary.
80
+ How to apply: always invoke yarn via the release script, never via yarn directly.
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Composability
86
+
87
+ - Uses `memory-management` skill for file locations and structure
88
+ - Uses `decision-recording` skill for architecture decisions
89
+ - Uses `memory-compaction` skill when files grow large
90
+ - Feeds from the `session-management` writeback gate