@danmoisan/drm-copilot-mcp 0.0.1 → 0.0.5
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/out/mcp-server.js +5 -1
- package/package.json +21 -5
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/MEMORY.md +15 -3
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_branch_base_check_unmerged_pr_deps.md +16 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_every_change_through_lifecycle.md +15 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_policy_compliance_not_optional.md +18 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_potential_to_issue_creates_github_issue.md +13 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_remediation_plan_em_dash_required.md +13 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_small_bug_uses_minor_audit.md +13 -0
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_test_files_count_against_500_cap.md +13 -0
- package/resources/claude-customizations/.claude/agents/atomic-executor.md +7 -7
- package/resources/claude-customizations/.claude/agents/csharp-typed-engineer.md +4 -5
- package/resources/claude-customizations/.claude/agents/feature-review.md +7 -3
- package/resources/claude-customizations/.claude/agents/orchestrator.md +16 -1
- package/resources/claude-customizations/.claude/agents/powershell-typed-engineer.md +1 -1
- package/resources/claude-customizations/.claude/hooks/enforce-checkpoint-monotonic.ps1 +245 -0
- package/resources/claude-customizations/.claude/hooks/enforce-completion-consistency.ps1 +273 -0
- package/resources/claude-customizations/.claude/hooks/enforce-feature-folder-order.ps1 +148 -0
- package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.ps1 +190 -0
- package/resources/claude-customizations/.claude/hooks/enforce-prd-feature-before-planner.ps1 +216 -0
- package/resources/claude-customizations/.claude/hooks/enforce-promotion-mcp-only.ps1 +84 -15
- package/resources/claude-customizations/.claude/hooks/validate-executor-output.ps1 +1 -1
- package/resources/claude-customizations/.claude/hooks/validate-feature-review-coverage.ps1 +75 -5
- package/resources/claude-customizations/.claude/hooks/validate-orchestrator-output.ps1 +93 -0
- package/resources/claude-customizations/.claude/hooks/validate-task-researcher-output.ps1 +68 -0
- package/resources/claude-customizations/.claude/rules/architecture-boundaries.md +46 -0
- package/resources/claude-customizations/.claude/rules/benchmark-baselines.md +35 -0
- package/resources/claude-customizations/.claude/rules/ci-workflows.md +36 -0
- package/resources/claude-customizations/.claude/rules/csharp.md +62 -16
- package/resources/claude-customizations/.claude/rules/general-code-change.md +12 -3
- package/resources/claude-customizations/.claude/rules/general-unit-test.md +47 -2
- package/resources/claude-customizations/.claude/rules/orchestrator-state.md +39 -0
- package/resources/claude-customizations/.claude/rules/powershell.md +5 -5
- package/resources/claude-customizations/.claude/rules/python.md +4 -3
- package/resources/claude-customizations/.claude/rules/quality-tiers.md +51 -0
- package/resources/claude-customizations/.claude/rules/typescript.md +37 -8
- package/resources/claude-customizations/.claude/settings.json +37 -12
- package/resources/claude-customizations/.claude/skills/atomic-plan-contract/SKILL.md +2 -2
- package/resources/claude-customizations/.claude/skills/csharp-qa-gate/SKILL.md +25 -10
- package/resources/claude-customizations/.claude/skills/execute-hard-lock/SKILL.md +6 -6
- package/resources/claude-customizations/.claude/skills/feature-promotion-lifecycle/SKILL.md +8 -8
- package/resources/claude-customizations/.claude/skills/feature-review-workflow/SKILL.md +17 -6
- package/resources/claude-customizations/.claude/skills/human-exception-runbook/SKILL.md +52 -0
- package/resources/claude-customizations/.claude/skills/human-exception-runbook/example.runbook.md +36 -0
- package/resources/claude-customizations/.claude/skills/invoke-csharp-engineer/SKILL.md +4 -4
- package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +96 -3
- package/resources/claude-customizations/.claude/skills/policy-audit-template-usage/SKILL.md +3 -3
- package/resources/claude-customizations/.claude/skills/powershell-qa-gate/SKILL.md +4 -4
- package/resources/claude-customizations/.claude/skills/pr-base-branch-merge-base/SKILL.md +3 -3
- package/resources/claude-customizations/.claude/skills/python-qa-gate/SKILL.md +1 -1
- package/resources/claude-customizations/.claude/skills/remediation-handoff-atomic-planner/SKILL.md +90 -17
- package/resources/claude-dir-customizations/.mcp.json +3 -3
- package/resources/codex-and-agents-customizations/.agents/README.md +1 -1
- package/resources/codex-and-agents-customizations/.agents/skills/acceptance-criteria-tracking/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/architecture-boundaries/SKILL.md +52 -0
- package/resources/codex-and-agents-customizations/.agents/skills/atomic-plan-contract/SKILL.md +16 -8
- package/resources/codex-and-agents-customizations/.agents/skills/benchmark-baselines/SKILL.md +44 -0
- package/resources/codex-and-agents-customizations/.agents/skills/ci-workflows/SKILL.md +45 -0
- package/resources/codex-and-agents-customizations/.agents/skills/commit-message/SKILL.md +3 -11
- package/resources/codex-and-agents-customizations/.agents/skills/csharp/SKILL.md +1 -5
- package/resources/codex-and-agents-customizations/.agents/skills/csharp-change-budget-router/SKILL.md +1 -6
- package/resources/codex-and-agents-customizations/.agents/skills/csharp-orchestration-state-machine/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/csharp-qa-gate/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/evidence-and-timestamp-conventions/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/execute-hard-lock/SKILL.md +8 -17
- package/resources/codex-and-agents-customizations/.agents/skills/feature-promotion-lifecycle/SKILL.md +13 -14
- package/resources/codex-and-agents-customizations/.agents/skills/feature-review-workflow/SKILL.md +1 -6
- package/resources/codex-and-agents-customizations/.agents/skills/fill-feature-docs/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/general-code-change/SKILL.md +86 -0
- package/resources/codex-and-agents-customizations/.agents/skills/general-unit-test/SKILL.md +111 -0
- package/resources/codex-and-agents-customizations/.agents/skills/human-exception-runbook/SKILL.md +57 -0
- package/resources/codex-and-agents-customizations/.agents/skills/human-exception-runbook/example.runbook.md +36 -0
- package/resources/codex-and-agents-customizations/.agents/skills/invoke-csharp-engineer/SKILL.md +0 -9
- package/resources/codex-and-agents-customizations/.agents/skills/invoke-powershell-engineer/SKILL.md +0 -9
- package/resources/codex-and-agents-customizations/.agents/skills/invoke-python-engineer/SKILL.md +0 -9
- package/resources/codex-and-agents-customizations/.agents/skills/make-skill-template/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/orchestrate/SKILL.md +93 -8
- package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-state/SKILL.md +48 -0
- package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-workflow/SKILL.md +61 -2
- package/resources/codex-and-agents-customizations/.agents/skills/policy-audit-template-usage/SKILL.md +3 -8
- package/resources/codex-and-agents-customizations/.agents/skills/policy-compliance-order/SKILL.md +0 -10
- package/resources/codex-and-agents-customizations/.agents/skills/powershell/SKILL.md +4 -8
- package/resources/codex-and-agents-customizations/.agents/skills/powershell-change-budget-router/SKILL.md +1 -6
- package/resources/codex-and-agents-customizations/.agents/skills/powershell-orchestration-state-machine/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/powershell-qa-gate/SKILL.md +3 -9
- package/resources/codex-and-agents-customizations/.agents/skills/pr-author/SKILL.md +1 -9
- package/resources/codex-and-agents-customizations/.agents/skills/pr-base-branch-merge-base/SKILL.md +4 -9
- package/resources/codex-and-agents-customizations/.agents/skills/pr-context-artifacts/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/python/SKILL.md +1 -5
- package/resources/codex-and-agents-customizations/.agents/skills/python-change-budget-router/SKILL.md +1 -6
- package/resources/codex-and-agents-customizations/.agents/skills/python-qa-gate/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/python-suppressions/SKILL.md +2 -6
- package/resources/codex-and-agents-customizations/.agents/skills/quality-tiers/SKILL.md +57 -0
- package/resources/codex-and-agents-customizations/.agents/skills/remediation-handoff-atomic-planner/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/repo-automation-adapter/SKILL.md +91 -72
- package/resources/codex-and-agents-customizations/.agents/skills/repo-automation-adapter/agents/openai.yaml +1 -1
- package/resources/codex-and-agents-customizations/.agents/skills/research-issue/SKILL.md +0 -10
- package/resources/codex-and-agents-customizations/.agents/skills/review-epic/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/review-feature/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/review-staged/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/self-explanatory-code-commenting/SKILL.md +2 -6
- package/resources/codex-and-agents-customizations/.agents/skills/skill-canonical-location-audit/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.agents/skills/tonality/SKILL.md +86 -0
- package/resources/codex-and-agents-customizations/.agents/skills/translate-claude-to-codex/SKILL.md +297 -0
- package/resources/codex-and-agents-customizations/.agents/skills/translate-copilot-to-claude/SKILL.md +0 -22
- package/resources/codex-and-agents-customizations/.agents/skills/typescript/SKILL.md +1 -5
- package/resources/codex-and-agents-customizations/.agents/skills/typescript-suppressions/SKILL.md +2 -6
- package/resources/codex-and-agents-customizations/.agents/skills/update-status/SKILL.md +0 -5
- package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor.toml +5 -5
- package/resources/codex-and-agents-customizations/.codex/agents/orchestrator.toml +91 -63
- package/resources/codex-and-agents-customizations/.codex/agents/powershell-atomic-executor.toml +1 -1
- package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer.toml +1 -1
- package/resources/codex-and-agents-customizations/.codex/config.toml +51 -136
- package/resources/codex-and-agents-customizations/.codex/hooks/enforce-promotion-mcp-only.ps1 +1 -1
- package/resources/codex-and-agents-customizations/.codex/prompts/orchestrate-work.md +4 -3
- package/resources/codex-and-agents-customizations/.codex/scripts/post-codex-worktree-session.ps1 +5 -0
- package/resources/codex-and-agents-customizations/.github/workflows/_validate-orchestrator-state.yml +68 -0
- package/resources/codex-and-agents-customizations/.github/workflows/validate-orchestrator-state.yml +15 -0
- package/resources/config/orchestration-routing.json +84 -0
- package/resources/customizations/.github/agents/Powershell DI Unit Test Engineer.agent.md +1 -1
- package/resources/customizations/.github/agents/atomic_executor.agent.md +1 -1
- package/resources/customizations/.github/agents/atomic_planning.agent.md +10 -10
- package/resources/customizations/.github/agents/csharp-orchestrator.agent.md +6 -2
- package/resources/customizations/.github/agents/feature-review.agent.md +2 -2
- package/resources/customizations/.github/agents/orchestrator.agent.md +6 -2
- package/resources/customizations/.github/agents/powershell-atomic-executor.agent.md +4 -4
- package/resources/customizations/.github/agents/powershell-atomic-planning.agent.md +10 -10
- package/resources/customizations/.github/agents/powershell-orchestrator.agent.md +6 -2
- package/resources/customizations/.github/agents/powershell-typed-engineer.agent.md +2 -2
- package/resources/customizations/.github/agents/python-orchestrator.agent.md +6 -2
- package/resources/customizations/.github/agents/staged-review.agent.md +1 -1
- package/resources/customizations/.github/instructions/powershell-code-change.instructions.md +6 -6
- package/resources/customizations/.github/prompts/generate-commit-message-repo.prompt.md +1 -1
- package/resources/customizations/.github/prompts/orchestrate-csharp-work.prompt.md +5 -3
- package/resources/customizations/.github/prompts/orchestrate-work.prompt.md +5 -3
- package/resources/customizations/.github/skills/atomic-plan-contract/SKILL.md +14 -1
- package/resources/customizations/.github/skills/feature-promotion-lifecycle/SKILL.md +11 -7
- package/resources/customizations/.github/skills/feature-review-workflow/SKILL.md +10 -1
- package/resources/customizations/.github/skills/pr-base-branch-merge-base/SKILL.md +2 -2
- package/resources/customizations/.github/skills/remediation-handoff-atomic-planner/SKILL.md +5 -0
- package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +7 -0
- package/resources/scripts/dev_tools/_orchestrator_state_human_interaction.py +127 -0
- package/resources/scripts/dev_tools/_orchestrator_state_routing.py +216 -0
- package/resources/scripts/dev_tools/push_down_claude_customizations.py +191 -5
- package/resources/scripts/dev_tools/validate_orchestration_artifacts.py +103 -411
- package/resources/scripts/dev_tools/validate_orchestration_review_artifacts.py +107 -0
- package/resources/scripts/dev_tools/validate_orchestrator_state.py +428 -0
- package/resources/scripts/dev_tools/validate_policy_audit_artifact.py +448 -0
- package/resources/templates/push_down_claude_customizations.py +227 -6
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_repo_root_is_source_of_truth.md +0 -11
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/feedback_vsce_verify_package_location.md +0 -19
- package/resources/claude-customizations/.claude/agent-memory/orchestrator/project_extension_location.md +0 -11
- package/resources/claude-customizations/.claude/agent-memory/prd-feature/MEMORY.md +0 -1
- package/resources/claude-customizations/.claude/agent-memory/prd-feature/project_push_down_pattern.md +0 -13
- package/resources/claude-customizations/.claude/agent-memory/task-researcher/MEMORY.md +0 -3
- package/resources/claude-customizations/.claude/agent-memory/task-researcher/project_push_down_claude_dir.md +0 -11
|
@@ -5,13 +5,45 @@ Purpose:
|
|
|
5
5
|
workflow while reusing the shared publisher engine behind the existing
|
|
6
6
|
`.github` customization flow. Settings-local configuration is excluded from
|
|
7
7
|
push-down because it holds host-specific overrides that must not propagate.
|
|
8
|
+
|
|
9
|
+
Agent-memory files under `.claude/agent-memory/` are filtered by a
|
|
10
|
+
content-based scope check: only memories whose frontmatter declares
|
|
11
|
+
`metadata.scope: general` are distributed to a destination workspace. A
|
|
12
|
+
memory with an absent, malformed, or unrecognized scope is treated as
|
|
13
|
+
`repo` and excluded (fail-safe default), so repository-specific memories do
|
|
14
|
+
not leak into consumer workspaces. Files outside `.claude/agent-memory/`
|
|
15
|
+
are copied verbatim and are never affected by the scope filter.
|
|
8
16
|
"""
|
|
9
17
|
|
|
10
18
|
from __future__ import annotations
|
|
11
19
|
|
|
12
20
|
import argparse
|
|
21
|
+
import re
|
|
13
22
|
from pathlib import Path
|
|
14
23
|
|
|
24
|
+
AGENT_MEMORY_RELATIVE_ROOT = Path(".claude/agent-memory")
|
|
25
|
+
GENERAL_MEMORY_SCOPE = "general"
|
|
26
|
+
REPO_MEMORY_SCOPE = "repo"
|
|
27
|
+
|
|
28
|
+
# Match a leading YAML frontmatter block: the first `---` line, the block body,
|
|
29
|
+
# and the closing `---` line. DOTALL lets the body span multiple lines.
|
|
30
|
+
_FRONTMATTER_PATTERN = re.compile(
|
|
31
|
+
r"\A---[ \t]*\r?\n(.*?)\r?\n---[ \t]*(?:\r?\n|\Z)", re.DOTALL
|
|
32
|
+
)
|
|
33
|
+
# Match a `metadata:` mapping key at column zero, then capture the indented
|
|
34
|
+
# block lines that belong to it (lines that are more-indented or blank) until
|
|
35
|
+
# the next column-zero key or end of the frontmatter body.
|
|
36
|
+
_METADATA_BLOCK_PATTERN = re.compile(
|
|
37
|
+
r"^metadata:[ \t]*\r?\n((?:[ \t]+.*(?:\r?\n|\Z)|\r?\n)*)",
|
|
38
|
+
re.MULTILINE,
|
|
39
|
+
)
|
|
40
|
+
# Match a `scope:` leaf inside the metadata block, capturing its scalar value
|
|
41
|
+
# up to an optional inline comment. Surrounding quotes are stripped later.
|
|
42
|
+
_SCOPE_LEAF_PATTERN = re.compile(
|
|
43
|
+
r"^[ \t]+scope:[ \t]*([^\r\n#]*)",
|
|
44
|
+
re.MULTILINE,
|
|
45
|
+
)
|
|
46
|
+
|
|
15
47
|
try:
|
|
16
48
|
from scripts.dev_tools.push_down_copilot_customizations import (
|
|
17
49
|
PushDownFileSystem,
|
|
@@ -41,9 +73,12 @@ ROOT_FOLDERS: tuple[Path, ...] = (Path(".claude"),)
|
|
|
41
73
|
EXCLUDED_RELATIVE_PATHS: tuple[Path, ...] = (Path(".claude/settings.local.json"),)
|
|
42
74
|
|
|
43
75
|
__all__ = [
|
|
76
|
+
"AGENT_MEMORY_RELATIVE_ROOT",
|
|
44
77
|
"ARTIFACT_DIRECTORY",
|
|
45
78
|
"EXCLUDED_RELATIVE_PATHS",
|
|
79
|
+
"GENERAL_MEMORY_SCOPE",
|
|
46
80
|
"PushDownSummary",
|
|
81
|
+
"REPO_MEMORY_SCOPE",
|
|
47
82
|
"ROOT_FOLDERS",
|
|
48
83
|
"main",
|
|
49
84
|
"parse_args",
|
|
@@ -51,14 +86,113 @@ __all__ = [
|
|
|
51
86
|
]
|
|
52
87
|
|
|
53
88
|
|
|
89
|
+
def _read_memory_scope(content: str) -> str:
|
|
90
|
+
"""Return the declared memory scope from a file's YAML frontmatter.
|
|
91
|
+
|
|
92
|
+
Purpose:
|
|
93
|
+
Extract the `metadata.scope` leaf from the leading YAML frontmatter
|
|
94
|
+
block using a narrow `re`-based parser. This avoids adding a runtime
|
|
95
|
+
YAML dependency (PyYAML) while reading only the single leaf the
|
|
96
|
+
push-down scope filter requires.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
content (str): The full text of a candidate memory file, including any
|
|
100
|
+
leading `---` frontmatter block.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
str: ``"general"`` only when the frontmatter contains a `metadata:`
|
|
104
|
+
mapping whose `scope:` leaf is exactly ``general`` (quotes and inline
|
|
105
|
+
comments stripped). In every other case — missing frontmatter, no
|
|
106
|
+
closing `---`, no `metadata:` block, no `scope:` leaf, or any value
|
|
107
|
+
other than exactly ``general`` — it returns ``"repo"`` as the fail-safe
|
|
108
|
+
default so nothing leaks by accident.
|
|
109
|
+
|
|
110
|
+
Raises:
|
|
111
|
+
None.
|
|
112
|
+
|
|
113
|
+
Side Effects:
|
|
114
|
+
None.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
# Isolate the leading frontmatter block; absent or unterminated frontmatter
|
|
118
|
+
# fails safe to the repo scope so unmarked files are never distributed.
|
|
119
|
+
frontmatter_match = _FRONTMATTER_PATTERN.match(content)
|
|
120
|
+
if frontmatter_match is None:
|
|
121
|
+
return REPO_MEMORY_SCOPE
|
|
122
|
+
frontmatter_body = frontmatter_match.group(1)
|
|
123
|
+
|
|
124
|
+
# Locate the metadata mapping; without it there is no scope leaf to read.
|
|
125
|
+
metadata_match = _METADATA_BLOCK_PATTERN.search(frontmatter_body)
|
|
126
|
+
if metadata_match is None:
|
|
127
|
+
return REPO_MEMORY_SCOPE
|
|
128
|
+
metadata_block = metadata_match.group(1)
|
|
129
|
+
|
|
130
|
+
# Read the scope leaf from within the metadata block only; a top-level
|
|
131
|
+
# `scope:` outside `metadata:` is intentionally ignored.
|
|
132
|
+
scope_match = _SCOPE_LEAF_PATTERN.search(metadata_block)
|
|
133
|
+
if scope_match is None:
|
|
134
|
+
return REPO_MEMORY_SCOPE
|
|
135
|
+
|
|
136
|
+
# Strip surrounding whitespace and optional matching quotes before the
|
|
137
|
+
# exact-match comparison; only an exact `general` is treated as general.
|
|
138
|
+
scope_value = scope_match.group(1).strip()
|
|
139
|
+
if (
|
|
140
|
+
len(scope_value) >= 2
|
|
141
|
+
and scope_value[0] == scope_value[-1]
|
|
142
|
+
and scope_value[0] in {'"', "'"}
|
|
143
|
+
):
|
|
144
|
+
scope_value = scope_value[1:-1].strip()
|
|
145
|
+
if scope_value == GENERAL_MEMORY_SCOPE:
|
|
146
|
+
return GENERAL_MEMORY_SCOPE
|
|
147
|
+
return REPO_MEMORY_SCOPE
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _is_general_memory_file(relative_path: Path, content: str) -> bool:
|
|
151
|
+
"""Return whether a candidate file may be distributed by push-down.
|
|
152
|
+
|
|
153
|
+
Purpose:
|
|
154
|
+
Decide inclusion for one source file. Files under
|
|
155
|
+
`.claude/agent-memory/` are distributed only when general-scoped;
|
|
156
|
+
every other file is always distributed and is unaffected by the scope
|
|
157
|
+
filter.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
relative_path (Path): The file path relative to the repository root.
|
|
161
|
+
content (str): The full text of the file, used to read the memory
|
|
162
|
+
scope when the path is under the agent-memory subtree.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
bool: ``True`` when the path is outside `.claude/agent-memory/`, or when
|
|
166
|
+
the path is under that subtree and `_read_memory_scope(content)` is
|
|
167
|
+
exactly ``general``. ``False`` only for an agent-memory file whose
|
|
168
|
+
scope is not general (the fail-safe exclusion).
|
|
169
|
+
|
|
170
|
+
Raises:
|
|
171
|
+
None.
|
|
172
|
+
|
|
173
|
+
Side Effects:
|
|
174
|
+
None.
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
# Files outside the agent-memory subtree are always copied; the scope
|
|
178
|
+
# filter never applies to rules, skills, agents, hooks, or settings.
|
|
179
|
+
try:
|
|
180
|
+
relative_path.relative_to(AGENT_MEMORY_RELATIVE_ROOT)
|
|
181
|
+
except ValueError:
|
|
182
|
+
return True
|
|
183
|
+
return _read_memory_scope(content) == GENERAL_MEMORY_SCOPE
|
|
184
|
+
|
|
185
|
+
|
|
54
186
|
class _ExcludingFileSystem:
|
|
55
187
|
"""Wrap a PushDownFileSystem and filter specified paths from list_files.
|
|
56
188
|
|
|
57
189
|
Purpose:
|
|
58
190
|
Prevent host-specific files (e.g. `settings.local.json`) from being
|
|
59
|
-
included when the publisher enumerates source files
|
|
60
|
-
|
|
61
|
-
|
|
191
|
+
included when the publisher enumerates source files, and exclude
|
|
192
|
+
repository-specific agent memories so only general-scoped memories are
|
|
193
|
+
distributed. Chosen over a post-enumeration filter so the exclusion
|
|
194
|
+
travels with the filesystem contract and is transparent to the shared
|
|
195
|
+
engine.
|
|
62
196
|
|
|
63
197
|
Usage:
|
|
64
198
|
Instantiate with the inner adapter and exclusion paths relative to
|
|
@@ -66,6 +200,8 @@ class _ExcludingFileSystem:
|
|
|
66
200
|
|
|
67
201
|
Invariants / Constraints:
|
|
68
202
|
Excluded paths are resolved once at construction time for O(1) checks.
|
|
203
|
+
The content-based scope filter reads file content only for candidates
|
|
204
|
+
under `.claude/agent-memory/`; all other files skip the read.
|
|
69
205
|
|
|
70
206
|
Side Effects:
|
|
71
207
|
Delegates all I/O to the inner adapter.
|
|
@@ -76,15 +212,65 @@ class _ExcludingFileSystem:
|
|
|
76
212
|
) -> None:
|
|
77
213
|
"""Set up the adapter; resolve exclusion paths relative to repo_root."""
|
|
78
214
|
self._inner = inner
|
|
215
|
+
# Retain the resolved repo root so per-file scope checks can derive the
|
|
216
|
+
# repo-relative path needed by the agent-memory scope filter.
|
|
217
|
+
self._repo_root = repo_root.resolve()
|
|
79
218
|
# Resolve once at init so list_files per-path checks are O(1).
|
|
80
219
|
self._excluded: frozenset[Path] = frozenset(
|
|
81
220
|
(repo_root / p).resolve() for p in excluded
|
|
82
221
|
)
|
|
83
222
|
|
|
223
|
+
def _is_scope_included(self, path: Path) -> bool:
|
|
224
|
+
"""Return whether a candidate file passes the agent-memory scope filter.
|
|
225
|
+
|
|
226
|
+
Purpose:
|
|
227
|
+
Apply the general-vs-repo memory scope decision to one enumerated
|
|
228
|
+
file, reading its content only when the path is under the
|
|
229
|
+
agent-memory subtree.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
path (Path): The absolute candidate path returned by the inner
|
|
233
|
+
adapter's ``list_files``.
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
bool: ``True`` when the file is outside `.claude/agent-memory/` or
|
|
237
|
+
is a general-scoped memory; ``False`` for a non-general memory.
|
|
238
|
+
|
|
239
|
+
Raises:
|
|
240
|
+
None.
|
|
241
|
+
|
|
242
|
+
Side Effects:
|
|
243
|
+
Reads file content via the inner adapter for agent-memory
|
|
244
|
+
candidates only.
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
# Derive the repo-relative path so the agent-memory check matches the
|
|
248
|
+
# `.claude/agent-memory/` prefix regardless of the absolute location.
|
|
249
|
+
try:
|
|
250
|
+
relative_path = path.resolve().relative_to(self._repo_root)
|
|
251
|
+
except ValueError:
|
|
252
|
+
# A path outside the repo root cannot be an agent memory; include it.
|
|
253
|
+
return True
|
|
254
|
+
|
|
255
|
+
# Skip the content read entirely for files outside the memory subtree.
|
|
256
|
+
try:
|
|
257
|
+
relative_path.relative_to(AGENT_MEMORY_RELATIVE_ROOT)
|
|
258
|
+
except ValueError:
|
|
259
|
+
return True
|
|
260
|
+
|
|
261
|
+
content = self._inner.read_text(path)
|
|
262
|
+
return _is_general_memory_file(relative_path, content)
|
|
263
|
+
|
|
84
264
|
def list_files(self, root: Path) -> list[Path]:
|
|
85
|
-
"""Return inner list_files output with excluded paths removed.
|
|
265
|
+
"""Return inner list_files output with excluded paths removed.
|
|
266
|
+
|
|
267
|
+
Drops paths in ``EXCLUDED_RELATIVE_PATHS`` and any agent-memory file
|
|
268
|
+
that is not general-scoped per the content-based scope filter.
|
|
269
|
+
"""
|
|
86
270
|
return [
|
|
87
|
-
p
|
|
271
|
+
p
|
|
272
|
+
for p in self._inner.list_files(root)
|
|
273
|
+
if p.resolve() not in self._excluded and self._is_scope_included(p)
|
|
88
274
|
]
|
|
89
275
|
|
|
90
276
|
def is_dir(self, path: Path) -> bool:
|