Skip to content

Default agentworkforce create to the cwd persona dir#50

Merged
willwashburn merged 4 commits intomainfrom
worktree-persona-maker-default-dir
May 8, 2026
Merged

Default agentworkforce create to the cwd persona dir#50
willwashburn merged 4 commits intomainfrom
worktree-persona-maker-default-dir

Conversation

@willwashburn
Copy link
Copy Markdown
Member

Summary

  • agentworkforce create now writes to <cwd>/.agentworkforce/workforce/personas by default, creating the directory if it does not already exist. Previously, the cwd-local target only won when .agentworkforce/workforce/ already existed; otherwise we fell back to the user persona dir or a configured defaultCreateTarget.
  • The --to <target> flag is now the only thing that changes the default. defaultCreateTarget in ~/.agentworkforce/workforce/config.json (and --save-default) still pin a persistent override for users who want one.
  • personas/persona-maker.json advertises the new TARGET_DIR default (.agentworkforce/workforce/personas) and the systemPrompt explains that the CLI sets it to a cwd-local absolute path.
  • READMEs (top-level + packages/cli) and the CLI CHANGELOG describe the new resolution order.

Test plan

  • corepack pnpm run check (lint + typecheck + tests across all workspace packages)
  • Updated parseCreateArgs test that the cwd target wins with no override AND the persona directory is created when missing
  • New parseCreateArgs test that a saved defaultCreateTarget still overrides the cwd default

🤖 Generated with Claude Code

`agentworkforce create` now writes to `<cwd>/.agentworkforce/workforce/personas`
unconditionally, creating the directory if it does not already exist. The
previous behavior fell back to the user persona dir when no cwd-local
workforce was present, which made the project-local layout opt-in. Override
with `--to <target>` (or persist a non-cwd default via `--save-default` /
`defaultCreateTarget`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR renames the create flag to --save-in-directory, makes the default persona save location the cwd-local .agentworkforce/workforce/personas (created if missing), and updates CLI parsing, help, README/CHANGELOG docs, persona-maker inputs, and tests to match.

Changes

Default Persona Creation Target & CLI Flag Rename

Layer / File(s) Summary
Persona Input Schema
personas/persona-maker.json
TARGET_DIR input default and docs changed to <cwd>/.agentworkforce/workforce/personas and note directory auto-creation; CREATE_MODE default changed to local.
Core Target Selection Logic & Flag Parsing
packages/cli/src/cli.ts
Replaced --to with --save-in-directory; parse both --save-in-directory <value> and --save-in-directory=<value>; defaultCreateTargetSelector() now uses loadPersonaSourceConfig().defaultCreateTarget ?? 'cwd'; error/help messages and CreateFlags updated; create resolves using flags.saveInDirectory.
Type Documentation
packages/cli/src/local-personas.ts
JSDoc for LoadOptions.defaultCreateTarget clarified as an override used by agentworkforce create (defaulting to cwd).
Help Text & Documentation
README.md, packages/cli/README.md, packages/cli/CHANGELOG.md, packages/agentworkforce/README.md
USAGE/help text and examples updated to document --save-in-directory, precedence rules (--save-in-directorydefaultCreateTargetcwd), and that the cwd persona directory is created with mkdir -p when missing.
Tests & Assertions
packages/cli/src/cli.test.ts, packages/workload-router/src/index.test.ts
Tests updated to use --save-in-directory; new parseCreateArgs tests assert cwd-local TARGET_DIR default and directory creation, and config-override behavior; workload-router test expectation updated for TARGET_DIR and CREATE_MODE defaults.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/workforce#42: Modifies the same create-related CLI flow and persona input handling (create command flags/targets and TARGET_DIR/CREATE_MODE inputs).
  • AgentWorkforce/workforce#35: Changes CLI handling and defaults for the local persona directory (cwd/.agentworkforce/workforce/personas).
  • AgentWorkforce/workforce#49: Adjusts persona-maker TARGET_DIR/input handling and related test expectations.

Poem

🐰 I hop through docs and CLI lines so spry,

Renamed a flag and told personas where to lie.
A hidden folder springs up on demand,
.agentworkforce/workforce — cozy and planned.
Save elsewhere? say --save-in-directory — that's the plan!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: defaulting agentworkforce create to the cwd persona directory, which is the primary objective of this PR.
Description check ✅ Passed The description is directly related to the changeset, providing context about the new default behavior, flag changes, documentation updates, and test coverage for the modified agentworkforce create functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-persona-maker-default-dir

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13ac187fd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 564 to 567
"default": ".agentworkforce/workforce/personas"
},
"CREATE_MODE": {
"description": "local|built-in: local writes JSON only; built-in also updates repo catalog/routing/test/docs.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep built-in persona-maker default output in personas/

When persona-maker is invoked directly (for example via agentworkforce agent persona-maker), runtime input defaults come from this generated spec, not from create's injected values. Setting TARGET_DIR to .agentworkforce/workforce/personas while leaving CREATE_MODE defaulted to built-in makes built-in authoring write the new JSON outside the repo personas/ tree, so the generator/checklist flow can miss the new file and fail integration. This regression only appears outside agentworkforce create, where no explicit TARGET_DIR is passed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@personas/persona-maker.json`:
- Line 17: Update the TARGET_DIR description string in persona-maker.json to
reflect actual precedence: note that the CLI default
`<cwd>/.agentworkforce/workforce/personas` is used unless `--to` is provided,
but when `--to` is absent a persisted config value `defaultCreateTarget` will
override the CLI default; edit the description text to mention
`defaultCreateTarget` alongside `--to` and the CLI default so the behavior
described matches the implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b151cada-1afb-455d-96db-8817407cd5ad

📥 Commits

Reviewing files that changed from the base of the PR and between 2de2d87 and 13ac187.

⛔ Files ignored due to path filters (1)
  • packages/workload-router/src/generated/personas.ts is excluded by !**/generated/**
📒 Files selected for processing (8)
  • README.md
  • packages/cli/CHANGELOG.md
  • packages/cli/README.md
  • packages/cli/src/cli.test.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/local-personas.ts
  • packages/workload-router/src/index.test.ts
  • personas/persona-maker.json

Comment thread personas/persona-maker.json Outdated
Replaces the somewhat opaque `--to <target>` flag with the more descriptive
`--save-in-directory=<target>` (also accepted as
`--save-in-directory <target>`). The previous name is removed without a
back-compat alias — `--to` now triggers the standard "unexpected argument"
guard, so the rename surfaces in stderr instead of silently continuing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@willwashburn
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…r-default-dir

# Conflicts:
#	packages/cli/CHANGELOG.md

Co-authored-by: willwashburn <957608+willwashburn@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

@copilot resolve the merge conflicts in this pull request

Resolved and pushed: I merged origin/main into this branch and fixed the conflict in packages/cli/CHANGELOG.md. Commit: 72161ff.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/cli.ts`:
- Around line 2345-2354: The parsing currently accepts empty or whitespace-only
values for the --save-in-directory flag; update both branches that set
flags.saveInDirectory (the valueOf(i, arg) branch and the inline
--save-in-directory=... branch) to trim the obtained value and reject it if it
is an empty/whitespace-only string by calling die(`create: --save-in-directory
requires a value.`). Also add the same trim+non-empty validation where the code
later resolves defaults (the block that inspects flags.saveInDirectory around
the later defaulting logic) so whitespace-only values cannot be treated as a
valid target.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f0684bc1-ebc7-452c-be02-338f7d95017b

📥 Commits

Reviewing files that changed from the base of the PR and between 13ac187 and 9205c06.

⛔ Files ignored due to path filters (1)
  • packages/workload-router/src/generated/personas.ts is excluded by !**/generated/**
📒 Files selected for processing (7)
  • README.md
  • packages/agentworkforce/README.md
  • packages/cli/CHANGELOG.md
  • packages/cli/README.md
  • packages/cli/src/cli.test.ts
  • packages/cli/src/cli.ts
  • personas/persona-maker.json
✅ Files skipped from review due to trivial changes (3)
  • packages/agentworkforce/README.md
  • packages/cli/CHANGELOG.md
  • README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/cli/src/cli.test.ts
  • personas/persona-maker.json

Comment thread packages/cli/src/cli.ts
- persona-maker's `CREATE_MODE` defaulted to `built-in` while `TARGET_DIR`
  defaulted to the cwd-local persona dir. Direct `agentworkforce agent
  persona-maker` runs (i.e. no `create`-injected inputs) would then ask the
  agent to write a built-in persona — which expects writes into the repo's
  `personas/` library plus catalog edits — into a cwd-local path. Default
  `CREATE_MODE` to `local` so the two inputs agree out of the box; the CLI
  still upgrades to `built-in` when `--save-in-directory=library` is selected.
- TARGET_DIR description now mentions `defaultCreateTarget` alongside the
  CLI flag so persona-maker's own docs match the actual override precedence.
- `parseCreateArgs` now trims `--save-in-directory` values and rejects
  empty/whitespace-only inputs in both the `=` and space-separated forms,
  so a wrapper passing an unset variable fails fast instead of silently
  saving to the cwd default.

Addresses review feedback on PR #50.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/cli.ts`:
- Around line 2364-2384: The CLI parsing removed support for the existing --to
flag; restore --to as an alias for --save-in-directory by updating the argument
checks around the create command where flags.saveInDirectory is set (the blocks
handling '--save-in-directory' and '--save-in-directory='). Specifically, accept
'--to' and '--to=' variants the same way (call valueOf(i, arg) for '--to' and
slice for '--to='), validate non-empty values the same way, and set
flags.saveInDirectory when either flag is used so existing scripts continue to
work unless you intend a breaking rename.
- Around line 1970-1971: The UI text for "Default create target" is inconsistent
with the runtime fallback in defaultCreateTargetSelector(); update the display
logic used by the "sources list" output to show "cwd" (or "cwd (implicit)") when
loadPersonaSourceConfig().defaultCreateTarget is undefined rather than printing
"(auto)". Locate where the sources list message is composed and replace the
conditional that prints "(auto)" with one that prints the actual fallback value
from defaultCreateTargetSelector() or explicitly "cwd (implicit)" when no saved
override exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27e33f9b-f338-4bc5-b386-766c21eeb902

📥 Commits

Reviewing files that changed from the base of the PR and between 72161ff and 5a86333.

⛔ Files ignored due to path filters (1)
  • packages/workload-router/src/generated/personas.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • packages/cli/src/cli.test.ts
  • packages/cli/src/cli.ts
  • packages/workload-router/src/index.test.ts
  • personas/persona-maker.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/workload-router/src/index.test.ts
  • packages/cli/src/cli.test.ts

Comment thread packages/cli/src/cli.ts
Comment on lines 1970 to +1971
function defaultCreateTargetSelector(): string {
if (existsSync(join(process.cwd(), '.agentworkforce', 'workforce'))) {
return 'cwd';
}
return loadPersonaSourceConfig().defaultCreateTarget ?? 'user';
return loadPersonaSourceConfig().defaultCreateTarget ?? 'cwd';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Show cwd instead of (auto) in the sources output.

With Line 1971 making the implicit fallback always cwd, sources list will still print Default create target: (auto) for users without a saved override. That UI now describes behavior that no longer exists, so it should be updated to show cwd (or cwd (implicit)) to match runtime behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli.ts` around lines 1970 - 1971, The UI text for "Default
create target" is inconsistent with the runtime fallback in
defaultCreateTargetSelector(); update the display logic used by the "sources
list" output to show "cwd" (or "cwd (implicit)") when
loadPersonaSourceConfig().defaultCreateTarget is undefined rather than printing
"(auto)". Locate where the sources list message is composed and replace the
conditional that prints "(auto)" with one that prints the actual fallback value
from defaultCreateTargetSelector() or explicitly "cwd (implicit)" when no saved
override exists.

Comment thread packages/cli/src/cli.ts
Comment on lines +2364 to 2384
if (arg === '--save-in-directory') {
const value = valueOf(i, arg).trim();
if (!value) die('create: --save-in-directory requires a non-empty value.');
flags.saveInDirectory = value;
i += 1;
continue;
}
if (arg.startsWith('--save-in-directory=')) {
const value = arg.slice('--save-in-directory='.length).trim();
if (!value) die('create: --save-in-directory requires a non-empty value.');
flags.saveInDirectory = value;
continue;
}
if (arg === '--save-default') {
flags.saveDefault = true;
continue;
}
if (arg === '-h' || arg === '--help') {
process.stdout.write(
'Usage: agentworkforce create [--to <cwd|user|dir:n|library|path>] [--save-default] [--install-in-repo] [--no-launch-metadata]\n'
'Usage: agentworkforce create [--save-in-directory=<cwd|user|dir:n|library|path>] [--save-default] [--install-in-repo] [--no-launch-metadata]\n'
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep --to working unless this PR is intentionally renaming the public flag.

Lines 2364-2397 stop accepting agentworkforce create --to ... and only recognize --save-in-directory. Given the stated goal here is changing default target resolution, this turns the PR into a breaking CLI flag rename for existing scripts and wrappers. Please keep --to as an alias here, or explicitly treat this as a breaking change and update the public contract everywhere in the same PR.

Minimal compatibility patch
-    if (arg === '--save-in-directory') {
+    if (arg === '--save-in-directory' || arg === '--to') {
       const value = valueOf(i, arg).trim();
-      if (!value) die('create: --save-in-directory requires a non-empty value.');
+      if (!value) die(`create: ${arg} requires a non-empty value.`);
       flags.saveInDirectory = value;
       i += 1;
       continue;
     }
-    if (arg.startsWith('--save-in-directory=')) {
-      const value = arg.slice('--save-in-directory='.length).trim();
-      if (!value) die('create: --save-in-directory requires a non-empty value.');
+    if (arg.startsWith('--save-in-directory=') || arg.startsWith('--to=')) {
+      const prefix = arg.startsWith('--to=') ? '--to=' : '--save-in-directory=';
+      const value = arg.slice(prefix.length).trim();
+      if (!value) die(`create: ${prefix.slice(0, -1)} requires a non-empty value.`);
       flags.saveInDirectory = value;
       continue;
     }

Also applies to: 2397-2397

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli.ts` around lines 2364 - 2384, The CLI parsing removed
support for the existing --to flag; restore --to as an alias for
--save-in-directory by updating the argument checks around the create command
where flags.saveInDirectory is set (the blocks handling '--save-in-directory'
and '--save-in-directory='). Specifically, accept '--to' and '--to=' variants
the same way (call valueOf(i, arg) for '--to' and slice for '--to='), validate
non-empty values the same way, and set flags.saveInDirectory when either flag is
used so existing scripts continue to work unless you intend a breaking rename.

@willwashburn willwashburn merged commit 95924ee into main May 8, 2026
2 checks passed
@willwashburn willwashburn deleted the worktree-persona-maker-default-dir branch May 8, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants