@tackup/cli 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +16 -1
- package/dist/builtins/extensions/docs/guides/day-two.md +3 -0
- package/dist/builtins/extensions/docs/guides/onboarding-2.md +3 -0
- package/dist/builtins/extensions/docs/guides/onboarding-3.md +3 -0
- package/dist/builtins/extensions/docs/skills/use-tack-docs/SKILL.md +67 -0
- package/dist/builtins/extensions/docs/skills/use-tack-docs/references/declare-docs.md +71 -0
- package/dist/builtins/extensions/docs/skills/use-tack-docs/references/docs-in-profiles.md +25 -0
- package/dist/builtins/extensions/docs/skills/use-tack-docs/references/docs-maintenance.md +35 -0
- package/dist/builtins/extensions/docs/skills/use-tack-docs/references/review.md +34 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/SKILL.md +66 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figure-components.md +20 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/architecture-map.md +86 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/chart.md +52 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/figure.md +79 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/file-tree.md +74 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/schema.md +116 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/system.md +81 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/walkthrough.md +45 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/page-components.md +82 -0
- package/dist/builtins/extensions/docs/skills/write-reader-figures/references/rules.md +27 -0
- package/dist/builtins/extensions/docs/tack.yaml +10 -0
- package/dist/builtins/extensions/scripts/guides/day-two.md +3 -0
- package/dist/builtins/extensions/scripts/guides/onboarding-2.md +3 -0
- package/dist/builtins/extensions/scripts/skills/author-tack-scripts/SKILL.md +48 -0
- package/dist/builtins/extensions/scripts/skills/author-tack-scripts/references/run-scripts.md +23 -0
- package/dist/builtins/extensions/scripts/skills/author-tack-scripts/references/script-api.md +76 -0
- package/dist/builtins/extensions/scripts/skills/author-tack-scripts/references/scripts-in-profiles.md +35 -0
- package/dist/builtins/extensions/scripts/skills/author-tack-scripts/references/scripts-in-sources.md +56 -0
- package/dist/builtins/extensions/scripts/tack.yaml +10 -0
- package/dist/builtins/skills/author-tack-profiles/SKILL.md +68 -0
- package/dist/builtins/skills/author-tack-profiles/references/apply.md +33 -0
- package/dist/builtins/skills/author-tack-profiles/references/bundles.md +59 -0
- package/dist/builtins/skills/author-tack-profiles/references/copy-workflows.md +46 -0
- package/dist/builtins/skills/manage-tack-sources/SKILL.md +75 -0
- package/dist/builtins/skills/manage-tack-sources/references/catalog-issues.md +38 -0
- package/dist/builtins/skills/manage-tack-sources/references/metadata.md +35 -0
- package/dist/builtins/skills/manage-tack-sources/references/tack-yaml.md +114 -0
- package/dist/builtins/skills/manage-tack-sources/references/worked-source.md +126 -0
- package/dist/builtins/skills/prepare-tack-checkout/SKILL.md +52 -0
- package/dist/builtins/skills/use-tack/SKILL.md +65 -0
- package/dist/builtins/skills/use-tack/references/agent-instructions.md +38 -0
- package/dist/builtins/skills/use-tack/references/day-two.md +35 -0
- package/dist/builtins/skills/use-tack/references/explore.md +13 -0
- package/dist/builtins/skills/use-tack/references/imports.md +30 -0
- package/dist/builtins/skills/use-tack/references/maintenance.md +51 -0
- package/dist/builtins/skills/use-tack/references/onboarding-2.md +41 -0
- package/dist/builtins/skills/use-tack/references/onboarding-3.md +29 -0
- package/dist/builtins/skills/use-tack/references/onboarding.md +54 -0
- package/dist/builtins/skills/use-tack/references/output.md +15 -0
- package/dist/builtins/skills/use-tack/references/selection.md +61 -0
- package/dist/builtins/skills/use-tack/references/setup.md +69 -0
- package/dist/builtins/tack.yaml +10 -0
- package/dist/bundle-support-ZGTM5CTZ.js +16 -0
- package/dist/chunk-CFUDY2NO.js +1791 -0
- package/dist/chunk-CRQMJGMU.js +225 -0
- package/dist/chunk-DCX5T7CG.js +281 -0
- package/dist/chunk-EZ5C7B2M.js +28 -0
- package/dist/chunk-H4AG4WIV.js +52 -0
- package/dist/chunk-I5RMMV2Y.js +18013 -0
- package/dist/chunk-JL3E32X5.js +92 -0
- package/dist/chunk-MR5PTCYF.js +26 -0
- package/dist/chunk-PHQL7OBB.js +162 -0
- package/dist/chunk-QQBCYPJZ.js +5733 -0
- package/dist/chunk-T6JAU547.js +12401 -0
- package/dist/chunk-W7GHLGII.js +16 -0
- package/dist/chunk-XARHV5M4.js +56 -0
- package/dist/chunk-XZH2XPII.js +1017 -0
- package/dist/chunk-ZT6BO7LG.js +36671 -0
- package/dist/corpus-effects-YWG5VVHJ.js +12069 -0
- package/dist/elk.bundled-EVXDSFFG.js +94125 -0
- package/dist/main-JHULX3QY.js +65517 -0
- package/dist/main.js +17 -0
- package/dist/reader/visuals.tsx +368 -0
- package/dist/script.d.ts +133 -0
- package/dist/script.js +90 -0
- package/dist/server-XF7NSYRQ.js +308 -0
- package/dist/src-DZKPD6VY.js +1871 -0
- package/dist/src-TC3RTKIS.js +1126 -0
- package/dist/tack-env.d.ts +137 -0
- package/dist/third-party-licenses.txt +2467 -0
- package/dist/worker-ZFY6P7X5.js +24246 -0
- package/package.json +29 -3
package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/file-tree.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# `FileTree`
|
|
2
|
+
|
|
3
|
+
Generated from the reader's component contracts. Do not edit by hand. No prop takes a position, a size or a colour: the reader draws every figure from meaning.
|
|
4
|
+
|
|
5
|
+
Answers: What is on disk, what points where, and what is temporary?
|
|
6
|
+
|
|
7
|
+
| Prop | Required | Meaning |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `id` | Yes | Unique on the page. A short lowercase slug. On the fence line or on the wrapper. |
|
|
10
|
+
| `title` | Yes | The claim, as a sentence of at least 4 words. Never a topic such as "Release layout". On the fence line or on the wrapper. |
|
|
11
|
+
| `summary` | No | One or two sentences under the caption, in plain text: Markdown is not rendered there. |
|
|
12
|
+
| `rule` | No | `{ title, text }`: how to read the tree, such as "Arrows are symlinks". Wrapper only. |
|
|
13
|
+
| `startWith` | No | Entry ids offered as entry points. Wrapper only. |
|
|
14
|
+
| `lenses` | No | `{ id?, label, note, focus?: [entry ids], present?: [entry ids] }`: a moment. `present` names the `[temp]` entries that exist in it; the others are stamped absent. Wrapper only. |
|
|
15
|
+
| `source` | No | Never written by hand: the reader fills it from the `tree` fenced block. |
|
|
16
|
+
| line | | One entry per line, two spaces per level. `name/` is a directory. `name -> target` is a symlink, resolved from the link's own directory. `# text` is the note. `[key]` emphasises, `[temp]` marks an entry that exists only sometimes, `[12 MB]` is a size. `...` stands for entries left out. |
|
|
17
|
+
| entry id | | Its path from the top-level entry: `~/.local/share/tack/current`. A trailing slash is optional. |
|
|
18
|
+
|
|
19
|
+
What the reader draws:
|
|
20
|
+
|
|
21
|
+
- Write a fenced block with the language `tree`, in `.md` or `.mdx`, with `id` and `title` on the fence line after the language. Wrap it in `<FileTree>` only for a rule, entry points or lenses.
|
|
22
|
+
- One row per entry on ruled lines, names in mono, directories in semibold, key entries boxed, temporary entries dashed.
|
|
23
|
+
- A symlink whose target is in the tree gets an arrow in a lane right of every name, ending on the first link its path passes through. Focus on an entry inks it, its chain of links and what points at it.
|
|
24
|
+
- Notes in an aligned column, at most two lines. Sizes right-aligned with bars to scale with the largest.
|
|
25
|
+
- The ground is ruled-lines by default.
|
|
26
|
+
|
|
27
|
+
Budget, checked by `tack check`:
|
|
28
|
+
|
|
29
|
+
- At most 60 entries. Fold the rest into `...`.
|
|
30
|
+
- At most 1,200 px tall at column width: about 50 rows.
|
|
31
|
+
- Indentation in two spaces; a tab or an odd indentation is reported with its line.
|
|
32
|
+
|
|
33
|
+
## Worked example
|
|
34
|
+
|
|
35
|
+
The plan, five lines kept out of the page:
|
|
36
|
+
|
|
37
|
+
1. Question: after an update, what is on disk, what points at what, what is temporary?
|
|
38
|
+
2. Claim: an update swaps one symlink, current; the releases never change.
|
|
39
|
+
3. Form: FileTree, because the question is what is on disk.
|
|
40
|
+
4. Parts: the bin link, the pointers, one release with its sizes, the temporary entries.
|
|
41
|
+
5. Cases: one lens per moment: during an update, after a rollback.
|
|
42
|
+
|
|
43
|
+
The figure:
|
|
44
|
+
|
|
45
|
+
````mdx
|
|
46
|
+
<FileTree
|
|
47
|
+
id="release-on-disk"
|
|
48
|
+
title="An update swaps one symlink, current; the releases never change"
|
|
49
|
+
rule={{ title: "Arrows are symlinks", text: "An arrow ends where the link resolves on disk." }}
|
|
50
|
+
startWith={["~/.local/bin/tack"]}
|
|
51
|
+
lenses={[
|
|
52
|
+
{ label: "During an update", note: "staging/ and update.lock exist until the gate passes.", present: ["~/.local/share/tack/staging/", "~/.local/share/tack/update.lock"] },
|
|
53
|
+
{ label: "After a rollback", note: "current points at the older release and hold exists.", present: ["~/.local/share/tack/hold"], focus: ["~/.local/share/tack/current"] },
|
|
54
|
+
]}
|
|
55
|
+
>
|
|
56
|
+
|
|
57
|
+
```tree
|
|
58
|
+
~/.local/
|
|
59
|
+
bin/
|
|
60
|
+
tack -> ../share/tack/current/bin/tack # created once, never rewritten
|
|
61
|
+
share/tack/
|
|
62
|
+
current -> releases/0.1.0+g1cfcfc7 # the pointer an update swaps [key]
|
|
63
|
+
releases/
|
|
64
|
+
0.1.0+g1cfcfc7/ # one immutable release [306 MB]
|
|
65
|
+
bin/tack # Bun plus the bundled CLI [69 MB]
|
|
66
|
+
node_modules/.bun/ # production dependencies [237 MB]
|
|
67
|
+
...
|
|
68
|
+
hold # after a gate failure or a rollback [temp]
|
|
69
|
+
update.lock # only during an update [temp]
|
|
70
|
+
staging/ # only during an update [temp]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
</FileTree>
|
|
74
|
+
````
|
package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/schema.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# `Schema`
|
|
2
|
+
|
|
3
|
+
Generated from the reader's component contracts. Do not edit by hand. No prop takes a position, a size or a colour: the reader draws every figure from meaning.
|
|
4
|
+
|
|
5
|
+
Answers: Which tables or entities exist, how do they relate at the level of a column, and which role may read or write what?
|
|
6
|
+
|
|
7
|
+
| Prop | Required | Meaning |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `id` | Yes | Unique on the page. A short lowercase slug. |
|
|
10
|
+
| `title` | Yes | The claim, as a sentence of at least 4 words. Never a topic such as "Release layout". |
|
|
11
|
+
| `summary` | No | One or two sentences under the caption, in plain text: Markdown is not rendered there. |
|
|
12
|
+
| `rule` | No | `{ title, text }`: how to read it. |
|
|
13
|
+
| `startWith` | No | Table names offered as entry points. |
|
|
14
|
+
| `tables` | Yes | The tables, or the entities. A dotted name `schema.table` puts the table in the group `schema`; the card drops the prefix. |
|
|
15
|
+
| `groups` | No | `{ id, label, note? }` to name and describe a group, such as a Postgres schema. |
|
|
16
|
+
| `links` | No | `{ from, to, label, cardinality? }` for a relation that is not a foreign key. Ends are `schema.table.column` or `schema.table`. Cardinalities: `one-to-one`, `one-to-many`, `many-to-one`, `many-to-many`. |
|
|
17
|
+
| `lenses` | No | `{ id?, label, note, focus?: [tables], access?: { "<table or schema.*>": level } }`. `focus` shows which tables a concern involves; `access` shows what a role may do to each, a table it does not list is `none`; `write` covers insert, update and delete, so say "insert only" in the note. Levels: `read`, `write`, `read-write`, `none`. |
|
|
18
|
+
| `replays` | No | `{ id?, label, steps: [{ at: name or [names], note }] }`. A step names the tables, or `schema.table.column` columns, a query touches, in order. |
|
|
19
|
+
| table | | `{ name, note?, columns, unique? }`. `unique` lists column sets that are unique together, such as `[["depot", "observed_at"]]`. |
|
|
20
|
+
| column | | `{ name, type?, key?: "pk" | "unique", ref?: "schema.table.column", nullable?, note? }`. A `ref` is a foreign key to a declared table. A table whose columns have no `type` is an entity: give every column a type, or none. |
|
|
21
|
+
|
|
22
|
+
What the reader draws:
|
|
23
|
+
|
|
24
|
+
- A card per table: the name, then one row per column with its key mark (PK, FK, UQ), its name, `?` when nullable, its type right-aligned in mono and its note on a second line.
|
|
25
|
+
- An entity card is lighter: the name and its attributes, no type column.
|
|
26
|
+
- A foreign key is a curve from the row of the referencing column to the row of the referenced column, with a crow's foot at the many end and a bar at the one end. A link that is not a key is dashed and labelled; between entities it is solid, labelled with its verb and marked by its cardinality.
|
|
27
|
+
- Groups are labelled regions, tinted in order. Cards are packed to keep the figure short, tables that reference each other near each other, each group as one block.
|
|
28
|
+
- Focus on a table inks it, what it references and what references it, and the panel says so column by column.
|
|
29
|
+
- An access lens stamps each table with R, W or RW and hatches the tables the role may not touch. A focus lens keeps its tables inked and fades the rest.
|
|
30
|
+
- The ground is dot-grid paper by default.
|
|
31
|
+
|
|
32
|
+
Budget, checked by `tack check`:
|
|
33
|
+
|
|
34
|
+
- At most 12 tables: split a larger schema by group. At most 12 steps in a replay.
|
|
35
|
+
- Every `ref` and link end names a declared table or column; every table has a column; no table is declared twice; SQL tables and entity cards are not mixed.
|
|
36
|
+
- Text is never drawn under 11 px. At most 1,200 px tall at column width.
|
|
37
|
+
|
|
38
|
+
## Worked example
|
|
39
|
+
|
|
40
|
+
The plan, five lines kept out of the page:
|
|
41
|
+
|
|
42
|
+
1. Question: which tables hold parcels, how do they join, and who may write them?
|
|
43
|
+
2. Claim: every parcel chains back to a depot, and only the collector writes events.
|
|
44
|
+
3. Form: Schema, because the question is tables, keys and roles.
|
|
45
|
+
4. Parts: depots, parcels, parcel_events and the job log they share a workflow with. auth is left out.
|
|
46
|
+
5. Cases: a lens per role, with access.
|
|
47
|
+
|
|
48
|
+
The figure:
|
|
49
|
+
|
|
50
|
+
```mdx
|
|
51
|
+
<Schema
|
|
52
|
+
id="parcel-schema"
|
|
53
|
+
title="Every parcel chains back to a depot, and only the collector writes events"
|
|
54
|
+
rule={{ title: "A line ends on the column it references", text: "A crow's foot marks the many end." }}
|
|
55
|
+
startWith={["public.parcels"]}
|
|
56
|
+
groups={[{ id: "public", label: "public", note: "application data" }, { id: "ops", label: "ops" }]}
|
|
57
|
+
tables={[
|
|
58
|
+
{ name: "public.depots", columns: [
|
|
59
|
+
{ name: "code", type: "text", key: "pk", note: "e.g. LYS1" },
|
|
60
|
+
{ name: "name", type: "text" },
|
|
61
|
+
] },
|
|
62
|
+
{ name: "public.parcels", columns: [
|
|
63
|
+
{ name: "id", type: "bigserial", key: "pk" },
|
|
64
|
+
{ name: "depot", type: "text", ref: "public.depots.code" },
|
|
65
|
+
{ name: "tracking_code", type: "text" },
|
|
66
|
+
{ name: "carrier", type: "text", nullable: true },
|
|
67
|
+
] },
|
|
68
|
+
{ name: "public.parcel_events", columns: [
|
|
69
|
+
{ name: "id", type: "bigserial", key: "pk" },
|
|
70
|
+
{ name: "parcel_id", type: "bigint", ref: "public.parcels.id", note: "on delete cascade" },
|
|
71
|
+
{ name: "kind", type: "text" },
|
|
72
|
+
{ name: "workflow_id", type: "text" },
|
|
73
|
+
] },
|
|
74
|
+
{ name: "ops.job_logs", columns: [
|
|
75
|
+
{ name: "id", type: "bigserial", key: "pk" },
|
|
76
|
+
{ name: "workflow_id", type: "text" },
|
|
77
|
+
] },
|
|
78
|
+
]}
|
|
79
|
+
links={[
|
|
80
|
+
{ from: "ops.job_logs.workflow_id", to: "public.parcel_events.workflow_id", label: "same workflow, no FK" },
|
|
81
|
+
]}
|
|
82
|
+
lenses={[
|
|
83
|
+
{ label: "collector", note: "Inserts parcels and their events, nothing else.", access: { "public.parcels": "write", "public.parcel_events": "write" } },
|
|
84
|
+
{ label: "worker-core", note: "Reads and writes public, writes ops.job_logs.", access: { "public.*": "read-write", "ops.job_logs": "write" } },
|
|
85
|
+
]}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Worked example: a domain model
|
|
90
|
+
|
|
91
|
+
The plan, five lines kept out of the page:
|
|
92
|
+
|
|
93
|
+
1. Question: where does a resource come from?
|
|
94
|
+
2. Claim: a resource exists only because a source declares it.
|
|
95
|
+
3. Form: Schema with entity cards, because the question is which things exist and how they relate.
|
|
96
|
+
4. Parts: the three terms from the glossary that answer it, with their attributes. Selection is left out.
|
|
97
|
+
5. Cases: none; the verbs carry it.
|
|
98
|
+
|
|
99
|
+
The figure:
|
|
100
|
+
|
|
101
|
+
```mdx
|
|
102
|
+
<Schema
|
|
103
|
+
id="source-domain"
|
|
104
|
+
title="A resource exists only because a source declares it"
|
|
105
|
+
rule={{ title: "Read the verbs along the lines", text: "A crow's foot marks the many end." }}
|
|
106
|
+
tables={[
|
|
107
|
+
{ name: "Source", columns: [{ name: "label" }, { name: "maintainers" }] },
|
|
108
|
+
{ name: "Resource declaration", columns: [{ name: "kind" }, { name: "declared path" }] },
|
|
109
|
+
{ name: "Resource", note: "identity: source, kind, name", columns: [{ name: "kind" }, { name: "name" }] },
|
|
110
|
+
]}
|
|
111
|
+
links={[
|
|
112
|
+
{ from: "Source", to: "Resource declaration", label: "declares", cardinality: "one-to-many" },
|
|
113
|
+
{ from: "Resource declaration", to: "Resource", label: "covers", cardinality: "one-to-many" },
|
|
114
|
+
]}
|
|
115
|
+
/>
|
|
116
|
+
```
|
package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/system.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# `System`
|
|
2
|
+
|
|
3
|
+
Generated from the reader's component contracts. Do not edit by hand. No prop takes a position, a size or a colour: the reader draws every figure from meaning.
|
|
4
|
+
|
|
5
|
+
Answers: Which parts run and what do they send each other? What happens when one fails?
|
|
6
|
+
|
|
7
|
+
| Prop | Required | Meaning |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `id` | Yes | Unique on the page. A short lowercase slug. |
|
|
10
|
+
| `title` | Yes | The claim, as a sentence of at least 4 words. Never a topic such as "Release layout". |
|
|
11
|
+
| `summary` | No | One or two sentences under the caption, in plain text: Markdown is not rendered there. |
|
|
12
|
+
| `rule` | No | `{ title, text }`: how to read it, such as "Links follow the data". |
|
|
13
|
+
| `startWith` | No | Node ids offered as entry points. |
|
|
14
|
+
| `nodes` | Yes | The parts that run, and what they touch. Kinds: `service`, `store`, `queue`, `external`, `actor`, `artifact`. |
|
|
15
|
+
| `groups` | No | `{ id, label, parent? }`: a boundary such as a host, a network, a trust zone or a process. A group may sit inside one other group. |
|
|
16
|
+
| `links` | Yes | `{ id?, from, to, label, kind? }`. The label is required: what moves, or what is done. Kinds: `call`, `async`, `reply` (default `call`). A link points the way the data or the request moves. |
|
|
17
|
+
| `replays` | No | `{ id?, label, steps: [{ at: id or [ids], note, broken?: [ids] }] }`. A step names the nodes and links it passes through. |
|
|
18
|
+
| `lenses` | No | `{ id?, label, note, focus: [ids], broken?: [ids] }`: a failure, a role or a moment. Ids name nodes and links. |
|
|
19
|
+
| node | | `{ id, label, kind, detail?, lines?, about?, group? }`. `detail` is one short line. `lines` are up to 6 mono lines inside the box: table names, sub-parts, settings. `about` shows in the panel when the node is pinned. |
|
|
20
|
+
|
|
21
|
+
What the reader draws:
|
|
22
|
+
|
|
23
|
+
- Shapes by kind: a service is a plain box, a store a cylinder, a queue a box with slots, an external part a dashed outline, an actor a pill, an artifact a sheet with a folded corner. The legend lists the shapes in use.
|
|
24
|
+
- Groups are labelled regions with a dashed border, tinted in order.
|
|
25
|
+
- Every link at rest, as a curve with its label on it. The kind sets the line and never changes: `call` solid, `async` dashed, `reply` dotted. Focus and cases change the ink, not the line.
|
|
26
|
+
- Box positions come from a layered layout that respects groups. Left to right when the whole drawing fits the column with text at full size, top to bottom otherwise, then the same with link labels on two lines. A link that would cross a box bows out around it.
|
|
27
|
+
- A step or a lens inks the nodes and links it names and fades the rest; broken parts are struck in red and their links end in a stop mark.
|
|
28
|
+
- The ground is quad-ruled paper by default.
|
|
29
|
+
|
|
30
|
+
Budget, checked by `tack check`:
|
|
31
|
+
|
|
32
|
+
- At most 12 nodes, 6 lines in a node and 12 steps in a replay.
|
|
33
|
+
- Every link has a label; every node is in a link.
|
|
34
|
+
- Text is never drawn under 11 px. A drawing that fits no way is reported and scrolls sideways; at most 1,200 px tall.
|
|
35
|
+
|
|
36
|
+
## Worked example
|
|
37
|
+
|
|
38
|
+
The plan, five lines kept out of the page:
|
|
39
|
+
|
|
40
|
+
1. Question: how does one parcel event reach the database, and what happens when a part is down?
|
|
41
|
+
2. Claim: an event leaves Redis only after Postgres has it.
|
|
42
|
+
3. Form: System, because the question is what runs and what it sends.
|
|
43
|
+
4. Parts: the feed, the collector in its untrusted worker, the stream, the consumer, Postgres. The backfill job is left out.
|
|
44
|
+
5. Cases: a replay of one event, a lens for Postgres down.
|
|
45
|
+
|
|
46
|
+
The figure:
|
|
47
|
+
|
|
48
|
+
```mdx
|
|
49
|
+
<System
|
|
50
|
+
id="capture-path"
|
|
51
|
+
title="An event leaves Redis only after Postgres has it"
|
|
52
|
+
rule={{ title: "Links follow the data", text: "A link points the way an event moves." }}
|
|
53
|
+
startWith={["redis"]}
|
|
54
|
+
groups={[{ id: "browser", label: "worker-browser (untrusted)" }]}
|
|
55
|
+
nodes={[
|
|
56
|
+
{ id: "feed", label: "Carrier tracking feed", kind: "external" },
|
|
57
|
+
{ id: "collector", label: "collector", kind: "service", detail: "headless browser + WebSocket", group: "browser" },
|
|
58
|
+
{ id: "redis", label: "Redis stream", kind: "queue", detail: "about 1 day at 3 GB" },
|
|
59
|
+
{ id: "consumer", label: "worker-core", kind: "service", detail: "consumer" },
|
|
60
|
+
{ id: "pg", label: "Postgres", kind: "store", lines: ["public.parcel_events"] },
|
|
61
|
+
]}
|
|
62
|
+
links={[
|
|
63
|
+
{ id: "capture", from: "feed", to: "collector", label: "parcel events" },
|
|
64
|
+
{ id: "xadd", from: "collector", to: "redis", label: "XADD" },
|
|
65
|
+
{ id: "read", from: "redis", to: "consumer", label: "XREADGROUP" },
|
|
66
|
+
{ id: "insert", from: "consumer", to: "pg", label: "INSERT" },
|
|
67
|
+
{ id: "ack", from: "consumer", to: "redis", label: "ack + delete", kind: "reply" },
|
|
68
|
+
]}
|
|
69
|
+
replays={[
|
|
70
|
+
{ label: "One event", steps: [
|
|
71
|
+
{ at: ["feed", "capture", "collector"], note: "The collector receives the event." },
|
|
72
|
+
{ at: ["xadd", "redis"], note: "It waits in the stream." },
|
|
73
|
+
{ at: ["read", "consumer", "insert", "pg"], note: "The consumer inserts it." },
|
|
74
|
+
{ at: ["ack"], note: "Only then is the entry acknowledged and deleted." },
|
|
75
|
+
] },
|
|
76
|
+
]}
|
|
77
|
+
lenses={[
|
|
78
|
+
{ label: "Postgres down", note: "Capture continues. Events wait in Redis.", focus: ["collector", "xadd", "redis"], broken: ["pg", "insert"] },
|
|
79
|
+
]}
|
|
80
|
+
/>
|
|
81
|
+
```
|
package/dist/builtins/extensions/docs/skills/write-reader-figures/references/figures/walkthrough.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# `Walkthrough`
|
|
2
|
+
|
|
3
|
+
Generated from the reader's component contracts. Do not edit by hand. No prop takes a position, a size or a colour: the reader draws every figure from meaning.
|
|
4
|
+
|
|
5
|
+
Answers: In what order do steps or decisions apply, when a reader follows them one at a time?
|
|
6
|
+
|
|
7
|
+
| Prop | Required | Meaning |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `id` | Yes | Unique on the page. A short lowercase slug. |
|
|
10
|
+
| `title` | Yes | The claim, as a sentence of at least 4 words. Never a topic such as "Release layout". |
|
|
11
|
+
| `steps` | Yes | `{ title, body, readable? }` in order. `body` is text or JSX; give `readable` the plain text when `body` is JSX. |
|
|
12
|
+
|
|
13
|
+
What the reader draws:
|
|
14
|
+
|
|
15
|
+
- One step at a time, with Previous, Next and the step count; the step shown is kept in the view state.
|
|
16
|
+
- Copy and search get every step, numbered, whichever is shown.
|
|
17
|
+
- A short list a reader scans at once stays a numbered Markdown list.
|
|
18
|
+
|
|
19
|
+
Budget, checked by `tack check`:
|
|
20
|
+
|
|
21
|
+
- Every step has a title.
|
|
22
|
+
|
|
23
|
+
## Worked example
|
|
24
|
+
|
|
25
|
+
The plan, five lines kept out of the page:
|
|
26
|
+
|
|
27
|
+
1. Question: what does a first sync take?
|
|
28
|
+
2. Claim: three commands, and only the last one writes.
|
|
29
|
+
3. Form: Walkthrough, because the reader does them in order, one at a time.
|
|
30
|
+
4. Parts: pick, preview, apply.
|
|
31
|
+
5. Cases: none; the order carries it.
|
|
32
|
+
|
|
33
|
+
The figure:
|
|
34
|
+
|
|
35
|
+
```mdx
|
|
36
|
+
<Walkthrough
|
|
37
|
+
id="first-sync"
|
|
38
|
+
title="A first sync takes three commands"
|
|
39
|
+
steps={[
|
|
40
|
+
{ title: "Pick", body: "Run tack pick and choose the skills this project needs." },
|
|
41
|
+
{ title: "Preview", body: "Run tack sync to see what would change; nothing is written." },
|
|
42
|
+
{ title: "Apply", body: "Run tack sync --apply to write the links." },
|
|
43
|
+
]}
|
|
44
|
+
/>
|
|
45
|
+
```
|
package/dist/builtins/extensions/docs/skills/write-reader-figures/references/page-components.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Page components
|
|
2
|
+
|
|
3
|
+
Authored figures, icons, callouts, tabs, terms and questions in `.mdx` pages. The `write-reader-figures` skill says when to draw; [figure-components.md](figure-components.md) lists the props of every figure component and kit element, and the token classes.
|
|
4
|
+
|
|
5
|
+
## Authored figures
|
|
6
|
+
|
|
7
|
+
Use an authored figure only when no component fits the question: a pipeline across two places on disk, a process tree, a tank that fills. You compose a `<Figure>` with one `<Drawing height>` of kit elements at explicit positions: `Box`, `Link`, `Band`, `Badge`, `Note`, `Label`. The frame still gives it the caption, cases, focus, panel, legend, text equivalent and view state.
|
|
8
|
+
|
|
9
|
+
1. Use the kit's `Drawing`. It is always 728 wide. Keep a 16 px margin and place on a 4 px grid.
|
|
10
|
+
2. Place kit elements. Use raw SVG (`<path>`, `<rect>`) only for the bespoke part no element covers.
|
|
11
|
+
3. No colour values and no inline styles. Tints (`tint={1}` to `6`) and ink come from the kit; raw SVG takes the token classes of the reference.
|
|
12
|
+
4. Do not size a box by eye. Let it size itself from its text; give `w` only to align a column.
|
|
13
|
+
5. Two text sizes. Every link has a `label`, or its style has a `legend` entry. A link never crosses a box that is not one of its ends: move the boxes.
|
|
14
|
+
6. The resting picture answers the question. Focus, replays and lenses come from the frame, by ids. Do not write event handlers.
|
|
15
|
+
7. Give an `id` to every box that takes part in focus or in a case. The text equivalent is built from them.
|
|
16
|
+
8. Run the figure check. It reports overlaps, text that does not fit, elements outside the drawing and crossings, and counts the raw shapes it cannot check.
|
|
17
|
+
|
|
18
|
+
## Icons
|
|
19
|
+
|
|
20
|
+
An `.mdx` page can mark a kind of thing with a Lucide icon, inline with the word it marks: `<Icon name="database" /> Postgres`. Add `label="..."` only when the icon carries meaning the text does not. Only the curated docs set works, so never write a name from memory: find one with `tack docs icons <word>`. Names say what an icon draws, so search for the object you picture (`flask` for research, `megaphone` for an announcement) or run it without a word to see them all; it also maps an old Lucide name such as `home` to `house`. Write the name as a plain string, also in a component, so the reader can bundle it. `tack check` names every unknown icon by line with the closest names; fix them before finishing.
|
|
21
|
+
|
|
22
|
+
## Callouts, tabs and terms
|
|
23
|
+
|
|
24
|
+
Three more components work in every `.mdx` page, without an import:
|
|
25
|
+
|
|
26
|
+
```mdx
|
|
27
|
+
<Callout kind="warning" title="Breaking">
|
|
28
|
+
`tack check` replaces `docs check`; there are no aliases.
|
|
29
|
+
</Callout>
|
|
30
|
+
|
|
31
|
+
<Tabs>
|
|
32
|
+
<Tab label="npm">`npm install --global @tackup/cli`</Tab>
|
|
33
|
+
<Tab label="Bun">`bun add --global @tackup/cli`</Tab>
|
|
34
|
+
</Tabs>
|
|
35
|
+
|
|
36
|
+
A <Term title="A folder of resources Tack reads through its tack.yaml">source</Term> declares what it offers.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `Callout` sets one note apart: `kind` is `note` (the default), `tip`, `warning` or `decision`, each with its icon; `title` is optional; `icon` swaps in a docs icon. One per point that must not be missed. Do not wrap ordinary paragraphs in it.
|
|
40
|
+
- `Tabs` holds alternatives a reader picks one of, such as per-platform steps. At least two `Tab`s, each with its own `label`. Do not hide sequential steps in tabs.
|
|
41
|
+
- `Term` defines a word on hover and focus; screen readers and copy get the definition after it. Define a term once, where it is first used.
|
|
42
|
+
- `<details><summary>…</summary>…</details>` folds long evidence; it needs no component.
|
|
43
|
+
|
|
44
|
+
`tack check` reports an unknown `kind`, a `Tab` without a label or outside `Tabs`, a label used twice, `Tabs` with fewer than two tabs and a `Term` without `title`, by line, and so does the reader's issue list.
|
|
45
|
+
|
|
46
|
+
## Questions
|
|
47
|
+
|
|
48
|
+
When a page needs the reader's decision, ask it in place with `Question`, beside the text it is about:
|
|
49
|
+
|
|
50
|
+
```mdx
|
|
51
|
+
<Question id="storage" title="Where should review batches live?">
|
|
52
|
+
|
|
53
|
+
A batch holds the reader's words and local paths.
|
|
54
|
+
|
|
55
|
+
- The **state directory** is private to this machine.
|
|
56
|
+
- The **docs source** is versioned, and may be shared.
|
|
57
|
+
|
|
58
|
+
<Option value="state" recommended>
|
|
59
|
+
In Tack's state directory
|
|
60
|
+
</Option>
|
|
61
|
+
<Option value="page">Beside the page, in the docs source</Option>
|
|
62
|
+
|
|
63
|
+
</Question>
|
|
64
|
+
|
|
65
|
+
<Question id="agents" title="Which agents should the first release teach?" multiple>
|
|
66
|
+
<Option value="claude-code">Claude Code</Option>
|
|
67
|
+
<Option value="codex">Codex</Option>
|
|
68
|
+
</Question>
|
|
69
|
+
|
|
70
|
+
<Question id="name" title="What should the command be called?" />
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- `id` is a slug, unique on the page: the answer is named by it. `title` is the question itself.
|
|
74
|
+
- Put what the reader needs to decide inside the `Question`, as Markdown or MDX: what is at stake, what each option costs, code or a figure. It shows between the title and the options. Start it at the beginning of the line with blank lines around it, as above: a formatter moves Markdown indented inside a component. Keep the title one question and move the rest there.
|
|
75
|
+
- The reader numbers questions in page order, `#1`, `#2`, and letters options, `a`, `b`, so people cite an answer as `#2: b`. Never write numbers or letters yourself. Put a follow-up `Question` directly inside the one it depends on: it shows after that one's options, as `#2.1`.
|
|
76
|
+
- Give two or more `Option`s, each with a unique `value` and its label as children, directly in the `Question` with a blank line between options and context, or none for a free answer. Every question also takes a free comment.
|
|
77
|
+
- Mark your pick with `recommended`, which shows as a small mark after the label; say why in the context: at most one, unless the question is `multiple`.
|
|
78
|
+
- Write questions and options in the page itself, never in an expression or an imported file: those get no number or letter, and the reader shows them disabled with the note "This question is not part of the review".
|
|
79
|
+
- The reader answers in `tack docs serve` and sends the answers as one review; the `use-tack-docs` skill says how to receive it.
|
|
80
|
+
- Ask only what you cannot decide from the code or the request, with options that differ in substance.
|
|
81
|
+
|
|
82
|
+
`tack check` reports a `Question` without a slug `id`, with an `id` used twice, without `title` or with one option, an `Option` without a `value`, outside a `Question` or not directly in it, a `Question` inside another but not directly in it, either one in an expression, with spread attributes or inside a sentence, a flag that is not `{true}` or `{false}`, an `Option` without a label, a `value` used twice and two recommendations in a single-choice question.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# More figure rules
|
|
2
|
+
|
|
3
|
+
The rules of `write-reader-figures` that only one form needs, where a figure should be bold, and how to derive its data from code.
|
|
4
|
+
|
|
5
|
+
## `System`: links follow the data
|
|
6
|
+
|
|
7
|
+
Links follow the data. In a `System`, write each link the way the data or the request moves, so the drawing reads as a path. A consumer reads from a queue: the link goes from the queue to the consumer (`redis -> worker-core: XREADGROUP`), not from the consumer to the queue. An answer to the link before it, such as an acknowledgement, is `kind: "reply"`; a task queue is `kind: "async"`. The check cannot know the direction of data: you must.
|
|
8
|
+
|
|
9
|
+
## `Schema`: a role is a lens
|
|
10
|
+
|
|
11
|
+
A role is a lens. In a `Schema`, give each role a lens with `access` (`"public.*": "read"`, `"ops.job_logs": "write"`); a table it does not list is `none`. `write` covers insert, update and delete: when a role may only insert, say so in the lens note. Do not keep a grants table beside the figure. A replay is worth adding only for a real query; the roles are the cases. Write keys as `ref` on the column, so the relation ends on that column; use `links` only for a relation with no foreign key, and say so in its label. A domain model is a `Schema` whose columns have no `type`: entities, their attributes, verbs with a `cardinality`.
|
|
12
|
+
|
|
13
|
+
## Be bold where it pays
|
|
14
|
+
|
|
15
|
+
The timid defaults are three boxes in a row, a figure that restates its table, one figure of the whole system, generic verbs on links, and an ASCII drawing. Each is a sign the claim is missing. Spend the boldness on the one thing the viewer must see: the barrier between two sibling tiers, the port where two layers meet, the step where a command crosses into a new tier. Make sure the resting state, before any click, already answers the main question.
|
|
16
|
+
|
|
17
|
+
## Derive, do not type
|
|
18
|
+
|
|
19
|
+
Relations that exist in code or data come from a script, not from memory. Generate a data module next to the page and import it:
|
|
20
|
+
|
|
21
|
+
```mdx
|
|
22
|
+
import { links } from "./cli-imports.ts";
|
|
23
|
+
|
|
24
|
+
<ArchitectureMap id="cli-architecture" title="..." rule={{ title: "...", text: "..." }} tiers={[...]} links={links} />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The data module exports literal data (`export const links = [...]`). The figure check reads it without running anything, so keep it literal: no function calls, no computed values. Write the generator script beside the page and rerun it when the code changes.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: tack-docs
|
|
3
|
+
description: The skills that ship with Tack's docs extension, for attaching, searching and writing docs and drawing their figures.
|
|
4
|
+
guidance:
|
|
5
|
+
- when: Before you edit any built-in skill.
|
|
6
|
+
body: |
|
|
7
|
+
Do not edit these skills. They ship with Tack, and the next upgrade replaces them. Report a
|
|
8
|
+
wrong or missing instruction to the operator instead.
|
|
9
|
+
skills:
|
|
10
|
+
- path: skills
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: author-tack-scripts
|
|
3
|
+
description: Write, declare, run and inspect the TypeScript scripts a Tack source declares, with Tack's scripts extension. Use for any `tack script` command - run, show, history - for `tack types`, and before writing or changing a script with `defineScript`. The `manage-tack-sources` skill covers the rest of a source; the `use-tack` skill covers every other `tack` command.
|
|
4
|
+
metadata:
|
|
5
|
+
tack: |
|
|
6
|
+
version: 1
|
|
7
|
+
activation: opt-in
|
|
8
|
+
user-activation: default
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Author and run Tack scripts
|
|
12
|
+
|
|
13
|
+
A script is a TypeScript module a source declares under `scripts` in its `tack.yaml`. Tack runs it by name in a registered project, the user's home or a registered root, with only the secrets it declares, and keeps a history of each run. Scripts are never linked into agent folders, so they need no sync. This skill ships with the scripts extension and is linked while it is on.
|
|
14
|
+
|
|
15
|
+
Scripts is an extension, off until `tack extension enable scripts` turns it on for the machine. While it is off, `script` and `types` fail with `extension-disabled`, and `next` names that command. A registered source that declares scripts while it is off makes Tack warn with `extension-needed`.
|
|
16
|
+
|
|
17
|
+
## Declare a script
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
version: 1
|
|
21
|
+
name: quality-tools
|
|
22
|
+
scripts:
|
|
23
|
+
- name: report
|
|
24
|
+
path: scripts/report.ts
|
|
25
|
+
description: Summarize open pull requests.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Each entry takes a `name` (lowercase letters, digits and single hyphens), a source-relative `path` to one `.ts` file, and a one-sentence `description`. The module default-exports one `defineScript` definition imported from `@tackup/cli`, which the running Tack provides: never install it in a source. Run `tack check PATH` after declaring.
|
|
29
|
+
|
|
30
|
+
Read the reference for the task:
|
|
31
|
+
|
|
32
|
+
- [script API](references/script-api.md): `defineScript`, arguments, secrets, the run context, outcome codes, editor types and dependencies. Read it before writing or changing a script.
|
|
33
|
+
- [run scripts](references/run-scripts.md): targets, arguments after `--`, JSON input, timeouts, outcomes and the run history.
|
|
34
|
+
- [scripts in sources](references/scripts-in-sources.md): the `scripts` entry of `tack.yaml`, its paths, overlap and catalog issues.
|
|
35
|
+
- [scripts in profiles](references/scripts-in-profiles.md): scripts in profiles, application and bundles.
|
|
36
|
+
|
|
37
|
+
## Run a script
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
tack extension enable scripts
|
|
41
|
+
tack catalog --kind script
|
|
42
|
+
tack script show report
|
|
43
|
+
tack types /path/to/source --apply
|
|
44
|
+
tack script run report --project PROJECT -- --name Ada
|
|
45
|
+
tack script history
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Do only what the request names. `script run` executes the script at once: it has no preview, so confirm the target and the input with the operator first unless the request already gives them. `script history clear` previews; add `--apply` only within the request. Report a run's outcome code and its result, not the raw logs, unless the person asks for them.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Run scripts
|
|
2
|
+
|
|
3
|
+
Running the scripts a source declares, and their run history.
|
|
4
|
+
|
|
5
|
+
Scripts is an extension, off until `tack extension enable scripts` turns it on for the machine. While it is off, `script` and `types` fail with `extension-disabled`, and `next` names that command.
|
|
6
|
+
|
|
7
|
+
Replace uppercase arguments with values obtained from inspection. Examples use the installed `tack`; a source run swaps in the form `use-tack` gives. Read the text view; add `--json` only when a program parses a stable payload.
|
|
8
|
+
|
|
9
|
+
## Run scripts
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
tack catalog --kind script
|
|
13
|
+
tack script show report
|
|
14
|
+
tack types /path/to/source --apply
|
|
15
|
+
tack script run report --project PROJECT -- --name Ada --times 2
|
|
16
|
+
tack script run report --project PROJECT --input-json '{"name":"Ada"}'
|
|
17
|
+
tack script history
|
|
18
|
+
tack script history show RUN_ID
|
|
19
|
+
tack script history clear
|
|
20
|
+
tack script history clear --apply
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A source declares scripts in its `tack.yaml` (see [scripts in sources](scripts-in-sources.md)). A script reference is its declared `name`, qualified with `source:` when ambiguous. A run has exactly one target: `--user`, `--project PROJECT` (one active root only), `--root PATH`, or the deepest registered root containing the current directory or `--cwd PATH`. `script show` lists the arguments and secrets a script declares; it loads the script but never runs it. Pass arguments after `--`, as `--name value`, `--name=value`, `--flag` or `--no-flag`, repeating a list argument; or pass one JSON object with `--input-json`, `--input-file` or `--input-stdin`, never both. Every argument problem is reported at once (`invalid_args`). With none, Tack supplies `{}`. `types` previews, and with `--apply` writes, a source's editor types for its scripts (see [script API](script-api.md#editor-types)). `--timeout MS` is a positive integer in milliseconds that interrupts the run, and `--quiet` stops mirroring script logs to standard error while the result and history keep them. The source supplies its own dependencies, so only `script run` finds a broken script. Run outcome codes use snake_case, unlike the kebab-case codes of other diagnostics. A run returns a `script-run` payload and `script history` a `run-history` payload. Every run leaves a history record; `script history clear` previews how many records `--apply` deletes. `script history` also accepts `list` and `ls`.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Write a Tack script
|
|
2
|
+
|
|
3
|
+
A script is a TypeScript module declared under `scripts` in the source's `tack.yaml`. It default-exports one `defineScript` definition imported from `@tackup/cli`. Tack provides that import at run time, from the Tack that runs the script: **never install `@tackup/cli`** (or the unrelated `tack` package) in a source, and do not add a `package.json` only for it. An installed copy is ignored when the script runs.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineScript } from "@tackup/cli";
|
|
7
|
+
|
|
8
|
+
export default defineScript({
|
|
9
|
+
args: {
|
|
10
|
+
repo: { type: "string", description: "The repository, such as nclsndr/tack" },
|
|
11
|
+
limit: { type: "number", default: 20 },
|
|
12
|
+
state: { type: "string", choices: ["open", "closed"], default: "open" },
|
|
13
|
+
labels: { type: "string", multiple: true, optional: true },
|
|
14
|
+
},
|
|
15
|
+
secrets: ["GITHUB_TOKEN"],
|
|
16
|
+
run: async ({ args, secrets, log, fs, exec, fail }) => {
|
|
17
|
+
const { stdout } = await exec("gh", ["pr", "list", "--repo", args.repo, "--json", "title"]);
|
|
18
|
+
const prs: unknown[] = JSON.parse(stdout);
|
|
19
|
+
if (prs.length === 0) fail(`No ${args.state} pull requests in ${args.repo}.`);
|
|
20
|
+
await fs.writeJson("reports/prs.json", prs);
|
|
21
|
+
log.info(`Saved ${prs.length} pull requests`);
|
|
22
|
+
return { count: prs.length };
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## The definition
|
|
28
|
+
|
|
29
|
+
`defineScript` takes three options and checks them when the module loads. A typo such as `arg:` fails the run with `invalid_definition` and names the fix.
|
|
30
|
+
|
|
31
|
+
| Option | Shape |
|
|
32
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `args` | `{ [name]: { type: "string" \| "number" \| "boolean", description?, default?, optional?, multiple?, choices? } }` |
|
|
34
|
+
| `secrets` | Names such as `["GITHUB_TOKEN"]`: uppercase, without the `TACK_` prefix |
|
|
35
|
+
| `run` | `async (context) => result`; return JSON data or nothing |
|
|
36
|
+
|
|
37
|
+
An argument is required unless it has a `default` or `optional: true`; `choices` restrict a string argument; `multiple: true` takes a list. A `default` must be a value the argument takes: of its type, one of its `choices`, and a list when `multiple: true`, or `defineScript` throws when the module loads. TypeScript infers `args` exactly from the declarations. Argument names are lower camel or kebab case.
|
|
38
|
+
|
|
39
|
+
An operator passes arguments after `--`: `tack script run report --project demo -- --repo nclsndr/tack --limit 5 --labels bug --labels ui`. A boolean takes `--dry-run` or `--no-dry-run`, and a camel-case name also answers to its kebab spelling. `tack script show report` prints the arguments, their defaults and the secrets, so write a `description` for every argument that is not obvious.
|
|
40
|
+
|
|
41
|
+
## The context
|
|
42
|
+
|
|
43
|
+
| Field | What it does |
|
|
44
|
+
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `args` | The validated arguments, with defaults filled in. |
|
|
46
|
+
| `secrets` | Each declared secret as a string, read from `TACK_<NAME>` in the environment or the state directory's `.env`. |
|
|
47
|
+
| `log` | `log(...)` or `log.debug`/`info`/`warn`/`error`; lines join the run log. `console.log` also works, as captured output. |
|
|
48
|
+
| `fs` | `read`, `readJson`, `write`, `writeJson`, `exists`, `list(glob)`, `remove`; relative paths resolve from `cwd`, `write` creates parent directories. |
|
|
49
|
+
| `exec` | `exec(command, args?, { cwd?, env?, allowFailure? })` runs one executable without a shell and returns `{ stdout, stderr, exitCode }`. It throws on a non-zero exit unless `allowFailure: true`. Write `exec("git", ["status"])`, not `exec("git status")`. |
|
|
50
|
+
| `cwd` | The run's working directory: the selected project root, or the user's home with `--user`. |
|
|
51
|
+
| `signal` | An `AbortSignal`, aborted when the operator cancels or the run times out. Clean up in `try`/`finally`: Tack waits for it. |
|
|
52
|
+
| `fail` | `fail(message, details?)` ends the run with an expected failure the operator should read. |
|
|
53
|
+
|
|
54
|
+
Tack replaces every declared secret value with `<redacted>` in logs, results and messages. A value the script writes to a file, or passes to a command, is the author's responsibility.
|
|
55
|
+
|
|
56
|
+
## Outcomes
|
|
57
|
+
|
|
58
|
+
| Code | When |
|
|
59
|
+
| -------------------- | ------------------------------------------------------------------------------------------ |
|
|
60
|
+
| `success` | `run` returned JSON data or nothing. |
|
|
61
|
+
| `invalid_args` | The run's arguments do not match the declarations; every problem is listed with its help. |
|
|
62
|
+
| `secret_missing` | A declared secret has no value. |
|
|
63
|
+
| `expected_failure` | `run` called `fail`. |
|
|
64
|
+
| `executed_defect` | `run` threw, an `exec` exited non-zero, or the result is not JSON. The message says which. |
|
|
65
|
+
| `invalid_definition` | The module's default export is not a valid `defineScript` definition. |
|
|
66
|
+
| `cleanup_failed` | Cleanup in `finally` threw after the run was cancelled. |
|
|
67
|
+
|
|
68
|
+
## Editor types
|
|
69
|
+
|
|
70
|
+
Run `tack types --apply` in the source folder (or `tack types PATH --apply`); it needs the scripts extension on, as `tack extension enable scripts` turns it. It writes `tack-env.d.ts`, the types of the API this Tack provides, and a `tsconfig.json` when the source has none, so the editor knows `@tackup/cli` and infers `args` and `secrets`. Commit both files, and run it again after upgrading Tack. An existing `tsconfig.json` is never changed: when it does not include `tack-env.d.ts`, the command warns (`types-stub-out-of-scope`) and you add it to `include`. Without `--apply`, it only previews.
|
|
71
|
+
|
|
72
|
+
## Dependencies and TypeScript
|
|
73
|
+
|
|
74
|
+
A script needs no `package.json`. When it imports other packages, give the source a `package.json` listing them and install them in the source; Tack checks that each declared dependency is installed before it runs a script, and never installs anything itself. A script that imports `node:` modules needs `@types/node` installed for editor types only.
|
|
75
|
+
|
|
76
|
+
Scripts run on Node or Bun with the same TypeScript: a type imported as a value, extensionless relative imports, enums and JSON imports all work.
|