synorch 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +314 -28
  3. package/dist/application/doctor-service.d.ts +16 -0
  4. package/dist/application/doctor-service.d.ts.map +1 -1
  5. package/dist/application/doctor-service.js +230 -32
  6. package/dist/application/doctor-service.js.map +1 -1
  7. package/dist/application/generated-skill-doctor.d.ts +9 -0
  8. package/dist/application/generated-skill-doctor.d.ts.map +1 -0
  9. package/dist/application/generated-skill-doctor.js +433 -0
  10. package/dist/application/generated-skill-doctor.js.map +1 -0
  11. package/dist/application/project-discovery.d.ts +12 -0
  12. package/dist/application/project-discovery.d.ts.map +1 -1
  13. package/dist/application/project-discovery.js +65 -2
  14. package/dist/application/project-discovery.js.map +1 -1
  15. package/dist/application/safe-path.d.ts +19 -0
  16. package/dist/application/safe-path.d.ts.map +1 -0
  17. package/dist/application/safe-path.js +35 -0
  18. package/dist/application/safe-path.js.map +1 -0
  19. package/dist/application/size-ceiling.d.ts +15 -0
  20. package/dist/application/size-ceiling.d.ts.map +1 -0
  21. package/dist/application/size-ceiling.js +32 -0
  22. package/dist/application/size-ceiling.js.map +1 -0
  23. package/dist/application/structure-service.d.ts.map +1 -1
  24. package/dist/application/structure-service.js +10 -1
  25. package/dist/application/structure-service.js.map +1 -1
  26. package/dist/cli.js +10 -1
  27. package/dist/cli.js.map +1 -1
  28. package/dist/domain/canonical-contracts.d.ts +69 -0
  29. package/dist/domain/canonical-contracts.d.ts.map +1 -0
  30. package/dist/domain/canonical-contracts.js +92 -0
  31. package/dist/domain/canonical-contracts.js.map +1 -0
  32. package/dist/domain/generated-skill.d.ts +55 -0
  33. package/dist/domain/generated-skill.d.ts.map +1 -0
  34. package/dist/domain/generated-skill.js +90 -0
  35. package/dist/domain/generated-skill.js.map +1 -0
  36. package/dist/domain/generation.d.ts +15 -2
  37. package/dist/domain/generation.d.ts.map +1 -1
  38. package/dist/domain/observation-ledger.d.ts +118 -0
  39. package/dist/domain/observation-ledger.d.ts.map +1 -0
  40. package/dist/domain/observation-ledger.js +183 -0
  41. package/dist/domain/observation-ledger.js.map +1 -0
  42. package/dist/domain/product.d.ts +1 -1
  43. package/dist/domain/product.js +1 -1
  44. package/dist/domain/relative-path.d.ts +21 -0
  45. package/dist/domain/relative-path.d.ts.map +1 -0
  46. package/dist/domain/relative-path.js +43 -0
  47. package/dist/domain/relative-path.js.map +1 -0
  48. package/dist/domain/skill-packs.d.ts.map +1 -1
  49. package/dist/domain/skill-packs.js +1 -0
  50. package/dist/domain/skill-packs.js.map +1 -1
  51. package/dist/domain/zod-issues.d.ts +21 -0
  52. package/dist/domain/zod-issues.d.ts.map +1 -0
  53. package/dist/domain/zod-issues.js +27 -0
  54. package/dist/domain/zod-issues.js.map +1 -0
  55. package/dist/infrastructure/frontmatter.d.ts +25 -0
  56. package/dist/infrastructure/frontmatter.d.ts.map +1 -0
  57. package/dist/infrastructure/frontmatter.js +75 -0
  58. package/dist/infrastructure/frontmatter.js.map +1 -0
  59. package/dist/templates/agent-manifests.d.ts +19 -0
  60. package/dist/templates/agent-manifests.d.ts.map +1 -0
  61. package/dist/templates/agent-manifests.js +302 -0
  62. package/dist/templates/agent-manifests.js.map +1 -0
  63. package/dist/templates/base-skills.d.ts +23 -0
  64. package/dist/templates/base-skills.d.ts.map +1 -0
  65. package/dist/templates/base-skills.js +477 -0
  66. package/dist/templates/base-skills.js.map +1 -0
  67. package/dist/templates/skill-creator-skill.d.ts +23 -0
  68. package/dist/templates/skill-creator-skill.d.ts.map +1 -0
  69. package/dist/templates/skill-creator-skill.js +235 -0
  70. package/dist/templates/skill-creator-skill.js.map +1 -0
  71. package/dist/templates/skill-references.d.ts +13 -0
  72. package/dist/templates/skill-references.d.ts.map +1 -0
  73. package/dist/templates/skill-references.js +280 -0
  74. package/dist/templates/skill-references.js.map +1 -0
  75. package/dist/templates/structure-templates.d.ts.map +1 -1
  76. package/dist/templates/structure-templates.js +15 -139
  77. package/dist/templates/structure-templates.js.map +1 -1
  78. package/dist/templates/task-conductor-skill.d.ts +1 -1
  79. package/dist/templates/task-conductor-skill.d.ts.map +1 -1
  80. package/dist/templates/task-conductor-skill.js +50 -22
  81. package/dist/templates/task-conductor-skill.js.map +1 -1
  82. package/package.json +1 -1
@@ -0,0 +1,477 @@
1
+ import { evidenceLadderReference, hypothesisPatternsReference, riskClassificationReference, severityRubricReference, } from "./skill-references.js";
2
+ import { skillCreatorReferences, skillCreatorSkill } from "./skill-creator-skill.js";
3
+ import { taskConductorSkill } from "./task-conductor-skill.js";
4
+ const planningSkill = `---
5
+ name: planning
6
+ description: Use before executing any new user brief, to turn it into a risk-classified plan with explicit ownership, acceptance criteria and a verification budget that the user can approve or reject.
7
+ version: 1.0.0
8
+ not_for: Do not use for an approved plan whose scope, tier and decisions are unchanged, and do not use it for step ordering inside a worker's own approved objective.
9
+ inputs:
10
+ - The user brief and every clarification already given
11
+ - The active project record and its skill registry
12
+ - Existing task records for related or superseded work
13
+ tools:
14
+ - File read, directory listing and symbol search
15
+ - Control-plane writes under .ai/tasks/**
16
+ outputs: approved-plan
17
+ references:
18
+ - references/risk-classification.md
19
+ ---
20
+
21
+ # Planning
22
+
23
+ ## When this applies
24
+
25
+ - A new brief arrives and no approved plan covers it.
26
+ - An approved plan's scope, risk tier or a material decision has changed.
27
+ - A worker escalated work the current plan does not authorize.
28
+
29
+ ## When it does not
30
+
31
+ - The plan exists, is approved, and nothing about it changed.
32
+ - The real question is what existing code does; that is \`codebase-exploration\`.
33
+ - The brief is one step: state the change, the owner and the proof in a single paragraph and skip the rest of this procedure.
34
+
35
+ ## Required inputs
36
+
37
+ - The brief verbatim, plus every clarification already given.
38
+ - The project record: languages, modules, commands and boundaries.
39
+ - Any prior task record this work supersedes or depends on.
40
+
41
+ Missing one of these, ask before planning. A plan built on assumed facts cannot be reviewed.
42
+
43
+ ## Procedure
44
+
45
+ 1. Restate the goal in one sentence and list the non-goals that bound it.
46
+ 2. Classify the tier using \`.ai/protocols/core/orchestration.md\`; open \`references/risk-classification.md\` when the tier is unclear or contested.
47
+ 3. Separate verified facts, assumptions and open questions; give every fact a source.
48
+ 4. Ask only the questions whose answers change the plan; carry the rest as recorded assumptions.
49
+ 5. Write acceptance criteria that name an observable outcome, never an activity.
50
+ 6. Decompose into dependency-ordered workstreams, each with one goal, explicit owned paths and one done-check.
51
+ 7. Assign a model tier and a verification budget per workstream, per \`.ai/protocols/core/model-routing.md\`.
52
+ 8. Name the conditions that must return control to the user.
53
+ 9. Present the plan and wait for explicit approval.
54
+
55
+ ## Tools
56
+
57
+ Read-only across the product tree. The only write is the plan record under \`.ai/tasks/**\`. Planning never edits product files and never dispatches before approval.
58
+
59
+ ## Verification
60
+
61
+ Walk four checks before presenting: every acceptance criterion is observable and owned; no two concurrent workstreams own the same path; every dependency points backwards; every stated fact names its source.
62
+
63
+ ## Stop and escalate
64
+
65
+ Stop when the brief admits two materially different solutions with different costs, when the requested outcome conflicts with the constitution, when a required fact cannot be verified, or when the work needs authority the user has not granted. Present the choice; never choose silently.
66
+
67
+ ## Output contract
68
+
69
+ An approved plan record holding: goal, non-goals, risk tier with justification, verified facts with sources, assumptions, workstreams with ownership and acceptance criteria, model tiers, verification budget, escalation conditions and the recorded approval.
70
+ `;
71
+ const projectDiscoverySkill = `---
72
+ name: project-discovery
73
+ description: Use to refresh a registered project's evidence-backed facts — languages, modules, package manager, commands and boundaries — after a manual sync or when the recorded snapshot no longer matches the repository.
74
+ version: 1.0.0
75
+ not_for: Do not use to answer a question about how specific code behaves, and never use it to invent structure for an empty or greenfield directory.
76
+ inputs:
77
+ - The project root and the current project record, if one exists
78
+ - Manifests, lockfiles, CI configuration and existing AI instruction files
79
+ tools:
80
+ - File read, directory listing and manifest parsing
81
+ - Control-plane writes to the project record and skill registry
82
+ outputs: project-record
83
+ ---
84
+
85
+ # Project Discovery
86
+
87
+ ## When this applies
88
+
89
+ - A project is registered for the first time.
90
+ - A manual sync was requested, or manifests changed since the last snapshot.
91
+ - A recorded command, module or stack fact no longer matches the tree.
92
+
93
+ ## When it does not
94
+
95
+ - The question concerns one file, symbol or behavior; use \`codebase-exploration\`.
96
+ - The directory has no manifest and no source. Record an empty project and stop.
97
+ - The snapshot is current. Re-reading it is cheaper than rediscovering it.
98
+
99
+ ## Required inputs
100
+
101
+ - The project root path and the scope it was registered under.
102
+ - The previous record, so the output can be reported as a delta.
103
+ - The directory traversal limits that apply to this repository.
104
+
105
+ ## Procedure
106
+
107
+ 1. Read existing AI instruction files first. They are claims about the project, recorded as claims rather than as facts.
108
+ 2. Read manifests and lockfiles before any source file: \`package.json\`, \`pom.xml\`, \`build.gradle\`, \`pyproject.toml\`, \`go.mod\`, \`Cargo.toml\`.
109
+ 3. Derive the package manager from the lockfile that exists, not from the one in common use.
110
+ 4. Take commands only from declared scripts, tasks or wrappers. Never invent a command no file declares.
111
+ 5. Read CI configuration to learn which of the declared commands are authoritative.
112
+ 6. Treat every directory with its own manifest as a module, and record its path, stack and commands separately.
113
+ 7. Record each fact with the source path that proves it; label anything inferred as a hypothesis.
114
+ 8. Stop at the evidence boundary. Architecture, intent and conventions are not facts a manifest can prove.
115
+
116
+ ## Tools
117
+
118
+ Read, list, search and manifest parsing. Writes are limited to the project record and the skill registry. Never install dependencies, never run a build, never reach the network.
119
+
120
+ ## Verification
121
+
122
+ Re-running discovery on an unchanged tree must produce a byte-identical record. Every recorded command must appear verbatim in a file you can name, and every fact must carry a source path that exists.
123
+
124
+ ## Stop and escalate
125
+
126
+ Stop before writing when two directories collapse to the same project id, when traversal hits a depth or directory-count limit, when a manifest cannot be parsed, or when declared commands contradict CI. Report the conflict; never write a truncated snapshot.
127
+
128
+ ## Output contract
129
+
130
+ An updated project record and skill registry containing modules with paths, stack facts with \`source\` and \`confidence: verified\`, commands with their working directories, plus an explicit list of what changed since the previous snapshot and what remains a hypothesis.
131
+ `;
132
+ const explorationSkill = `---
133
+ name: codebase-exploration
134
+ description: Use to answer one specific, bounded question about existing code with paths, symbols and quoted evidence, before a plan is written or an implementer is dispatched.
135
+ version: 1.0.0
136
+ not_for: Do not use for an open-ended tour of a repository, for refreshing project-wide facts (that is project-discovery), or for a question the project record or existing task evidence already answers.
137
+ inputs:
138
+ - One question and the shape its answer must take
139
+ - The read scope, and the evidence already gathered for this task
140
+ tools:
141
+ - File read, directory listing, symbol and literal search
142
+ - Read-only inspection commands named in the packet
143
+ outputs: evidence-report
144
+ ---
145
+
146
+ # Codebase Exploration
147
+
148
+ ## When this applies
149
+
150
+ - A plan or a packet depends on a fact about the code that nobody has verified.
151
+ - A worker's assumption must be confirmed before an edit is authorized.
152
+ - A reviewer needs the surrounding code a diff does not show.
153
+
154
+ ## When it does not
155
+
156
+ - The project record or a prior evidence report already answers it.
157
+ - The question is really "how should this be built?"; that is \`planning\`.
158
+ - The goal is to fix something. Exploration produces evidence, never edits.
159
+
160
+ ## Required inputs
161
+
162
+ - One question, with the answer shape it requires.
163
+ - The read scope: paths in bounds, and paths out of bounds.
164
+ - Prior evidence for this task, so nothing is rediscovered.
165
+
166
+ ## Procedure
167
+
168
+ 1. Restate the question and what a sufficient answer looks like.
169
+ 2. Check the project record and prior evidence; if the answer is there, return it with its provenance and stop.
170
+ 3. Choose entry points: an exported symbol, a route, a UI literal, a configuration key, a failing test name.
171
+ 4. Search by name and literal before opening files; open a file only when a hit implicates it.
172
+ 5. Follow the chain in the direction the question needs — callers for impact, callees for behavior.
173
+ 6. Quote the smallest excerpt that proves each claim, with \`path:line\`.
174
+ 7. Record the conventions the surrounding code enforces and the risks a change here would face.
175
+ 8. Stop at the first sufficient answer, and state what you did not look at.
176
+
177
+ ## Tools
178
+
179
+ Read, list and search, plus read-only inspection commands the packet names. No writes of any kind, and no command that builds, installs or mutates state.
180
+
181
+ ## Verification
182
+
183
+ Every claim traces to a quoted \`path:line\`. Nothing is labelled verified on the strength of a name or a comment. The answer matches the shape the question asked for, and a second reader could reach the same conclusion from the citations alone.
184
+
185
+ ## Stop and escalate
186
+
187
+ Escalate when the question is ambiguous, when the answer requires a path outside the read scope, when the search budget is spent without converging, or when the code contradicts a fact the packet stated.
188
+
189
+ ## Output contract
190
+
191
+ An evidence report: the question, the answer, verified facts with \`path:line\` provenance, inferences labelled as inferences, relevant conventions and risks, files inspected, unanswered questions and a confidence statement.
192
+ `;
193
+ const implementationSkill = `---
194
+ name: implementation
195
+ description: Use when an approved plan and a task packet exist, to make the smallest coherent product change that satisfies one objective inside its declared ownership and to prove it.
196
+ version: 1.0.0
197
+ not_for: Do not use without an approved objective and explicit ownership, to explore unfamiliar code (codebase-exploration), or to chase an unexplained failure (debugging).
198
+ inputs:
199
+ - The objective, acceptance criteria and owned, readable and forbidden paths
200
+ - Verification commands, the browser policy and verified facts with provenance
201
+ tools:
202
+ - File edits limited to owned paths, and reads within the read scope
203
+ - The verification commands named in the packet
204
+ outputs: completion-packet
205
+ ---
206
+
207
+ # Implementation
208
+
209
+ ## When this applies
210
+
211
+ - A packet grants one objective, explicit ownership and acceptance criteria.
212
+ - A follow-up delta packet extends an already approved objective.
213
+
214
+ ## When it does not
215
+
216
+ - Ownership or criteria are missing or ambiguous. Ask first.
217
+ - The cause of the required behavior is unknown; that is \`debugging\`.
218
+ - The work is judging someone else's diff; that is \`code-review\`.
219
+
220
+ ## Required inputs
221
+
222
+ - The objective and its acceptance criteria.
223
+ - Owned, readable and forbidden paths.
224
+ - Verification commands and the browser policy for this task.
225
+ - Verified facts and decisions, each with provenance.
226
+
227
+ ## Procedure
228
+
229
+ 1. Confirm objective, criteria and ownership are unambiguous; ask rather than guess.
230
+ 2. Read the current content of every file you will change. Never edit from remembered or summarized content.
231
+ 3. Match the file you are in: its naming, layering, error handling and test style are the local standard, whatever your own preference.
232
+ 4. Change one behavior at a time, keeping the tree compiling or passing between units.
233
+ 5. Verify incrementally at the cheapest sufficient rung of \`.ai/protocols/core/verification.md\`; do not batch every check to the end.
234
+ 6. Add or update only the tests an acceptance criterion requires, and make each new test fail before the change.
235
+ 7. Re-read the complete diff hunk by hunk, deleting anything the objective does not require.
236
+ 8. Assemble the completion packet, including the checks deliberately skipped and the decisions taken.
237
+
238
+ ## Tools
239
+
240
+ Edits limited to owned paths; reads limited to the read scope; the verification commands the packet names; the project's registered technology skills when they match the owned work. Never add a dependency, a tool or a browser harness as a side effect.
241
+
242
+ ## Verification
243
+
244
+ Each criterion maps to named evidence. Every new test fails before the change and passes after it. The diff carries no unrelated formatting, no debug output and no file outside ownership. Every command is recorded with its outcome.
245
+
246
+ ## Stop and escalate
247
+
248
+ Stop when the objective requires a forbidden path, when criteria conflict with the code, when a packet fact proves false, when a required check fails for a cause outside the objective, when the change is outgrowing the approved scope, or when the only remaining idea repeats an approach that already failed.
249
+
250
+ ## Output contract
251
+
252
+ A completion packet matching \`.ai/schemas/completion-packet.schema.json\`: status, summary, changed_files, commands_run with outcomes, checks_skipped, loaded_skills, decisions_made and unresolved_risks.
253
+ `;
254
+ const verificationSkill = `---
255
+ name: verification
256
+ description: Use before any implementation is reported complete, to choose the cheapest evidence that actually proves each approved claim and to record what ran, what failed and what was deliberately skipped.
257
+ version: 1.0.0
258
+ not_for: Do not use to judge whether a change is a good idea (that is code-review), and do not use it to run checks unrelated to the approved claims.
259
+ inputs:
260
+ - The approved acceptance criteria and the diff that claims to satisfy them
261
+ - The verification commands and browser policy the packet allows
262
+ tools:
263
+ - Diff, search and static inspection
264
+ - The project's existing type, lint and test commands
265
+ outputs: verification-record
266
+ references:
267
+ - references/evidence-ladder.md
268
+ ---
269
+
270
+ # Verification
271
+
272
+ ## When this applies
273
+
274
+ - A worker is about to report an objective complete.
275
+ - An orchestrator must judge whether a returned claim is supported.
276
+ - A reviewer must confirm that reported evidence proves what it claims.
277
+
278
+ ## When it does not
279
+
280
+ - Nothing has changed yet. Verification proves claims, it does not explore.
281
+ - The claim is about taste or design; that is \`code-review\`.
282
+ - The evidence was produced and read in this same step and nothing has changed since.
283
+
284
+ ## Required inputs
285
+
286
+ - Each approved acceptance criterion, stated as a claim.
287
+ - The diff, and the commands the packet authorizes.
288
+ - The risk tier, which sets whether independent review is required.
289
+
290
+ ## Procedure
291
+
292
+ 1. List the approved criteria; each becomes exactly one claim to prove.
293
+ 2. For each claim, name the observation that would show it false.
294
+ 3. Choose the lowest rung of \`.ai/protocols/core/verification.md\` that can produce that observation; \`references/evidence-ladder.md\` maps common claims to sufficient evidence.
295
+ 4. Run the check exactly as recorded, and read its output rather than its exit code.
296
+ 5. Confirm the check had subjects: a suite that matched zero tests proves nothing.
297
+ 6. Stop at the first sufficient evidence for each claim; do not climb further for reassurance.
298
+ 7. Record every command, working directory and outcome, plus every check not run and why.
299
+ 8. Order independent review where the protocol requires it for this tier.
300
+
301
+ ## Tools
302
+
303
+ Diff, search and static inspection; the type, lint and test commands the project already declares. A headed browser stays opt-in under the protocol, and no verification step may create test or browser infrastructure that did not exist.
304
+
305
+ ## Verification
306
+
307
+ Verify the verification: every criterion has exactly one named evidence; no command was paraphrased; no pass is reported for a check that did not execute; the skipped list is explicit rather than implied.
308
+
309
+ ## Stop and escalate
310
+
311
+ Escalate when a check fails for a cause outside the change, when no available evidence can settle a criterion, when proving a claim would require new infrastructure or a browser, or when the evidence contradicts the completion claim.
312
+
313
+ ## Output contract
314
+
315
+ A verification record: claim to command to outcome, the rung reached for each claim, checks skipped with reasons, and an explicit statement naming any criterion that remains unproven.
316
+ `;
317
+ const debuggingSkill = `---
318
+ name: debugging
319
+ description: Use for a defect, a flaky test or an unexplained failure, to reach an evidenced root cause and land the smallest fix that removes the cause rather than the symptom.
320
+ version: 1.0.0
321
+ not_for: Do not use for a known change with a known cause (that is implementation), and do not use it to explore code that is not failing.
322
+ inputs:
323
+ - The symptom, with the exact command, input or trigger that produces it
324
+ - Expected versus actual behavior, and any prior failed attempt
325
+ tools:
326
+ - Reproduction and verification commands from the packet
327
+ - Temporary instrumentation, removed before completion
328
+ outputs: completion-packet
329
+ references:
330
+ - references/hypothesis-patterns.md
331
+ ---
332
+
333
+ # Debugging
334
+
335
+ ## When this applies
336
+
337
+ - Observed behavior contradicts expected behavior and nobody can say why.
338
+ - A test fails intermittently, or fails only in one environment.
339
+ - A previous fix did not hold, or fixed the symptom and not the cause.
340
+
341
+ ## When it does not
342
+
343
+ - The cause is already known and evidenced; implement the fix directly.
344
+ - Nothing is failing and the goal is understanding; use \`codebase-exploration\`.
345
+ - The failure is an unmet requirement rather than a defect; that is planning work.
346
+
347
+ ## Required inputs
348
+
349
+ - The exact command, input or trigger, and its full output.
350
+ - Expected versus actual behavior, and when it last worked if known.
351
+ - Owned paths, verification commands and every attempt already made.
352
+
353
+ ## Procedure
354
+
355
+ 1. Reproduce the failure and record the exact command and output. If it will not reproduce, that is the first finding.
356
+ 2. Reduce to a minimal failing case, and note the nearest case that does not fail.
357
+ 3. Write ranked hypotheses, each naming a mechanism and predicting an observation; \`references/hypothesis-patterns.md\` holds the failure catalogue when the list looks thin.
358
+ 4. Run the cheapest observation that would disprove the top hypothesis; discard hypotheses rather than defending them.
359
+ 5. Name the root cause and the mechanism that turns it into the symptom.
360
+ 6. Add a regression test that fails before the fix and passes after it.
361
+ 7. Apply the smallest fix at the cause, then rerun the reproduction and the affected checks.
362
+ 8. Remove all instrumentation and confirm the diff contains only the fix and its test.
363
+
364
+ ## Tools
365
+
366
+ The reproduction and verification commands the packet names, search and read across the failing path, and temporary instrumentation that must not survive into the diff. Never widen a catch, a timeout or a tolerance to make a symptom disappear.
367
+
368
+ ## Verification
369
+
370
+ The minimal case fails before the fix and passes after it, using the same command both times. The mechanism is stated in one sentence. You can explain why the defect did not surface earlier or elsewhere. No instrumentation, skipped test or debug output remains.
371
+
372
+ ## Stop and escalate
373
+
374
+ Escalate when the failure will not reproduce, when the root cause lies outside the owned paths, when the fix would change a public contract or a data shape, or when two hypotheses remain and no available evidence separates them.
375
+
376
+ ## Output contract
377
+
378
+ A completion packet matching \`.ai/schemas/completion-packet.schema.json\` with \`root_cause\` populated: the mechanism, the hypotheses disproved, the regression test, and the reproduction evidence before and after.
379
+ `;
380
+ const codeReviewSkill = `---
381
+ name: code-review
382
+ description: Use for independent review of a completed diff, to judge it against the approved task and its evidence and to return findings by severity with an explicit verdict.
383
+ version: 1.0.0
384
+ not_for: Do not use to review your own implementation, to review an unfinished change, or to enforce style the project does not already enforce.
385
+ inputs:
386
+ - The approved plan, its acceptance criteria and the diff under review
387
+ - The completion packet and the verification evidence it reports
388
+ tools:
389
+ - Diff and file read across the changed area
390
+ - Re-running the verification commands the packet reports
391
+ outputs: review-report
392
+ references:
393
+ - references/severity-rubric.md
394
+ ---
395
+
396
+ # Code Review
397
+
398
+ ## When this applies
399
+
400
+ - A worker returned a completion packet for material standard or high-risk work.
401
+ - The change crosses a module, contract or security boundary.
402
+ - Reported evidence needs an independent party to confirm it.
403
+
404
+ ## When it does not
405
+
406
+ - You wrote the diff. Independence is the point of this skill.
407
+ - The work is trivial under \`.ai/protocols/core/verification.md\` and its claim is settled by the diff itself.
408
+ - The change is still being written; review the finished diff.
409
+
410
+ ## Required inputs
411
+
412
+ - The approved plan and the acceptance criteria it fixed.
413
+ - The complete diff, not a summary of it.
414
+ - The completion packet, with the commands it reports and their outcomes.
415
+
416
+ ## Procedure
417
+
418
+ 1. Read the approved criteria before the diff, so expectation precedes exposure.
419
+ 2. Read every changed hunk, then the surrounding code that gives it meaning.
420
+ 3. Map each acceptance criterion to the hunk and evidence that satisfies it; a criterion with no hunk is a blocking finding.
421
+ 4. Work the checklist in \`references/severity-rubric.md\`: scope, criteria, edges, errors, boundaries, tests, evidence, leftovers.
422
+ 5. Test the reported evidence — does the named command actually prove the claim it is attached to?
423
+ 6. Classify each finding by the rubric's severities and drop anything with no stated consequence.
424
+ 7. Issue one verdict: approved, approved with required follow-up, or rejected.
425
+
426
+ ## Tools
427
+
428
+ Diff and file read across the changed area, and re-runs of the commands the packet already reports. Never edit the implementation, and never fix a finding yourself.
429
+
430
+ ## Verification
431
+
432
+ Every acceptance criterion carries a verdict. Every blocking finding names a \`path:line\`, a mechanism and a consequence. The review rests on the diff rather than on the worker's summary, and the absence of blocking findings is stated explicitly rather than implied.
433
+
434
+ ## Stop and escalate
435
+
436
+ Escalate when the diff exceeds the approved scope, when a criterion cannot be judged from the available evidence, when the change is unsafe for a reason outside the review brief, or when the packet reports a check that did not run.
437
+
438
+ ## Output contract
439
+
440
+ A review report: verdict, findings ordered by severity with \`path:line\` and consequence, criteria judged satisfied and unsatisfied, evidence re-run with outcomes, and an explicit statement when no blocking finding exists.
441
+ `;
442
+ export const BASE_SKILL_DOCUMENTS = [
443
+ {
444
+ id: "planning",
445
+ skill: planningSkill,
446
+ references: [
447
+ { fileName: "risk-classification.md", content: riskClassificationReference },
448
+ ],
449
+ },
450
+ { id: "project-discovery", skill: projectDiscoverySkill, references: [] },
451
+ { id: "codebase-exploration", skill: explorationSkill, references: [] },
452
+ { id: "implementation", skill: implementationSkill, references: [] },
453
+ {
454
+ id: "verification",
455
+ skill: verificationSkill,
456
+ references: [{ fileName: "evidence-ladder.md", content: evidenceLadderReference }],
457
+ },
458
+ {
459
+ id: "debugging",
460
+ skill: debuggingSkill,
461
+ references: [
462
+ { fileName: "hypothesis-patterns.md", content: hypothesisPatternsReference },
463
+ ],
464
+ },
465
+ {
466
+ id: "code-review",
467
+ skill: codeReviewSkill,
468
+ references: [{ fileName: "severity-rubric.md", content: severityRubricReference }],
469
+ },
470
+ { id: "task-conductor", skill: taskConductorSkill, references: [] },
471
+ {
472
+ id: "skill-creator",
473
+ skill: skillCreatorSkill,
474
+ references: skillCreatorReferences,
475
+ },
476
+ ];
477
+ //# sourceMappingURL=base-skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-skills.js","sourceRoot":"","sources":["../../src/templates/base-skills.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AA0B/D,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkErB,CAAC;AAEF,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4D7B,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DxB,CAAC;AAEF,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4D3B,CAAC;AAEF,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DzB,CAAC;AAEF,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DtB,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DvB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAiC;IAChE;QACE,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,aAAa;QACpB,UAAU,EAAE;YACV,EAAE,QAAQ,EAAE,wBAAwB,EAAE,OAAO,EAAE,2BAA2B,EAAE;SAC7E;KACF;IACD,EAAE,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,EAAE,EAAE;IACzE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,EAAE;IACvE,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,EAAE,EAAE;IACpE;QACE,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,iBAAiB;QACxB,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;KACnF;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,cAAc;QACrB,UAAU,EAAE;YACV,EAAE,QAAQ,EAAE,wBAAwB,EAAE,OAAO,EAAE,2BAA2B,EAAE;SAC7E;KACF;IACD;QACE,EAAE,EAAE,aAAa;QACjB,KAAK,EAAE,eAAe;QACtB,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;KACnF;IACD,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,EAAE,EAAE;IACnE;QACE,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,iBAAiB;QACxB,UAAU,EAAE,sBAAsB;KACnC;CACF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { FileDefinition } from "../domain/generation.ts";
2
+ import type { SkillReferenceDocument } from "./base-skills.ts";
3
+ export declare const skillCreatorSkill = "---\nname: skill-creator\ndescription: Use at task completion to record non-obvious project discoveries as sourced observations, and to propose, author, review and activate a generated project skill once one observation has been confirmed by three distinct tasks or corrected by the user.\nnot_for: Mid-task use, first sessions, and cold repository scans. A trivial task may record observations but never proposes a skill.\nversion: 1.0.0\nreferences:\n - references/observation-ledger.md\n - references/generated-skill-contract.md\n - references/retirement.md\n---\n\n# Skill Creator\n\nThe system earns a skill; it never assumes one. Observations are cheap and unattended. Promotion is rare, approved by the user, written by a worker and verified by an independent reviewer.\n\n## When this applies\n\n- At the end of a completed task, while writing the final report, for every worker completion packet.\n- When the user corrects an approach (\"not that way, this way\"): record the observation and propose immediately.\n- When `doctor` reports stale evidence, or a worker identifies a stale or superseded project skill and a natural pause has arrived.\n\n## When it does not\n\n- Mid-task. Recording is a completion step; proposing interrupts nothing that is still running.\n- On a first session, or from a repository scan. Day one has facts, not procedures; the project record already holds the facts.\n- For anything a bundled technology skill already covers, or for a discovery with no source path.\n- Never propose more than one skill in one final report. If several are ready, take the highest `count` and leave the rest.\n\n## Required inputs\n\n- The completed task's id, and the worker completion packets with their `commands_run`, `decisions_made` and source paths.\n- `.ai/tasks/observations.yaml` (the ledger) and the current contents of `.ai/skills/project/`.\n- For a proposal: the user's explicit approval, and the active project-skill count.\n\n## Procedure\n\n1. **Qualify.** An observation must be non-obvious, repeatable and carry at least one source path. No source, no observation. Discard anything a bundled skill already states.\n2. **Record.** Append or update the entry in `.ai/tasks/observations.yaml` \u2014 the orchestrator's only writable area, so this needs no constitutional change. Increment `tasks_seen` exactly once per completed task. Format and expiry: `references/observation-ledger.md`.\n3. **Confirm.** Add the task id to `confirmed_by` only if it is not already there. The same task hitting the same wall twice counts once. Set `count` to the number of distinct ids and `last_seen_task_index` to `tasks_seen`.\n4. **Decide.** At `count` 3, set `status: ready-to-propose`. A user correction sets `origin: user-correction` and is ready at once.\n5. **Budget.** Before proposing, count `status: active` skills under `.ai/skills/project/`. At 12, propose a retirement first and let the user choose; do not propose an addition alongside it.\n6. **Propose.** In the final report, state the claim, its sources and its confirming task ids, and ask. On approval continue; on refusal set `status: declined`, which is permanent \u2014 never ask again for that id.\n7. **Author.** Delegate to an implementer: write `.ai/skills/project/<id>/SKILL.md` against the contract in `references/generated-skill-contract.md`.\n8. **Review.** Delegate to an independent reviewer, never the author. The reviewer opens every `source`, confirms the claim it backs and recomputes its digest.\n9. **Activate.** Only after the review passes, and only through two writes: the implementer sets `status: active` in the skill's own frontmatter, and the orchestrator sets the observation to `status: promoted` with `promoted_to: <id>`. There is no registry entry to make \u2014 `.ai/projects/<id>.skills.yaml` is regenerated by every `sync` and sits outside `.ai/tasks/**`.\n10. **Maintain.** Apply stale-evidence and manually identified supersession signals from `references/retirement.md` at the next pause. The first slice has no skill-usage telemetry, so usage-based retirement is manual.\n\n## Tools\n\nFile reads for sources; the ledger write; `syn doctor` for the contract, budget, size and digest checks; delegation to an implementer and a reviewer. No model call inside the CLI, and no external skill import.\n\n## Verification\n\n- `syn doctor` reports no `generated.*` error for the new skill.\n- Every `evidence` entry names a file that exists inside the root and whose digest matches.\n- The active project-skill count is at most 12 and the file is at most 15KB.\n- The reviewer's report names each claim and the source it was checked against.\n\n## Stop and escalate\n\n- Stop if a claim cannot be traced to a source, if the reviewer rejects any claim, or if the author and the reviewer are the same worker.\n- Stop if the proposal would exceed the budget without an approved retirement.\n- Stop and ask if the content would belong in a protocol or the constitution. A generated skill holds `priority: skill` only; it never overrides a core protocol and never claims constitutional authority.\n- Never delete a skill. Retirement is proposed, then the implementer moves the file to `RETIRED.md` and sets `status: retired`, and the orchestrator records it in the ledger.\n\n## Output contract\n\nLedger entries are the ordinary output. A promotion additionally yields: one proposal paragraph in the final report; on approval, `.ai/skills/project/<id>/SKILL.md` with complete evidence frontmatter and `status: active`; a reviewer verdict per claim; and the observation moved to `status: promoted` with `promoted_to` naming the skill.\n";
4
+ /**
5
+ * The reference documents of the `skill-creator` base skill. `BASE_SKILL_DOCUMENTS` in
6
+ * `base-skills.ts` is the single place that turns these into files, exactly as it does for
7
+ * every other base skill, so the skill and its references can never be emitted twice.
8
+ */
9
+ export declare const skillCreatorReferences: readonly SkillReferenceDocument[];
10
+ /**
11
+ * The control-plane files the distillation loop needs beside the skill itself: the Git-tracked
12
+ * observation ledger and the ignore rule that keeps per-task working directories out of history.
13
+ * They are canonical structure rather than skill content, so `createStructureFiles` emits them.
14
+ *
15
+ * The two carry different write policies on purpose. The ignore rule is pure canonical policy
16
+ * with no user state in it, so `--force` may refresh it. The ledger is the opposite: from the
17
+ * first completed task it holds approved, promoted and permanently declined observations that
18
+ * only the orchestrator and the user may change. It is therefore seeded once and never
19
+ * rewritten — design D12 and §9 forbid destroying user-approved state, and `syn init --force`
20
+ * is the documented migration command, so it must not be the command that erases it.
21
+ */
22
+ export declare const skillCreatorLedgerFiles: readonly FileDefinition[];
23
+ //# sourceMappingURL=skill-creator-skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-creator-skill.d.ts","sourceRoot":"","sources":["../../src/templates/skill-creator-skill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,yBAAyB,CAAC;AAG/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,8hLAoE7B,CAAC;AAsIF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,sBAAsB,EAInE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,cAAc,EAQ5D,CAAC"}