Skip to content

Commit 3b8857d

Browse files
committed
feat: add $DOCS_DIR variable for configurable documentation path (coleam00#982)
Projects with docs outside `docs/` (e.g., `packages/docs-web/src/content/docs/`) get broken bundled commands because the path is hardcoded. Add `docs.path` to `.archon/config.yaml` and thread it through the workflow engine as `$DOCS_DIR` (default: `docs/`), following the same pipeline as `$BASE_BRANCH`. Changes: - Add `docs.path` to RepoConfig and `docsPath` to MergedConfig/WorkflowConfig - Thread `docsDir` through executor-shared, executor, and dag-executor - Update bundled commands to use `$DOCS_DIR` instead of hardcoded `docs/` - Add optional docs path prompt to `archon setup` - Add variable reference and configuration documentation - Resolve pre-existing merge conflicts in server/api.ts Fixes coleam00#982
1 parent 8283d5d commit 3b8857d

17 files changed

Lines changed: 215 additions & 26 deletions

File tree

.archon/commands/defaults/archon-docs-impact-agent.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ gh pr diff {number}
4444
cat CLAUDE.md
4545

4646
# List docs folder
47-
ls -la docs/
47+
ls -la $DOCS_DIR
4848

4949
# List agent definitions
5050
ls -la .claude/agents/ 2>/dev/null || true
@@ -131,8 +131,8 @@ Write to `$ARTIFACTS_DIR/review/docs-impact-findings.md`:
131131
| Document | Impact | Required Update |
132132
|----------|--------|-----------------|
133133
| CLAUDE.md | NONE/LOW/HIGH | {description or "None"} |
134-
| docs/architecture.md | NONE/LOW/HIGH | {description or "None"} |
135-
| docs/configuration.md | NONE/LOW/HIGH | {description or "None"} |
134+
| $DOCS_DIR/architecture.md | NONE/LOW/HIGH | {description or "None"} |
135+
| $DOCS_DIR/configuration.md | NONE/LOW/HIGH | {description or "None"} |
136136
| README.md | NONE/LOW/HIGH | {description or "None"} |
137137
| .claude/agents/*.md | NONE/LOW/HIGH | {description or "None"} |
138138
| .archon/commands/*.md | NONE/LOW/HIGH | {description or "None"} |

.archon/commands/defaults/archon-pr-review-scope.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ Write `$ARTIFACTS_DIR/review/scope.md`:
351351
- `src/...test.ts`
352352

353353
### Documentation ({count})
354-
- `docs/...`
354+
- `$DOCS_DIR/...`
355355
- `README.md`
356356

357357
### Configuration ({count})
@@ -367,7 +367,7 @@ Based on changes, reviewers should focus on:
367367
2. **Error Handling**: {files with try/catch, error handling}
368368
3. **Test Coverage**: {new functionality needing tests}
369369
4. **Comments/Docs**: {files with documentation changes}
370-
5. **Docs Impact**: {check if CLAUDE.md or docs/ need updates}
370+
5. **Docs Impact**: {check if CLAUDE.md or $DOCS_DIR need updates}
371371

372372
---
373373

.archon/commands/defaults/archon-workflow-summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Structure the output for easy decision-making:
206206
| File | Section | Update Needed |
207207
|------|---------|---------------|
208208
| CLAUDE.md | Database Schema | Add ended_reason column |
209-
| docs/architecture.md | Sessions | Update deactivateSession signature |
209+
| $DOCS_DIR/architecture.md | Sessions | Update deactivateSession signature |
210210

211211
**Your choice**:
212212
- [ ] Send docs agent to fix all

packages/cli/src/commands/setup.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,29 @@ export async function setupCommand(options: SetupOptions): Promise<void> {
15351535
skillInstalledPath = join(skillTarget, '.claude', 'skills', 'archon');
15361536
}
15371537

1538+
// Optional: configure docs directory
1539+
const wantsDocsPath = await confirm({
1540+
message: 'Configure a non-default docs directory? (default: docs/)',
1541+
initialValue: false,
1542+
});
1543+
1544+
if (!isCancel(wantsDocsPath) && wantsDocsPath) {
1545+
const docsPath = await text({
1546+
message: 'Where are your project docs? (relative to repo root)',
1547+
placeholder: 'docs/',
1548+
});
1549+
1550+
if (!isCancel(docsPath) && typeof docsPath === 'string' && docsPath.trim()) {
1551+
const archonDir = join(options.repoPath, '.archon');
1552+
mkdirSync(archonDir, { recursive: true });
1553+
const configPath = join(archonDir, 'config.yaml');
1554+
const existing = existsSync(configPath) ? readFileSync(configPath, 'utf-8') : '';
1555+
if (!existing.includes('docs:')) {
1556+
writeFileSync(configPath, existing + `\ndocs:\n path: ${docsPath.trim()}\n`);
1557+
}
1558+
}
1559+
}
1560+
15381561
// Summary
15391562
const configuredPlatforms: string[] = [];
15401563
if (config.platforms.github) configuredPlatforms.push('GitHub');

packages/core/src/config/config-loader.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ function mergeRepoConfig(merged: MergedConfig, repo: RepoConfig): MergedConfig {
368368
result.baseBranch = repo.worktree.baseBranch.trim();
369369
}
370370

371+
// Propagate docs path for $DOCS_DIR substitution in workflow commands
372+
if (repo.docs?.path?.trim()) {
373+
result.docsPath = repo.docs.path.trim();
374+
}
375+
371376
// Propagate per-project env vars from repo config
372377
if (repo.env) {
373378
result.envVars = { ...result.envVars, ...repo.env };

packages/core/src/config/config-types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ export interface RepoConfig {
141141
copyFiles?: string[];
142142
};
143143

144+
/**
145+
* Documentation directory settings
146+
*/
147+
docs?: {
148+
/**
149+
* Path to documentation directory (relative to repo root)
150+
* @default 'docs/'
151+
*/
152+
path?: string;
153+
};
154+
144155
/**
145156
* Per-project environment variables injected into Claude SDK subprocess env.
146157
* Values here override process.env for workflow node execution.
@@ -219,6 +230,12 @@ export interface MergedConfig {
219230
* When undefined, workflows referencing $BASE_BRANCH will fail with an error.
220231
*/
221232
baseBranch?: string;
233+
/**
234+
* Docs directory path from repo config (docs.path).
235+
* Used for $DOCS_DIR substitution in workflow commands.
236+
* @default 'docs/'
237+
*/
238+
docsPath?: string;
222239
/**
223240
* Merged per-project env vars from .archon/config.yaml env: section.
224241
* DB env vars (from Web UI) are merged on top by executeWorkflow.

packages/docs-web/src/content/docs/getting-started/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ assistants:
3535
codex:
3636
model: gpt-5.3-codex
3737
modelReasoningEffort: medium
38+
39+
# docs:
40+
# path: packages/docs-web/src/content/docs # Optional: default is docs/
3841
```
3942

4043
See the [full configuration reference](/reference/configuration/) for all options.

packages/docs-web/src/content/docs/reference/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ worktree:
114114
- .env.example -> .env # Rename during copy
115115
- .vscode # Copy entire directory
116116
117+
# Documentation directory
118+
docs:
119+
path: docs # Optional: default is docs/
120+
117121
# Defaults configuration
118122
defaults:
119123
loadDefaultCommands: true # Load app's bundled default commands at runtime
@@ -157,6 +161,8 @@ This is useful when you maintain coding style or identity preferences in `~/.cla
157161
2. If omitted: Auto-detects the default branch via `git remote show origin`. Works without any config for standard repos.
158162
3. If auto-detection fails and a workflow references `$BASE_BRANCH`: Fails with an error explaining the resolution chain.
159163

164+
**Docs path behavior:** The `docs.path` setting controls where the `$DOCS_DIR` variable points. When not configured, `$DOCS_DIR` defaults to `docs/`. Unlike `$BASE_BRANCH`, this variable always has a safe default and never throws an error. Configure it when your documentation lives outside the standard `docs/` directory (e.g., `packages/docs-web/src/content/docs`).
165+
160166
## Environment Variables
161167

162168
Environment variables override all other configuration. They are organized by category below.

packages/docs-web/src/content/docs/reference/variables.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ These variables are substituted by the workflow executor in all node types (`com
2121
| `$WORKFLOW_ID` | Unique ID for the current workflow run | Useful for artifact naming and log correlation |
2222
| `$ARTIFACTS_DIR` | Pre-created external artifacts directory (`~/.archon/workspaces/<owner>/<repo>/artifacts/runs/<id>/`) | Always exists before node execution; stored outside the repo to avoid polluting the working tree |
2323
| `$BASE_BRANCH` | Base branch for git operations | Auto-detected from the repository's default branch, or set via `worktree.baseBranch` in `.archon/config.yaml`. Throws an error if referenced in a prompt but cannot be resolved |
24+
| `$DOCS_DIR` | Documentation directory path | Configured via `docs.path` in `.archon/config.yaml`. Defaults to `docs/` when not set. Never throws |
2425
| `$CONTEXT` | GitHub issue or PR context, if available | Populated when the workflow is triggered from a GitHub issue/PR. Replaced with empty string when unavailable |
2526
| `$EXTERNAL_CONTEXT` | Same as `$CONTEXT` | Alias |
2627
| `$ISSUE_CONTEXT` | Same as `$CONTEXT` | Alias |
@@ -87,7 +88,7 @@ nodes:
8788
8889
Variables are substituted in a defined order:
8990
90-
1. **Workflow variables** -- `$WORKFLOW_ID`, `$USER_MESSAGE`, `$ARGUMENTS`, `$ARTIFACTS_DIR`, `$BASE_BRANCH`, `$LOOP_USER_INPUT`, `$REJECTION_REASON`
91+
1. **Workflow variables** -- `$WORKFLOW_ID`, `$USER_MESSAGE`, `$ARGUMENTS`, `$ARTIFACTS_DIR`, `$BASE_BRANCH`, `$DOCS_DIR`, `$LOOP_USER_INPUT`, `$REJECTION_REASON`
9192
2. **Context variables** -- `$CONTEXT`, `$EXTERNAL_CONTEXT`, `$ISSUE_CONTEXT`
9293
3. **Node output references** -- `$nodeId.output`, `$nodeId.output.field`
9394

@@ -102,6 +103,7 @@ Positional arguments (`$1` through `$9`) are substituted separately by the comma
102103
| `$WORKFLOW_ID` | Yes | No | No |
103104
| `$ARTIFACTS_DIR` | Yes | No | No |
104105
| `$BASE_BRANCH` | Yes | No | No |
106+
| `$DOCS_DIR` | Yes | No | No |
105107
| `$CONTEXT` / aliases | Yes | No | No |
106108
| `$LOOP_USER_INPUT` | Yes (loop nodes) | No | No |
107109
| `$REJECTION_REASON` | Yes (`on_reject` only) | No | No |

packages/server/src/routes/api.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ import {
3636
getDefaultCommandsPath,
3737
getDefaultWorkflowsPath,
3838
getArchonWorkspacesPath,
39-
<<<<<<< HEAD
4039
getRunArtifactsPath,
4140
getArchonHome,
42-
=======
4341
isDocker,
44-
>>>>>>> 75eec3f7 (fix: hide 'Open in IDE' button in Docker deployments (#898))
4542
} from '@archon/paths';
4643
import { discoverWorkflowsWithConfig } from '@archon/workflows/workflow-discovery';
4744
import { parseWorkflow } from '@archon/workflows/loader';
@@ -798,11 +795,8 @@ const getHealthRoute = createRoute({
798795
adapter: z.string(),
799796
concurrency: z.record(z.unknown()),
800797
runningWorkflows: z.number(),
801-
<<<<<<< HEAD
802798
version: z.string().optional(),
803-
=======
804799
is_docker: z.boolean(),
805-
>>>>>>> 75eec3f7 (fix: hide 'Open in IDE' button in Docker deployments (#898))
806800
})
807801
.openapi('HealthResponse'),
808802
},
@@ -2495,11 +2489,8 @@ export function registerApiRoutes(
24952489
activeConversationIds: allActiveIds,
24962490
},
24972491
runningWorkflows: runningWorkflowRows.length,
2498-
<<<<<<< HEAD
24992492
version: appVersion,
2500-
=======
25012493
is_docker: isDocker(),
2502-
>>>>>>> 75eec3f7 (fix: hide 'Open in IDE' button in Docker deployments (#898))
25032494
});
25042495
});
25052496
}

0 commit comments

Comments
 (0)