@agent-smith/feat-agents 0.0.1

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 (39) hide show
  1. package/README.md +267 -0
  2. package/dist/agents/agent-smith-assistant.yml +31 -0
  3. package/dist/agents/agent-smith-code.yml +33 -0
  4. package/dist/agents/agent-smith-colab.yml +38 -0
  5. package/dist/agents/agent-smith-doc-colab.yml +55 -0
  6. package/dist/agents/agent-smith-doc.yml +52 -0
  7. package/dist/agents/agent-smith-help-assistant.yml +46 -0
  8. package/dist/agents/agent-smith-help-light.yml +44 -0
  9. package/dist/agents/agent-smith-help.yml +43 -0
  10. package/dist/agents/agent-smith-light.yml +19 -0
  11. package/dist/agents/agent-smith-project.yml +43 -0
  12. package/dist/agents/agent-smith-search.yml +40 -0
  13. package/dist/agents/agent-smith-sql.yml +31 -0
  14. package/dist/agents/agent-smith-state.yml +40 -0
  15. package/dist/agents/agent-smith.yml +42 -0
  16. package/dist/agents/collaborator.yml +16 -0
  17. package/dist/agents/infer.yml +12 -0
  18. package/dist/fragments/ctx-helper-files.md +6 -0
  19. package/dist/fragments/workspace.md +6 -0
  20. package/dist/skills/create-project-docs/SKILL.md +124 -0
  21. package/dist/skills/create-readme/SKILL.md +103 -0
  22. package/dist/skills/create-task/SKILL.md +55 -0
  23. package/dist/skills/create-task-solo/SKILL.md +146 -0
  24. package/dist/skills/create-task-team/SKILL.md +119 -0
  25. package/dist/skills/document-package/SKILL.md +83 -0
  26. package/dist/skills/execute-task-phase/SKILL.md +25 -0
  27. package/dist/skills/execute-task-solo/SKILL.md +64 -0
  28. package/dist/skills/execute-task-team/SKILL.md +49 -0
  29. package/dist/skills/task-mode/SKILL.md +99 -0
  30. package/dist/skills/update-codebase-summary/SKILL.md +44 -0
  31. package/dist/skills/update-doc-map/SKILL.md +8 -0
  32. package/dist/skills/update-doc-map/scripts/generate-doc-map.mjs +197 -0
  33. package/dist/skills/update-project-nav/SKILL.md +97 -0
  34. package/dist/skills/use-tasks/SKILL.md +103 -0
  35. package/dist/workflows/agent-smith-config-info.yml +9 -0
  36. package/dist/workflows/agent-smith-db.yml +9 -0
  37. package/dist/workflows/q.yml +3 -0
  38. package/dist/workflows/vision.yml +3 -0
  39. package/package.json +15 -0
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: create-task-team
3
+ description: use this to create a new task with proper structure for multi-agent (team) execution with coordinator-executor delegation
4
+ ---
5
+
6
+ # Create Task Instructions (Coordinator Agent)
7
+
8
+ ## Task Directory Structure
9
+
10
+ Tasks are located in `.agents/tasks/[task-name]/`. Structure:
11
+
12
+ ```
13
+ [task-name]/
14
+ ├── goals.md # Goals and success criteria
15
+ ├── plan.md # Full execution plan (reference)
16
+ ├── state.md # Progress tracking
17
+ ├── coordinator-instructions.md # Your orchestration instructions
18
+ └── phases/
19
+ ├── phase-1.md
20
+ └── phase-2.md
21
+ ```
22
+
23
+ ## Creating Task Files
24
+
25
+ ### 1. `goals.md` — Goals & Success Criteria
26
+ ```md
27
+ # Goals and Success Criteria: [task-name]
28
+
29
+ ## Primary Goal
30
+ [Clear statement of what the task achieves]
31
+
32
+ ## Success Criteria
33
+ - [ ] Criterion 1
34
+ - [ ] Criterion 2
35
+
36
+ ## Files Modified
37
+ - `path/to/file` — description of changes
38
+
39
+ ## Exclusions
40
+ [What is NOT included in this task]
41
+ ```
42
+
43
+ ### 2. `plan.md` — Full Execution Plan
44
+ Contains the complete plan with all phases and steps. Used as reference only.
45
+
46
+ ### 3. `phases/phase-X.md` — Individual Phase Files
47
+
48
+ Each phase file must contain **context** (so executor can work independently) and **step-by-step instructions**:
49
+
50
+ ```md
51
+ # Phase X: [Phase Name]
52
+
53
+ ## Context
54
+ - **Task ID:** [task-name]
55
+ - **Current state:** [metrics/status]
56
+ - **Target:** [what we're aiming for]
57
+
58
+ ### Files to Modify
59
+ | File | Purpose |
60
+ |------|---------|
61
+ | `path/to/file` | What changes here |
62
+
63
+ ---
64
+
65
+ ## Phase Goal
66
+ [What this phase achieves]
67
+
68
+ ---
69
+
70
+ ### Step X.1: [Step Name]
71
+ **File:** `path/to/file`
72
+ **Execution Plan:** [Detailed instructions]
73
+ **Success Criteria:**
74
+ - [ ] Criterion 1 (verifiable)
75
+ ```
76
+
77
+ **Phase file rules:**
78
+ - Include full context — executor agents should NOT read other files
79
+ - Each step has explicit execution plan AND success criteria
80
+ - Success criteria must be verifiable (e.g., "test passes", "file contains X")
81
+
82
+ ### 4. `coordinator-instructions.md` — Your Orchestration Guide
83
+ ```md
84
+ # Coordinator Instructions: [task-name]
85
+
86
+ ## Phase Files
87
+ | Phase | File | Steps |
88
+ |-------|------|-------|
89
+ | 1: [name] | phases/phase-1.md | N |
90
+
91
+ ## Execution Workflow
92
+ 1. Read `state.md` to identify next phase
93
+ 2. Delegate phase to executor agent
94
+ 3. Wait for completion, verify success criteria
95
+ 4. Update `state.md` to mark phase completed
96
+ 5. Repeat until all phases done
97
+ ```
98
+
99
+ The coordinator must instruct subagents that they can use the `.agents/tasks/[task-name]/documents` directory to create markdown file that other agents will be able to read. Each agent must report what documents it created if it did, so that the next agent can be informed to read these documents if necessary
100
+
101
+ ### 5. `state.md` — Progress Tracking
102
+ ```md
103
+ # Task State: [task-name]
104
+
105
+ ## Status: [planned | in-progress | completed]
106
+
107
+ ## Phase Files
108
+ | Phase | File | Steps |
109
+ |-------|------|-------|
110
+ | 1: [name] | phases/phase-1.md | N |
111
+
112
+ ## Progress
113
+ ### Phase X: [name]
114
+ - [ ] Step X.1: [description]
115
+ - [x] Step X.2: [description] ✓
116
+
117
+ ## Notes
118
+ - Next phase to execute: Phase X
119
+ ```
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: document-package
3
+ description: use when asked to create or update package documentation in the docsite
4
+ ---
5
+
6
+ This skill describes the workflow to document a package for the Agent Smith CLI.
7
+
8
+ ## Workflow
9
+
10
+ Execute this one step after the other:
11
+
12
+ 1. **Locate the package** — Read `.agents/documentation/codebase-summary.md` to find the package path
13
+
14
+ 2. **Read codebase summary** — Read `[package-path].agents/documentation/codebase-summary.md` (e.g., `agent-smith-plugins/system/shell/.agents/documentation/codebase-summary.md`). This provides a quick overview of tools, agents, dependencies, and architecture.
15
+
16
+ 3. **Read source code** — Inspect `src/actions/`, `dist/agents/*.yml`, `dist/tasks/*.yml` to identify tools, agents, and capabilities.
17
+
18
+ 4. **Find next number** — List existing docs in `agent-smith/docsite/public/doc/plugins/`. Use the next available number (e.g., if 1-8 exist, use 9).
19
+
20
+ 5. **Write the doc** at `agent-smith/docsite/public/doc/plugins/<N>.<name>.md` using this exact structure:
21
+
22
+ ```markdown
23
+ # <PackageName>
24
+
25
+ ![pub package](https://img.shields.io/npm/v/@agent-smith/feat-<name>)
26
+
27
+ One-line description of what the package does.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ npm i -g @agent-smith/feat-<name>
33
+ ```
34
+
35
+ Add the package to your `config.yml` file and run the `conf` command:
36
+
37
+ ```yml
38
+ plugins:
39
+ - "@agent-smith/feat-<name>"
40
+ ```
41
+
42
+ ```bash
43
+ lm conf
44
+ ```
45
+
46
+ ## Actions and tools
47
+
48
+ ### <category>
49
+
50
+ Available tools:
51
+
52
+ - <kbd>tool-name</kbd> one-line description of what it does (include container image if applicable)
53
+
54
+ ## Agents
55
+
56
+ Available agents:
57
+
58
+ - <kbd>agent-name</kbd> one-line description. Lists tools used:
59
+ - `tool-a` — purpose
60
+ - `tool-b` — purpose
61
+
62
+ ## Example agent
63
+
64
+ ```yaml
65
+ description: A brief description
66
+ model: qwen4b
67
+ toolsList:
68
+ - agent-name # this tool is a subagent
69
+ ```
70
+
71
+ ## Links
72
+
73
+ Add a next page link. All internal links must be of this form:
74
+
75
+ <a href="javascript:openLink('/plugins/overview')">Back: Overview</a>
76
+ ```
77
+
78
+ ## Rules
79
+
80
+ - Keep it short and information-dense — match the style of `6.filesystem.md` and `8.search.md`
81
+ - Use `<kbd>tool-name</kbd>` for all tools/agents
82
+ - Use backticks `for tool names in prose
83
+ - End with navigation link to overview (or next package if known)
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: execute-task-phase
3
+ description: behavioral contract for executor agents in team tasks
4
+ ---
5
+
6
+ # Executor Agent Contract
7
+
8
+ ## Your Role
9
+ You are an **Executor Agent**. Execute your assigned phase independently.
10
+
11
+ ## Core Rules
12
+
13
+ 1. **Read ONLY your assigned phase file** — Do NOT read other phase files, `plan.md`, or `goals.md`
14
+ 2. **Execute steps sequentially** — Complete each step before moving to the next
15
+ 3. **Verify success criteria** — Each step must pass its criteria before proceeding
16
+ 4. **No regressions** — Run existing tests to ensure nothing breaks
17
+ 5. **Share context via documents** — Use `.agents/tasks/[task-name]/documents/` to create markdown files for subsequent agents
18
+
19
+ ## Reporting
20
+
21
+ After completing your phase, report:
22
+ - Summary of changes made
23
+ - Steps completed successfully
24
+ - Any issues encountered
25
+ - Documents created (if any) in the `documents/` directory
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: execute-task-solo
3
+ description: use this to execute a solo task (single agent executes all phases)
4
+ ---
5
+
6
+ # Execute Task (Solo Mode)
7
+
8
+ This skill describes how to execute a task created with `create-task-solo`. A single agent executes all phases sequentially.
9
+
10
+ ## Task Location
11
+
12
+ Tasks are located in `.agents/tasks/[task-name]/` directory.
13
+
14
+ ## Task Structure
15
+
16
+ ```
17
+ [task-name]/
18
+ ├── goals.md # Goals and success criteria
19
+ ├── plan.md # Full execution plan with all phases
20
+ ├── state.md # Progress tracking
21
+ └── notes.md # Optional: additional context/notes
22
+ ```
23
+
24
+ ## Execution Workflow
25
+
26
+ ### 1. Start/Resume Task
27
+ 1. Read `state.md` to determine current progress
28
+ 2. Identify the next step to execute
29
+ 3. If status is `completed`, notify user and exit
30
+
31
+ ### 2. Execute Steps
32
+ For each step:
33
+ 1. Read the step instructions from `plan.md`
34
+ 2. Perform the action (edit files, run commands, etc.)
35
+ 3. Verify success criteria
36
+ 4. If verification fails, fix issues and re-verify
37
+ 5. Once verified, mark step as complete in `state.md`
38
+
39
+ ### 3. Update State
40
+ After completing each phase:
41
+ 1. Mark all steps in that phase as `[x]` with `✓`
42
+ 2. Mark the phase as `[x]`
43
+ 3. Update "Next" note to point to the next phase/step
44
+ 4. If all phases complete, set status to `completed`
45
+
46
+ ### 4. Completion
47
+ 1. When all phases are done, notify user
48
+ 2. Ask user to verify the results
49
+ 3. Only delete the task directory if user confirms everything is correct
50
+
51
+ ## State Management
52
+
53
+ If the task is interrupted before completion, update `state.md` to indicate:
54
+ - What was done
55
+ - What remains to do
56
+ - Current status (`in-progress`)
57
+
58
+ ## Important Rules
59
+
60
+ - Always execute steps one by one — never skip ahead
61
+ - Verify success criteria after each step before proceeding
62
+ - Update `state.md` after each completed step
63
+ - Do not verify previously completed steps (check `state.md` first)
64
+ - Ask user for confirmation before deleting task directory
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: execute-task-team
3
+ description: use this to execute a team task (coordinator delegates phases to executor agents)
4
+ ---
5
+
6
+ # Coordinator Agent Instructions (Task Execution)
7
+
8
+ ## Your Role
9
+ You are the **Coordinator Agent**. Delegate phases to executor agents.
10
+
11
+ Instruct subagents that they can use the `.agents/tasks/[task-name]/documents` directory to create markdown file that other agents will be able to read. Each agent must report what documents it created if it did, so that the next agent can be informed to read these documents if necessary
12
+
13
+ ## Execution Workflow
14
+
15
+ 1. Read `state.md` to identify next phase
16
+ 2. Delegate phase to an executor agent using the prompt template below
17
+ 3. Wait for completion, verify success criteria met
18
+ 4. Update `state.md` to mark phase completed
19
+ 5. Repeat until all phases done
20
+
21
+ ## Delegating to Executor Agents
22
+
23
+ Use this prompt template:
24
+ ```
25
+ You are an executor agent for the "[task-name]" task.
26
+
27
+ Your assignment: Execute Phase X — [Phase Name]
28
+
29
+ Instructions:
30
+ 1. Load the `execute-task-phase` skill for behavioral rules
31
+ 2. Read your phase file at: .agents/tasks/[task-name]/phases/phase-X.md
32
+ 3. Execute steps as specified in the phase file
33
+ 4. Report completion with summary and any documents created
34
+
35
+ Important: Follow the executor contract — do NOT read other phase files.
36
+ ```
37
+
38
+ ## State Management
39
+ After each phase: update `state.md` with progress, issues, and next phase.
40
+
41
+ ## Verification Rules
42
+ - Each step must pass success criteria before moving on
43
+ - All existing tests must continue passing (no regressions)
44
+ - Final phase should verify overall targets are met
45
+
46
+ ## After Task Completion
47
+ 1. Ask user if everything is satisfactory
48
+ 2. Only delete task directory if user confirms
49
+ 3. If incomplete: update `state.md` with what was done and what remains
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: task-mode
3
+ description: use this to decide between solo (create-task-solo) or team (create-task-team) task execution mode
4
+ ---
5
+
6
+ # Task Mode Selection
7
+
8
+ This skill helps you choose the right execution mode before creating a task. Use it to determine whether to use `create-task-solo` (single agent) or `create-task-team` (coordinator-executor with multiple agents).
9
+
10
+ ## Quick Decision Checklist
11
+
12
+ Evaluate the task against these criteria:
13
+
14
+ ### Solo Mode (`create-task-solo`) Indicators
15
+ Check each that applies:
16
+ - [ ] Task involves reading/analyzing lots of data to produce output
17
+ - [ ] Phases are tightly coupled with shared state
18
+ - [ ] Task complexity fits in one agent's context window
19
+ - [ ] Quick iteration/refinement is needed
20
+ - [ ] Same expertise required throughout all phases
21
+
22
+ ### Team Mode (`create-task-team`) Indicators
23
+ Check each that applies:
24
+ - [ ] Different phases require different expertise/domains
25
+ - [ ] Phases are independent or parallelizable
26
+ - [ ] Context isolation would improve output quality
27
+ - [ ] Task is too large/complex for one agent's context
28
+ - [ ] Long-running task that benefits from checkpointing between phases
29
+
30
+ ## Decision Rule
31
+
32
+ | Score | Decision |
33
+ |-------|----------|
34
+ | 3+ solo indicators | Use **`create-task-solo`** (single agent) |
35
+ | 3+ team indicators | Use **`create-task-team`** (multi-agent) |
36
+ | Tie | Default to **`create-task-solo`** (simpler, less overhead) |
37
+
38
+ ## Key Principle: Context Isolation vs Unified Context
39
+
40
+ ### When Unified Context Wins (`create-task-solo`)
41
+ > "Read all docs and create a summary" — The agent needs to hold all the data in context to produce coherent output. Splitting this across agents would lose the unified view.
42
+
43
+ **Use `create-task-solo` when:** The task benefits from having all information available in one context window. Reading → Processing → Output flows work best with a single agent.
44
+
45
+ ### When Context Isolation Wins (`create-task-team`)
46
+ > "Create module with tests, docs, and integration" — Each phase needs focused expertise. Isolating context prevents interference between phases and lets each agent specialize.
47
+
48
+ **Use `create-task-team` when:** Different phases benefit from separate, focused contexts. Multi-agent execution prevents context pollution and allows specialization.
49
+
50
+ ## Decision Flow
51
+
52
+ ```
53
+ Task Analysis
54
+
55
+ ├─→ Need to read/analyze lots of data → produce output?
56
+ │ └─ YES → create-task-solo (unified context)
57
+
58
+ ├─→ Phases tightly coupled with shared state?
59
+ │ └─ YES → create-task-solo (keep context together)
60
+
61
+ ├─→ Different phases need different expertise?
62
+ │ └─ YES → create-task-team (context isolation helps)
63
+
64
+ ├─→ Task too complex for one context window?
65
+ │ └─ YES → create-task-team (split across agents)
66
+
67
+ ├─→ Phases independent/parallelizable?
68
+ │ └─ YES → create-task-team (leverage isolation)
69
+
70
+ └─→ Default → create-task-solo (simpler, less overhead)
71
+ ```
72
+
73
+ ## Examples
74
+
75
+ ### Use `create-task-solo` (Single Agent):
76
+ - "Read all documentation files and create a summary"
77
+ - "Analyze codebase metrics and generate a report"
78
+ - "Refactor function X across the project"
79
+ - "Add feature Y to existing module"
80
+ - "Update configuration based on new requirements"
81
+ - "Generate documentation from code comments"
82
+
83
+ ### Use `create-task-team` (Multi-Agent):
84
+ - "Create new module with tests, docs, and integration"
85
+ - "Migrate database schema, update queries, update API"
86
+ - "Implement feature requiring frontend + backend + tests"
87
+ - "Large refactoring across multiple unrelated modules"
88
+ - "Build new service with API, CLI, and documentation"
89
+ - "Add authentication: update backend, frontend, and tests"
90
+
91
+ ## Output Format
92
+
93
+ When using this skill, output your decision as:
94
+
95
+ ```
96
+ Task Mode Decision: [create-task-solo | create-task-team]
97
+ Reasoning: [Brief explanation based on checklist]
98
+ Next Step: Use the `create-task-solo` or `create-task-team` skill to create the task
99
+ ```
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: update-codebase-summary
3
+ description: use when asked to create or update the codebase summary documentation
4
+ ---
5
+
6
+ This skill describes the workflow to create or update a codebase documentation file (`[project-path].agents/documentation/codebase-summary.md`).
7
+
8
+ ## Workflow
9
+
10
+ 1. **Explore the project** — Walk the directory tree, identify package/module boundaries, read manifest files (e.g., `package.json`), locate entry points, and understand inter-module dependencies.
11
+
12
+ 2. **Check for existing file** — Look for `[project-path].agents/documentation/codebase-summary.md` in the project directory. If it exists, update it. If not, create it.
13
+
14
+ 3. **Write the file** using exactly these 7 sections in this order:
15
+
16
+ ### Section Format
17
+
18
+ # <module-name>
19
+
20
+ ## Summary
21
+ One sentence: what the module does and why it exists.
22
+
23
+ ## Dependencies
24
+ - `<dep-module>` — key types, functions, or services used
25
+ - External: `<library>` (<purpose>)
26
+
27
+ ## Used By
28
+ - `<consumer-module>` — why it uses this module
29
+
30
+ ## Entry Point
31
+ - `<path>` — one-line description of what it exports or provides
32
+
33
+ ## Key Files
34
+ | File | Purpose |
35
+ |------|---------|
36
+ | `<src/path>` | One-line: what the file does conceptually |
37
+
38
+ ## Architecture
39
+ - 2–4 bullet points on main design patterns and data flow.
40
+
41
+ ## Related
42
+ - See `<related-module>` — how they work together
43
+
44
+ Keep the file as short and condensed as possible
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: update-doc-map
3
+ description: read this only when instructed to update the documentation map
4
+ ---
5
+
6
+ Run the `agent-smith-plugins/agents/dist/skills/update-doc-map/scripts/generate-doc-map.mjs` Nodejs script.
7
+
8
+ Report only the end result: if the script has run ok or not.
@@ -0,0 +1,197 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * generate-doc-map.mjs
5
+ *
6
+ * Scans the project for all documentation files and generates a doc-map.md
7
+ * file that helps AI agents navigate the codebase documentation.
8
+ */
9
+
10
+ import { readdir, stat, writeFile } from 'node:fs/promises';
11
+ import { join, relative, dirname, basename } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ // The script is in .agents/, so the project root is one level up
16
+ // Accept PROJECT_ROOT from command line argument or environment variable, otherwise calculate
17
+ const PROJECT_ROOT = process.argv[2] || process.env.PROJECT_ROOT || join(__dirname, '../../../../..');
18
+
19
+ // Packages that have their own .agents/documentation
20
+ const PACKAGES = [
21
+ 'core', 'agent', 'cli', 'wscli', 'types', 'smem', 'tmem', 'server'
22
+ ];
23
+
24
+ /**
25
+ * Recursively find all markdown files in a directory
26
+ */
27
+ async function findMarkdownFiles(dir, baseDir) {
28
+ const files = [];
29
+ try {
30
+ const entries = await readdir(dir, { withFileTypes: true });
31
+ for (const entry of entries) {
32
+ const fullPath = join(dir, entry.name);
33
+ if (entry.isDirectory()) {
34
+ // Skip node_modules and other non-doc directories
35
+ if (!['node_modules', '.git', 'dist', 'build', '__pycache__'].includes(entry.name)) {
36
+ files.push(...await findMarkdownFiles(fullPath, baseDir));
37
+ }
38
+ } else if (entry.isFile() && entry.name.endsWith('.md')) {
39
+ const relPath = relative(baseDir, fullPath);
40
+ files.push({ path: fullPath, relative: relPath });
41
+ }
42
+ }
43
+ } catch (err) {
44
+ // Skip directories we can't read
45
+ }
46
+ return files;
47
+ }
48
+
49
+ /**
50
+ * Extract a human-readable title from the filename
51
+ */
52
+ function extractTitle(fileRelative) {
53
+ const parts = fileRelative.split('/');
54
+ const filename = basename(fileRelative, '.md');
55
+
56
+ // Try to get a better name from the path segments
57
+ if (parts.length > 1) {
58
+ return parts.slice(0, -1).join('/') + '/' + filename;
59
+ }
60
+ return filename;
61
+ }
62
+
63
+ /**
64
+ * Format a file path for display and linking using full workspace-relative path
65
+ */
66
+ function formatLink(fileRelative, basePath) {
67
+ // Return full path from workspace root with .md extension preserved
68
+ return `${basePath}/${fileRelative}`;
69
+ }
70
+
71
+ /**
72
+ * Generate the documentation map markdown content
73
+ */
74
+ async function generateDocMap() {
75
+ const docSections = [];
76
+
77
+ // Scan public documentation (docsite/public/doc)
78
+ const publicDocPath = join(PROJECT_ROOT, 'docsite/public/doc');
79
+ try {
80
+ await stat(publicDocPath);
81
+ const files = await findMarkdownFiles(publicDocPath, publicDocPath);
82
+
83
+ if (files.length > 0) {
84
+ // Group by top-level category
85
+ const grouped = {};
86
+ for (const file of files) {
87
+ const parts = file.relative.split('/');
88
+ const category = parts[0] || 'root';
89
+ if (!grouped[category]) grouped[category] = [];
90
+ grouped[category].push(file);
91
+ }
92
+
93
+ docSections.push({
94
+ title: '📚 Public Documentation',
95
+ description: 'Main project documentation hosted in the docsite.',
96
+ files: grouped,
97
+ basePath: 'docsite/public/doc'
98
+ });
99
+ }
100
+ } catch (err) {
101
+ // Skip if directory doesn't exist
102
+ }
103
+
104
+ // Scan root .agents/documentation
105
+ const rootAgentsPath = join(PROJECT_ROOT, '.agents/documentation');
106
+ try {
107
+ await stat(rootAgentsPath);
108
+ const files = await findMarkdownFiles(rootAgentsPath, rootAgentsPath);
109
+
110
+ if (files.length > 0) {
111
+ docSections.push({
112
+ title: '🤖 Root Agent Documentation',
113
+ description: 'Documentation for the agent system itself.',
114
+ files: { '': files },
115
+ basePath: '.agents'
116
+ });
117
+ }
118
+ } catch (err) {
119
+ // Skip if directory doesn't exist
120
+ }
121
+
122
+ // Scan each package's .agents/documentation
123
+ for (const pkg of PACKAGES) {
124
+ const pkgAgentsPath = join(PROJECT_ROOT, `packages/${pkg}/.agents/documentation`);
125
+ try {
126
+ await stat(pkgAgentsPath);
127
+ const files = await findMarkdownFiles(pkgAgentsPath, pkgAgentsPath);
128
+
129
+ if (files.length > 0) {
130
+ docSections.push({
131
+ title: `📦 Package: @agent-smith/${pkg}`,
132
+ description: `Documentation for the ${pkg} package.`,
133
+ files: { '': files },
134
+ basePath: `packages/${pkg}/.agents`
135
+ });
136
+ }
137
+ } catch (err) {
138
+ // Skip if directory doesn't exist or has no docs
139
+ }
140
+ }
141
+
142
+ // Generate the markdown content - compact format for AI agents
143
+ const lines = [
144
+ '# 🗺️ Documentation Map',
145
+ '',
146
+ ];
147
+
148
+ // Detailed sections only (no summary table, no horizontal rules)
149
+ for (const section of docSections) {
150
+ lines.push(`## ${section.title}`);
151
+ lines.push('');
152
+
153
+ for (const [category, files] of Object.entries(section.files)) {
154
+ if (files.length === 0) continue;
155
+
156
+ if (category) {
157
+ lines.push(`### ${category}`);
158
+ lines.push('');
159
+ }
160
+
161
+ // Sort files: files starting with numbers come first, then alphabetical
162
+ const sortedFiles = [...files].sort((a, b) => {
163
+ const aName = basename(a.relative, '.md');
164
+ const bName = basename(b.relative, '.md');
165
+ return aName.localeCompare(bName, undefined, { numeric: true });
166
+ });
167
+
168
+ for (const file of sortedFiles) {
169
+ const fullPath = formatLink(file.relative, section.basePath);
170
+ const workspacePath = `agent-smith/${fullPath}`;
171
+ lines.push(`- [\`${workspacePath}\`](${workspacePath})`);
172
+ }
173
+
174
+ lines.push('');
175
+ }
176
+ }
177
+
178
+ return lines.join('\n');
179
+ }
180
+
181
+ // Main execution
182
+ async function main() {
183
+ console.log('🔍 Scanning for documentation files...');
184
+
185
+ const content = await generateDocMap();
186
+ const outputPath = join(PROJECT_ROOT, '.agents/documentation/documentation-map.md');
187
+
188
+ // Write the file
189
+ await writeFile(outputPath, content, 'utf-8');
190
+
191
+ console.log(`✅ Documentation map generated: ${outputPath}`);
192
+ }
193
+
194
+ main().catch(err => {
195
+ console.error('❌ Error generating doc-map:', err);
196
+ process.exit(1);
197
+ });