@aabadin/project-memory-context 0.1.0

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. package/LICENSE +674 -0
  2. package/README.md +123 -0
  3. package/bin/pmc.mjs +11 -0
  4. package/cli/apply-enrichment-result.mjs +31 -0
  5. package/cli/batch-enrich.mjs +5 -0
  6. package/cli/bootstrap.mjs +357 -0
  7. package/cli/build-worklist.mjs +35 -0
  8. package/cli/context.mjs +49 -0
  9. package/cli/doctor.mjs +29 -0
  10. package/cli/enrich-batch.mjs +11 -0
  11. package/cli/enrich-loop.sh +117 -0
  12. package/cli/enrich-orchestrator.mjs +5 -0
  13. package/cli/enrich-queue.mjs +525 -0
  14. package/cli/enrich-sync.mjs +5 -0
  15. package/cli/enrich.mjs +51 -0
  16. package/cli/fail-enrichment.mjs +28 -0
  17. package/cli/finalize-enrichment.mjs +25 -0
  18. package/cli/init.mjs +66 -0
  19. package/cli/install-pmc.mjs +153 -0
  20. package/cli/materialize-enrichment-artifacts.mjs +38 -0
  21. package/cli/new-project.mjs +41 -0
  22. package/cli/prepare-semantic-jobs.mjs +8 -0
  23. package/cli/project-context.mjs +224 -0
  24. package/cli/sanitize.mjs +235 -0
  25. package/cli/save-intake-context.mjs +22 -0
  26. package/cli/setup.mjs +80 -0
  27. package/cli/status.mjs +81 -0
  28. package/mcp/local-model-server.mjs +74 -0
  29. package/package.json +60 -0
  30. package/plugin/index.mjs +27 -0
  31. package/src/artifacts.mjs +39 -0
  32. package/src/change-detector.mjs +10 -0
  33. package/src/command-dispatch.mjs +84 -0
  34. package/src/declared-intake.mjs +25 -0
  35. package/src/doctor.mjs +114 -0
  36. package/src/enrichment-artifacts.mjs +67 -0
  37. package/src/enrichment-attempts.mjs +17 -0
  38. package/src/enrichment-config.mjs +121 -0
  39. package/src/enrichment-driver.mjs +167 -0
  40. package/src/enrichment-errors.mjs +46 -0
  41. package/src/enrichment-linker.mjs +29 -0
  42. package/src/extractors/architecture-extractor.mjs +8 -0
  43. package/src/extractors/js-ts-extractor.mjs +118 -0
  44. package/src/extractors/regex-extractor.mjs +439 -0
  45. package/src/extractors/rules-extractor.mjs +9 -0
  46. package/src/extractors/stack-extractor.mjs +48 -0
  47. package/src/extractors/structure-extractor.mjs +31 -0
  48. package/src/fail-enrichment.mjs +33 -0
  49. package/src/finalize-enrichment.mjs +30 -0
  50. package/src/graph-backfill.mjs +35 -0
  51. package/src/graph-node-resolver.mjs +64 -0
  52. package/src/index.mjs +2 -0
  53. package/src/intake-context.mjs +16 -0
  54. package/src/invalidation-matrix.mjs +33 -0
  55. package/src/markdown-renderer.mjs +27 -0
  56. package/src/materializer.mjs +128 -0
  57. package/src/memory-payload.mjs +55 -0
  58. package/src/persist-enrichment-result.mjs +33 -0
  59. package/src/platform.mjs +111 -0
  60. package/src/plugin-config.mjs +17 -0
  61. package/src/prepare-semantic-jobs.mjs +33 -0
  62. package/src/project-context-schema.mjs +57 -0
  63. package/src/providers/cloud-api-provider.mjs +88 -0
  64. package/src/providers/local-model-provider.mjs +67 -0
  65. package/src/refresh-state.mjs +21 -0
  66. package/src/result-input.mjs +9 -0
  67. package/src/retrieval/context-renderer.mjs +97 -0
  68. package/src/retrieval/query-engine.mjs +230 -0
  69. package/src/semantic-report.mjs +26 -0
  70. package/src/semantic-unit.mjs +74 -0
  71. package/src/setup-bootstrap.mjs +131 -0
  72. package/src/symbol-extractor.mjs +29 -0
  73. package/src/symbol-index.mjs +30 -0
  74. package/src/symbol-keys.mjs +28 -0
  75. package/src/sync-manifest.mjs +119 -0
  76. package/src/template-installer.mjs +181 -0
  77. package/src/worklist-state.mjs +12 -0
  78. package/templates/claude-code/CLAUDE.md.snippet +36 -0
  79. package/templates/cursor/.cursorrules.snippet +36 -0
  80. package/templates/generic/README-SETUP.md +53 -0
  81. package/templates/opencode/agent/enrich.md +28 -0
  82. package/templates/opencode/autostart-snippet.md +13 -0
  83. package/templates/opencode/commands/get-context.md +22 -0
  84. package/templates/opencode/commands/new-project.md +32 -0
  85. package/templates/opencode/commands/sanitize.md +21 -0
  86. package/templates/opencode/commands/sync-context.md +22 -0
  87. package/templates/project-memory-context workflow.md +129 -0
  88. package/templates/project-memory-context.md +42 -0
@@ -0,0 +1,13 @@
1
+ <!-- pmc:autostart -->
2
+ When starting a session in a project with `.planning/project-memory-context/`:
3
+
4
+ 1. Check `.planning/project-memory-context/enrichment/worklist.json` for pending or stale entries.
5
+ 2. If pending/stale entries exist, launch background enrichment:
6
+ ```bash
7
+ {{PMC_BIN}} enrich .
8
+ ```
9
+ 3. Check `.planning/project-memory-context/enrichment/sync-manifest.json` for pending entries.
10
+ 4. If sync-manifest has pending entries, remind the user: "PMC has {n} pending sync operations. Run `/sync-context` to apply them."
11
+ 5. Search agent-memory for `project context overview` to fetch base context (stack, architecture, structure). Present a brief summary to establish session context.
12
+ 6. Remind the user: "Use `/get-context <target>` for structural deep-dive before reading files."
13
+ <!-- /pmc:autostart -->
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: get-context
3
+ description: Retrieve structured project context from agent-memory for the current project.
4
+ argument-hint: "<target>"
5
+ allowed-tools:
6
+ - Bash
7
+ - Read
8
+ ---
9
+
10
+ <objective>
11
+ Retrieve and display structured project context from agent-memory. Use before reading files to get a structural overview.
12
+ </objective>
13
+
14
+ <execution>
15
+ Run:
16
+
17
+ ```bash
18
+ {{PMC_BIN}} context . --refresh
19
+ ```
20
+
21
+ This materializes or refreshes the 9 base project-context memories and outputs a summary.
22
+ </execution>
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: new-project
3
+ description: Bootstrap PMC in the current project with graphify, worklist, and base memories.
4
+ argument-hint: "[--all] [--enrich]"
5
+ allowed-tools:
6
+ - Bash
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Glob
11
+ - Grep
12
+ ---
13
+
14
+ <objective>
15
+ Bootstrap PMC in the current project. Runs graphify, builds the enrichment worklist, materializes 9 base project-context memories, and writes the sync-manifest.
16
+ </objective>
17
+
18
+ <execution>
19
+ Run:
20
+
21
+ ```bash
22
+ {{PMC_BIN}} bootstrap . --all --enrich
23
+ ```
24
+
25
+ Then follow up with `pmc status .` to verify the worklist was created.
26
+ </execution>
27
+
28
+ <success_criteria>
29
+ - `.planning/project-memory-context/` directory exists with `graph/`, `enrichment/worklist.json`, and `enrichment/sync-manifest.json`
30
+ - 9 base project-context memories materialized in `agent-memory`
31
+ - Background enrichment started if `--enrich` was passed
32
+ </success_criteria>
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: sanitize
3
+ description: Re-run graphify, diff symbols, mark stale entries, and optionally start background enrichment.
4
+ argument-hint: ""
5
+ allowed-tools:
6
+ - Bash
7
+ ---
8
+
9
+ <objective>
10
+ Sanitize the PMC enrichment state. Re-runs graphify, diffs the symbol graph, marks stale or removed entries, and optionally starts background enrichment.
11
+ </objective>
12
+
13
+ <execution>
14
+ Run:
15
+
16
+ ```bash
17
+ {{PMC_BIN}} sanitize .
18
+ ```
19
+
20
+ This will re-run graphify, compare symbols against the existing worklist, mark stale entries, and delete orphaned enrichments. If pending items remain, background enrichment is launched automatically.
21
+ </execution>
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: sync-context
3
+ description: Upsert enriched memories from the sync-manifest into agent-memory.
4
+ argument-hint: ""
5
+ allowed-tools:
6
+ - Bash
7
+ ---
8
+
9
+ <objective>
10
+ Process `.planning/project-memory-context/enrichment/sync-manifest.json` and upsert pending entries into `{{AGENT_MEMORY_CMD}}`.
11
+ </objective>
12
+
13
+ <execution>
14
+ Run the sync using `agent-memory` MCP tools. For each pending entry in the sync-manifest, call `agent-memory_store` or `agent-memory_update` with the enrichment payload.
15
+
16
+ After processing, mark entries as `synced` in the sync-manifest.
17
+ </execution>
18
+
19
+ <success_criteria>
20
+ - All pending entries in sync-manifest marked as `synced`
21
+ - No orphaned memories remaining
22
+ </success_criteria>
@@ -0,0 +1,129 @@
1
+ <purpose>
2
+ Run a resumable project-memory-context workflow for existing repositories.
3
+
4
+ Stage A collects project intent, uses `brainstorming` to clarify ambiguity, persists intake artifacts, and invokes `graphify` as the structural mapping phase.
5
+
6
+ Stage B scans supported files (`JS/TS + .NET`), extracts top-level symbols, computes stable symbol identities, and writes `.planning/project-memory-context/enrichment/worklist.json` for semantic enrichment and agent-memory upserts.
7
+ </purpose>
8
+
9
+ <process>
10
+
11
+ <step name="parse_stage" priority="first">
12
+ Parse `$ARGUMENTS` and normalize one of:
13
+
14
+ - `stage-a`
15
+ - `stage-b`
16
+ - `all`
17
+
18
+ Default to `stage-a` when omitted.
19
+ </step>
20
+
21
+ <step name="stage_a_intake" condition="stage-a or all">
22
+ Ask the user for:
23
+
24
+ - a short project description
25
+ - the mapping goals
26
+ - optional focus areas
27
+
28
+ Then invoke the `brainstorming` skill to clarify any ambiguity in the intake before continuing.
29
+
30
+ Persist the normalized intake using:
31
+
32
+ ```bash
33
+ node "__PMC_PACKAGE_ROOT__/cli/save-intake-context.mjs" "<project description>" <goal1> <goal2>
34
+ ```
35
+ </step>
36
+
37
+ <step name="stage_a_graphify" condition="stage-a or all">
38
+ Run `graphify` against the current workspace after intake has been clarified.
39
+
40
+ Expected graph artifacts:
41
+
42
+ - `.planning/project-memory-context/graph/graph.json`
43
+ - `.planning/project-memory-context/graph/graph.html`
44
+ - `.planning/project-memory-context/graph/GRAPH_REPORT.md`
45
+ - `.planning/project-memory-context/graph/graph.metadata.json`
46
+
47
+ If `graphify` writes to `graphify-out/`, copy or mirror the resulting graph artifacts into `.planning/project-memory-context/graph/`.
48
+ </step>
49
+
50
+ <step name="stage_b_scan" condition="stage-b or all">
51
+ Select supported files from the repo for v1:
52
+
53
+ - `*.js`, `*.jsx`, `*.ts`, `*.tsx`
54
+ - `*.mjs`, `*.cjs`
55
+ - `*.cs`
56
+
57
+ Exclude generated folders such as `node_modules`, `dist`, `.git`, `bin`, `obj`.
58
+
59
+ Build the deterministic worklist with:
60
+
61
+ ```bash
62
+ node "__PMC_PACKAGE_ROOT__/cli/build-worklist.mjs" <relative-file-paths>
63
+ ```
64
+
65
+ The script writes `.planning/project-memory-context/enrichment/worklist.json`.
66
+ </step>
67
+
68
+ <step name="stage_b_semantic_enrichment" condition="stage-b or all">
69
+ Prepare semantic jobs with:
70
+
71
+ ```bash
72
+ node "__PMC_PACKAGE_ROOT__/cli/prepare-semantic-jobs.mjs"
73
+ ```
74
+
75
+ The script writes `.planning/project-memory-context/enrichment/semantic-jobs.json`.
76
+
77
+ For each pending job in `semantic-jobs.json`:
78
+
79
+ 1. load the exact file fragment for the symbol range
80
+ 2. call the `pmc-local-model` MCP with the prepared prompt and require a `semantic_report` result using this stable prefix format:
81
+
82
+ ```text
83
+ responsibility: ...
84
+ inputs: item1, item2
85
+ output: ...
86
+ dependencies: dep1, dep2
87
+ role: ...
88
+ ```
89
+
90
+ 3. materialize the memory payload before calling `pmc-agent-memory`:
91
+
92
+ ```bash
93
+ node "__PMC_PACKAGE_ROOT__/cli/materialize-enrichment-artifacts.mjs" @<job-file> @<report-file>
94
+ ```
95
+
96
+ 4. persist or update the semantic payload in `pmc-agent-memory`
97
+
98
+ 5. once `pmc-agent-memory` returns the `memoryId`, materialize the graph update payload:
99
+
100
+ ```bash
101
+ node "__PMC_PACKAGE_ROOT__/cli/materialize-enrichment-artifacts.mjs" @<job-file> @<report-file> <memory-id>
102
+ ```
103
+
104
+ 6. finalize the successful symbol using:
105
+
106
+ ```bash
107
+ node "__PMC_PACKAGE_ROOT__/cli/finalize-enrichment.mjs" @<symbol>.result.json
108
+ ```
109
+
110
+ If a symbol cannot be processed, mark it as `error` without aborting the rest of the run:
111
+
112
+ ```bash
113
+ node "__PMC_PACKAGE_ROOT__/cli/fail-enrichment.mjs" <symbol-key> "<error message>"
114
+ ```
115
+ </step>
116
+
117
+ <step name="report">
118
+ Print a compact summary:
119
+
120
+ - intake saved
121
+ - graph artifacts present or missing
122
+ - supported symbols found
123
+ - worklist count
124
+ - pending / enriched counts when Stage B runs
125
+
126
+ End by pointing to `.planning/project-memory-context/` as the persistent run directory.
127
+ </step>
128
+
129
+ </process>
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: project-memory-context
3
+ description: Intake an existing project, clarify mapping goals, run graphify, and build a resumable semantic enrichment worklist for JS/TS and .NET symbols.
4
+ argument-hint: "[stage-a|stage-b|all] [--paths <p1,p2,...>]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - Edit
11
+ - Write
12
+ - Agent
13
+ - TaskOutput
14
+ - Question
15
+ - Skill
16
+ ---
17
+
18
+ <objective>
19
+ Create a persistent project memory context for an existing codebase by combining intake context, graphify structural mapping, symbol extraction, local semantic enrichment, and agent-memory persistence.
20
+ </objective>
21
+
22
+ <execution_context>
23
+ @./project-memory-context workflow.md
24
+ </execution_context>
25
+
26
+ <context>
27
+ Arguments: $ARGUMENTS
28
+
29
+ Supported stages:
30
+ - `stage-a` — intake, clarification, graphify, artifact persistence
31
+ - `stage-b` — load graph artifacts, build symbol worklist, prepare semantic enrichment
32
+ - `all` — run Stage A then Stage B
33
+
34
+ Default stage is `stage-a`.
35
+ </context>
36
+
37
+ <success_criteria>
38
+ - Intake artifacts persisted under `.planning/project-memory-context/intake/`
39
+ - Graph artifacts persisted under `.planning/project-memory-context/graph/`
40
+ - Enrichment worklist persisted under `.planning/project-memory-context/enrichment/worklist.json`
41
+ - Workflow leaves resumable metadata for future semantic enrichment runs
42
+ </success_criteria>