--- name: workflow-work-package-context-setup description: Set up or validate repository defaults for the AL development workflow, including work-item retrieval, implementation branch naming, and pull-request routing. Use when the user asks for "AL workflow setup", asks to configure work-package context, or when work-package, implementation, or pull-request context is missing or incomplete. user-invocable: false --- # Setup Work Package Context Create or update `.github/copilot/work-package-context.json` so work-package skills can resolve short Azure DevOps and GitHub references, name implementation branches with a confirmed developer or team prefix, and route pull requests without guessing. Keep this repository-local configuration and generated `plans` artifacts out of version control with root `.gitignore` rules when Git ignore configuration is available. When a repository `.code-workspace` file is selected, add the repository-root `plans` directory as a named workspace folder so generated planning artifacts are visible in the multi-root workspace. Read [Work Package Context](references/work-package-context.md) before inspecting or writing configuration. ## Scope and efficiency Treat this as repository metadata setup, not AL application setup. Do not inspect AL manifests, launch profiles, source code, symbols, builds, deployments, or tests unless the user separately requests them. Reuse evidence already available in the conversation or current configuration. Perform repository discovery in one bundled read-only action and post-write verification in one bundled validation action. Do not repeat a successful probe. If one fact cannot be retrieved, retry only that fact with the narrowest available action. ## Process 1. Read the current configuration first. When it parses and contains a complete selected source, valid `branch.prefix`, and complete pull-request routing, use those persisted values as the setup candidates. Inspect only the integration state that cannot be established from that file: root `.gitignore`, tracking state, and repository `.code-workspace` metadata. Query Git remotes or the default branch only when a required value is missing, conflicts with current evidence, or has no persisted value. When configuration is absent or incomplete, gather the configuration, root `.gitignore`, Git remotes, default branch, tracking state, and workspace metadata in one bundled read-only action before asking questions. Recognize GitHub and Azure DevOps HTTPS or SSH remotes. Keep work-item source and pull-request provider separate. Discover repository `.code-workspace` files and identify the currently opened file from workspace metadata when available; otherwise select the only candidate or leave the target unresolved when multiple candidates exist. For the selected workspace file, treat any folder entry that resolves to the repository-root `plans` directory as existing regardless of its stored path or name. Done when every required candidate value has an evidence source or is marked missing, both ignore states are known, and the workspace target and folder state are known or explicitly unresolved without duplicate repository probes. 2. Infer only values supported by repository evidence. Distinguish observed values from proposed values; never infer credentials, tokens, access rights, or `branch.prefix` from Git identity, repository ownership, or work-item assignment. Done when conflicts and unsupported values are explicit. 3. Present the evidence-backed values and ask only for required values, default-source choices, or workspace-file selection that remains missing or conflicting. When multiple workspace files exist and workspace metadata does not identify the active one, require the user to select one. Done when the proposed configuration has no unresolved required field and the workspace target is selected or explicitly unavailable because no repository `.code-workspace` file exists. 4. Show the complete proposed configuration, the proposed root `.gitignore` changes for `/.github/copilot/work-package-context.json` and `/plans/`, and the selected `.code-workspace` file with its proposed folder entry when missing. Compute the folder `path` relative to the selected workspace file, using `plans` only when that file is in the repository root. Obtain explicit confirmation before writing any file. A correction, skipped answer, or request to proceed without confirmation is not consent. Done when the exact proposal, including the workspace target and computed folder entry when applicable, is confirmed. 5. Create or update the configuration without replacing unknown properties or unrelated user changes. If the root `.gitignore` is writable, append each required root-anchored rule only when no existing rule already ignores that path; create `.gitignore` when absent. Update the selected `.code-workspace` file with a JSONC-aware structured edit that preserves comments, trailing commas, existing folders, settings, formatting, and line-ending style. Add the proposed `plans` folder entry only when no existing entry resolves to the repository-root `plans` directory. Preserve existing rules, comments, ordering, formatting, and line-ending style in every changed file. Done when the configuration contains the confirmed values, both ignore rules are effective or each failure is reported, and the selected workspace file includes the repository-root `plans` folder exactly once. 6. In one bundled validation action, parse the written configuration JSON and validate it against the shared contract. Verify that `branch.prefix` is present and valid. Verify that the configuration path and `plans` directory are ignored; for each root-anchored rule added by this workflow, verify that exact entry occurs once. Parse the updated `.code-workspace` file as JSONC and verify that exactly one entry in its `folders` array resolves to the repository-root `plans` directory. Reuse the result instead of re-reading or re-querying each invariant separately. Done when the selected default source and branch prefix are complete, persisted values match the confirmed proposal, ignore handling has been verified, and workspace-folder handling has been verified or explicitly reported unavailable because no repository `.code-workspace` file exists. Do not write secrets. A rerun must update the existing files rather than create duplicate configuration or ignore entries. Adding an ignore rule does not untrack an already tracked configuration file; report that state and ask before running any command that removes it from the Git index. The setup is complete only when the configuration parses, the selected default source and branch prefix are fully configured, persisted values match the confirmed proposal, both ignore paths are verified or explicitly unavailable, workspace-folder handling is verified or explicitly unavailable because no repository `.code-workspace` file exists, and the user has been told which files and values were written. Otherwise end with `Blocked by setup` and name the unresolved requirement.