mirror of
https://github.com/waybarrios/opencode-power-pack.git
synced 2026-11-18 18:03:43 +00:00
Fix portable rule resource loading
This commit is contained in:
@@ -8,7 +8,7 @@ license: Apache-2.0 (modified; see UPSTREAMS.json)
|
||||
|
||||
Audit, evaluate, and improve project-rules files across a codebase to ensure the agent has optimal project context.
|
||||
|
||||
Read `skills/agents-md-improver/references/project-rule-resolution.md` before discovery or resolution analysis. Apply only the behavior for the target client and pinned version; do not collapse OpenCode startup, OpenCode lazy nested, and Claude Code resolution into one rule.
|
||||
Read `references/project-rule-resolution.md`, resolved relative to this loaded `SKILL.md` directory and not the consuming project's CWD or working directory, before discovery or resolution analysis. Apply only the behavior for the target client and pinned version; do not collapse OpenCode startup, OpenCode lazy nested, and Claude Code resolution into one rule.
|
||||
|
||||
**This skill can write to project-rules files.** After presenting a quality report and getting user approval, it updates the files with targeted improvements.
|
||||
|
||||
@@ -30,7 +30,8 @@ Inventory only accessible and relevant sources supported by the matrix:
|
||||
|
||||
- Repository and applicable ancestor `AGENTS.md`, `CLAUDE.md`, deprecated `CONTEXT.md`, `CLAUDE.local.md`, `.claude/CLAUDE.md`, and `.claude/rules/**/*.md` files.
|
||||
- Nested files that can load lazily for paths in scope.
|
||||
- Files imported from applicable Claude rules and sources added through OpenCode `instructions` paths or globs.
|
||||
- Recursively follow effective Claude `@` imports relative to each containing file. Track canonical visited paths for cycle detection, stop at the verified maximum of four import hops, and, before reading an import outside the project, obtain explicit user approval.
|
||||
- Include sources added through OpenCode `instructions` paths or globs.
|
||||
- Relevant global, managed, and configured sources exposed by the target client. Record remote configured URLs without trusting their contents.
|
||||
- Unsupported lookalikes as findings, not as effective rules. `.agents.local.md` and `.claude.local.md` are unsupported; `CLAUDE.local.md` is Claude-native but not OpenCode-native.
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ The Claude documentation URLs are mutable, so these hashes describe the dated ob
|
||||
## Claude Code v2.1.220
|
||||
|
||||
- Claude loads applicable `CLAUDE.md`, `.claude/CLAUDE.md`, `CLAUDE.local.md`, and `.claude/rules/**/*.md` sources. Nested and path-scoped rules are loaded lazily when their scope becomes relevant.
|
||||
- Recursively follow effective Claude `@` imports, resolving each path relative to its containing file. Track canonical visited paths to detect cycles and stop at the verified maximum of four import hops. Before reading an import outside the project, obtain explicit user approval. For a concrete two-hop chain, project `CLAUDE.md` imports `@rules/team.md`, then `rules/team.md` imports `@../shared/testing.md`, which resolves to `shared/testing.md`.
|
||||
- Claude Code does not natively read `AGENTS.md`.
|
||||
- `.claude/settings.json` and `.claude/settings.local.json` are configuration files, not replacement instructions files.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ license: Apache-2.0 (modified; see UPSTREAMS.json)
|
||||
|
||||
Review the current session for learnings about working in this codebase, then update the project-rules file with context that would help future sessions be more effective.
|
||||
|
||||
Read `skills/agents-md-improver/references/project-rule-resolution.md` before target selection. Resolve the actual target client and phase instead of assuming that co-located files behave alike across OpenCode and Claude Code.
|
||||
Read `../agents-md-improver/references/project-rule-resolution.md`, resolved relative to this loaded `SKILL.md` directory and not the consuming project's CWD or working directory, before target selection. Resolve the actual target client and phase instead of assuming that co-located files behave alike across OpenCode and Claude Code.
|
||||
|
||||
## Untrusted data boundary
|
||||
|
||||
@@ -45,6 +45,7 @@ Read the matrix before selecting a target. Use native file search or glob when a
|
||||
- Startup directory, applicable ancestors, and any nested path scope for the learning.
|
||||
- Existing canonical shared file, Claude imports, OpenCode configured sources, and relevant global or managed sources when accessible.
|
||||
- Effective files under OpenCode startup family selection, OpenCode lazy nested selection, and Claude native/import/path-scoped behavior.
|
||||
- Recursively follow effective Claude `@` imports relative to each containing file. Track canonical visited paths for cycle detection, stop at the verified maximum of four import hops, and, before reading an import outside the project, obtain explicit user approval.
|
||||
|
||||
Decide where each addition belongs:
|
||||
|
||||
|
||||
@@ -9,6 +9,18 @@ const improver = read("skills/agents-md-improver/SKILL.md");
|
||||
const revise = read("skills/agents-md-revise/SKILL.md");
|
||||
const matrixPath = "skills/agents-md-improver/references/project-rule-resolution.md";
|
||||
const matrix = existsSync(join(REPO, matrixPath)) ? read(matrixPath) : "";
|
||||
const matrixConsumers = [
|
||||
{
|
||||
name: "agents-md-improver",
|
||||
skill: improver,
|
||||
locator: "references/project-rule-resolution.md",
|
||||
},
|
||||
{
|
||||
name: "agents-md-revise",
|
||||
skill: revise,
|
||||
locator: "../agents-md-improver/references/project-rule-resolution.md",
|
||||
},
|
||||
];
|
||||
|
||||
test("project-rule matrix pins the verified clients and evidence", () => {
|
||||
assert.ok(matrix.length > 0, "project-rule matrix exists");
|
||||
@@ -37,9 +49,18 @@ test("project-rule matrix describes Claude native files and the portable bridge"
|
||||
assert.match(matrix, /settings\.json.*settings\.local\.json.*configuration.*not.*instructions/is);
|
||||
});
|
||||
|
||||
test("rules skills use the matrix and stop treating invented local names as native", () => {
|
||||
for (const skill of [improver, revise]) {
|
||||
assert.ok(skill.includes(matrixPath));
|
||||
test("rules skills resolve the same packaged matrix relative to their SKILL.md", () => {
|
||||
for (const { name, skill, locator } of matrixConsumers) {
|
||||
assert.ok(skill.includes(`\`${locator}\``), `${name} declares its relative locator`);
|
||||
assert.match(skill, /relative to.*loaded `SKILL\.md` directory.*not.*(?:CWD|working directory)/is);
|
||||
const resolved = join(REPO, "skills", name, locator);
|
||||
assert.ok(existsSync(resolved), `${name} locator resolves`);
|
||||
assert.equal(readFileSync(resolved, "utf8"), matrix, `${name} loads the shared matrix`);
|
||||
}
|
||||
});
|
||||
|
||||
test("rules skills stop treating invented local names as native", () => {
|
||||
for (const { skill } of matrixConsumers) {
|
||||
assert.match(skill, /read.*matrix.*before.*(?:discovery|target)/is);
|
||||
assert.match(skill, /\.agents\.local\.md.*unsupported/is);
|
||||
assert.match(skill, /\.claude\.local\.md.*unsupported/is);
|
||||
@@ -48,6 +69,20 @@ test("rules skills use the matrix and stop treating invented local names as nati
|
||||
assert.doesNotMatch(revise, /first-match-wins per directory/i);
|
||||
});
|
||||
|
||||
test("matrix and rules skills recursively traverse bounded Claude imports", () => {
|
||||
for (const source of [matrix, improver, revise]) {
|
||||
assert.match(source, /recursiv.*Claude.*@.*imports/is);
|
||||
assert.match(source, /relative to.*containing file/is);
|
||||
assert.match(source, /cycle/is);
|
||||
assert.match(source, /maximum.*four import hops/is);
|
||||
assert.match(source, /outside.*project.*explicit user approval/is);
|
||||
}
|
||||
assert.match(
|
||||
matrix,
|
||||
/CLAUDE\.md.*@rules\/team\.md.*rules\/team\.md.*@\.\.\/shared\/testing\.md.*shared\/testing\.md/is,
|
||||
);
|
||||
});
|
||||
|
||||
test("rules skills prohibit secrets in every prompt-loaded file", () => {
|
||||
for (const skill of [improver, revise]) {
|
||||
assert.match(skill, /never.*secret values.*prompt-loaded file/is);
|
||||
|
||||
Reference in New Issue
Block a user