Skip to content

Commit 7e8ba39

Browse files
committed
feat!: namespaces, lint mode, and markdown-aware task parsing
Add multi-team isolation via namespaces, dry-run lint validation, and goldmark-based parsing so slash commands inside code blocks are ignored. Namespaces: - Support namespace/taskname syntax (e.g. myteam/fix-bug) for shared .agents/ - Tasks, rules, commands, and skills under .agents/namespaces/<team>/ - Namespace assets take precedence over global; rules and skills merge - Add docs/how-to/use-namespaces.md and namespace selector in rule frontmatter Lint mode: - Run context assembly without bootstrap or shell execution - Track loaded files and collect structural errors (parse, missing commands, skill validation, selector mismatches) in LintResult - Add WithLint() option, ListTasks(), and include_unmatched task frontmatter - Parse errors include line/column; selector/command errors use task path Task parser: - Integrate goldmark Extension for AST-based code range detection - Slash commands in fenced, indented, and HTML code blocks no longer detected - ParseMarkdownFile populates Markdown.Task; re-parse only on content change Infrastructure: - Enable golangci-lint with comprehensive linter configuration - Fix lint issues across codebase (revive, gosec, wrapcheck, etc.) - Add t.Parallel() to tests; expand test coverage - Documentation corrections and new how-to guides.
1 parent 3a9b6eb commit 7e8ba39

68 files changed

Lines changed: 8791 additions & 3748 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# https://golangci-lint.run/usage/linters/
2+
# The goal here is to:
3+
# (a) reduce bugs
4+
# (b) make code more readable to make code reviews faster
5+
# (c) speed up development by catching some things that would otherwise be caught by the compiler
6+
# (d) prefer automatically fixing code
7+
version: "2"
8+
linters:
9+
default: all
10+
enable:
11+
- wsl_v5
12+
disable:
13+
- wsl
14+
- depguard
15+
- noinlineerr
16+
- exhaustruct
17+
- testpackage
18+
- varnamelen
19+
settings:
20+
funlen:
21+
lines: 100
22+
gocognit:
23+
min-complexity: 50
24+
cyclop:
25+
max-complexity: 15
26+
wsl_v5:
27+
allow-first-in-block: true
28+
allow-whole-block: false
29+
branch-max-lines: 2
30+
tagliatelle:
31+
case:
32+
rules:
33+
json: snake
34+
yaml: snake

README.md

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The tool assembles context into a structured prompt with the following component
5555
- **Task-Specific Prompts**: Use different prompts for different tasks (e.g., `feature`, `bugfix`).
5656
- **Rule-Based Context**: Define reusable context snippets (rules) that can be included or excluded.
5757
- **Skills System**: Progressive disclosure of specialized capabilities via skill directories.
58+
- **Namespaces**: Isolate multiple teams' assets under `.agents/namespaces/<team>/` while sharing a global layer.
5859
- **Frontmatter Filtering**: Select rules based on metadata using frontmatter selectors (matches top-level YAML fields only).
5960
- **Bootstrap Scripts**: Run scripts to fetch or generate context dynamically.
6061
- **Parameter Substitution**: Inject values into your task prompts.
@@ -66,14 +67,14 @@ This tool is compatible with configuration files from various AI coding agents a
6667

6768
### Primary Supported Agents (with dedicated `-a` flag)
6869

69-
- **[GitHub Copilot](https://github.com/features/copilot)**: `.github/copilot-instructions.md`, `.github/agents` (`-a copilot`)
70-
- **[Anthropic Claude](https://claude.ai/)**: `CLAUDE.md`, `CLAUDE.local.md`, `.claude/CLAUDE.md` (`-a claude`)
71-
- **[Cursor](https://cursor.sh/)**: `.cursor/rules`, `.cursorrules` (`-a cursor`)
72-
- **[Google Gemini](https://gemini.google.com/)**: `GEMINI.md`, `.gemini/styleguide.md` (`-a gemini`)
73-
- **[Augment](https://augmentcode.com/)**: `.augment/rules`, `.augment/guidelines.md` (`-a augment`)
74-
- **[Windsurf](https://codeium.com/windsurf)**: `.windsurf/rules`, `.windsurfrules` (`-a windsurf`)
75-
- **[OpenCode.ai](https://opencode.ai/)**: `.opencode/agent`, `.opencode/command`, `.opencode/rules` (`-a opencode`)
76-
- **[Codex](https://codex.ai/)**: `AGENTS.md`, `.codex/AGENTS.md` (`-a codex`)
70+
- **[GitHub Copilot](https://github.com/features/copilot)**: `.github/copilot-instructions.md`, `.github/agents/` (`-a copilot`)
71+
- **[Anthropic Claude](https://claude.ai/)**: `CLAUDE.md`, `CLAUDE.local.md`, `.claude/` (directory) (`-a claude`)
72+
- **[Cursor](https://cursor.sh/)**: `.cursor/rules/`, `.cursorrules` (`-a cursor`)
73+
- **[Google Gemini](https://gemini.google.com/)**: `GEMINI.md`, `.gemini/styleguide.md`, `.gemini/` (directory) (`-a gemini`)
74+
- **[Augment](https://augmentcode.com/)**: `.augment/rules/`, `.augment/guidelines.md` (`-a augment`)
75+
- **[Windsurf](https://codeium.com/windsurf)**: `.windsurf/rules/`, `.windsurfrules` (`-a windsurf`)
76+
- **[OpenCode.ai](https://opencode.ai/)**: `.opencode/agent/`, `.opencode/rules/` (rules); `.opencode/command/` (commands) (`-a opencode`)
77+
- **[Codex](https://codex.ai/)**: `AGENTS.md`, `.codex/` (directory) (`-a codex`)
7778

7879
### Additional Compatible Agents
7980

@@ -158,13 +159,15 @@ Options:
158159
Go Getter URL to a manifest file containing search paths (one per line). Every line is included as-is.
159160
-p value
160161
Parameter to substitute in the prompt. Can be specified multiple times as key=value.
161-
-r Resume mode: skip outputting rules and select task with 'resume: true' in frontmatter.
162+
-r Resume mode: set 'resume=true' selector to filter tasks by their frontmatter resume field. Does not skip rules; use --skip-bootstrap to skip rule discovery.
162163
-s value
163164
Include rules with matching frontmatter. Can be specified multiple times as key=value.
164165
Note: Only matches top-level YAML fields in frontmatter.
165166
-a string
166167
Target agent to use. Required when using -w to write rules to the agent's user rules path. Supported agents: cursor, opencode, copilot, claude, gemini, augment, windsurf, codex.
167168
-w Write rules to agent's config file and output only task to stdout. Requires agent (via task or -a flag).
169+
--skip-bootstrap
170+
Skip discovering rules, skills, and running bootstrap scripts.
168171
```
169172

170173
### Examples
@@ -325,6 +328,57 @@ coding-context \
325328
/implement-feature
326329
```
327330

331+
## Namespaces
332+
333+
Namespaces let multiple teams share a single `.agents/` directory without conflicts. Select a namespace by prefixing the task name with `namespace/`:
334+
335+
```bash
336+
# Global task (existing behaviour)
337+
coding-context fix-bug
338+
339+
# Namespaced task — activates the "myteam" namespace
340+
coding-context myteam/fix-bug
341+
```
342+
343+
**Directory structure:**
344+
345+
```
346+
.agents/
347+
├── tasks/ # Global tasks
348+
├── rules/ # Global rules (always included)
349+
├── commands/ # Global commands
350+
├── skills/ # Global skills
351+
└── namespaces/ # Namespace root (new)
352+
├── myteam/
353+
│ ├── tasks/ # Tasks accessed as "myteam/<name>"
354+
│ ├── rules/ # Namespace rules (included first)
355+
│ ├── commands/ # Override global commands
356+
│ └── skills/
357+
└── otherteam/
358+
└── ...
359+
```
360+
361+
**Resolution rules:**
362+
- **Tasks**: Namespace directory first, falls back to global if not found
363+
- **Rules**: Namespace rules included first, then all global rules (both always included)
364+
- **Commands**: Namespace command wins over global command with the same name
365+
- **Skills**: Namespace and global skills both discovered; namespace listed first
366+
367+
**Scoping rules to a namespace** — add `namespace: myteam` to a rule's frontmatter:
368+
369+
```markdown
370+
---
371+
namespace: myteam
372+
---
373+
# myteam Internal Standards
374+
375+
Only included for myteam/* tasks.
376+
```
377+
378+
Rules with no `namespace` field are always included regardless of namespace.
379+
380+
For a complete guide, see [How to Use Namespaces](https://kitproj.github.io/coding-context-cli/how-to/use-namespaces).
381+
328382
## File Formats
329383

330384
### Task Files
@@ -438,23 +492,23 @@ The `expand` field works in:
438492

439493
### Resume Mode
440494

441-
Resume mode is designed for continuing work on a task where you've already established context. When using the `-r` flag:
495+
Resume mode is designed for continuing work on a task where you've already established context. The `-r` flag adds a `resume=true` selector, which filters tasks to those with `resume: true` in their frontmatter.
442496

443-
1. **Rules are skipped**: All rule files are excluded from output, saving tokens and reducing context size
444-
2. **Resume-specific task prompts are selected**: Automatically adds `-s resume=true` selector to find task files with `resume: true` in their frontmatter
497+
**What the `-r` flag does:**
498+
- Adds `-s resume=true` selector to find task files with `resume: true` in their frontmatter
445499

446-
This is particularly useful in agentic workflows where an AI agent has already been primed with rules and is continuing work from a previous session.
447-
448-
**The `-r` flag is shorthand for:**
449-
- Adding `-s resume=true` selector
450-
- Skipping all rules output
500+
**What the `-r` flag does NOT do:**
501+
- It does **not** skip rules or bootstrap scripts. To skip those, use `--skip-bootstrap`.
451502

452503
**Example usage:**
453504
```bash
454-
# Initial task invocation (includes all rules, uses task with resume: false)
505+
# Initial task invocation (includes all rules and bootstrap)
455506
coding-context -s resume=false fix-bug | ai-agent
456507
457-
# Resume the task (skips rules, uses task with resume: true)
508+
# Resume the task with rules skipped (uses resume task, skips rules and bootstrap)
509+
coding-context -r --skip-bootstrap fix-bug | ai-agent
510+
511+
# Resume the task keeping rules (just selects the resume variant of the task)
458512
coding-context -r fix-bug | ai-agent
459513
```
460514

@@ -482,7 +536,7 @@ Continue working on the bug fix.
482536
Review your previous work and complete remaining tasks.
483537
```
484538

485-
With this approach, you can have multiple task prompts for the same task name, differentiated by the `resume` frontmatter field. Use `-s resume=false` to select the initial task (with rules), or `-r` to select the resume task (without rules).
539+
With this approach, you can have multiple task prompts for the same task name, differentiated by the `resume` frontmatter field. Use `-s resume=false` to select the initial task, or `-r` to select the resume task. Combine with `--skip-bootstrap` to also skip rules.
486540

487541
### Rule Files
488542

docs/how-to/create-tasks.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ coding-context implement-feature
186186

187187
The frontmatter (with `selectors`, `languages`, etc.) is parsed and used to filter rules and control behavior, but it does not appear in the final output sent to the AI agent.
188188

189+
## Namespaced Tasks
190+
191+
If your project uses namespaces (multiple teams sharing `.agents/`), create team-specific tasks under `.agents/namespaces/<team>/tasks/`:
192+
193+
```
194+
.agents/namespaces/myteam/tasks/build.md
195+
```
196+
197+
Invoke with the `team/task` format:
198+
199+
```bash
200+
coding-context myteam/build
201+
```
202+
203+
If the task file doesn't exist in the namespace directory, the tool automatically falls back to `.agents/tasks/build.md`.
204+
205+
See [How to Use Namespaces](./use-namespaces) for a full guide including rules, commands, and skills.
206+
189207
## Best Practices
190208

191209
1. **Use descriptive task names**: Make them clear and specific

docs/how-to/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ These guides are problem-oriented and help you achieve specific goals.
1717
- [Create Rule Files](./create-rules) - Provide reusable context
1818
- [Create Skills](./create-skills) - Organize specialized capabilities with progressive disclosure
1919
- [Use Frontmatter Selectors](./use-selectors) - Filter rules and tasks
20+
- [Use Namespaces](./use-namespaces) - Isolate team assets in a shared repository
2021
- [Use Remote Directories](./use-remote-directories) - Load rules from Git, HTTP, or S3
2122
- [Use with AI Agents](./use-with-ai-agents) - Integrate with various AI tools
2223
- [Integrate with GitHub Actions](./github-actions) - Automate with CI/CD

0 commit comments

Comments
 (0)