@softize/opus 8.8.1 → 8.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/bin/cli.mjs +45 -15
- package/bin/lib/create.mjs +5 -5
- package/bin/lib/init.mjs +20 -228
- package/bin/lib/materialize.mjs +273 -0
- package/bin/lib/mcp.mjs +3 -3
- package/bin/lib/postinstall.mjs +7 -4
- package/bin/lib/validate-skill.mjs +40 -0
- package/docs/code-style.md +4 -4
- package/docs/releasing.md +12 -14
- package/package.json +16 -14
- package/registry/git/pre-push +8 -0
- package/registry/git/pre-push.d/opus +9 -0
- package/registry/github/opus.yml +22 -0
- package/registry/instructions/opus.md +15 -0
- package/registry/skills/build-opus-ui/SKILL.md +39 -0
- package/registry/skills/build-opus-ui/agents/openai.yaml +4 -0
- package/registry/skills/build-opus-ui/references/evaluations.md +5 -0
- package/registry/skills/build-opus-ui/references/ui-patterns.md +8 -0
- package/registry/skills/create-opus-action/SKILL.md +43 -0
- package/registry/skills/create-opus-action/agents/openai.yaml +4 -0
- package/registry/skills/create-opus-action/references/contract-and-binding.md +12 -0
- package/registry/skills/create-opus-action/references/evaluations.md +5 -0
- package/registry/skills/create-opus-action/scripts/scaffold.mjs +100 -0
- package/registry/skills/implement-opus-change/SKILL.md +43 -0
- package/registry/skills/implement-opus-change/agents/openai.yaml +4 -0
- package/registry/skills/implement-opus-change/references/evaluations.md +5 -0
- package/registry/skills/implement-opus-change/references/protocol-boundaries.md +11 -0
- package/registry/skills/test-opus-action/SKILL.md +38 -0
- package/registry/skills/test-opus-action/agents/openai.yaml +4 -0
- package/registry/skills/test-opus-action/references/evaluations.md +5 -0
- package/registry/skills/test-opus-action/references/harness.md +10 -0
- package/registry/skills/upgrade-opus/SKILL.md +37 -0
- package/registry/skills/upgrade-opus/agents/openai.yaml +4 -0
- package/registry/skills/upgrade-opus/references/evaluations.md +5 -0
- package/registry/skills/upgrade-opus/references/upgrade-checklist.md +8 -0
- package/registry/templates/app/src/domains/tasks/index.ts +1 -1
- package/src/ui/components/primitives/select.tsx +18 -6
- package/src/ui/docs/content/actions.md +1 -1
- package/src/ui/docs/content/cli.md +2 -2
- package/src/ui/docs/content/customization.md +1 -1
- package/src/ui/docs/content/data.md +1 -1
- package/src/ui/docs/content/microcopy.md +1 -1
- package/src/ui/docs/content/scroll-area.md +1 -1
- package/src/ui/docs/content/tokens.md +1 -1
- package/src/ui/docs/content/ui.md +1 -1
- package/src/ui/docs/doc-client.tsx +2 -2
- package/src/ui/theme.css +1 -1
- package/registry/hooks/hooks.json +0 -26
- package/registry/hooks/link-memory-on-start.mjs +0 -46
- package/registry/skills/create-action/SKILL.md +0 -49
- package/registry/skills/create-action/scaffold.mjs +0 -122
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: create-action
|
|
3
|
-
description: Cria uma opus action no formato canônico (passa no opus check por construção). Use ao implementar uma nova action/endpoint num projeto Opus-based.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# create-action
|
|
7
|
-
|
|
8
|
-
Procedimento pra criar uma **opus action** padronizada. Gera o esqueleto certo e
|
|
9
|
-
deixa você só com a lógica — sem decorar convenção, sem reprovar no `opus check`.
|
|
10
|
-
|
|
11
|
-
> Língua: **código em inglês; comentários/UI em pt-BR** (ver `code-style.md`).
|
|
12
|
-
|
|
13
|
-
## Passo a passo
|
|
14
|
-
|
|
15
|
-
1. **Decida** `<resource>.<verb>` e o `kind`:
|
|
16
|
-
- `list` — lista paginada · `view` — leitura de um recurso
|
|
17
|
-
- `form` — mutação com campos de UI · `simple` — mutação atômica
|
|
18
|
-
- Namespacing por sub-área é ok: `ticket.sla.check`.
|
|
19
|
-
|
|
20
|
-
2. **Gere o esqueleto** (formato canônico, ordem dos campos correta):
|
|
21
|
-
```bash
|
|
22
|
-
node scaffold.mjs <resource> <verb> <kind> # ex.: ticket create form
|
|
23
|
-
```
|
|
24
|
-
Cole o resultado em `src/domains/<resource>/actions/<verb>.ts`.
|
|
25
|
-
|
|
26
|
-
3. **Preencha**: `input`/`output` (zod + `t.*` pra tipos lógicos), `summary`/`label`
|
|
27
|
-
(pt-BR), e o `handler` (a lógica). Não reordene os campos.
|
|
28
|
-
|
|
29
|
-
4. **Exporte no barrel** `src/domains/<resource>/actions/index.ts` e garanta que o
|
|
30
|
-
domínio está registrado no `src/runtime.ts` (`defineDomain` + `runtime.register`).
|
|
31
|
-
|
|
32
|
-
5. **Front (quando aplicável)**: invoque via `@softize/opus/client` + `ui/react`
|
|
33
|
-
(`useLookupAction`/`useTriggerAction`/`useFormAction`/`useViewAction`) — **não**
|
|
34
|
-
escreva fetch/tipos na mão.
|
|
35
|
-
|
|
36
|
-
6. **Valide**: `opus check src` → tem que dar **0 violação**. Rode antes do handoff.
|
|
37
|
-
|
|
38
|
-
## O contrato é o `actions.md`
|
|
39
|
-
|
|
40
|
-
Kinds, ordem canônica dos campos e garantias vivem na página Actions (`/docs/actions`;
|
|
41
|
-
`node_modules/@softize/opus/src/ui/docs/content/actions.md`) — não reproduza aqui. O
|
|
42
|
-
`scaffold.mjs` já emite a ordem certa e o `opus check` cobra; esta skill é o
|
|
43
|
-
PROCEDIMENTO, não a referência.
|
|
44
|
-
|
|
45
|
-
Checklist rápido do que o `opus check` reprova (antes do handoff):
|
|
46
|
-
- `name` = `<resource>(.<sub>)*.<verb>`, minúsculo, ponto.
|
|
47
|
-
- `kind` ∈ `simple|form|list|view`.
|
|
48
|
-
- Campos na ordem canônica (do scaffold; ver `actions.md`).
|
|
49
|
-
- `defineAction` é **`export const`**.
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scaffold de opus action — gera o esqueleto canônico (passa no `opus check` por
|
|
3
|
-
* construção: action-name, kind, field-order, export). O agente preenche a lógica.
|
|
4
|
-
*
|
|
5
|
-
* Uso: node scaffold.mjs <resource> <verb> [kind=simple]
|
|
6
|
-
* ex.: node scaffold.mjs widget list list → const widgetList (widget.list)
|
|
7
|
-
* node scaffold.mjs user set-password simple
|
|
8
|
-
*
|
|
9
|
-
* Comentários em pt-BR (UI/comentários em PT; código em inglês — ver code-style.md).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1)
|
|
13
|
-
const camel = (verb) => verb.split('-').map((p, i) => (i === 0 ? p : cap(p))).join('')
|
|
14
|
-
/** const name = resource + PascalVerb. Ex.: user + set-password → userSetPassword. */
|
|
15
|
-
const constName = (resource, verb) => resource + verb.split('-').map(cap).join('')
|
|
16
|
-
|
|
17
|
-
const HEAD = `import { z } from 'zod'
|
|
18
|
-
import { defineAction } from '@softize/opus/core'
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
/** Gera o conteúdo .ts canônico da action pro kind. */
|
|
22
|
-
export function actionTemplate({ resource, verb, kind = 'simple' }) {
|
|
23
|
-
const cn = constName(resource, verb)
|
|
24
|
-
const name = `${resource}.${verb}`
|
|
25
|
-
|
|
26
|
-
if (kind === 'list') {
|
|
27
|
-
return `${HEAD}
|
|
28
|
-
export const ${cn} = defineAction({
|
|
29
|
-
name: '${name}',
|
|
30
|
-
kind: 'list',
|
|
31
|
-
summary: 'TODO: o que lista (pt-BR)',
|
|
32
|
-
input: z.object({
|
|
33
|
-
// TODO: filtros / paginação
|
|
34
|
-
}),
|
|
35
|
-
output: z.object({
|
|
36
|
-
// TODO: shape de um item
|
|
37
|
-
id: z.string(),
|
|
38
|
-
}),
|
|
39
|
-
paginate: 'cursor',
|
|
40
|
-
handler: async (_ctx, _input) => {
|
|
41
|
-
// TODO: buscar
|
|
42
|
-
return { items: [], cursor: { next: null }, total: 0 }
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
`
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (kind === 'form') {
|
|
49
|
-
return `${HEAD}
|
|
50
|
-
export const ${cn} = defineAction({
|
|
51
|
-
name: '${name}',
|
|
52
|
-
kind: 'form',
|
|
53
|
-
label: 'TODO: rótulo (pt-BR)',
|
|
54
|
-
messages: { success: 'TODO', error: 'TODO' },
|
|
55
|
-
input: z.object({
|
|
56
|
-
// TODO: campos do form
|
|
57
|
-
}),
|
|
58
|
-
output: z.object({ id: z.string() }),
|
|
59
|
-
fields: {
|
|
60
|
-
// TODO: { campo: { label: 'pt-BR' } }
|
|
61
|
-
},
|
|
62
|
-
handler: async (_ctx, _input) => {
|
|
63
|
-
// TODO: criar/editar
|
|
64
|
-
return { id: '' }
|
|
65
|
-
},
|
|
66
|
-
invalidates: ['${resource}.list'],
|
|
67
|
-
})
|
|
68
|
-
`
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (kind === 'view') {
|
|
72
|
-
return `${HEAD}
|
|
73
|
-
export const ${cn} = defineAction({
|
|
74
|
-
name: '${name}',
|
|
75
|
-
kind: 'view',
|
|
76
|
-
summary: 'TODO: o que retorna (pt-BR)',
|
|
77
|
-
input: z.object({ id: z.string() }),
|
|
78
|
-
output: z.object({
|
|
79
|
-
// TODO: shape do recurso
|
|
80
|
-
id: z.string(),
|
|
81
|
-
}),
|
|
82
|
-
handler: async (_ctx, input) => {
|
|
83
|
-
// TODO: carregar
|
|
84
|
-
return { id: input.id }
|
|
85
|
-
},
|
|
86
|
-
})
|
|
87
|
-
`
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// simple (default)
|
|
91
|
-
return `${HEAD}
|
|
92
|
-
export const ${cn} = defineAction({
|
|
93
|
-
name: '${name}',
|
|
94
|
-
kind: 'simple',
|
|
95
|
-
label: 'TODO: rótulo (pt-BR)',
|
|
96
|
-
messages: { success: 'TODO', error: 'TODO' },
|
|
97
|
-
input: z.object({ id: z.string() }),
|
|
98
|
-
output: z.object({ ok: z.boolean() }),
|
|
99
|
-
handler: async (_ctx, _input) => {
|
|
100
|
-
// TODO: mutação
|
|
101
|
-
return { ok: true }
|
|
102
|
-
},
|
|
103
|
-
invalidates: ['${resource}.list'],
|
|
104
|
-
})
|
|
105
|
-
`
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Nome do arquivo sugerido (kebab do verb). */
|
|
109
|
-
export function actionFileName(verb) {
|
|
110
|
-
return `${verb}.ts`
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// CLI: imprime o template no stdout (a skill diz onde colar).
|
|
114
|
-
const isMain = import.meta.url === `file://${process.argv[1]}`
|
|
115
|
-
if (isMain) {
|
|
116
|
-
const [resource, verb, kind] = process.argv.slice(2)
|
|
117
|
-
if (!resource || !verb) {
|
|
118
|
-
console.error('uso: node scaffold.mjs <resource> <verb> [kind=simple|form|list|view]')
|
|
119
|
-
process.exit(1)
|
|
120
|
-
}
|
|
121
|
-
process.stdout.write(actionTemplate({ resource, verb, kind }))
|
|
122
|
-
}
|