mirror of
https://github.com/coder/coder.git
synced 2026-11-22 03:18:31 +08:00
feea5ab959f59cd2135443ed2a0c19bf7643db8f
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7c7e2e73cf |
feat: honor disable-model-invocation in uploaded skill content (#31159)
Addresses @ethanndickson's [review comment on #30882](https://github.com/coder/coder/pull/30882#discussion_r4344815088): the same `SKILL.md` file could be manual-only in Claude Code and the project dialog but automatic in Coder, because the server and the browser each handled `disable-model-invocation` in their own way. The server now owns the key for personal, organization, and project skills: - When a create or update request leaves `model_invocable` unset, `disable-model-invocation: true` in the content turns automatic use off, and `false` turns it back on. The key is read with the function workspace skills use, so a file gets the same setting in both places. Only YAML booleans count, so a quoted `"true"` is ignored. - An explicit `model_invocable` in the request always wins. - New content without the key leaves the setting unchanged, so editing text never turns it back on. - Content is stored as uploaded. Every API response returns content whose key agrees with `model_invocable`: when the stored file says otherwise, the server replaces the value of the key or adds the key before the first one, and leaves every other byte alone. - **Download** and **Export all** save the content the API returns, so the browser no longer edits the file. `withDisabledModelInvocation` is removed. - An upload is rejected with a 400 when the key holds a value the server can't replace with a boolean, such as a list. A later change to `model_invocable` can then always reach the file. Two edges: - Adding the key makes the returned file about 30 bytes larger, so a file at the 64 KB upload limit can be too large to upload again. - A skill stored before the upload check with a value the server can't replace is returned as stored. Workspace skills already honor the key since #31147. #31160, the frontend PR on top of this one, adds the switch to the personal and organization skill editors. > Generated by an agent on behalf of the user --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Nick Vigilante <nickvigilante@users.noreply.github.com> |
||
|
|
4866d0fb1f |
feat: add display names to project skill actions (#31747)
closes CODAGT-1506 Project skill action chips show the skill's slug (`deploy-bot`, `security-review`), because skill names must be kebab-case. This adds an optional display name that labels the chip instead. Project skills get a `display_name` column, set through `display_name` on the create and update requests. It is limited to project skills (the same rule as `action`), trimmed, single line, and at most 64 Unicode code points. The chip, its tooltip, and the "More" menu show the display name, sort by it, and fall back to the skill name when it is empty. When a display name is set, the tooltip and the menu item also show the `/name` slash command, so actions that share a display name stay distinguishable. Clicking an action still inserts `/name`, and the `/` menu is unchanged. The project skill editor shows a **Display name** field under **Show as action** only while that switch is on. Turning the switch off hides the field but keeps its value, and saves omit `display_name` while the action is off, so the stored value stays. The display name lives in the database rather than SKILL.md frontmatter, so downloading and re-importing a skill does not carry it. To share the code-point length check with the editor, `countCharacters` and `maxCharacters` move from `ChatProjectDialog.tsx` into `site/src/utils/formUtils.ts`. <img width="637" alt="Project skill editor with the Display name field under Show as action" src="https://raw.githubusercontent.com/coder/coder/assets/pr-skill-action-display-name/pr/edit.png" /> <img width="520" alt="Action chips labeled with display names, with the tooltip open" src="https://raw.githubusercontent.com/coder/coder/assets/pr-skill-action-display-name/pr/chips.png" /> Refs CODAGT-1506 |
||
|
|
514f23979a |
feat: honor disable-model-invocation in skill frontmatter (#31147)
Extends #30882's `model_invocable` semantics to workspace skills and to stored skills created through the API. Claude Code and Xum let skill authors set `disable-model-invocation: true` in SKILL.md frontmatter, so agents never pick the skill on their own and it runs only when a person invokes it. Coder Agents honored the key only when someone imported a SKILL.md file while adding a project skill (#30884). ## What changes - **Workspace skills:** when the pinned SKILL.md sets the key to the YAML boolean `true`, chatd leaves the skill out of `<available-skills>` before merging sources, so a listed skill with the same name keeps its bare name, and `read_skill` reports it as not found. The skill stays in the `/` menu, and invoking it still loads its body. `read_skill_file` serves its supporting files under the bare name or `workspace/<name>` and refuses its `SKILL.md` (case-insensitive, after `path.Clean`). Skills without the key behave as on the base. - **Invoked workspace skills:** invoking a workspace skill now stores the pinned skill directory on the invocation part, and the prompt renders it as `dir` on `<invoked-skill>`, escaped as an attribute value. Before, only `read_skill` gave the model a skill's directory, and it refuses a hidden skill, so a hidden skill could not run the scripts it bundles. The part also stores the chat's workspace, and the prompt shows `dir` only while the chat stays bound to it, as it does for workspace file references. This changes #30861's invocation code. Hook payloads drop the directory and its workspace like the body, and API responses strip both. - **Stored skills:** a create request whose content sets the key and that omits `model_invocable` stores `model_invocable = false`. An explicit value wins, and PATCH is unchanged. This covers personal, organization, and project skills, which share `createSkill`. - `workspacesdk.SkillDisablesModelInvocation` reads the key. The `CreateSkillRequest.ModelInvocable` doc comment, the generated API docs, and `extending-agents.md` (the SKILL.md format, a new "Turn off automatic use" section, and the notes on the skill index, the skill tools, and aliases) describe the new behavior. ## Follow-ups - The personal and organization skill editors have no "Agents can use it automatically" switch yet. Only the project editor from #30884 has one. ## Testing - Go tests cover the parser, the turn's skill index and aliases, `read_skill`, `read_skill_file`, invocation of a hidden skill and the directory it carries (attribute escaping, no directory after the chat changes workspace, no directory in hook payloads), and the create default for personal and organization skills. Each new test fails when its code path is removed. - Remote dogfood UAT with a real model failed rounds 1 to 3. Rounds 1 and 2 found the hidden SKILL.md still readable through `read_skill_file` by symlinks and stale pins, plus a bare-name lookup bug and a docs gap that round 2 fixed. Round 3 found that the content check added against those bypasses refused a listed skill's file whose own frontmatter sets the key. After round 3 we narrowed the rule to the hidden skill's `SKILL.md` path. The key decides what agents are offered (the index and `read_skill`), not which files they can read: `read_file` and `execute` already open any workspace file, so a content check in `read_skill_file` protected nothing and kept producing edge cases. - Round 4 passed on `c9ff25dc29f`. Later commits added a behavior-neutral cleanup (`cd617533c2e`), one test case from the test audit (`044c1e6e23a`), and a comment fix (`9ec3768b18b`), which passed validation without another UAT round. Round 5 passed on `2b518c6c2b1`, which adds the skill directory. A real model ran hidden skills' scripts from the `dir` on `<invoked-skill>`, including directories whose paths contain `&`, `'`, `"`, `<` and `>`, and API responses carried no directory. Merging main after #30884 landed (`2d7d3cb9674`) did not change this PR's diff, so UAT was not rerun. `8f043b2a342`, which shows the directory only while the chat stays bound to the skill's workspace, has Go tests but no UAT round. - The doc-check skill ran in author self-check mode on `2d7d3cb9674`, and `27de7f5c6d7` fixes its findings: the skill index sentence said every skill is listed, the stored-skill sentence claimed any project editor import honors the key and presented the API default as fixed, the API path came before the UI path, and some wording broke the docs style rules. The fix is docs-only, so UAT was not rerun. - Polish and the test audit stayed inside the implementation diff. No new dependencies. - Codex review found no major issues on `9ec3768b18b`, then raised one P2 on the same head when the PR was marked ready: an invoked hidden skill gets no skill directory. A probe confirmed it, and `2b518c6c2b1` fixes it. Its earlier finding on that head (honor `CODER_AGENT_EXP_SKILL_META_FILE`) was refuted, because the pinned skill snapshot always reads `SKILL.md`. Both threads are resolved, and Codex found no major issues on `2b518c6c2b1` or on the merge `2d7d3cb9674`. - On `27de7f5c6d7`, Codex raised two P2s. One was confirmed: an invoked skill's directory stayed in the prompt after the chat moved to another workspace, which a prompt test showed on that head, and `8f043b2a342` fixes it. The other was declined: on Windows, `scripts\..\SKILL.md` gets past the `SKILL.md` check in `read_skill_file`, but that check is not an access boundary (`read_file` opens any path), and Windows has more aliases (`SKILL.md.`, `SKILL.md::$DATA`, `SKILL~1.MD`) that normalizing backslashes would not stop. On `8f043b2a342`, Codex asked to bind the directory to the workspace build instead. That was declined: every workspace start is a new build with new agent IDs, so the directory would drop after each stop and start, and the pinned body and the live files can diverge without a rebuild anyway, as they do for `read_skill`. A later request on that head asked to limit a hidden skill's `read_skill_file` access to invocations in the current workspace. That was declined too: `read_skill_file` resolves names against the current pin for listed skills on main as well, and the key decides which skills agents are offered, not which files they can read. All four threads are resolved. `a697dcd927f` adds the `format:"uuid"` tag that `TestSDKFieldsFormatted` requires on the new field, and Codex found no major issues on `a697dcd927f`. `ae70b2c533f` is docs-only: it applies the doc-check suggestion to say that an invoked skill's directory is included only while the chat stays in that workspace. The author doc-check self-check found no blocking findings on it, and Codex found no major issues on `ae70b2c533f`. > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. --------- Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> |
||
|
|
c4d76a4009 |
feat: add skill action and automatic-use settings (#30882)
Adds two per-skill settings that the project skills UI will expose next: - `action` marks a project skill to show as an action button above project chat composers. A `skills_action_project_only` check keeps it to project skills; the personal and organization routes reject `action` with 400. - `model_invocable` (default true, every stored source) controls automatic use. When it's false the skill is left out of `<available-skills>` and `read_skill` reports it as not found, but a structured skill invocation (a chip from the `/` menu or an action) still loads it, as long as the skill is enabled and the chat owner can read it. Workspace skills always count as model-invocable. Migration 000625 adds both columns with defaults, so existing skills keep today's behavior. The list, get, insert and update queries, `codersdk.SkillMetadata` and the create/update requests carry both fields, and the audit table tracks them. `coderd/x/chatd/ARCHITECTURE.md` gets TODO notes for the author. **NOTE**: the migration adds two columns with constant defaults and a CHECK constraint to `skills`. Stack (merge top to bottom): - #30826 - #30827 - #30838 - #30840 - #30854 - #30855 - #30856 - #30861 - #30880 - #30881 - #30882 👈 - #30884 - #31122 - #31126 --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Nick Vigilante <nickvigilante@users.noreply.github.com> |
||
|
|
db7f5a7703 |
feat: add organization skill API routes (#30610)
## Stack Part of [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. #30609 data model: one migration, queries, RBAC and dbauthz 2. **#30610** organization skill API routes and the scope-neutral SDK (this PR) 3. #30611 sharing ACL routes 4. #30612 settings UI: shared skills table, admin page, member section 5. #30613 chats: chatd loading, `/` menu, docs ## What changes This PR adds the organization skill CRUD routes and makes the skill SDK types owner-neutral so personal and organization skills share them. **API contract change (experimental API, personal and organization skills):** skill list and get responses gain `enabled`, and `PATCH .../skills/{skillName}` now takes `{content?, enabled?}`, so `content` is optional and a toggle doesn't resend it. A PATCH with neither field returns 400; `content`, when present, is validated as before. In the SDK, `UserSkill`, `UserSkillMetadata`, `CreateUserSkillRequest` and `UpdateUserSkillRequest` become `Skill`, `SkillMetadata`, `CreateSkillRequest` and `UpdateSkillRequest` (`codersdk/userskills.go` moves to `codersdk/skills.go`), and `UpdateSkillRequest.Content` is now `*string`. The personal client method names are unchanged. The site changes are the handwritten edits that rename forces (`api.ts`, `queries/userSkills.ts`, `testHelpers/skills.ts` and three call sites), with no UI change. Organization routes under `/api/experimental/organizations/{organization}/skills`, not gated by an experiment or license, like the personal ones: - `GET` lists with the caller's own permissions, so admins, the site owner and org auditors see every skill and members see only skills shared with them. `GET /{skillName}` goes through the new `httpmw.ExtractOrganizationSkillParam` and admits only read, so a missing skill and a denied one both return 404. - `POST` checks `create` on the organization before reading the body, then seeds `group_acl` with the Everyone group (whose ID is the organization ID) so a new skill reaches every member until an admin narrows it. The 100-skill cap and a duplicate name return 409. - `PATCH` admits only callers who can read the skill, because its response includes the content; `DELETE` admits callers who can read or delete it. A reader who can't change the skill gets a write-specific 403 from the database wrapper, and everyone else gets 404. PATCH locks the row as system, updates as the caller in the same transaction, and audits the locked row only after the transaction commits. - Audit: `database.AuditableOrganizationSkill` records resource type `organization_skill` with the organization ID; personal skills keep `user_skill`. Personal and organization handlers share one create and update path in `coderd/userskills.go` (`createSkill`, `updateSkill`, and a `skillWriteErrors` table per owner and action). ## Commits The first commit reproduces the reviewed code from the old stack; each later commit is a labeled trim or fix. - `49cb2c84276` feat: add organization skill API routes. Reproduction: every file this commit changes, including the SDK layer's site edits, equals the reviewed old `write-routes` head `aa597100f28`; the rest of the tree differs only by #30609's migration merge and main. - `dc893bc60d6` refactor(coderd): share the skill create and update path across owners (production +164/-188). It keeps the organization create check before the body read, the lock as system then update as caller order, and audit assignment after the transaction. No swagger, `codersdk` or `typesGenerated.ts` change; `make gen` is clean. - `f94925425ef` test(coderd): merge duplicate personal and organization skill tests. `TestSkillsCRUD`, `TestSkillValidationAndConflicts` and `TestSkillAudit` are table-driven over Personal, OrgAdmin and SiteOwner, alongside `TestOrganizationSkillAuditsDeniedWrites` and one `ScopedAPIKeys` subtest; `TestPatchUserSkill` is deleted because none of its blocks were unique. Coverage of `userskills.go`, `organizationskills.go` and `httpmw/organizationskillparam.go` is 101 of 117 blocks before and after, the same block set. - `ad0a7a37504` fix(coderd): require read access to patch an organization skill. The organization PATCH route now admits only `read`, because its response carries the skill's content: a key scoped to `organization_skill:update` without read gets 404, like GET, instead of 200 with the content. Readers without update still get 403, and DELETE is unchanged. `TestOrganizationSkillAccess/ScopedAPIKeys` asserts the 404, that the response has no content, and that the skill is unchanged; against the old route it fails with 200. - `69d00ded0b6` and `f67b79343ec` merge the updated #30609 layer, including main; `69d00ded0b6` resolves a conflict in the personal skills page with main. No other changes of their own. - `18373ffd59e` merges the updated #30609 layer (main at `e7b76872098`) and reapplies the `AuditableOrganizationSkill` entry in `enterprise/audit/table.go` alongside main's new `AuditableChatProjectInstructions` entries. ## Size Production +838/-308, tests +733/-322, generated +801/-274; total +2372/-904. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30587 (scope-neutral SDK and personal enabled state), #30588 (read routes), #30589 (write routes and audit). ## Validation - The coverage comparison above, before and after the test merge. - `make gen` leaves no diff after the shared create and update refactor. - On `18373ffd59e`: `make gen` is clean; build, vet, the `coderd` and `enterprise/coderd` skill tests, `rbac`, `httpmw`, `dbauthz` and `enterprise/audit` pass; `pnpm check`, `pnpm lint` and `make pre-commit` pass. - Remote UAT round 7 through Coder Agents passed on the whole stack; see #30613's Validation for scope and findings. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
b67587c875 |
feat: add the organization skills data model (#30609)
## Stack Part of [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. **#30609** data model: one migration, queries, RBAC and dbauthz (this PR) 2. #30610 organization skill API routes and the scope-neutral SDK 3. #30611 sharing ACL routes 4. #30612 settings UI: shared skills table, admin page, member section 5. #30613 chats: chatd loading, `/` menu, docs ## What changes This PR adds the data model and authorization for organization skills. Personal skills keep working unchanged: `git diff origin/main -- codersdk site` shows only generated RBAC and API key scope additions (`apikey_scopes_gen.go`, `rbacresources_gen.go`, `rbacresourcesGenerated.ts`, the RBAC and scope unions in `typesGenerated.ts`) and `codersdk.ResourceTypeOrganizationSkill` with its friendly string. No personal route, SDK type or site component changes, and `coderd/userskills_test.go` changes only by mechanical constant renames. **One migration, `000621_skills`** (please review it closely): - renames `user_skills` to `skills` with its constraints, index and triggers, and recreates the cap function and `delete_deleted_user_resources`, whose PL/pgSQL bodies name the table; - adds `organization_id` and `project_id` (`ON DELETE CASCADE`), `enabled` (default true), and `group_acl` / `user_acl` (`jsonb`, default `{}`), with CHECKs for exactly one owner, ACLs that are JSON objects, and ACLs that stay empty unless an organization owns the row, plus partial unique name indexes per owner kind; - replaces the cap trigger with `enforce_skills_per_owner_limit()`: 100 rows per owner, disabled rows included, locking the owner row `FOR NO KEY UPDATE` so unrelated foreign key checks are not blocked; - adds a `BEFORE DELETE` trigger on `organization_members` that removes a departing member from `user_acl` on that organization's skills, so rejoining doesn't restore a direct grant; - adds the `organization_skill` `resource_type` and `api_key_scope` enum values last; nothing in the migration uses them. The down migration undoes the three old migrations in reverse order: it drops organization and project rows and restores `user_skills`, its names, the cap function and `user_id NOT NULL`. Authorization: a new RBAC resource `organization_skill` (create, read, update, delete, share). Owner and org admin get it; site and org auditors get read; members read only through the skill's ACL, which applies only to members of its organization. `Skill.RBACObject()` returns the organization object with both ACLs; project rows stay denied to everyone. New sqlc queries cover organization insert, get, list (SQL-filtered through `GetAuthorizedOrganizationSkillMetadata` and a `regosql` converter), update and delete, with dbauthz wrappers and the audit table entries. No routes yet. ## Commits The first commit reproduces the reviewed code from the old stack; each later commit is a labeled trim or fix. - `baa3150e3b7` feat: add the organization skills data model. Reproduction: every non-site file this commit changes equals the reviewed old `authz` head `1e16b3004c4`, except that the old stack's migrations 000615, 000616 and 000617 are merged into one migration (then `000615_skills`, now `000621_skills`) with one fixture (`testdata/fixtures/000621_skills.up.sql`) and one migration test (now `testMigration000621Skills`). At that commit, `dump.sql` was byte-identical to the old head's. - `1b84e83463a` test(coderd/database): keep only the SQL paths of the org skill matrix. `TestOrganizationSkillAuthorization` becomes `TestOrganizationSkillQueries` instead of being deleted, because coverage showed it is this PR's only run of the `GetAuthorizedOrganizationSkillMetadata` row scan (80% to 65% without it) and of the organization update and delete queries (100% to 0%). Swapping `group_acl` and `user_acl` in the converter makes `GrantedMember` fail. The removed cases are decided by `TestRolePermissions`, `TestSkillRBACObjectOrganizationACL` and the dbauthz method suite. - `e2931b412e9` test(coderd/database): fold the skill cap cases into existing coverage. The user case is covered by `TestUserSkillLimit` and `TestUserSkillLimitConcurrentCreates`; the organization case folds into `ConcurrentOrganizationInsertsHonorCap`, which now also checks that disabled rows count and another organization is unaffected (mutation checked); the project case stays. - `be62aea9021` test(coderd/rbac): drop `TestOrganizationSkillReadScope`, covered by `TestExternalScopeNames` and the generated scope file. - `0c275ba37de` merges main at `454a2fcc697`, which took 000615 to 000618: it renumbers the migration to 000619 and resolves `dump.sql`, `check_constraint.go` and the generated API docs. `8f2b4b87ee2` merges main at `ad85646164e`, which took 000619: it renumbers the migration to 000620. - `5248d56b64f` merges main at `e7b76872098`, which took 000620 (`000620_audit_chat_project_instructions_resource_type`): it renumbers the migration, fixture and migration test to `000621_skills` (step `Migration000621Skills`, version 621), and resolves `enterprise/audit/table.go` (keeping main's `AuditableChatProjectInstructions` entries and the `Skill` entry), `dump.sql` and `models.go` (the `resource_type` enum gets `chat_project_instructions`, then `organization_skill`) and the regenerated `schemas.md`. The up and down SQL are unchanged by every renumbering. ## Size Production +549/-67, tests +728/-33, generated +881/-314; total +2158/-414. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30584 (rename `user_skills` to `skills`), #30585 (skill owners), #30586 (organization skill authorization). ## Validation - Migration test: up keeps the existing personal row and its ID; down restores the `user_skills` names, cap function and `NOT NULL`, and drops organization rows; soft-deleting a user removes their skills after up, after down, and after re-up. - `go test` passed on `be62aea9021`, before the main merges, for `coderd` (skill tests), `coderd/database`, `dbauthz`, `migrations`, `gentest`, `coderd/rbac/...`, `coderd/x/chatd`, `coderd/x/skills`, `enterprise/audit` and `enterprise/coderd`; `make lint/check-scopes` passed; the four personal skills Vitest files pass unchanged. - On `5248d56b64f`: build, vet, `TestMigrate`, `TestMigrationChain`, the `migrations`, `database`, `dbauthz`, `gentest`, `rbac` and `enterprise/audit` packages pass; `make gen` run twice is clean, and `make pre-commit` passes. - Remote UAT round 7 through Coder Agents passed on the whole stack; see #30613's Validation for scope and findings. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
63900d212d |
feat: support personal skills in chats (#25366)
> Mux updated this PR on behalf of Mike. ## Stack Context This PR builds on #25365 in the experimental personal skills stack and completes the chat integration. Stack order: 1. #25362 personal skill resolver 2. #25363 storage, permissions, API, and SDK 3. #25365 API test coverage 4. #25366 chattool and chatd integration 5. #25066 settings UI and docs 6. #25386 personal skills slash menu ## What? Updates chattool skill formatting and `read_skill` resolution so tools can read personal skills from the database, then injects personal skill metadata into chatd prompts and registers the skill-reading tools when skills are available. This branch has also been merged with current `origin/main` to resolve merge conflicts. ## Why? The chattool and chatd changes need to land together so the intermediate stack state stays buildable. This completes personal skill availability in chats without syncing personal skills into workspace filesystems. ## Validation - `go test -count=1 ./coderd/x/chatd/chattool -run 'TestFormatResolvedSkillIndex|TestReadSkillTool|TestReadSkillFileTool'` - `go test -count=1 ./coderd/x/chatd -run 'TestPersonalSkillsInSystemPrompt|TestPersonalAndWorkspaceSkillCollisionInSystemPrompt|TestSkillIndexRefreshReplacesStaleAliases|TestFetchPersonalSkillMetadata|TestLoadPersonalSkillBody'` - `go test -count=1 ./coderd -run 'Test.*UserSkill'` - `git diff --cached --check` - `make lint` - pre-commit hook |
||
|
|
e105e3af45 |
test: cover personal skill API (#25365)
> Mux updated this PR on behalf of Mike. ## Stack Context This PR is the API test coverage slice in the experimental personal skills stack. The storage, schema, permissions, API, and SDK implementation merged in #25363. Stack order: 1. #25362 personal skill resolver 2. #25363 storage, permissions, API, and SDK 3. #25365 API test coverage 4. #25366 chattool and chatd integration 5. #25066 settings UI and docs 6. #25386 personal skills slash menu ## What? Adds API and audit tests for personal skill CRUD, validation failures, limits, authorization, soft-delete cleanup, and audit content tracking. This PR is now test-only. It does not include migrations, generated database code, or API implementation changes. ## Why? The feature touches storage, permissions, and audit behavior. These tests make the server behavior reviewable and protected without re-reviewing the implementation that already merged in #25363. ## Validation - `go test ./coderd -run '^(TestUserSkill|TestPatchUserSkill)' -count=1` - `go test ./enterprise/coderd -run '^TestUserSkillAuditDiffTracksContent$' -count=1` - pre-commit hook via `gt modify --no-edit` |
||
|
|
5a8d0016a5 |
feat: add personal skill storage, API, and SDK (#25363)
> Mux updated this PR on behalf of Mike. ## Stack Context This PR is the storage, permissions, API, and SDK layer for experimental personal skills. #25362 has landed on `main`, so this branch is restacked directly on `main`. Stack order: 1. #25363 storage, permissions, API, and SDK 2. #25365 API test coverage 3. #25366 chattool and chatd integration 4. #25066 settings UI and docs 5. #25386 personal skills slash menu ## What? Adds the `user_skills` database table, generated queries, RBAC resources and scopes, audit resource handling, experimental user-scoped CRUD endpoints, SDK types, and generated API/site types. Follow-up review and restack fixes: - Enforce a bounded personal skill description in parser and database constraints. - Return `403 Forbidden` for unauthorized create and update attempts. - Return explicit conflict responses when soft-deleted users are targeted. - Keep user admins out of personal skills, while site owners can read and delete but not create or update. - Document trigger-raised constraint names and keep schema constants covered by tests. - Reuse `UserSkillMetadata` in the full `UserSkill` SDK response type. - Generate user skill IDs in Go instead of relying on a database default. - Rebase on latest `main` and renumber the user skills migration to `000502_user_skills`. ## Why? Personal skills need durable user-owned storage with owner authorization, limited site-owner moderation, and a hidden API surface before chatd can consume them. ## Validation - `make gen` - `go test ./coderd/database -run '^TestUserSkillSchemaConstants$' -count=1` - `go test ./coderd/database/dbauthz -run '^TestMethodTestSuite/TestUserSkills$' -count=1` - `go test ./coderd -run '^TestPatchUserSkill$' -count=1` - `go test ./codersdk ./coderd/database/db2sdk` - `make lint` - pre-commit hook on `97fd58108d` |