@srobroek/pi-chezmoi-editor 0.0.0-stage → 0.7.2
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 +69 -0
- package/LICENSE +202 -0
- package/README.md +71 -2
- package/extensions/chezmoi.js +920 -0
- package/package.json +31 -4
- package/skills/chezmoi-editor/SKILL.md +67 -0
- package/skills/chezmoi-editor/references/conventions.md +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srobroek/pi-chezmoi-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"description": "Refuse edits and shell writes to chezmoi-managed live files, naming the source to edit, plus the chezmoi-editor skill.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/srobroek/harness-plugins.git",
|
|
12
|
+
"directory": "plugins/chezmoi/pi"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.md",
|
|
18
|
+
"extensions",
|
|
19
|
+
"skills"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"provenance": true
|
|
24
|
+
},
|
|
25
|
+
"pi": {
|
|
26
|
+
"extensions": [
|
|
27
|
+
"./extensions/chezmoi.js"
|
|
28
|
+
],
|
|
29
|
+
"skills": [
|
|
30
|
+
"./skills"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: chezmoi-editor
|
|
3
|
+
description: Edits chezmoi-managed dotfiles at their source; use when changing dotfiles, templates, or global agent and tool config.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Chezmoi Editor
|
|
7
|
+
|
|
8
|
+
Use this skill when a task changes files managed by chezmoi. Resolve the managed
|
|
9
|
+
source first; do not edit the rendered live target of a continuously managed file as
|
|
10
|
+
the durable fix (live-owned targets: see Rules).
|
|
11
|
+
|
|
12
|
+
In OpenCode, the chezmoi plugin refuses `edit`, `write` and `patch` calls that
|
|
13
|
+
target a managed file, and common literal shell writes (`>`/`>>` redirects, `tee`,
|
|
14
|
+
`cp`/`mv`, `sed -i`, `perl -i`). The refusal names the source path to edit. It reads
|
|
15
|
+
literal words only: writes through `sh -c`, the shell eval builtin, scripts, variables other than
|
|
16
|
+
`$HOME`, or other tools pass unchecked, so resolve the source yourself.
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
1. Determine whether the target is managed:
|
|
21
|
+
- `chezmoi managed`
|
|
22
|
+
- `chezmoi source-path <target>` when a specific target is known
|
|
23
|
+
- existing symlink/source layout when chezmoi cannot resolve it directly
|
|
24
|
+
2. Edit the source under the chezmoi source tree, not `$HOME` runtime output, unless
|
|
25
|
+
the target is live-owned (see Rules).
|
|
26
|
+
3. Use native chezmoi names for dotfiles, executables, private files, readonly
|
|
27
|
+
files, symlinks, scripts, and templates.
|
|
28
|
+
4. Never write a credential in plaintext. With the 1Password CLI, read it at apply time
|
|
29
|
+
with `{{ onepasswordRead "op://<vault>/<item>/<field>" }}` in a `.tmpl` file.
|
|
30
|
+
chezmoi has template functions for other password managers too (Bitwarden,
|
|
31
|
+
KeePassXC, `pass`, Vault and more). Use the one the user already has. Or store the
|
|
32
|
+
file encrypted with `chezmoi add --encrypt <target>`, which uses the age or GPG
|
|
33
|
+
`encryption` from the chezmoi config. `private_` only sets `0600` permissions, and
|
|
34
|
+
the file stays plaintext in git.
|
|
35
|
+
5. Preview with `chezmoi diff`. Apply only when the source diff is correct and
|
|
36
|
+
the user wants the live target updated now.
|
|
37
|
+
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
- Treat the chezmoi source directory as the source of truth.
|
|
41
|
+
- Prefer native chezmoi patterns over ad hoc symlink or copy schemes.
|
|
42
|
+
- If a live target changed outside chezmoi, reconcile it back into source
|
|
43
|
+
instead of patching around the generated copy.
|
|
44
|
+
- A one-off change to hosts that already exist, such as adding or removing one entry
|
|
45
|
+
or fixing one live key, gets no reconcile machinery: no `run_once_` or
|
|
46
|
+
`run_onchange_` script, retirement list entry, or declared key that only exists so a
|
|
47
|
+
reconcile script carries it. This applies only to live-owned targets: seed-once
|
|
48
|
+
`create_` files, and files that a reconcile script or the user owns on the host after
|
|
49
|
+
seeding. Edit those live files on each affected host directly, and change the source
|
|
50
|
+
only where newly seeded hosts should differ. Reconcile code is for state that must
|
|
51
|
+
keep converging on every apply.
|
|
52
|
+
- Continuously managed files and templates are not live-owned. A host-specific change to
|
|
53
|
+
one still goes in the source (use the template's host conditionals); a live edit is
|
|
54
|
+
refused by the OpenCode guard and overwritten by the next `chezmoi apply`.
|
|
55
|
+
- Temporary runtime experiments are allowed only when the user explicitly asks
|
|
56
|
+
for them; record how to promote the result into source.
|
|
57
|
+
- Resolve locations only through `chezmoi source-path` and `chezmoi managed`.
|
|
58
|
+
Do not assume a source-tree path, home-directory layout, or username.
|
|
59
|
+
|
|
60
|
+
## Scripts
|
|
61
|
+
|
|
62
|
+
- Status and diff: `chezmoi status`, `chezmoi diff`.
|
|
63
|
+
|
|
64
|
+
## References
|
|
65
|
+
|
|
66
|
+
- Read `references/conventions.md` in this skill's directory when choosing file
|
|
67
|
+
naming prefixes.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Chezmoi Conventions
|
|
2
|
+
|
|
3
|
+
## Source-file name prefixes
|
|
4
|
+
|
|
5
|
+
Attributes stack in a fixed order (for example `private_executable_dot_foo` or
|
|
6
|
+
`run_once_before_install.sh.tmpl`); `chezmoi add` writes them for you.
|
|
7
|
+
|
|
8
|
+
| Prefix / suffix | Meaning |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `dot_` | target name starts with `.` |
|
|
11
|
+
| `private_` | `0600` file or `0700` directory; permissions only, not encryption |
|
|
12
|
+
| `readonly_` | write permission removed |
|
|
13
|
+
| `executable_` | executable file |
|
|
14
|
+
| `empty_` | keep the file even when it is empty |
|
|
15
|
+
| `encrypted_` | encrypted in source; written by `chezmoi add --encrypt` |
|
|
16
|
+
| `create_` | write the target only when it does not exist yet |
|
|
17
|
+
| `modify_` | script that receives the current target on stdin and prints the new contents |
|
|
18
|
+
| `remove_` | remove the target |
|
|
19
|
+
| `symlink_` | target is a symlink; file contents are the link destination |
|
|
20
|
+
| `exact_` | directory: remove target entries not present in source |
|
|
21
|
+
| `external_` | directory: ignore attributes in child entries |
|
|
22
|
+
| `literal_` | stop attribute parsing; the rest of the name is literal |
|
|
23
|
+
| `run_` | script run by `chezmoi apply` |
|
|
24
|
+
| `once_` | with `run_`: run once per content hash |
|
|
25
|
+
| `onchange_` | with `run_`: run when contents change |
|
|
26
|
+
| `before_` / `after_` | with `run_`: run before or after updating targets |
|
|
27
|
+
| `.tmpl` | Go template rendered at apply time |
|
|
28
|
+
| `.literal` | suffix: stop suffix parsing |
|
|
29
|
+
|
|
30
|
+
Resolve the source tree with `chezmoi source-path` (or `chezmoi source-path
|
|
31
|
+
<target>` for one target); it is not at a fixed location.
|