facult 2.13.5 → 2.13.9
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 +10 -8
- package/assets/packs/facult-operating-model/AGENTS.global.md +35 -41
- package/assets/packs/facult-operating-model/instructions/CAPABILITY_COMPOSITION.md +4 -4
- package/assets/packs/facult-operating-model/instructions/EVOLUTION.md +3 -3
- package/assets/packs/facult-operating-model/instructions/LEARNING_AND_WRITEBACK.md +1 -1
- package/assets/packs/facult-operating-model/snippets/global/baseline.md +3 -0
- package/assets/packs/facult-operating-model/snippets/global/core/feedback-loops.md +10 -0
- package/assets/packs/facult-operating-model/snippets/global/core/verification.md +6 -0
- package/assets/packs/facult-operating-model/snippets/global/core/work-units.md +6 -0
- package/assets/packs/facult-operating-model/snippets/global/core/writeback.md +9 -0
- package/docs/composable-capability.md +21 -22
- package/docs/reference.md +8 -0
- package/package.json +1 -1
- package/src/agents.ts +16 -0
- package/src/builtin-assets.ts +2 -1
- package/src/doctor.ts +237 -7
- package/src/global-docs.ts +10 -3
- package/src/remote.ts +3 -8
- package/src/snippets-cli.ts +2 -2
- package/src/snippets.ts +1 -1
package/README.md
CHANGED
|
@@ -89,9 +89,11 @@ fclt doctor --repair
|
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
`doctor --json` is read-only. `doctor --repair` is the self-heal path for legacy
|
|
92
|
-
state, broken
|
|
93
|
-
local integration layout.
|
|
94
|
-
|
|
92
|
+
state, broken rendered global guidance, missing review artifacts, and stale
|
|
93
|
+
local integration layout. It validates the rendered form of `AGENTS.global.md`
|
|
94
|
+
while preserving that file as a composable source template, and it repairs
|
|
95
|
+
leaked `${refs.*}` placeholders in direct-readable instruction files. Canonical
|
|
96
|
+
repairs keep a backup under `.ai/.facult/backups/doctor/`.
|
|
95
97
|
|
|
96
98
|
Update an installed binary:
|
|
97
99
|
|
|
@@ -149,8 +151,8 @@ fclt status --project
|
|
|
149
151
|
Create individual capability units:
|
|
150
152
|
|
|
151
153
|
```bash
|
|
152
|
-
fclt templates init instruction
|
|
153
|
-
fclt templates init snippet global/
|
|
154
|
+
fclt templates init instruction LANGUAGE
|
|
155
|
+
fclt templates init snippet global/policy/review
|
|
154
156
|
fclt templates init skill project-review
|
|
155
157
|
fclt templates init agent review-operator
|
|
156
158
|
```
|
|
@@ -212,7 +214,7 @@ Canonical capability can include:
|
|
|
212
214
|
Refs let markdown point at canonical assets without hard-coding paths:
|
|
213
215
|
|
|
214
216
|
```text
|
|
215
|
-
@ai/instructions/
|
|
217
|
+
@ai/instructions/LANGUAGE.md
|
|
216
218
|
@project/instructions/TESTING.md
|
|
217
219
|
@builtin/facult-operating-model/instructions/WORK_UNITS.md
|
|
218
220
|
```
|
|
@@ -220,8 +222,8 @@ Refs let markdown point at canonical assets without hard-coding paths:
|
|
|
220
222
|
Snippet markers let repeated blocks stay independently editable:
|
|
221
223
|
|
|
222
224
|
```md
|
|
223
|
-
<!-- fclty:global/
|
|
224
|
-
<!-- /fclty:global/
|
|
225
|
+
<!-- fclty:global/policy/review -->
|
|
226
|
+
<!-- /fclty:global/policy/review -->
|
|
225
227
|
```
|
|
226
228
|
|
|
227
229
|
The rule is simple: target the smallest unit that needs to change. Use instructions for doctrine, snippets for repeated blocks, skills for workflows, agents for roles, MCP/tool config for interfaces, and automations for scheduled loops.
|
|
@@ -1,41 +1,35 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fclt doctor --json
|
|
37
|
-
fclt status --json
|
|
38
|
-
fclt ai writeback list
|
|
39
|
-
fclt ai writeback group --by asset
|
|
40
|
-
fclt ai evolve list
|
|
41
|
-
```
|
|
1
|
+
# Global Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Working mode
|
|
4
|
+
|
|
5
|
+
<!-- fclty:global/baseline -->
|
|
6
|
+
<!-- /fclty:global/baseline -->
|
|
7
|
+
|
|
8
|
+
<!-- fclty:global/core/work-units -->
|
|
9
|
+
<!-- /fclty:global/core/work-units -->
|
|
10
|
+
|
|
11
|
+
<!-- fclty:global/core/feedback-loops -->
|
|
12
|
+
<!-- /fclty:global/core/feedback-loops -->
|
|
13
|
+
|
|
14
|
+
<!-- fclty:global/core/verification -->
|
|
15
|
+
<!-- /fclty:global/core/verification -->
|
|
16
|
+
|
|
17
|
+
<!-- fclty:global/core/writeback -->
|
|
18
|
+
<!-- /fclty:global/core/writeback -->
|
|
19
|
+
|
|
20
|
+
## Shared instruction sources
|
|
21
|
+
|
|
22
|
+
- For work-unit definition and scope clarification, read ${refs.work_units}.
|
|
23
|
+
- For identifying, improving, and validating feedback loops, read ${refs.feedback_loops}.
|
|
24
|
+
- For verification and anti-false-positive checks, read ${refs.verification}.
|
|
25
|
+
- For learning, decisions, and writeback, read ${refs.learning_writeback}.
|
|
26
|
+
- For capability evolution, proposal kinds, and `facult ai` workflow, read ${refs.evolution}.
|
|
27
|
+
- For deciding whether something belongs in global or project scope, read ${refs.project_capability}.
|
|
28
|
+
- Add private language, coding, or writing refs in local config only when they belong to the user's own operating layer.
|
|
29
|
+
|
|
30
|
+
## Layering
|
|
31
|
+
|
|
32
|
+
- Treat this file as the global baseline.
|
|
33
|
+
- Treat repo-level `AGENTS.md` files as more specific additions layered after this file.
|
|
34
|
+
- Repo-level files may add or refine project-specific behavior, but they should not weaken global defaults for rigor, verification, or writeback discipline.
|
|
35
|
+
- If a closer `AGENTS.override.md` exists, follow it as the most specific instructions file in that directory while still preserving the global baseline unless the closer file explicitly tightens it.
|
|
@@ -29,8 +29,8 @@ The main units are:
|
|
|
29
29
|
|
|
30
30
|
Examples:
|
|
31
31
|
|
|
32
|
-
- `@ai/instructions/
|
|
33
|
-
- `@ai/instructions/
|
|
32
|
+
- `@ai/instructions/LANGUAGE.md` for a user-owned language/tooling preference.
|
|
33
|
+
- `@ai/instructions/REVIEW.md` for a user-owned review standard.
|
|
34
34
|
- `@project/instructions/TESTING.md` for repo-specific test policy.
|
|
35
35
|
- `<!-- fclty:global/codex/baseline -->` for a shared rendered block.
|
|
36
36
|
|
|
@@ -56,7 +56,7 @@ Target the smallest affected unit.
|
|
|
56
56
|
Good writeback targets are graph-backed selectors when possible:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
fclt ai writeback add --kind missing_context --summary "
|
|
59
|
+
fclt ai writeback add --kind missing_context --summary "Language guidance did not cover test runner selection." --asset instruction:LANGUAGE
|
|
60
60
|
fclt ai writeback add --kind reusable_pattern --summary "Project test policy should become a shared verification snippet." --asset @project/instructions/TESTING.md
|
|
61
61
|
fclt ai writeback add --kind bad_default --summary "The review automation escalated one-off preferences." --asset automation:evolution-review
|
|
62
62
|
```
|
|
@@ -65,7 +65,7 @@ Use `fclt ai evolve ...` only after repeated signal, a clearly missing capabilit
|
|
|
65
65
|
|
|
66
66
|
## Agent Defaults
|
|
67
67
|
|
|
68
|
-
When an agent sees a repeated
|
|
68
|
+
When an agent sees a repeated language, framework, or test preference, it should not bury that in chat. It should identify whether the durable unit is:
|
|
69
69
|
|
|
70
70
|
- a global instruction
|
|
71
71
|
- a project instruction
|
|
@@ -64,9 +64,9 @@ Every good writeback should try to include:
|
|
|
64
64
|
|
|
65
65
|
Good target examples:
|
|
66
66
|
|
|
67
|
-
- `instruction:
|
|
67
|
+
- `instruction:LANGUAGE` when shared language/tooling guidance is stale or missing
|
|
68
68
|
- `@project/instructions/TESTING.md` when repo test policy needs project-scoped evolution
|
|
69
|
-
- `snippet:global/
|
|
69
|
+
- `snippet:global/policy/review` when a repeated rendered block should be fixed or extracted
|
|
70
70
|
- `skill:capability-evolution` when a workflow skill is missing steps or examples
|
|
71
71
|
- `automation:evolution-review` when the scheduled review loop is noisy or incomplete
|
|
72
72
|
|
|
@@ -135,7 +135,7 @@ Use the smallest durable change that fits the evidence.
|
|
|
135
135
|
Examples:
|
|
136
136
|
|
|
137
137
|
- `update_asset`: fix a stale instruction, snippet, agent, or automation markdown asset.
|
|
138
|
-
- `create_asset`: add a missing instruction such as `
|
|
138
|
+
- `create_asset`: add a missing instruction such as `LANGUAGE.md` or `REVIEW.md`.
|
|
139
139
|
- `extract_snippet`: move repeated guidance out of several docs into one snippet.
|
|
140
140
|
- `add_skill`: create a workflow when instructions are not enough.
|
|
141
141
|
- `promote_asset`: move a proven project instruction/snippet/skill toward global reuse.
|
|
@@ -63,7 +63,7 @@ Target the smallest composable unit that explains the friction:
|
|
|
63
63
|
- a cross-project behavior probably belongs in global capability
|
|
64
64
|
- a skill, tool, MCP, plugin, automation, or instruction gap repeatedly slows work down
|
|
65
65
|
- an agent has to restate the same workaround, verification rule, or review rule
|
|
66
|
-
- a repeated preference should become an atomic instruction
|
|
66
|
+
- a repeated preference should become an atomic user-owned instruction or project-specific testing policy
|
|
67
67
|
|
|
68
68
|
## Do Not Record Writeback For
|
|
69
69
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
- For any task, identify the highest-signal feedback loops available.
|
|
2
|
+
- Prefer loops that can verify progress, falsify weak assumptions, and expose failure early.
|
|
3
|
+
- Do not rely on a single shallow positive signal if stronger verification exists.
|
|
4
|
+
- If the available loop is stale, weak, noisy, or easy to game, improve it or say what is missing.
|
|
5
|
+
- When useful, leave behind a stronger loop than the one you started with.
|
|
6
|
+
- Treat verification, evaluation, and writeback as part of the work, not cleanup after it.
|
|
7
|
+
- For work-unit clarification, read ${refs.work_units}.
|
|
8
|
+
- For verification guidance, read ${refs.verification}.
|
|
9
|
+
- For learning and writeback, read ${refs.learning_writeback}.
|
|
10
|
+
- For deeper guidance, read ${refs.feedback_loops}.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
- Treat verification as part of the work, not a final checkbox.
|
|
2
|
+
- Prefer the strongest available proof that matches the real risk.
|
|
3
|
+
- Make clear what has actually been verified and what remains assumed.
|
|
4
|
+
- Distrust shallow green signals when stronger checks are available.
|
|
5
|
+
- If the current harness is stale, weak, or misleading, say so and improve it where possible.
|
|
6
|
+
- For deeper guidance, read ${refs.verification}.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
- Treat every task as a work unit, not just a request.
|
|
2
|
+
- A work unit should have a goal, acceptance criteria, required context, constraints, signals or evidence, an output artifact, and a verification path.
|
|
3
|
+
- If any of those are missing and the gap blocks correctness, surface it early and try to recover it.
|
|
4
|
+
- Prefer making the work unit more explicit before increasing execution speed.
|
|
5
|
+
- If the task is vague, ambiguous, or overloaded, narrow it before acting.
|
|
6
|
+
- For deeper guidance, read ${refs.work_units}.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
- Do not end at output if something important was learned.
|
|
2
|
+
- Preserve decisions, failures, successes, and reusable signal when they will improve future work.
|
|
3
|
+
- Prefer writing to a real destination over leaving knowledge in chat.
|
|
4
|
+
- When useful, leave behind better docs, tests, evals, prompts, notes, or follow-up tasks.
|
|
5
|
+
- When a high-signal learning clearly points at a canonical asset or durable destination, record a writeback before ending the task.
|
|
6
|
+
- Prefer one strong writeback over many weak ones.
|
|
7
|
+
- If you can name the target asset, the expected scope, and the actual signal, use `fclt ai writeback add ...` instead of merely mentioning that writeback would be useful.
|
|
8
|
+
- If repeated signal is already accumulating, use the `capability-evolution` skill or `fclt ai evolve ...` flow to turn it into a reviewable proposal.
|
|
9
|
+
- For deeper guidance, read ${refs.learning_writeback}.
|
|
@@ -18,8 +18,8 @@ Use `instructions/` for reusable markdown doctrine.
|
|
|
18
18
|
Examples:
|
|
19
19
|
|
|
20
20
|
```text
|
|
21
|
-
~/.ai/instructions/
|
|
22
|
-
~/.ai/instructions/
|
|
21
|
+
~/.ai/instructions/LANGUAGE.md
|
|
22
|
+
~/.ai/instructions/REVIEW.md
|
|
23
23
|
<repo>/.ai/instructions/TESTING.md
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ Examples:
|
|
|
29
29
|
|
|
30
30
|
```text
|
|
31
31
|
~/.ai/snippets/global/codex/baseline.md
|
|
32
|
-
~/.ai/snippets/global/
|
|
32
|
+
~/.ai/snippets/global/policy/review.md
|
|
33
33
|
<repo>/.ai/snippets/global/project/testing.md
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ Use `skills/` for executable workflows, `agents/` for delegated roles, `mcp/` fo
|
|
|
40
40
|
Canonical refs let a markdown asset point at another asset without hard-coding machine paths:
|
|
41
41
|
|
|
42
42
|
```text
|
|
43
|
-
@ai/instructions/
|
|
43
|
+
@ai/instructions/LANGUAGE.md
|
|
44
44
|
@project/instructions/TESTING.md
|
|
45
45
|
@builtin/facult-operating-model/instructions/WORK_UNITS.md
|
|
46
46
|
```
|
|
@@ -53,7 +53,7 @@ Config-backed refs are useful when the concrete path should be named in `config.
|
|
|
53
53
|
version = 1
|
|
54
54
|
|
|
55
55
|
[refs]
|
|
56
|
-
language_defaults = "@ai/instructions/
|
|
56
|
+
language_defaults = "@ai/instructions/LANGUAGE.md"
|
|
57
57
|
project_testing = "@project/instructions/TESTING.md"
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -64,22 +64,22 @@ Rendered markdown can use those refs through the render context when a tool adap
|
|
|
64
64
|
Snippets use paired HTML markers:
|
|
65
65
|
|
|
66
66
|
```md
|
|
67
|
-
<!-- fclty:global/
|
|
68
|
-
<!-- /fclty:global/
|
|
67
|
+
<!-- fclty:global/policy/review -->
|
|
68
|
+
<!-- /fclty:global/policy/review -->
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
The marker above resolves to:
|
|
72
72
|
|
|
73
73
|
```text
|
|
74
|
-
snippets/global/
|
|
74
|
+
snippets/global/policy/review.md
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Create and inspect snippets with:
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
fclt templates init snippet global/
|
|
80
|
+
fclt templates init snippet global/policy/review
|
|
81
81
|
fclt snippets list
|
|
82
|
-
fclt snippets show global/
|
|
82
|
+
fclt snippets show global/policy/review
|
|
83
83
|
fclt snippets sync --dry-run AGENTS.global.md
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -90,22 +90,21 @@ Use snippets when the same block appears in more than one rendered doc, or when
|
|
|
90
90
|
Create a new instruction scaffold with:
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
|
-
fclt templates init instruction
|
|
94
|
-
fclt templates init instruction
|
|
93
|
+
fclt templates init instruction LANGUAGE
|
|
94
|
+
fclt templates init instruction REVIEW
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
That writes:
|
|
98
98
|
|
|
99
99
|
```text
|
|
100
|
-
instructions/
|
|
101
|
-
instructions/
|
|
100
|
+
instructions/LANGUAGE.md
|
|
101
|
+
instructions/REVIEW.md
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
An instruction can include refs, snippet markers, examples, and writeback targeting guidance. Keep one instruction focused on one reusable domain. For example:
|
|
105
105
|
|
|
106
|
-
- `
|
|
107
|
-
- `
|
|
108
|
-
- `WRITING.md`: voice and editorial rules.
|
|
106
|
+
- `LANGUAGE.md`: user-owned language or tooling preferences.
|
|
107
|
+
- `REVIEW.md`: user-owned review standards.
|
|
109
108
|
- `VERIFICATION.md`: proof standards.
|
|
110
109
|
|
|
111
110
|
## Composition Pattern
|
|
@@ -116,8 +115,8 @@ A global `AGENTS.global.md` can stay short and compose units:
|
|
|
116
115
|
# Global Agent Instructions
|
|
117
116
|
|
|
118
117
|
For work-unit framing, read `@ai/instructions/WORK_UNITS.md`.
|
|
119
|
-
For
|
|
120
|
-
For
|
|
118
|
+
For language/tooling preferences, read `@ai/instructions/LANGUAGE.md`.
|
|
119
|
+
For review standards, read `@ai/instructions/REVIEW.md`.
|
|
121
120
|
|
|
122
121
|
<!-- fclty:global/codex/baseline -->
|
|
123
122
|
<!-- /fclty:global/codex/baseline -->
|
|
@@ -148,7 +147,7 @@ Target the smallest unit that actually needs to change:
|
|
|
148
147
|
Examples:
|
|
149
148
|
|
|
150
149
|
```bash
|
|
151
|
-
fclt ai writeback add --kind missing_context --summary "
|
|
150
|
+
fclt ai writeback add --kind missing_context --summary "Language guidance did not cover test runner selection." --asset instruction:LANGUAGE
|
|
152
151
|
fclt ai writeback add --kind reusable_pattern --summary "Project testing policy should become a shared verification snippet." --asset @project/instructions/TESTING.md
|
|
153
152
|
fclt ai evolve propose
|
|
154
153
|
```
|
|
@@ -162,9 +161,9 @@ Use these surfaces:
|
|
|
162
161
|
```bash
|
|
163
162
|
fclt list instructions --global
|
|
164
163
|
fclt list snippets --global
|
|
165
|
-
fclt show instruction:
|
|
164
|
+
fclt show instruction:LANGUAGE
|
|
166
165
|
fclt graph deps AGENTS.global.md
|
|
167
|
-
fclt graph dependents @ai/instructions/
|
|
166
|
+
fclt graph dependents @ai/instructions/LANGUAGE.md
|
|
168
167
|
fclt ai writeback group --by asset
|
|
169
168
|
fclt ai evolve list
|
|
170
169
|
```
|
package/docs/reference.md
CHANGED
|
@@ -26,6 +26,14 @@ sync policy, invalid canonical global guidance, and missing Markdown review
|
|
|
26
26
|
artifacts. Destructive-looking canonical repairs keep a backup under
|
|
27
27
|
`.ai/.facult/backups/doctor/`.
|
|
28
28
|
|
|
29
|
+
`doctor` renders `AGENTS.global.md` in memory before judging it. That file is a
|
|
30
|
+
source template, so empty `fclty` blocks and `${refs.work_units}` placeholders
|
|
31
|
+
are valid when they render into filled, concrete tool guidance. `doctor` flags
|
|
32
|
+
the global docs only when the rendered output still has empty managed sections,
|
|
33
|
+
unresolved placeholders, or marker errors. It also checks direct-readable
|
|
34
|
+
instruction files for leaked `${refs.*}` placeholders and can repair known refs
|
|
35
|
+
there with backups.
|
|
36
|
+
|
|
29
37
|
## Graph
|
|
30
38
|
|
|
31
39
|
```bash
|
package/package.json
CHANGED
package/src/agents.ts
CHANGED
|
@@ -147,6 +147,22 @@ export async function loadRenderContext(
|
|
|
147
147
|
PROJECT_SLUG: projectSlug ?? "",
|
|
148
148
|
TARGET_PATH: targetPath ?? "",
|
|
149
149
|
TARGET_TOOL: targetTool ?? "",
|
|
150
|
+
refs: {
|
|
151
|
+
evolution: join(rootDir, "instructions", "EVOLUTION.md"),
|
|
152
|
+
feedback_loops: join(rootDir, "instructions", "FEEDBACK_LOOPS.md"),
|
|
153
|
+
learning_writeback: join(
|
|
154
|
+
rootDir,
|
|
155
|
+
"instructions",
|
|
156
|
+
"LEARNING_AND_WRITEBACK.md"
|
|
157
|
+
),
|
|
158
|
+
project_capability: join(
|
|
159
|
+
rootDir,
|
|
160
|
+
"instructions",
|
|
161
|
+
"PROJECT_CAPABILITY.md"
|
|
162
|
+
),
|
|
163
|
+
verification: join(rootDir, "instructions", "VERIFICATION.md"),
|
|
164
|
+
work_units: join(rootDir, "instructions", "WORK_UNITS.md"),
|
|
165
|
+
},
|
|
150
166
|
};
|
|
151
167
|
|
|
152
168
|
let context = contextBase;
|
package/src/builtin-assets.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Generated by scripts/generate-builtin-assets.ts. Do not edit by hand.
|
|
2
2
|
|
|
3
3
|
export const BUILTIN_OPERATING_MODEL_FILES = JSON.parse(
|
|
4
|
-
'{"AGENTS.global.md":"# Facult Operating Defaults\\n\\nThis machine has a default Facult operating-model layer available.\\n\\nDefault behavior:\\n\\n- Treat meaningful work as a work unit: know the goal, acceptance criteria, required context, constraints, evidence, output artifact, verification path, and likely writeback target.\\n- Use the strongest practical feedback loop for the risk. Do not treat shallow success as proof when a better check is available.\\n- When work produces durable friction, weak verification, stale guidance, or a missing skill/tool capability, preserve that signal with `fclt ai writeback ...` when the target and scope are clear.\\n- Use `fclt ai evolve ...` or the `capability-evolution` skill only when repeated writebacks, a clearly missing capability, or a stale canonical asset point at a concrete improvement.\\n- Keep one-off preferences and speculative ideas out of evolution. Use writeback, notes, or task tracking instead.\\n- Use project scope for repo-specific workflow and global scope for reusable cross-project doctrine. Promote project capability only after evidence shows reuse.\\n- Use Linear or another task system for executable product/tooling work that needs ownership, priority, state, or delivery follow-through.\\n- Keep writeback/evolution runtime and review artifacts in the global `.ai` review tree; do not commit generated writeback queues or private review artifacts into project repos.\\n\\nFor work-unit framing, read `@builtin/facult-operating-model/instructions/WORK_UNITS.md`.\\nFor composing refs, snippets, instructions, skills, agents, MCP, and automations as evolvable units, read `@builtin/facult-operating-model/instructions/CAPABILITY_COMPOSITION.md`.\\nFor writeback and evolution, read `@builtin/facult-operating-model/instructions/EVOLUTION.md`.\\nFor learning and writeback defaults, read `@builtin/facult-operating-model/instructions/LEARNING_AND_WRITEBACK.md`.\\nFor deciding whether capability belongs in global or project scope, read `@builtin/facult-operating-model/instructions/PROJECT_CAPABILITY.md`.\\nFor project operating-layer design, read `@builtin/facult-operating-model/instructions/INTEGRATION.md`.\\n\\nBuiltin specialist agents are available for:\\n- writeback curation\\n- evolution planning\\n- scope promotion\\n- integration auditing\\n\\nBuiltin skills are available for:\\n- capability evolution\\n- project operating-layer design\\n\\nUseful health and review commands:\\n\\n```bash\\nfclt doctor --json\\nfclt status --json\\nfclt ai writeback list\\nfclt ai writeback group --by asset\\nfclt ai evolve list\\n```\\n","agents/evolution-planner/agent.toml":"name = \\"evolution-planner\\"\\ndescription = \\"Turn repeated writeback into concrete capability proposals.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou plan capability evolution.\\n\\nPrioritize:\\n- smallest useful change\\n- correct target asset type\\n- correct target scope\\n- evidence that justifies the change\\n- repeated writeback clusters or clearly missing capabilities, not isolated preferences\\n\\nProposal kinds you should consider first:\\n- update_asset\\n- create_asset\\n- extract_snippet\\n- add_skill\\n- promote_asset\\n\\nDefault to project scope when the pattern is repo-local.\\nPromote to global only when reuse is demonstrated and pollution risk is low.\\n\\nReturn concise proposals ordered by expected leverage, including:\\n- proposal kind\\n- target asset\\n- target scope\\n- why this is the smallest durable change\\n\\nDo not escalate to evolution when a single writeback is enough.\\nDo not use evolution as a substitute for executable task tracking when the main need is owner, priority, state, or implementation follow-through.\\n\\"\\"\\"\\n","agents/integration-auditor/agent.toml":"name = \\"integration-auditor\\"\\ndescription = \\"Find where local success can still fail system-wide.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou audit integration risk.\\n\\nPrioritize:\\n- hidden dependencies\\n- rollout hazards\\n- operational constraints\\n- gaps between local verification and real system behavior\\n\\nReturn concise findings ordered by impact.\\n\\"\\"\\"\\n","agents/scope-promoter/agent.toml":"name = \\"scope-promoter\\"\\ndescription = \\"Decide whether learning belongs at project or global scope.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou decide scope.\\n\\nPrioritize:\\n- project specificity\\n- cross-project reuse potential\\n- pollution risk from globalizing too early\\n\\nWhen recommending promotion, make the standard path explicit:\\n- keep the source capability in project scope until promotion is approved\\n- create a reviewable global proposal\\n- do not treat promotion as implicit apply\\n\\nReturn concise decisions with rationale.\\n\\"\\"\\"\\n","agents/writeback-curator/agent.toml":"name = \\"writeback-curator\\"\\ndescription = \\"Turn noisy outcomes into high-signal writeback.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou curate durable writeback.\\n\\nPrioritize:\\n- repeated failures\\n- repeated wins\\n- stale guidance\\n- missing capability edges\\n- tool, skill, MCP, plugin, automation, or instruction friction that repeatedly slows work down\\n\\nFor each recommendation, prefer returning:\\n- suggested writeback kind\\n- best target asset or destination\\n- best scope (`project` or `global`)\\n- the evidence that justifies recording it\\n\\nDo not emit low-signal noise.\\nIf the learning is repo-specific, keep it project-scoped by default.\\nWhen the signal is already strong and the target is clear, prefer recommending direct writeback capture rather than abstract advice.\\nWhen the issue is executable tooling work, recommend task tracking for the fix and writeback only for the reusable operating-model learning.\\n\\"\\"\\"\\n","instructions/CAPABILITY_COMPOSITION.md":"---\\ndescription: \\"Compose small capability units across global and project roots, then evolve the smallest affected unit.\\"\\ntags: [\\"facult\\", \\"composition\\", \\"refs\\", \\"snippets\\", \\"instructions\\"]\\n---\\n\\n# Capability Composition\\n\\nUse `fclt` capability as small units that can be composed, inspected, rendered, and evolved independently.\\n\\nThe main units are:\\n\\n- instructions: standalone markdown doctrine such as language preferences, verification rules, or review standards\\n- snippets: small markdown partials inserted into one or more rendered docs\\n- skills: task-specific workflows with `SKILL.md`\\n- agents: focused role manifests\\n- MCP definitions: tool interfaces and their safe auth shape\\n- automations: scheduled review or maintenance loops\\n- tool rules/config: tool-specific defaults and policy\\n\\n## Composition Rules\\n\\n- Keep reusable doctrine in `instructions/`.\\n- Keep repeated paragraphs or policy blocks in `snippets/`.\\n- Keep workflow execution in `skills/`.\\n- Keep persona or delegation behavior in `agents/`.\\n- Keep tool wiring in `mcp/` and `tools/<tool>/`.\\n- Compose broad agent docs from refs and snippets instead of copying text by hand.\\n- Prefer one narrow reusable unit over one large instruction file that mixes unrelated domains.\\n\\nExamples:\\n\\n- `@ai/instructions/BUN.md` for shared Bun preferences.\\n- `@ai/instructions/RUST.md` for shared Rust preferences.\\n- `@project/instructions/TESTING.md` for repo-specific test policy.\\n- `<!-- fclty:global/codex/baseline -->` for a shared rendered block.\\n\\n## Scope\\n\\nUse global scope for capability that should follow the user across projects.\\n\\nUse project scope for capability that belongs to a repo, team workflow, architecture, or local test harness.\\n\\nPromote project capability to global only when repeated evidence shows reuse across projects. Do not globalize a project quirk just because it worked once.\\n\\n## Writeback and Evolution\\n\\nTarget the smallest affected unit.\\n\\n- If a paragraph is reused in several rendered docs, target the snippet.\\n- If a domain rule is wrong, target the instruction.\\n- If a workflow is incomplete, target the skill.\\n- If a delegated role is unclear, target the agent.\\n- If a tool interface is missing or unsafe, target the MCP or tool config.\\n- If a scheduled review loop is noisy or missing context, target the automation.\\n\\nGood writeback targets are graph-backed selectors when possible:\\n\\n```bash\\nfclt ai writeback add --kind missing_context --summary \\"Bun guidance did not cover test runner selection.\\" --asset instruction:BUN\\nfclt ai writeback add --kind reusable_pattern --summary \\"Project test policy should become a shared verification snippet.\\" --asset @project/instructions/TESTING.md\\nfclt ai writeback add --kind bad_default --summary \\"The review automation escalated one-off preferences.\\" --asset automation:evolution-review\\n```\\n\\nUse `fclt ai evolve ...` only after repeated signal, a clearly missing capability, or a stale canonical asset points at a concrete change. Prefer the smallest valid proposal kind: `update_asset`, `create_asset`, `extract_snippet`, `add_skill`, or `promote_asset`.\\n\\n## Agent Defaults\\n\\nWhen an agent sees a repeated preference like \\"use Bun for JS projects\\" or \\"prefer Cargo nextest for Rust tests\\", it should not bury that in chat. It should identify whether the durable unit is:\\n\\n- a global instruction\\n- a project instruction\\n- a snippet reused by rendered docs\\n- a skill workflow\\n- a project-to-global promotion candidate\\n\\nThen it should record writeback against that unit, or draft a proposal when the evidence is already strong enough.\\n","instructions/EVOLUTION.md":"---\\ndescription: Turn repeated signal into concrete capability changes.\\ntags: [facult, evolution, writeback]\\n---\\n\\n# Evolution\\n\\nUse writeback and evolution to improve the AI operating layer itself.\\n\\nEvolution is the synthesis and change side of the feedback loop. It turns accumulated writebacks, repeated tool friction, stale canonical assets, or clearly missing capability into small reviewable changes to instructions, skills, snippets, agents, or other markdown canonical assets.\\n\\nUse capability composition when choosing the target. Instructions, snippets, skills, agents, MCP/tool config, and automations are separate units. Target the smallest unit that actually needs to change instead of rewriting a broad agent doc.\\n\\n## When To Record Writeback\\n\\nRecord writeback when one of these is true:\\n\\n- the same failure repeats\\n- the same success pattern repeats\\n- guidance is stale or missing\\n- a prompt or loop has to be restated often\\n- a project-specific pattern looks reusable\\n\\nDo not record low-signal noise:\\n\\n- one-off annoyance with no reuse value\\n- generic \\"could be better\\" commentary\\n- duplicate observations with no new evidence\\n\\nThe intended default is that agents record strong writebacks themselves when the signal is clear enough, rather than only recommending that a user do it manually later.\\n\\nDo not wait for a weekly review to preserve high-signal evidence. Do wait for repeated evidence or a clearly missing capability before drafting a proposal.\\n\\n## Scope\\n\\nChoose `project` scope when the learning depends on:\\n\\n- repo architecture\\n- team workflow\\n- project tooling\\n- local testing or verification behavior\\n\\nChoose `global` scope when the learning is reusable across projects.\\n\\nPromote from project to global only after repeated reuse or strong evidence.\\n\\n## Writeback Kinds\\n\\nCommon kinds:\\n\\n- `weak_verification`\\n- `false_positive`\\n- `missing_context`\\n- `reusable_pattern`\\n- `capability_gap`\\n- `bad_default`\\n\\nEvery good writeback should try to include:\\n\\n- a concrete summary\\n- the best target asset if known\\n- the right scope\\n- domain or tags when useful\\n\\nGood target examples:\\n\\n- `instruction:BUN` when shared Bun guidance is stale or missing\\n- `@project/instructions/TESTING.md` when repo test policy needs project-scoped evolution\\n- `snippet:global/lang/bun` when a repeated rendered block should be fixed or extracted\\n- `skill:capability-evolution` when a workflow skill is missing steps or examples\\n- `automation:evolution-review` when the scheduled review loop is noisy or incomplete\\n\\n## Operator Flow\\n\\nTypical workflow:\\n\\n```bash\\nfclt ai writeback add --kind weak_verification --summary \\"Checks were too shallow\\" --asset instruction:VERIFICATION\\nfclt ai writeback group --by asset\\nfclt ai writeback summarize --by domain\\nfclt ai evolve propose\\nfclt ai evolve draft EV-00001\\nfclt ai evolve accept EV-00001\\nfclt ai evolve apply EV-00001\\n```\\n\\nUse `fclt ai evolve draft <id> --append \\"...\\"` to revise a draft while preserving draft history.\\n\\nReview surfaces:\\n\\n- open `~/.ai/writebacks/` and `~/.ai/evolution/` in a Markdown editor for frontmatter-rich global and project-scoped review artifacts\\n- `fclt status --json` for queue/proposal paths, review artifact paths, counts, and active scope\\n- `fclt ai writeback list|show|group|summarize` for raw and clustered signal\\n- `fclt ai evolve list|show|review` for proposal state without applying changes\\n- `fclt templates init automation learning-review` for recurring capture/review\\n- `fclt templates init automation evolution-review` for recurring proposal review\\n- `fclt templates init automation tool-call-audit` for repeated tool-friction review\\n\\nEvolution proposal metadata, markdown drafts, patch artifacts, writeback queues,\\nand journals are runtime state. `fclt` stores JSON queues, proposal records,\\ndraft refs, patches, and journals in machine-local `fclt` state. It mirrors\\nhuman-readable review artifacts into global `~/.ai/writebacks/...` and\\n`~/.ai/evolution/...`, including project-scoped artifacts under\\n`projects/<slug-hash>/` with cwd/project metadata in frontmatter. Canonical\\nassets in `~/.ai` or `<repo>/.ai` should only change when a proposal is applied.\\n\\n## Default Agent Behavior\\n\\nUse the smallest action that fits the signal:\\n\\n1. record one strong writeback when there is a clear durable learning\\n2. use `writeback-curator` when the target, kind, or scope is ambiguous\\n3. use `capability-evolution` or `evolution-planner` when repeated signal should become a proposal\\n4. do not draft or apply proposals just because a writeback exists; require repeated evidence or a clearly missing capability\\n\\nAvoid creating writeback/evolution noise for one-off nits, vague preferences, or speculative ideas without evidence.\\n\\nWhen the friction is executable product/tooling work that needs ownership,\\npriority, state, or implementation follow-through, create or update a real task\\nsystem item instead of forcing it into capability evolution. Use evolution for\\nthe reusable operating-layer change.\\n\\n## Proposal Kinds\\n\\nCurrent supported proposal kinds:\\n\\n- `update_asset`\\n- `create_asset`\\n- `extract_snippet`\\n- `add_skill`\\n- `promote_asset`\\n\\nUse the smallest durable change that fits the evidence.\\n\\nExamples:\\n\\n- `update_asset`: fix a stale instruction, snippet, agent, or automation markdown asset.\\n- `create_asset`: add a missing instruction such as `BUN.md` or `RUST.md`.\\n- `extract_snippet`: move repeated guidance out of several docs into one snippet.\\n- `add_skill`: create a workflow when instructions are not enough.\\n- `promote_asset`: move a proven project instruction/snippet/skill toward global reuse.\\n\\n## Review And Apply Rules\\n\\n- draft before apply\\n- accept before apply\\n- prefer the smallest safe change\\n- keep reviewable evidence tied to source writebacks\\n- do not globalize project behavior too early\\n- do not apply high-risk global instruction, skill, plugin, or shared-tool changes without explicit review/approval\\n\\nApply is for markdown canonical assets only. If the target is wrong, revise the proposal rather than forcing it through.\\n","instructions/INTEGRATION.md":"---\\ndescription: Detect where local success can still fail at integration boundaries.\\ntags: [facult, integration, verification]\\n---\\n\\n# Integration\\n\\nDistinguish local correctness from system correctness. Check hidden dependencies, rollout order, and operational constraints before calling work done.\\n","instructions/LEARNING_AND_WRITEBACK.md":"---\\ndescription: Preserve durable signal and record writeback when the operating layer should learn.\\ntags: [facult, learning, writeback]\\n---\\n\\n# Learning And Writeback\\n\\nUse this when work produces a durable decision, failure, success pattern, or missing guardrail that should outlive the current task.\\n\\nThis is the capture side of the feedback loop. The goal is to let normal agent work produce reusable signal without requiring a human to manually restate every friction point later.\\n\\n## Default Behavior\\n\\nThe normal path should be agent-driven.\\n\\nIf you can clearly answer:\\n\\n- what was learned\\n- why it matters\\n- where it should land\\n- whether it belongs in `project` or `global`\\n\\nthen record the writeback instead of only suggesting that someone should do it later.\\n\\nUse:\\n\\n```bash\\nfclt ai writeback add --kind <kind> --summary \\"<summary>\\" --asset <asset-selector>\\n```\\n\\nThe writeback queue is runtime state, not canonical source. `fclt` stores JSON\\nqueue state in machine-local `fclt` state so sandboxed agents can record durable\\nfriction without mutating canonical assets unless an evolution proposal is later\\nreviewed and applied.\\n\\nEvery writeback also refreshes a Markdown review artifact under the global\\n`~/.ai/writebacks/...` tree. Global signal lands in `~/.ai/writebacks/global/`;\\nproject-scoped signal lands in `~/.ai/writebacks/projects/<slug-hash>/` with\\nfrontmatter for scope, project root, cwd, target asset, status, tags, evidence,\\nand timestamps. Do not write writeback review artifacts into a repo-local `.ai`;\\nrepo-local state should contribute project metadata and evidence, not bundled\\nprivate review files.\\n\\nProject-scoped writebacks should usually be recorded from the repo that produced\\nthe evidence. Global writebacks should be reserved for shared doctrine, shared\\nskills, shared agents, tool behavior, or cross-project capability gaps.\\n\\nTarget the smallest composable unit that explains the friction:\\n\\n- instruction: domain guidance, preferences, verification rules, or review doctrine\\n- snippet: repeated markdown block used by more than one rendered doc\\n- skill: workflow execution steps or examples\\n- agent: delegated role behavior\\n- MCP/tool config: tool interface, auth shape, or rendered integration\\n- automation: scheduled review loop, cadence, prompt, or memory\\n\\n## Record Writeback When\\n\\n- the same failure or weak loop appears again\\n- a reusable success pattern shows up\\n- guidance is clearly stale or missing\\n- a repo-local behavior probably belongs in project capability\\n- a cross-project behavior probably belongs in global capability\\n- a skill, tool, MCP, plugin, automation, or instruction gap repeatedly slows work down\\n- an agent has to restate the same workaround, verification rule, or review rule\\n- a repeated preference should become an atomic instruction such as `BUN.md`, `RUST.md`, or a project-specific testing policy\\n\\n## Do Not Record Writeback For\\n\\n- one-off annoyance with no durable value\\n- weak commentary with no target\\n- speculative ideas without evidence\\n- duplicate noise with no new signal\\n\\n## Follow Through\\n\\n- prefer one strong writeback over many weak ones\\n- mention the writeback id when summarizing what changed\\n- escalate to `capability-evolution` or `fclt ai evolve ...` only when the signal is repeated or clearly points at a durable capability change\\n- use `fclt ai writeback group --by asset` or `fclt ai writeback summarize --by domain` to review accumulated signal before proposing broad changes\\n- use scheduled `learning-review`, `evolution-review`, or `tool-call-audit` automations when the signal should be reviewed in the background\\n","instructions/PROJECT_CAPABILITY.md":"---\\ndescription: Decide what belongs in repo-local .ai versus the global store.\\ntags: [facult, project, scope]\\n---\\n\\n# Project Capability\\n\\nPrefer project scope when the guidance depends on repo architecture, team workflow, or colocated tooling. Promote to global only after repeated cross-project reuse.\\n\\n## Project First\\n\\nDefault to `<repo>/.ai` when the capability is about:\\n\\n- local architecture\\n- repo-specific testing or verification\\n- team conventions\\n- project tools and workflows\\n\\n## Promote Carefully\\n\\nPromote to `~/.ai` only when:\\n\\n- the same pattern succeeds in more than one repo\\n- the capability is not coupled to local architecture\\n- the global version will not create noise for unrelated projects\\n\\nUse:\\n\\n```bash\\nfclt ai evolve promote EV-00001 --to global --project\\n```\\n\\nThat creates a new global proposal for review. It does not auto-apply the promotion.\\n","instructions/WORK_UNITS.md":"---\\ndescription: \\"Define work units so agent tasks have a clear goal, evidence path, artifact, and writeback target.\\"\\ntags: [\\"work-units\\", \\"planning\\", \\"verification\\", \\"writeback\\"]\\n---\\n\\n# Work Units\\n\\nA work unit is the smallest coherent unit of agent work that can be understood, verified, and preserved.\\n\\nIt is not just the user\'s latest sentence. It is the operational shape around that sentence: what is being changed, why it matters, what evidence is needed, what artifact should remain, and how future agents should benefit from the result.\\n\\n## Minimum Contract\\n\\nA well-formed work unit names:\\n\\n- goal: the outcome the user needs\\n- acceptance criteria: what must be true when the work is done\\n- required context: source files, docs, systems, messages, or prior decisions needed for correctness\\n- constraints: permissions, privacy, compatibility, deadlines, ownership, or scope limits\\n- signals or evidence: checks that can confirm progress or falsify assumptions\\n- output artifact: code, docs, proposal, issue, note, draft, or report\\n- verification path: commands, review surfaces, manual checks, or source-of-truth reads\\n- writeback target: where durable learning belongs if the work teaches something reusable\\n\\nIf one of these is missing and the gap blocks correctness, surface the gap early and recover it before moving faster.\\n\\n## Why It Exists\\n\\nWork-unit framing prevents shallow completion. It helps agents avoid:\\n\\n- changing files before understanding the target\\n- treating a weak green signal as proof\\n- losing reusable learning in chat\\n- creating duplicate tasks or proposals\\n- turning one-off preferences into global rules\\n- pushing project-specific details into global capability\\n\\n## How To Use It\\n\\nFor simple tasks, keep the work unit implicit but still verify the result.\\n\\nFor ambiguous, high-impact, or multi-step tasks, make the work unit explicit before executing. A compact form is enough:\\n\\n```text\\nGoal:\\nAcceptance:\\nContext:\\nConstraints:\\nEvidence:\\nArtifact:\\nVerification:\\nWriteback:\\n```\\n\\nUse the smallest framing that makes the task correct. Do not turn every request into paperwork.\\n\\n## Writeback\\n\\nWhen the work reveals durable friction, missing capability, stale guidance, or a repeatable workflow, prefer one strong writeback over many weak ones.\\n\\nUse `fclt ai writeback add ...` when the target asset, scope, and evidence are clear. Use `fclt ai evolve ...` only when repeated signal supports a concrete proposal.\\n","skills/capability-evolution/SKILL.md":"---\\ndescription: Convert repeated writeback into concrete fclt capability proposals.\\ntags: [facult, evolution, writeback]\\n---\\n\\n# capability-evolution\\n\\n## When To Use\\nUse this skill when the same missing guidance, weak loop, or recurring win appears often enough that the AI system itself should probably change.\\n\\nDo not wait for a human operator by default if the signal is already clear and the environment permits local AI runtime state to be updated.\\n\\nUse writeback first when the signal is useful but not yet repeated. Use evolution when accumulated writebacks, repeated tool friction, or a clearly missing capability point at a specific target asset or new capability.\\n\\n## Scope Decision\\n\\nChoose `project` when the behavior depends on repo-local architecture or workflow.\\n\\nChoose `global` when the behavior is broadly reusable.\\n\\nIf unsure, start at project scope and promote later with evidence.\\n\\n## Working Flow\\n\\n1. record the strongest writeback\\n2. group or summarize repeated signal\\n3. choose the smallest valid proposal kind\\n4. draft the proposal\\n5. accept only after the target and scope are correct\\n6. apply only when the markdown target is the intended canonical asset\\n\\nUse:\\n\\n```bash\\nfclt ai writeback add ...\\nfclt ai writeback group --by asset\\nfclt ai writeback summarize --by domain\\nfclt ai evolve propose\\nfclt ai evolve draft EV-00001\\nfclt ai evolve draft EV-00001 --append \\"tighten the rule with a concrete verification step\\"\\nfclt ai evolve accept EV-00001\\nfclt ai evolve apply EV-00001\\n```\\n\\nFor background review loops, use:\\n\\n```bash\\nfclt templates init automation learning-review\\nfclt templates init automation evolution-review\\nfclt templates init automation tool-call-audit\\n```\\n\\nIf there is not yet enough repeated signal for evolution, record the writeback and stop there.\\n\\n## Proposal Kind Selection\\n\\n- `update_asset` for tightening existing guidance\\n- `create_asset` for missing instructions or docs\\n- `extract_snippet` for reusable partial guidance\\n- `add_skill` for reusable workflow instruction\\n- `promote_asset` for project-to-global promotion\\n\\nUse task tracking instead of evolution when the main work is an executable tool or product fix that needs an owner, priority, state, or delivery plan. Use evolution for the reusable instruction, skill, or operating-model change that should survive that fix.\\n\\n## Output Contract\\n- repeated signal\\n- proposed asset change\\n- target scope\\n- evidence\\n- smallest useful next step\\n","skills/project-operating-layer-design/SKILL.md":"---\\ndescription: Design or improve a repo-local .ai operating layer.\\ntags: [facult, project, design]\\n---\\n\\n# project-operating-layer-design\\n\\n## When To Use\\nUse this skill when a project needs its own `.ai/` structure, repo-specific instructions, or local bootstrap guidance.\\n\\n## Output Contract\\n- recommended `.ai/` layout\\n- what stays project-local\\n- what stays global\\n- what should remain generated runtime output only\\n"}'
|
|
4
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: Built-in templates intentionally contain literal render placeholders.
|
|
5
|
+
'{"AGENTS.global.md":"# Global Agent Instructions\\n\\n## Working mode\\n\\n<!-- fclty:global/baseline -->\\n<!-- /fclty:global/baseline -->\\n\\n<!-- fclty:global/core/work-units -->\\n<!-- /fclty:global/core/work-units -->\\n\\n<!-- fclty:global/core/feedback-loops -->\\n<!-- /fclty:global/core/feedback-loops -->\\n\\n<!-- fclty:global/core/verification -->\\n<!-- /fclty:global/core/verification -->\\n\\n<!-- fclty:global/core/writeback -->\\n<!-- /fclty:global/core/writeback -->\\n\\n## Shared instruction sources\\n\\n- For work-unit definition and scope clarification, read ${refs.work_units}.\\n- For identifying, improving, and validating feedback loops, read ${refs.feedback_loops}.\\n- For verification and anti-false-positive checks, read ${refs.verification}.\\n- For learning, decisions, and writeback, read ${refs.learning_writeback}.\\n- For capability evolution, proposal kinds, and `facult ai` workflow, read ${refs.evolution}.\\n- For deciding whether something belongs in global or project scope, read ${refs.project_capability}.\\n- Add private language, coding, or writing refs in local config only when they belong to the user\'s own operating layer.\\n\\n## Layering\\n\\n- Treat this file as the global baseline.\\n- Treat repo-level `AGENTS.md` files as more specific additions layered after this file.\\n- Repo-level files may add or refine project-specific behavior, but they should not weaken global defaults for rigor, verification, or writeback discipline.\\n- If a closer `AGENTS.override.md` exists, follow it as the most specific instructions file in that directory while still preserving the global baseline unless the closer file explicitly tightens it.\\n","agents/evolution-planner/agent.toml":"name = \\"evolution-planner\\"\\ndescription = \\"Turn repeated writeback into concrete capability proposals.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou plan capability evolution.\\n\\nPrioritize:\\n- smallest useful change\\n- correct target asset type\\n- correct target scope\\n- evidence that justifies the change\\n- repeated writeback clusters or clearly missing capabilities, not isolated preferences\\n\\nProposal kinds you should consider first:\\n- update_asset\\n- create_asset\\n- extract_snippet\\n- add_skill\\n- promote_asset\\n\\nDefault to project scope when the pattern is repo-local.\\nPromote to global only when reuse is demonstrated and pollution risk is low.\\n\\nReturn concise proposals ordered by expected leverage, including:\\n- proposal kind\\n- target asset\\n- target scope\\n- why this is the smallest durable change\\n\\nDo not escalate to evolution when a single writeback is enough.\\nDo not use evolution as a substitute for executable task tracking when the main need is owner, priority, state, or implementation follow-through.\\n\\"\\"\\"\\n","agents/integration-auditor/agent.toml":"name = \\"integration-auditor\\"\\ndescription = \\"Find where local success can still fail system-wide.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou audit integration risk.\\n\\nPrioritize:\\n- hidden dependencies\\n- rollout hazards\\n- operational constraints\\n- gaps between local verification and real system behavior\\n\\nReturn concise findings ordered by impact.\\n\\"\\"\\"\\n","agents/scope-promoter/agent.toml":"name = \\"scope-promoter\\"\\ndescription = \\"Decide whether learning belongs at project or global scope.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou decide scope.\\n\\nPrioritize:\\n- project specificity\\n- cross-project reuse potential\\n- pollution risk from globalizing too early\\n\\nWhen recommending promotion, make the standard path explicit:\\n- keep the source capability in project scope until promotion is approved\\n- create a reviewable global proposal\\n- do not treat promotion as implicit apply\\n\\nReturn concise decisions with rationale.\\n\\"\\"\\"\\n","agents/writeback-curator/agent.toml":"name = \\"writeback-curator\\"\\ndescription = \\"Turn noisy outcomes into high-signal writeback.\\"\\n\\ndeveloper_instructions = \\"\\"\\"\\nYou curate durable writeback.\\n\\nPrioritize:\\n- repeated failures\\n- repeated wins\\n- stale guidance\\n- missing capability edges\\n- tool, skill, MCP, plugin, automation, or instruction friction that repeatedly slows work down\\n\\nFor each recommendation, prefer returning:\\n- suggested writeback kind\\n- best target asset or destination\\n- best scope (`project` or `global`)\\n- the evidence that justifies recording it\\n\\nDo not emit low-signal noise.\\nIf the learning is repo-specific, keep it project-scoped by default.\\nWhen the signal is already strong and the target is clear, prefer recommending direct writeback capture rather than abstract advice.\\nWhen the issue is executable tooling work, recommend task tracking for the fix and writeback only for the reusable operating-model learning.\\n\\"\\"\\"\\n","instructions/CAPABILITY_COMPOSITION.md":"---\\ndescription: \\"Compose small capability units across global and project roots, then evolve the smallest affected unit.\\"\\ntags: [\\"facult\\", \\"composition\\", \\"refs\\", \\"snippets\\", \\"instructions\\"]\\n---\\n\\n# Capability Composition\\n\\nUse `fclt` capability as small units that can be composed, inspected, rendered, and evolved independently.\\n\\nThe main units are:\\n\\n- instructions: standalone markdown doctrine such as language preferences, verification rules, or review standards\\n- snippets: small markdown partials inserted into one or more rendered docs\\n- skills: task-specific workflows with `SKILL.md`\\n- agents: focused role manifests\\n- MCP definitions: tool interfaces and their safe auth shape\\n- automations: scheduled review or maintenance loops\\n- tool rules/config: tool-specific defaults and policy\\n\\n## Composition Rules\\n\\n- Keep reusable doctrine in `instructions/`.\\n- Keep repeated paragraphs or policy blocks in `snippets/`.\\n- Keep workflow execution in `skills/`.\\n- Keep persona or delegation behavior in `agents/`.\\n- Keep tool wiring in `mcp/` and `tools/<tool>/`.\\n- Compose broad agent docs from refs and snippets instead of copying text by hand.\\n- Prefer one narrow reusable unit over one large instruction file that mixes unrelated domains.\\n\\nExamples:\\n\\n- `@ai/instructions/LANGUAGE.md` for a user-owned language/tooling preference.\\n- `@ai/instructions/REVIEW.md` for a user-owned review standard.\\n- `@project/instructions/TESTING.md` for repo-specific test policy.\\n- `<!-- fclty:global/codex/baseline -->` for a shared rendered block.\\n\\n## Scope\\n\\nUse global scope for capability that should follow the user across projects.\\n\\nUse project scope for capability that belongs to a repo, team workflow, architecture, or local test harness.\\n\\nPromote project capability to global only when repeated evidence shows reuse across projects. Do not globalize a project quirk just because it worked once.\\n\\n## Writeback and Evolution\\n\\nTarget the smallest affected unit.\\n\\n- If a paragraph is reused in several rendered docs, target the snippet.\\n- If a domain rule is wrong, target the instruction.\\n- If a workflow is incomplete, target the skill.\\n- If a delegated role is unclear, target the agent.\\n- If a tool interface is missing or unsafe, target the MCP or tool config.\\n- If a scheduled review loop is noisy or missing context, target the automation.\\n\\nGood writeback targets are graph-backed selectors when possible:\\n\\n```bash\\nfclt ai writeback add --kind missing_context --summary \\"Language guidance did not cover test runner selection.\\" --asset instruction:LANGUAGE\\nfclt ai writeback add --kind reusable_pattern --summary \\"Project test policy should become a shared verification snippet.\\" --asset @project/instructions/TESTING.md\\nfclt ai writeback add --kind bad_default --summary \\"The review automation escalated one-off preferences.\\" --asset automation:evolution-review\\n```\\n\\nUse `fclt ai evolve ...` only after repeated signal, a clearly missing capability, or a stale canonical asset points at a concrete change. Prefer the smallest valid proposal kind: `update_asset`, `create_asset`, `extract_snippet`, `add_skill`, or `promote_asset`.\\n\\n## Agent Defaults\\n\\nWhen an agent sees a repeated language, framework, or test preference, it should not bury that in chat. It should identify whether the durable unit is:\\n\\n- a global instruction\\n- a project instruction\\n- a snippet reused by rendered docs\\n- a skill workflow\\n- a project-to-global promotion candidate\\n\\nThen it should record writeback against that unit, or draft a proposal when the evidence is already strong enough.\\n","instructions/EVOLUTION.md":"---\\ndescription: Turn repeated signal into concrete capability changes.\\ntags: [facult, evolution, writeback]\\n---\\n\\n# Evolution\\n\\nUse writeback and evolution to improve the AI operating layer itself.\\n\\nEvolution is the synthesis and change side of the feedback loop. It turns accumulated writebacks, repeated tool friction, stale canonical assets, or clearly missing capability into small reviewable changes to instructions, skills, snippets, agents, or other markdown canonical assets.\\n\\nUse capability composition when choosing the target. Instructions, snippets, skills, agents, MCP/tool config, and automations are separate units. Target the smallest unit that actually needs to change instead of rewriting a broad agent doc.\\n\\n## When To Record Writeback\\n\\nRecord writeback when one of these is true:\\n\\n- the same failure repeats\\n- the same success pattern repeats\\n- guidance is stale or missing\\n- a prompt or loop has to be restated often\\n- a project-specific pattern looks reusable\\n\\nDo not record low-signal noise:\\n\\n- one-off annoyance with no reuse value\\n- generic \\"could be better\\" commentary\\n- duplicate observations with no new evidence\\n\\nThe intended default is that agents record strong writebacks themselves when the signal is clear enough, rather than only recommending that a user do it manually later.\\n\\nDo not wait for a weekly review to preserve high-signal evidence. Do wait for repeated evidence or a clearly missing capability before drafting a proposal.\\n\\n## Scope\\n\\nChoose `project` scope when the learning depends on:\\n\\n- repo architecture\\n- team workflow\\n- project tooling\\n- local testing or verification behavior\\n\\nChoose `global` scope when the learning is reusable across projects.\\n\\nPromote from project to global only after repeated reuse or strong evidence.\\n\\n## Writeback Kinds\\n\\nCommon kinds:\\n\\n- `weak_verification`\\n- `false_positive`\\n- `missing_context`\\n- `reusable_pattern`\\n- `capability_gap`\\n- `bad_default`\\n\\nEvery good writeback should try to include:\\n\\n- a concrete summary\\n- the best target asset if known\\n- the right scope\\n- domain or tags when useful\\n\\nGood target examples:\\n\\n- `instruction:LANGUAGE` when shared language/tooling guidance is stale or missing\\n- `@project/instructions/TESTING.md` when repo test policy needs project-scoped evolution\\n- `snippet:global/policy/review` when a repeated rendered block should be fixed or extracted\\n- `skill:capability-evolution` when a workflow skill is missing steps or examples\\n- `automation:evolution-review` when the scheduled review loop is noisy or incomplete\\n\\n## Operator Flow\\n\\nTypical workflow:\\n\\n```bash\\nfclt ai writeback add --kind weak_verification --summary \\"Checks were too shallow\\" --asset instruction:VERIFICATION\\nfclt ai writeback group --by asset\\nfclt ai writeback summarize --by domain\\nfclt ai evolve propose\\nfclt ai evolve draft EV-00001\\nfclt ai evolve accept EV-00001\\nfclt ai evolve apply EV-00001\\n```\\n\\nUse `fclt ai evolve draft <id> --append \\"...\\"` to revise a draft while preserving draft history.\\n\\nReview surfaces:\\n\\n- open `~/.ai/writebacks/` and `~/.ai/evolution/` in a Markdown editor for frontmatter-rich global and project-scoped review artifacts\\n- `fclt status --json` for queue/proposal paths, review artifact paths, counts, and active scope\\n- `fclt ai writeback list|show|group|summarize` for raw and clustered signal\\n- `fclt ai evolve list|show|review` for proposal state without applying changes\\n- `fclt templates init automation learning-review` for recurring capture/review\\n- `fclt templates init automation evolution-review` for recurring proposal review\\n- `fclt templates init automation tool-call-audit` for repeated tool-friction review\\n\\nEvolution proposal metadata, markdown drafts, patch artifacts, writeback queues,\\nand journals are runtime state. `fclt` stores JSON queues, proposal records,\\ndraft refs, patches, and journals in machine-local `fclt` state. It mirrors\\nhuman-readable review artifacts into global `~/.ai/writebacks/...` and\\n`~/.ai/evolution/...`, including project-scoped artifacts under\\n`projects/<slug-hash>/` with cwd/project metadata in frontmatter. Canonical\\nassets in `~/.ai` or `<repo>/.ai` should only change when a proposal is applied.\\n\\n## Default Agent Behavior\\n\\nUse the smallest action that fits the signal:\\n\\n1. record one strong writeback when there is a clear durable learning\\n2. use `writeback-curator` when the target, kind, or scope is ambiguous\\n3. use `capability-evolution` or `evolution-planner` when repeated signal should become a proposal\\n4. do not draft or apply proposals just because a writeback exists; require repeated evidence or a clearly missing capability\\n\\nAvoid creating writeback/evolution noise for one-off nits, vague preferences, or speculative ideas without evidence.\\n\\nWhen the friction is executable product/tooling work that needs ownership,\\npriority, state, or implementation follow-through, create or update a real task\\nsystem item instead of forcing it into capability evolution. Use evolution for\\nthe reusable operating-layer change.\\n\\n## Proposal Kinds\\n\\nCurrent supported proposal kinds:\\n\\n- `update_asset`\\n- `create_asset`\\n- `extract_snippet`\\n- `add_skill`\\n- `promote_asset`\\n\\nUse the smallest durable change that fits the evidence.\\n\\nExamples:\\n\\n- `update_asset`: fix a stale instruction, snippet, agent, or automation markdown asset.\\n- `create_asset`: add a missing instruction such as `LANGUAGE.md` or `REVIEW.md`.\\n- `extract_snippet`: move repeated guidance out of several docs into one snippet.\\n- `add_skill`: create a workflow when instructions are not enough.\\n- `promote_asset`: move a proven project instruction/snippet/skill toward global reuse.\\n\\n## Review And Apply Rules\\n\\n- draft before apply\\n- accept before apply\\n- prefer the smallest safe change\\n- keep reviewable evidence tied to source writebacks\\n- do not globalize project behavior too early\\n- do not apply high-risk global instruction, skill, plugin, or shared-tool changes without explicit review/approval\\n\\nApply is for markdown canonical assets only. If the target is wrong, revise the proposal rather than forcing it through.\\n","instructions/INTEGRATION.md":"---\\ndescription: Detect where local success can still fail at integration boundaries.\\ntags: [facult, integration, verification]\\n---\\n\\n# Integration\\n\\nDistinguish local correctness from system correctness. Check hidden dependencies, rollout order, and operational constraints before calling work done.\\n","instructions/LEARNING_AND_WRITEBACK.md":"---\\ndescription: Preserve durable signal and record writeback when the operating layer should learn.\\ntags: [facult, learning, writeback]\\n---\\n\\n# Learning And Writeback\\n\\nUse this when work produces a durable decision, failure, success pattern, or missing guardrail that should outlive the current task.\\n\\nThis is the capture side of the feedback loop. The goal is to let normal agent work produce reusable signal without requiring a human to manually restate every friction point later.\\n\\n## Default Behavior\\n\\nThe normal path should be agent-driven.\\n\\nIf you can clearly answer:\\n\\n- what was learned\\n- why it matters\\n- where it should land\\n- whether it belongs in `project` or `global`\\n\\nthen record the writeback instead of only suggesting that someone should do it later.\\n\\nUse:\\n\\n```bash\\nfclt ai writeback add --kind <kind> --summary \\"<summary>\\" --asset <asset-selector>\\n```\\n\\nThe writeback queue is runtime state, not canonical source. `fclt` stores JSON\\nqueue state in machine-local `fclt` state so sandboxed agents can record durable\\nfriction without mutating canonical assets unless an evolution proposal is later\\nreviewed and applied.\\n\\nEvery writeback also refreshes a Markdown review artifact under the global\\n`~/.ai/writebacks/...` tree. Global signal lands in `~/.ai/writebacks/global/`;\\nproject-scoped signal lands in `~/.ai/writebacks/projects/<slug-hash>/` with\\nfrontmatter for scope, project root, cwd, target asset, status, tags, evidence,\\nand timestamps. Do not write writeback review artifacts into a repo-local `.ai`;\\nrepo-local state should contribute project metadata and evidence, not bundled\\nprivate review files.\\n\\nProject-scoped writebacks should usually be recorded from the repo that produced\\nthe evidence. Global writebacks should be reserved for shared doctrine, shared\\nskills, shared agents, tool behavior, or cross-project capability gaps.\\n\\nTarget the smallest composable unit that explains the friction:\\n\\n- instruction: domain guidance, preferences, verification rules, or review doctrine\\n- snippet: repeated markdown block used by more than one rendered doc\\n- skill: workflow execution steps or examples\\n- agent: delegated role behavior\\n- MCP/tool config: tool interface, auth shape, or rendered integration\\n- automation: scheduled review loop, cadence, prompt, or memory\\n\\n## Record Writeback When\\n\\n- the same failure or weak loop appears again\\n- a reusable success pattern shows up\\n- guidance is clearly stale or missing\\n- a repo-local behavior probably belongs in project capability\\n- a cross-project behavior probably belongs in global capability\\n- a skill, tool, MCP, plugin, automation, or instruction gap repeatedly slows work down\\n- an agent has to restate the same workaround, verification rule, or review rule\\n- a repeated preference should become an atomic user-owned instruction or project-specific testing policy\\n\\n## Do Not Record Writeback For\\n\\n- one-off annoyance with no durable value\\n- weak commentary with no target\\n- speculative ideas without evidence\\n- duplicate noise with no new signal\\n\\n## Follow Through\\n\\n- prefer one strong writeback over many weak ones\\n- mention the writeback id when summarizing what changed\\n- escalate to `capability-evolution` or `fclt ai evolve ...` only when the signal is repeated or clearly points at a durable capability change\\n- use `fclt ai writeback group --by asset` or `fclt ai writeback summarize --by domain` to review accumulated signal before proposing broad changes\\n- use scheduled `learning-review`, `evolution-review`, or `tool-call-audit` automations when the signal should be reviewed in the background\\n","instructions/PROJECT_CAPABILITY.md":"---\\ndescription: Decide what belongs in repo-local .ai versus the global store.\\ntags: [facult, project, scope]\\n---\\n\\n# Project Capability\\n\\nPrefer project scope when the guidance depends on repo architecture, team workflow, or colocated tooling. Promote to global only after repeated cross-project reuse.\\n\\n## Project First\\n\\nDefault to `<repo>/.ai` when the capability is about:\\n\\n- local architecture\\n- repo-specific testing or verification\\n- team conventions\\n- project tools and workflows\\n\\n## Promote Carefully\\n\\nPromote to `~/.ai` only when:\\n\\n- the same pattern succeeds in more than one repo\\n- the capability is not coupled to local architecture\\n- the global version will not create noise for unrelated projects\\n\\nUse:\\n\\n```bash\\nfclt ai evolve promote EV-00001 --to global --project\\n```\\n\\nThat creates a new global proposal for review. It does not auto-apply the promotion.\\n","instructions/WORK_UNITS.md":"---\\ndescription: \\"Define work units so agent tasks have a clear goal, evidence path, artifact, and writeback target.\\"\\ntags: [\\"work-units\\", \\"planning\\", \\"verification\\", \\"writeback\\"]\\n---\\n\\n# Work Units\\n\\nA work unit is the smallest coherent unit of agent work that can be understood, verified, and preserved.\\n\\nIt is not just the user\'s latest sentence. It is the operational shape around that sentence: what is being changed, why it matters, what evidence is needed, what artifact should remain, and how future agents should benefit from the result.\\n\\n## Minimum Contract\\n\\nA well-formed work unit names:\\n\\n- goal: the outcome the user needs\\n- acceptance criteria: what must be true when the work is done\\n- required context: source files, docs, systems, messages, or prior decisions needed for correctness\\n- constraints: permissions, privacy, compatibility, deadlines, ownership, or scope limits\\n- signals or evidence: checks that can confirm progress or falsify assumptions\\n- output artifact: code, docs, proposal, issue, note, draft, or report\\n- verification path: commands, review surfaces, manual checks, or source-of-truth reads\\n- writeback target: where durable learning belongs if the work teaches something reusable\\n\\nIf one of these is missing and the gap blocks correctness, surface the gap early and recover it before moving faster.\\n\\n## Why It Exists\\n\\nWork-unit framing prevents shallow completion. It helps agents avoid:\\n\\n- changing files before understanding the target\\n- treating a weak green signal as proof\\n- losing reusable learning in chat\\n- creating duplicate tasks or proposals\\n- turning one-off preferences into global rules\\n- pushing project-specific details into global capability\\n\\n## How To Use It\\n\\nFor simple tasks, keep the work unit implicit but still verify the result.\\n\\nFor ambiguous, high-impact, or multi-step tasks, make the work unit explicit before executing. A compact form is enough:\\n\\n```text\\nGoal:\\nAcceptance:\\nContext:\\nConstraints:\\nEvidence:\\nArtifact:\\nVerification:\\nWriteback:\\n```\\n\\nUse the smallest framing that makes the task correct. Do not turn every request into paperwork.\\n\\n## Writeback\\n\\nWhen the work reveals durable friction, missing capability, stale guidance, or a repeatable workflow, prefer one strong writeback over many weak ones.\\n\\nUse `fclt ai writeback add ...` when the target asset, scope, and evidence are clear. Use `fclt ai evolve ...` only when repeated signal supports a concrete proposal.\\n","skills/capability-evolution/SKILL.md":"---\\ndescription: Convert repeated writeback into concrete fclt capability proposals.\\ntags: [facult, evolution, writeback]\\n---\\n\\n# capability-evolution\\n\\n## When To Use\\nUse this skill when the same missing guidance, weak loop, or recurring win appears often enough that the AI system itself should probably change.\\n\\nDo not wait for a human operator by default if the signal is already clear and the environment permits local AI runtime state to be updated.\\n\\nUse writeback first when the signal is useful but not yet repeated. Use evolution when accumulated writebacks, repeated tool friction, or a clearly missing capability point at a specific target asset or new capability.\\n\\n## Scope Decision\\n\\nChoose `project` when the behavior depends on repo-local architecture or workflow.\\n\\nChoose `global` when the behavior is broadly reusable.\\n\\nIf unsure, start at project scope and promote later with evidence.\\n\\n## Working Flow\\n\\n1. record the strongest writeback\\n2. group or summarize repeated signal\\n3. choose the smallest valid proposal kind\\n4. draft the proposal\\n5. accept only after the target and scope are correct\\n6. apply only when the markdown target is the intended canonical asset\\n\\nUse:\\n\\n```bash\\nfclt ai writeback add ...\\nfclt ai writeback group --by asset\\nfclt ai writeback summarize --by domain\\nfclt ai evolve propose\\nfclt ai evolve draft EV-00001\\nfclt ai evolve draft EV-00001 --append \\"tighten the rule with a concrete verification step\\"\\nfclt ai evolve accept EV-00001\\nfclt ai evolve apply EV-00001\\n```\\n\\nFor background review loops, use:\\n\\n```bash\\nfclt templates init automation learning-review\\nfclt templates init automation evolution-review\\nfclt templates init automation tool-call-audit\\n```\\n\\nIf there is not yet enough repeated signal for evolution, record the writeback and stop there.\\n\\n## Proposal Kind Selection\\n\\n- `update_asset` for tightening existing guidance\\n- `create_asset` for missing instructions or docs\\n- `extract_snippet` for reusable partial guidance\\n- `add_skill` for reusable workflow instruction\\n- `promote_asset` for project-to-global promotion\\n\\nUse task tracking instead of evolution when the main work is an executable tool or product fix that needs an owner, priority, state, or delivery plan. Use evolution for the reusable instruction, skill, or operating-model change that should survive that fix.\\n\\n## Output Contract\\n- repeated signal\\n- proposed asset change\\n- target scope\\n- evidence\\n- smallest useful next step\\n","skills/project-operating-layer-design/SKILL.md":"---\\ndescription: Design or improve a repo-local .ai operating layer.\\ntags: [facult, project, design]\\n---\\n\\n# project-operating-layer-design\\n\\n## When To Use\\nUse this skill when a project needs its own `.ai/` structure, repo-specific instructions, or local bootstrap guidance.\\n\\n## Output Contract\\n- recommended `.ai/` layout\\n- what stays project-local\\n- what stays global\\n- what should remain generated runtime output only\\n","snippets/global/baseline.md":"- Preserve existing user changes unless asked to rewrite them.\\n- Prefer small, reviewable diffs and verify meaningful changes before claiming success.\\n- State constraints, risks, and follow-up steps directly.\\n","snippets/global/core/feedback-loops.md":"- For any task, identify the highest-signal feedback loops available.\\n- Prefer loops that can verify progress, falsify weak assumptions, and expose failure early.\\n- Do not rely on a single shallow positive signal if stronger verification exists.\\n- If the available loop is stale, weak, noisy, or easy to game, improve it or say what is missing.\\n- When useful, leave behind a stronger loop than the one you started with.\\n- Treat verification, evaluation, and writeback as part of the work, not cleanup after it.\\n- For work-unit clarification, read ${refs.work_units}.\\n- For verification guidance, read ${refs.verification}.\\n- For learning and writeback, read ${refs.learning_writeback}.\\n- For deeper guidance, read ${refs.feedback_loops}.\\n","snippets/global/core/verification.md":"- Treat verification as part of the work, not a final checkbox.\\n- Prefer the strongest available proof that matches the real risk.\\n- Make clear what has actually been verified and what remains assumed.\\n- Distrust shallow green signals when stronger checks are available.\\n- If the current harness is stale, weak, or misleading, say so and improve it where possible.\\n- For deeper guidance, read ${refs.verification}.\\n","snippets/global/core/work-units.md":"- Treat every task as a work unit, not just a request.\\n- A work unit should have a goal, acceptance criteria, required context, constraints, signals or evidence, an output artifact, and a verification path.\\n- If any of those are missing and the gap blocks correctness, surface it early and try to recover it.\\n- Prefer making the work unit more explicit before increasing execution speed.\\n- If the task is vague, ambiguous, or overloaded, narrow it before acting.\\n- For deeper guidance, read ${refs.work_units}.\\n","snippets/global/core/writeback.md":"- Do not end at output if something important was learned.\\n- Preserve decisions, failures, successes, and reusable signal when they will improve future work.\\n- Prefer writing to a real destination over leaving knowledge in chat.\\n- When useful, leave behind better docs, tests, evals, prompts, notes, or follow-up tasks.\\n- When a high-signal learning clearly points at a canonical asset or durable destination, record a writeback before ending the task.\\n- Prefer one strong writeback over many weak ones.\\n- If you can name the target asset, the expected scope, and the actual signal, use `fclt ai writeback add ...` instead of merely mentioning that writeback would be useful.\\n- If repeated signal is already accumulating, use the `capability-evolution` skill or `fclt ai evolve ...` flow to turn it into a reviewable proposal.\\n- For deeper guidance, read ${refs.learning_writeback}.\\n"}'
|
|
5
6
|
) as Record<string, string>;
|
package/src/doctor.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "node:fs/promises";
|
|
16
16
|
import { homedir } from "node:os";
|
|
17
17
|
import { dirname, join } from "node:path";
|
|
18
|
+
import { renderCanonicalText } from "./agents";
|
|
18
19
|
import {
|
|
19
20
|
ensureAiGraphPath,
|
|
20
21
|
ensureAiIndexPath,
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
loadConfiguredProjectSyncTools,
|
|
42
43
|
writeProjectSyncPolicy,
|
|
43
44
|
} from "./project-sync";
|
|
45
|
+
import { renderSnippetText } from "./snippets";
|
|
44
46
|
import { packageVersion } from "./status";
|
|
45
47
|
|
|
46
48
|
const TOML_FILE_SUFFIX_RE = /\.toml$/;
|
|
@@ -104,6 +106,9 @@ export interface DoctorReport {
|
|
|
104
106
|
evolutionReviewDirExists: boolean;
|
|
105
107
|
canonicalGlobalDocsValid: boolean;
|
|
106
108
|
canonicalGlobalDocsIssueCodes: string[];
|
|
109
|
+
canonicalTemplateRefsValid: boolean;
|
|
110
|
+
canonicalTemplateRefsIssueCodes: string[];
|
|
111
|
+
canonicalTemplateRefsIssuePaths: string[];
|
|
107
112
|
projectSyncRepairNeeded: boolean;
|
|
108
113
|
projectSyncRepairTools: string[];
|
|
109
114
|
};
|
|
@@ -446,6 +451,24 @@ async function repairLegacyCodexAuthoringLayout(args: {
|
|
|
446
451
|
return { changed, conflicts };
|
|
447
452
|
}
|
|
448
453
|
|
|
454
|
+
interface CanonicalTemplateIssue {
|
|
455
|
+
path: string;
|
|
456
|
+
relPath: string;
|
|
457
|
+
code: string;
|
|
458
|
+
message: string;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
interface CanonicalTemplateRefsInspection {
|
|
462
|
+
valid: boolean;
|
|
463
|
+
issues: CanonicalTemplateIssue[];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
interface CanonicalTemplateRefsRepair {
|
|
467
|
+
changed: boolean;
|
|
468
|
+
repairedPaths: string[];
|
|
469
|
+
backupPaths: string[];
|
|
470
|
+
}
|
|
471
|
+
|
|
449
472
|
async function repairCanonicalGlobalDocs(args: {
|
|
450
473
|
home: string;
|
|
451
474
|
rootDir: string;
|
|
@@ -468,11 +491,35 @@ async function repairCanonicalGlobalDocs(args: {
|
|
|
468
491
|
await copyFile(targetPath, backupPath);
|
|
469
492
|
await mkdir(dirname(targetPath), { recursive: true });
|
|
470
493
|
await writeFile(targetPath, await readFile(sourcePath, "utf8"), "utf8");
|
|
494
|
+
await copyMissingBuiltinOperatingModelSnippets(args.rootDir);
|
|
471
495
|
await ensureAiIndexPath({ homeDir: args.home, rootDir: args.rootDir });
|
|
472
496
|
await ensureAiGraphPath({ homeDir: args.home, rootDir: args.rootDir });
|
|
473
497
|
return { changed: true, backupPath };
|
|
474
498
|
}
|
|
475
499
|
|
|
500
|
+
async function copyMissingBuiltinOperatingModelSnippets(
|
|
501
|
+
rootDir: string
|
|
502
|
+
): Promise<void> {
|
|
503
|
+
const relPaths = [
|
|
504
|
+
"snippets/global/baseline.md",
|
|
505
|
+
"snippets/global/core/work-units.md",
|
|
506
|
+
"snippets/global/core/feedback-loops.md",
|
|
507
|
+
"snippets/global/core/verification.md",
|
|
508
|
+
"snippets/global/core/writeback.md",
|
|
509
|
+
];
|
|
510
|
+
const sourceRoot = facultBuiltinPackRoot();
|
|
511
|
+
|
|
512
|
+
for (const relPath of relPaths) {
|
|
513
|
+
const sourcePath = join(sourceRoot, relPath);
|
|
514
|
+
const targetPath = join(rootDir, relPath);
|
|
515
|
+
if (await pathExists(targetPath)) {
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
519
|
+
await copyFile(sourcePath, targetPath);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
476
523
|
async function listProjectSkillNames(rootDir: string): Promise<string[]> {
|
|
477
524
|
const skillsDir = join(rootDir, "skills");
|
|
478
525
|
const entries = await readdir(skillsDir, { withFileTypes: true }).catch(
|
|
@@ -547,6 +594,7 @@ async function hasProjectGlobalDocs(rootDir: string): Promise<boolean> {
|
|
|
547
594
|
}
|
|
548
595
|
|
|
549
596
|
const UNRESOLVED_TEMPLATE_REF_RE = /\$\{[^}\n]+\}/g;
|
|
597
|
+
const UNRESOLVED_REFS_TEMPLATE_RE = /\$\{refs\.([A-Za-z0-9_.-]+)\}/g;
|
|
550
598
|
const FCLTY_BLOCK_RE =
|
|
551
599
|
/<!--\s*fclty:([^>]+?)\s*-->([\s\S]*?)<!--\s*\/fclty:\1\s*-->/g;
|
|
552
600
|
|
|
@@ -562,19 +610,37 @@ async function inspectCanonicalGlobalDocs(rootDir: string): Promise<{
|
|
|
562
610
|
|
|
563
611
|
const text = await readFile(pathValue, "utf8");
|
|
564
612
|
const issues: DoctorIssue[] = [];
|
|
565
|
-
const
|
|
613
|
+
const withSnippets = await renderSnippetText({
|
|
614
|
+
text,
|
|
615
|
+
filePath: pathValue,
|
|
616
|
+
rootDir,
|
|
617
|
+
});
|
|
618
|
+
for (const error of withSnippets.errors) {
|
|
619
|
+
issues.push({
|
|
620
|
+
severity: "warning",
|
|
621
|
+
code: "canonical-global-docs-render-error",
|
|
622
|
+
message: error,
|
|
623
|
+
fix: "Review AGENTS.global.md snippet markers or refresh the built-in operating model with `fclt templates init operating-model --global --force`.",
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const rendered = await renderCanonicalText(withSnippets.text, {
|
|
627
|
+
rootDir,
|
|
628
|
+
});
|
|
629
|
+
const unresolvedRefs = new Set(
|
|
630
|
+
rendered.match(UNRESOLVED_TEMPLATE_REF_RE) ?? []
|
|
631
|
+
);
|
|
566
632
|
if (unresolvedRefs.size > 0) {
|
|
567
633
|
issues.push({
|
|
568
634
|
severity: "warning",
|
|
569
635
|
code: "canonical-global-docs-unresolved-template",
|
|
570
636
|
message:
|
|
571
|
-
"
|
|
572
|
-
fix: "Review
|
|
637
|
+
"Rendered AGENTS.global.md contains unresolved template references.",
|
|
638
|
+
fix: "Review AGENTS.global.md refs or refresh the built-in operating model with `fclt templates init operating-model --global --force`.",
|
|
573
639
|
});
|
|
574
640
|
}
|
|
575
641
|
|
|
576
642
|
const emptySections: string[] = [];
|
|
577
|
-
for (const match of
|
|
643
|
+
for (const match of rendered.matchAll(FCLTY_BLOCK_RE)) {
|
|
578
644
|
const key = match[1]?.trim();
|
|
579
645
|
const body = match[2]?.trim();
|
|
580
646
|
if (key && !body) {
|
|
@@ -585,8 +651,8 @@ async function inspectCanonicalGlobalDocs(rootDir: string): Promise<{
|
|
|
585
651
|
issues.push({
|
|
586
652
|
severity: "warning",
|
|
587
653
|
code: "canonical-global-docs-empty-managed-sections",
|
|
588
|
-
message: `
|
|
589
|
-
fix: "
|
|
654
|
+
message: `Rendered AGENTS.global.md has empty fclty managed sections: ${emptySections.join(", ")}.`,
|
|
655
|
+
fix: "Add the missing snippets or refresh the built-in operating model with `fclt templates init operating-model --global --force`.",
|
|
590
656
|
});
|
|
591
657
|
}
|
|
592
658
|
|
|
@@ -597,6 +663,124 @@ async function inspectCanonicalGlobalDocs(rootDir: string): Promise<{
|
|
|
597
663
|
};
|
|
598
664
|
}
|
|
599
665
|
|
|
666
|
+
const CANONICAL_TEMPLATE_REF_DIRS = ["instructions"] as const;
|
|
667
|
+
|
|
668
|
+
function canonicalRefValues(rootDir: string): Record<string, string> {
|
|
669
|
+
return {
|
|
670
|
+
evolution: join(rootDir, "instructions", "EVOLUTION.md"),
|
|
671
|
+
feedback_loops: join(rootDir, "instructions", "FEEDBACK_LOOPS.md"),
|
|
672
|
+
learning_writeback: join(
|
|
673
|
+
rootDir,
|
|
674
|
+
"instructions",
|
|
675
|
+
"LEARNING_AND_WRITEBACK.md"
|
|
676
|
+
),
|
|
677
|
+
project_capability: join(rootDir, "instructions", "PROJECT_CAPABILITY.md"),
|
|
678
|
+
verification: join(rootDir, "instructions", "VERIFICATION.md"),
|
|
679
|
+
work_units: join(rootDir, "instructions", "WORK_UNITS.md"),
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
function resolveKnownCanonicalRefs(text: string, rootDir: string): string {
|
|
684
|
+
const refs = canonicalRefValues(rootDir);
|
|
685
|
+
return text.replace(UNRESOLVED_REFS_TEMPLATE_RE, (match, key: string) => {
|
|
686
|
+
return refs[key] ?? match;
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
async function listCanonicalMarkdownFiles(rootDir: string): Promise<string[]> {
|
|
691
|
+
const out: string[] = [];
|
|
692
|
+
|
|
693
|
+
async function visit(dir: string): Promise<void> {
|
|
694
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(
|
|
695
|
+
() => [] as import("node:fs").Dirent[]
|
|
696
|
+
);
|
|
697
|
+
for (const entry of entries) {
|
|
698
|
+
if (entry.name.startsWith(".")) {
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
const pathValue = join(dir, entry.name);
|
|
702
|
+
if (entry.isDirectory()) {
|
|
703
|
+
await visit(pathValue);
|
|
704
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
705
|
+
out.push(pathValue);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
for (const relDir of CANONICAL_TEMPLATE_REF_DIRS) {
|
|
711
|
+
await visit(join(rootDir, relDir));
|
|
712
|
+
}
|
|
713
|
+
return out.sort((a, b) => a.localeCompare(b));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function relPathFromRoot(rootDir: string, pathValue: string): string {
|
|
717
|
+
return pathValue.startsWith(`${rootDir}/`)
|
|
718
|
+
? pathValue.slice(rootDir.length + 1)
|
|
719
|
+
: pathValue;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
async function inspectCanonicalTemplateRefs(
|
|
723
|
+
rootDir: string
|
|
724
|
+
): Promise<CanonicalTemplateRefsInspection> {
|
|
725
|
+
const files = await listCanonicalMarkdownFiles(rootDir);
|
|
726
|
+
const issues: CanonicalTemplateIssue[] = [];
|
|
727
|
+
|
|
728
|
+
for (const pathValue of files) {
|
|
729
|
+
const text = await readFile(pathValue, "utf8");
|
|
730
|
+
const refs = new Set(text.match(UNRESOLVED_REFS_TEMPLATE_RE) ?? []);
|
|
731
|
+
if (refs.size === 0) {
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
const relPath = relPathFromRoot(rootDir, pathValue);
|
|
735
|
+
issues.push({
|
|
736
|
+
path: pathValue,
|
|
737
|
+
relPath,
|
|
738
|
+
code: "canonical-source-unresolved-template-ref",
|
|
739
|
+
message: `${relPath} contains unresolved template refs: ${[...refs].join(", ")}.`,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
return {
|
|
744
|
+
valid: issues.length === 0,
|
|
745
|
+
issues,
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
async function repairCanonicalTemplateRefs(
|
|
750
|
+
rootDir: string
|
|
751
|
+
): Promise<CanonicalTemplateRefsRepair> {
|
|
752
|
+
const files = await listCanonicalMarkdownFiles(rootDir);
|
|
753
|
+
const repairedPaths: string[] = [];
|
|
754
|
+
const backupPaths: string[] = [];
|
|
755
|
+
|
|
756
|
+
for (const pathValue of files) {
|
|
757
|
+
const before = await readFile(pathValue, "utf8");
|
|
758
|
+
const after = resolveKnownCanonicalRefs(before, rootDir);
|
|
759
|
+
if (after === before) {
|
|
760
|
+
continue;
|
|
761
|
+
}
|
|
762
|
+
const relPath = relPathFromRoot(rootDir, pathValue);
|
|
763
|
+
const backupPath = join(
|
|
764
|
+
rootDir,
|
|
765
|
+
".facult",
|
|
766
|
+
"backups",
|
|
767
|
+
"doctor",
|
|
768
|
+
`${relPath.replaceAll("/", "__")}.${timestampForBackup()}`
|
|
769
|
+
);
|
|
770
|
+
await mkdir(dirname(backupPath), { recursive: true });
|
|
771
|
+
await copyFile(pathValue, backupPath);
|
|
772
|
+
await writeFile(pathValue, after, "utf8");
|
|
773
|
+
repairedPaths.push(relPath);
|
|
774
|
+
backupPaths.push(backupPath);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return {
|
|
778
|
+
changed: repairedPaths.length > 0,
|
|
779
|
+
repairedPaths,
|
|
780
|
+
backupPaths,
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
|
|
600
784
|
async function hasProjectToolRules(
|
|
601
785
|
rootDir: string,
|
|
602
786
|
tool: string
|
|
@@ -778,6 +962,7 @@ export async function buildDoctorReport(opts?: {
|
|
|
778
962
|
writebackReviewDirExists,
|
|
779
963
|
evolutionReviewDirExists,
|
|
780
964
|
canonicalGlobalDocs,
|
|
965
|
+
canonicalTemplateRefs,
|
|
781
966
|
projectSyncPlan,
|
|
782
967
|
] = await Promise.all([
|
|
783
968
|
pathExists(rootDir),
|
|
@@ -788,6 +973,7 @@ export async function buildDoctorReport(opts?: {
|
|
|
788
973
|
pathExists(writebackReviewDir),
|
|
789
974
|
pathExists(evolutionReviewDir),
|
|
790
975
|
inspectCanonicalGlobalDocs(rootDir),
|
|
976
|
+
inspectCanonicalTemplateRefs(rootDir),
|
|
791
977
|
planProjectSyncPolicyRepair({ home, rootDir }),
|
|
792
978
|
]);
|
|
793
979
|
|
|
@@ -836,6 +1022,23 @@ export async function buildDoctorReport(opts?: {
|
|
|
836
1022
|
});
|
|
837
1023
|
}
|
|
838
1024
|
|
|
1025
|
+
for (const issue of canonicalTemplateRefs.issues) {
|
|
1026
|
+
issues.push({
|
|
1027
|
+
severity: "warning",
|
|
1028
|
+
code: issue.code,
|
|
1029
|
+
message: issue.message,
|
|
1030
|
+
fix: "Run fclt doctor --repair to resolve known refs into concrete paths, then review any remaining placeholders.",
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
if (!canonicalTemplateRefs.valid) {
|
|
1034
|
+
actions.push({
|
|
1035
|
+
id: "repair-canonical-template-refs",
|
|
1036
|
+
label: "Repair unresolved canonical template refs",
|
|
1037
|
+
command: "fclt doctor --repair",
|
|
1038
|
+
risk: "canonical_write",
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
839
1042
|
if (generatedOnlyProjectRoot) {
|
|
840
1043
|
issues.push({
|
|
841
1044
|
severity: "error",
|
|
@@ -927,7 +1130,7 @@ export async function buildDoctorReport(opts?: {
|
|
|
927
1130
|
state = "project_generated_only";
|
|
928
1131
|
} else if (!(rootExists && canonicalSourceExists)) {
|
|
929
1132
|
state = "uninitialized";
|
|
930
|
-
} else if (!canonicalGlobalDocs.valid) {
|
|
1133
|
+
} else if (!(canonicalGlobalDocs.valid && canonicalTemplateRefs.valid)) {
|
|
931
1134
|
state = "canonical_source_attention";
|
|
932
1135
|
} else if (!(writebackReviewDirExists && evolutionReviewDirExists)) {
|
|
933
1136
|
state = "partial_global_config";
|
|
@@ -971,6 +1174,13 @@ export async function buildDoctorReport(opts?: {
|
|
|
971
1174
|
canonicalGlobalDocsIssueCodes: canonicalGlobalDocs.issues.map(
|
|
972
1175
|
(issue) => issue.code
|
|
973
1176
|
),
|
|
1177
|
+
canonicalTemplateRefsValid: canonicalTemplateRefs.valid,
|
|
1178
|
+
canonicalTemplateRefsIssueCodes: canonicalTemplateRefs.issues.map(
|
|
1179
|
+
(issue) => issue.code
|
|
1180
|
+
),
|
|
1181
|
+
canonicalTemplateRefsIssuePaths: canonicalTemplateRefs.issues.map(
|
|
1182
|
+
(issue) => issue.relPath
|
|
1183
|
+
),
|
|
974
1184
|
projectSyncRepairNeeded: projectSyncPlan.needed,
|
|
975
1185
|
projectSyncRepairTools,
|
|
976
1186
|
},
|
|
@@ -1029,6 +1239,7 @@ export async function doctorCommand(argv: string[]) {
|
|
|
1029
1239
|
let codexAuthoringConflicts: string[] = [];
|
|
1030
1240
|
let canonicalGlobalDocsRepaired = false;
|
|
1031
1241
|
let canonicalGlobalDocsBackupPath: string | undefined;
|
|
1242
|
+
let canonicalTemplateRefsRepair: CanonicalTemplateRefsRepair | undefined;
|
|
1032
1243
|
let reviewArtifactsRefreshed:
|
|
1033
1244
|
| {
|
|
1034
1245
|
writebackCount: number;
|
|
@@ -1061,6 +1272,7 @@ export async function doctorCommand(argv: string[]) {
|
|
|
1061
1272
|
});
|
|
1062
1273
|
canonicalGlobalDocsRepaired = globalDocsRepair.changed;
|
|
1063
1274
|
canonicalGlobalDocsBackupPath = globalDocsRepair.backupPath;
|
|
1275
|
+
canonicalTemplateRefsRepair = await repairCanonicalTemplateRefs(rootDir);
|
|
1064
1276
|
const { refreshAiReviewArtifacts } = await import("./ai");
|
|
1065
1277
|
reviewArtifactsRefreshed = await refreshAiReviewArtifacts({
|
|
1066
1278
|
homeDir: home,
|
|
@@ -1132,6 +1344,12 @@ export async function doctorCommand(argv: string[]) {
|
|
|
1132
1344
|
`Repaired canonical AGENTS.global.md from the built-in operating model. Backup: ${canonicalGlobalDocsBackupPath}`
|
|
1133
1345
|
);
|
|
1134
1346
|
}
|
|
1347
|
+
if (canonicalTemplateRefsRepair?.changed) {
|
|
1348
|
+
console.log("Resolved canonical template refs in:");
|
|
1349
|
+
for (const repairedPath of canonicalTemplateRefsRepair.repairedPaths) {
|
|
1350
|
+
console.log(`- ${repairedPath}`);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1135
1353
|
if (reviewArtifactsRefreshed) {
|
|
1136
1354
|
console.log(
|
|
1137
1355
|
`Refreshed AI review artifacts: ${reviewArtifactsRefreshed.writebackCount} writebacks in ${reviewArtifactsRefreshed.writebackReviewDir}, ${reviewArtifactsRefreshed.proposalCount} proposals in ${reviewArtifactsRefreshed.evolutionReviewDir}.`
|
|
@@ -1157,6 +1375,18 @@ export async function doctorCommand(argv: string[]) {
|
|
|
1157
1375
|
return;
|
|
1158
1376
|
}
|
|
1159
1377
|
}
|
|
1378
|
+
const canonicalTemplateRefs = await inspectCanonicalTemplateRefs(rootDir);
|
|
1379
|
+
if (!canonicalTemplateRefs.valid) {
|
|
1380
|
+
for (const issue of canonicalTemplateRefs.issues) {
|
|
1381
|
+
console.log(
|
|
1382
|
+
`${issue.message} Run \`fclt doctor --repair\` to resolve known refs into concrete paths, then review any remaining placeholders.`
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
if (!repair) {
|
|
1386
|
+
process.exitCode = 1;
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1160
1390
|
if (await isGeneratedOnlyProjectRoot({ home, rootDir })) {
|
|
1161
1391
|
console.log(
|
|
1162
1392
|
"Project .ai root contains generated state only. Canonical project source is missing, so managed project sync should be treated as unsafe until source is initialized, restored, or management is detached."
|
package/src/global-docs.ts
CHANGED
|
@@ -228,18 +228,25 @@ async function renderSourceTarget(args: {
|
|
|
228
228
|
tool: string;
|
|
229
229
|
}): Promise<string> {
|
|
230
230
|
const raw = await Bun.file(args.sourcePath).text();
|
|
231
|
+
const builtinRoot = facultBuiltinPackRoot();
|
|
232
|
+
const sourceRoot = args.sourcePath.startsWith(`${builtinRoot}/`)
|
|
233
|
+
? builtinRoot
|
|
234
|
+
: args.rootDir;
|
|
231
235
|
const withSnippets = await renderSnippetText({
|
|
232
236
|
text: raw,
|
|
233
237
|
filePath: args.sourcePath,
|
|
234
|
-
rootDir:
|
|
238
|
+
rootDir: sourceRoot,
|
|
235
239
|
});
|
|
236
240
|
if (withSnippets.errors.length) {
|
|
237
241
|
throw new Error(withSnippets.errors.join("\n"));
|
|
238
242
|
}
|
|
239
243
|
return await renderCanonicalText(withSnippets.text, {
|
|
240
244
|
homeDir: args.homeDir,
|
|
241
|
-
rootDir:
|
|
242
|
-
projectRoot:
|
|
245
|
+
rootDir: sourceRoot,
|
|
246
|
+
projectRoot:
|
|
247
|
+
sourceRoot === args.rootDir
|
|
248
|
+
? (projectRootFromAiRoot(args.rootDir, args.homeDir) ?? undefined)
|
|
249
|
+
: undefined,
|
|
243
250
|
targetTool: args.tool,
|
|
244
251
|
targetPath: args.targetPath,
|
|
245
252
|
});
|
package/src/remote.ts
CHANGED
|
@@ -394,17 +394,12 @@ Ship reliable changes quickly while keeping behavior predictable.
|
|
|
394
394
|
type: "snippet",
|
|
395
395
|
title: "Snippet Template",
|
|
396
396
|
description:
|
|
397
|
-
"Reusable snippet block template for
|
|
397
|
+
"Reusable snippet block template for a compact quality checklist.",
|
|
398
398
|
version: "1.0.0",
|
|
399
399
|
tags: ["template", "dx", "snippet"],
|
|
400
400
|
snippet: {
|
|
401
|
-
marker: "team/
|
|
402
|
-
content: `##
|
|
403
|
-
- Prefer explicit, descriptive names over abbreviations.
|
|
404
|
-
- Keep functions focused and side-effect boundaries obvious.
|
|
405
|
-
- Add tests when behavior changes.
|
|
406
|
-
|
|
407
|
-
## Review Checklist
|
|
401
|
+
marker: "team/quality-checklist",
|
|
402
|
+
content: `## Quality Checklist
|
|
408
403
|
- Is behavior correct for edge cases?
|
|
409
404
|
- Are failure modes clear and actionable?
|
|
410
405
|
- Is the change minimal for the goal?
|
package/src/snippets-cli.ts
CHANGED
|
@@ -20,8 +20,8 @@ Usage:
|
|
|
20
20
|
fclt snippets sync [--dry-run] [file...]
|
|
21
21
|
|
|
22
22
|
Notes:
|
|
23
|
-
- <name> is the snippet marker name (e.g.
|
|
24
|
-
- Unscoped names (e.g.
|
|
23
|
+
- <name> is the snippet marker name (e.g. qualitychecklist, global/qualitychecklist, myproject/context)
|
|
24
|
+
- Unscoped names (e.g. qualitychecklist) resolve to project snippet first (if in a git repo), then global.
|
|
25
25
|
`);
|
|
26
26
|
}
|
|
27
27
|
|
package/src/snippets.ts
CHANGED
|
@@ -202,7 +202,7 @@ export function formatSnippetInjection(snippet: string): string {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export interface SnippetResolution {
|
|
205
|
-
/** The marker name requested (e.g. "
|
|
205
|
+
/** The marker name requested (e.g. "qualitychecklist", "global/qualitychecklist", "myproj/context"). */
|
|
206
206
|
marker: string;
|
|
207
207
|
/** The snippet file path used for injection. */
|
|
208
208
|
path: string;
|