Skip to content

feat(adf): populate command, unknown-op error clarity, CONTEXT scaffold section#48

Closed
SmartBrandStrategies wants to merge 2 commits intomainfrom
feat/adf-populate
Closed

feat(adf): populate command, unknown-op error clarity, CONTEXT scaffold section#48
SmartBrandStrategies wants to merge 2 commits intomainfrom
feat/adf-populate

Conversation

@SmartBrandStrategies
Copy link
Copy Markdown
Contributor

Summary

  • charter adf populate — new command that auto-fills ADF context files from codebase signals (package.json, README, stack detection). Eliminates the "ADF files are pure boilerplate after init" problem observed in downstream repos. Idempotent: skips files with non-scaffold content unless --force.
  • Patcher error clarity — unknown ops now produce Unknown patch op: 'replace'. Valid ops: ADD_BULLET, ... instead of the cryptic handlers[op.op] is not a function TypeError.
  • CORE_SCAFFOLD CONTEXT section — scaffold now includes a CONTEXT placeholder so ADD_BULLET section:CONTEXT works immediately post-init without a preceding ADD_SECTION.
  • adf patch help — lists all valid ops with concrete JSON examples for the three most common cases.
  • Bootstrap/init next steps — step 1 now points to charter adf populate instead of vague "edit core.adf manually" guidance.
  • Harness — extended SDLC corpus and runner with mixed QA/backend signal scenarios that surfaced the classifier routing issues tracked in Classifier routes smoke-test approval bullets to infra.adf when CI/deploy terms coexist with QA language #44 and Classifier overweights API/request/response keywords and underweights QA signals in mixed checklist bullets #45.

Motivation

From a downstream repo session: after charter bootstrap, the agent tried to fill ADF files with Write(), failed on the lock file, then spent several turns discovering ADD_BULLET via trial and error, and got handlers[op.op] is not a function when using the wrong op name. This PR fixes all of that friction.

Test plan

  • charter adf populate --dry-run on a fresh repo shows detected project/stack
  • charter adf populate fills core.adf CONTEXT, state.adf STATE, backend/frontend.adf CONTEXT
  • Re-running populate skips already-customized files
  • charter adf patch ... --ops '[{"op":"badOp"}]' shows clear error with valid ops list
  • charter adf init then charter adf patch .ai/core.adf --ops '[{"op":"ADD_BULLET","section":"CONTEXT","value":"test"}]' works without ADD_SECTION first
  • All 274 tests pass

🤖 Generated with Claude Code

kovermier and others added 2 commits March 5, 2026 17:02
…versal

Closes #43: Remove shell: true from runGit() in git-helpers.ts. Node.js
resolves the git binary via PATH directly without a shell on WSL, Linux,
macOS, and Windows. shell: true is unnecessary and allows shell metacharacters
in args to be interpreted as shell syntax.

Closes #42: Validate module paths in adf create before path.join. Paths
containing ".." or absolute paths are rejected with a clear error. A secondary
resolved-path check confirms the final path stays within the .ai/ directory,
guarding against platform-specific bypass patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ld section

charter adf populate [--dry-run] [--force] [--ai-dir <dir>]
  Reads package.json, README.md, and stack detection signals to auto-fill
  ADF files with project-specific content after charter adf init. Populates
  CONTEXT in core/backend/frontend.adf and STATE in state.adf. Idempotent:
  skips files with non-scaffold content unless --force.

patcher: unknown ops now produce a clear error listing valid op names
  instead of the cryptic "handlers[op.op] is not a function" TypeError.

CORE_SCAFFOLD: add a CONTEXT section placeholder so ADD_BULLET
  section:CONTEXT works immediately after adf init without requiring
  ADD_SECTION first.

adf patch help: list all valid ops with concrete usage examples.

bootstrap/init next steps: point to charter adf populate as step 1
  instead of generic "edit core.adf manually" guidance.

harness: extend SDLC corpus and runner with mixed QA/backend signal
  scenarios that exposed the classifier routing issues filed in #44/#45.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stackbilt-admin
Copy link
Copy Markdown
Member

Review

Verdict: NEEDS FIX before merge

Critical

  • adf-populate.ts lines 670, 752, 789, 828 — buildCoreOps, buildStateOps, buildBackendOps, buildFrontendOps all call fs.readFileSync after caller's existsSync check with no try/catch. Any I/O failure produces a raw Node stack trace instead of a CLIError. Wrap each in try/catch.

Non-critical

  • parseAdf can throw on malformed .adf input mid-loop with no recovery — single bad file aborts entire populate run
  • contentToModule specificity tiebreak has no test coverage
  • ESM detection reads ctx.source as relative path — works from project root only (documented contract, but fragile)

Missing

  • Zero unit tests for the populate command (390 LOC of new logic). Needs tests for: idempotency (hasScaffoldContent), readReadmeSummary edge cases, --force behavior

Good

  • Security surface is clean (no shell injection, path traversal guard solid)
  • Classifier and patcher changes are well-exercised by harness corpus
  • Code style is consistent

🤖 Generated with Claude Code

@stackbilt-admin
Copy link
Copy Markdown
Member

Superseded by 3ba3957 — populate command and CONTEXT scaffold section landed directly on main.

@stackbilt-admin stackbilt-admin deleted the feat/adf-populate branch March 12, 2026 11:55
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.

3 participants