@diagonal-hq/cli 0.12.3 → 0.12.5
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/README.md +4 -3
- package/dist/cli.mjs +1742 -1707
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,9 +60,10 @@ The build reads each file with a parser. It runs only the workflow tests.
|
|
|
60
60
|
- The build removes imports from `@diagonal-hq/cli`. Pages, layouts, components, and workflow scripts can import workspace files through `@app/`. A resource file can import only `@app/generated/resources`. Workflow scripts can also import `@diagonal/workflow` and `@diagonal/workflow/workspace`. Other external imports in these source files are rejected.
|
|
61
61
|
- The second argument of `definePage`, and the default export of a layout or component file, must be one function.
|
|
62
62
|
- Each page has a key that is unique in the workspace: a camelCase name of at most 64 letters and digits, such as `members`. The page's id comes from the key. Without a `key` option, the key comes from the file path below `pages/`: `pages/members/[id].tsx` is `membersId`, `pages/404.tsx` is `page404`, and `pages/index.tsx` is `home`. Set `key` when the page must keep its identity and its `Pages.<key>` links after a file move. Two pages with the same key fail at the second file.
|
|
63
|
+
- Each page also has a `uid`. See [Definition uids and slugs](#definition-uids-and-slugs). Nothing reads it yet: the key still gives the page its id.
|
|
63
64
|
- Pages, layouts, and components link to a page with `Pages.<key>`: `Pages.members.url()`, `Pages.member.url({ id })`, and `Pages.members.navigate()`. `Pages` needs no import, and `import { Pages } from '@diagonal/pages'` also works. The check fails at an unknown key and at a call without the route parameters of the page.
|
|
64
65
|
- Pages, layouts, and components go through the page lint gate: syntax, scope, the component return shape, and a type check against the page Sdk contract and the workspace resources. A page names a resource by slug, for example `Sdk.resource(Resources.Members.slug)`.
|
|
65
|
-
- Each `workflows/<name>.ts` is a script workflow. It has one `export const config = { title, trigger, runAs? } satisfies WorkflowConfig` and one `export default defineWorkflow(...)`. The config must be a static literal. The build validates it: the trigger fields, the resources (see [Resource references](#resource-references)), the workflow paths of `workflowEvent` triggers, and the run-as rules. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`.
|
|
66
|
+
- Each `workflows/<name>.ts` is a script workflow. It has one `export const config = { uid, title, trigger, runAs? } satisfies WorkflowConfig` and one `export default defineWorkflow(...)`. The config must be a static literal. The build validates it: the uid (see [Definition uids and slugs](#definition-uids-and-slugs)), the trigger fields, the resources (see [Resource references](#resource-references)), the workflow paths of `workflowEvent` triggers, and the run-as rules. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`.
|
|
66
67
|
- Each `skills/<name>.md` is a workspace AI skill: YAML front matter with `uid`, `name`, `description`, and optionally `enabled` and `manualOnly`, then a Markdown body with its instructions. The build validates the front matter, the uid (see [Definition uids and slugs](#definition-uids-and-slugs)), and that no two skill files declare one `name`.
|
|
67
68
|
- The build removes the config and the `@diagonal-hq/cli` imports from the workflow, with spaces in their place, and compiles the rest with the workflow script compiler against the workspace resources. A compiler error has the line and column of the workflow file.
|
|
68
69
|
- `workflows/<name>.test.ts` tests `workflows/<name>.ts` with `node:test` and `node:assert`. It imports the workflow, `runWorkflow` and `MockTransport` from `@diagonal/workflow/testing`, and `Resources` from `@app/generated/resources`. The build transpiles the test and the workflows and runs them in one Node process. The process can read only its own temporary directory, cannot start processes, and has an empty environment. Each failing test is an error at the test. A test file without a workflow is an error.
|
|
@@ -72,12 +73,12 @@ The build reads each file with a parser. It runs only the workflow tests.
|
|
|
72
73
|
|
|
73
74
|
## Definition uids and slugs
|
|
74
75
|
|
|
75
|
-
A definition can have two identity options. A resource and the front matter of a skill file have a `uid`. No definition uses `slug` yet.
|
|
76
|
+
A definition can have two identity options. A resource, a page, a workflow `config`, and the front matter of a skill file have a `uid`. No definition uses `slug` yet.
|
|
76
77
|
|
|
77
78
|
- `uid` is the stable identity of the definition. Its value is a lowercase UUID string literal, such as `uid: '3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c'`. In skill front matter, it is a YAML string, such as `uid: 3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c`. A file move, a file rename, or a name change keeps the uid. Do not change a uid.
|
|
78
79
|
- `slug` is the editable, user-facing name of the definition. It is kebab-case: lowercase letters and digits in groups that one `-` joins, such as `job-postings`. A slug change keeps the uid.
|
|
79
80
|
|
|
80
|
-
`diagonal check` writes a new uid into each definition that has none. It adds `uid: '<uuid>'` as the first option of the `defineX()` object, or `uid: <uuid>` as the first line of the front matter of a skill file, and leaves the rest of the file unchanged. Commit the change.
|
|
81
|
+
`diagonal check` writes a new uid into each definition that has none. It adds `uid: '<uuid>'` as the first option of the `defineX()` object or of the `export const config` object of a workflow, or `uid: <uuid>` as the first line of the front matter of a skill file, and leaves the rest of the file unchanged. Commit the change.
|
|
81
82
|
|
|
82
83
|
The platform writes the missing uids too: a save in Files, and every other commit that the platform makes, adds a uid to each definition of the changed files that has none. A git push does not, so a pushed definition without a uid fails the deploy, and the error tells you to run `diagonal check`.
|
|
83
84
|
|