pi-anchorloop 0.0.0-stage → 2.0.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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -2
  3. package/README.zh-TW.md +64 -0
  4. package/hooks/validate_tool_use.py +88 -0
  5. package/hooks/validators/__init__.py +1 -0
  6. package/hooks/validators/constants.py +47 -0
  7. package/hooks/validators/durable_validator.py +89 -0
  8. package/hooks/validators/rule_validator.py +42 -0
  9. package/hooks/validators/skill_validator.py +144 -0
  10. package/hooks/validators/utils.py +71 -0
  11. package/package.json +44 -4
  12. package/pi/anchor-gate.ts +84 -0
  13. package/pi/decision-tool.ts +88 -0
  14. package/pi/second-thought.ts +242 -0
  15. package/pi/support/validators.ts +403 -0
  16. package/pi/ttsr.ts +516 -0
  17. package/pi/validate-tool-use.ts +27 -0
  18. package/skills/agent-terse/SKILL.md +46 -0
  19. package/skills/anchorloop/PRINCIPLES.md +34 -0
  20. package/skills/anchorloop/SKILL.md +76 -0
  21. package/skills/anchorloop/playbooks/autonomous-run.md +12 -0
  22. package/skills/anchorloop/playbooks/pause.md +10 -0
  23. package/skills/anchorloop/playbooks/pickup.md +11 -0
  24. package/skills/answering/SKILL.md +19 -0
  25. package/skills/answering/playbooks/compare.md +9 -0
  26. package/skills/answering/playbooks/explain.md +9 -0
  27. package/skills/coding/MINI-SDD.md +61 -0
  28. package/skills/coding/SKILL.md +27 -0
  29. package/skills/coding/playbooks/bug-fix.md +11 -0
  30. package/skills/coding/playbooks/feature.md +15 -0
  31. package/skills/coding/playbooks/perf.md +10 -0
  32. package/skills/coding/playbooks/prototype.md +14 -0
  33. package/skills/coding/playbooks/refactoring.md +12 -0
  34. package/skills/domain-modeling/ADR-FORMAT.md +47 -0
  35. package/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  36. package/skills/domain-modeling/SKILL.md +48 -0
  37. package/skills/grilling/SKILL.md +30 -0
  38. package/skills/human-feedback/SKILL.md +83 -0
  39. package/skills/inspecting/SKILL.md +49 -0
  40. package/skills/inspecting/playbooks/diff-review.md +57 -0
  41. package/skills/inspecting/playbooks/qa-release.md +9 -0
  42. package/skills/investigating/SKILL.md +22 -0
  43. package/skills/investigating/playbooks/diagnose.md +9 -0
  44. package/skills/investigating/playbooks/research.md +9 -0
  45. package/skills/solid-loop/SKILL.md +50 -0
  46. package/skills/solid-loop/playbooks/apply-friction.md +15 -0
  47. package/skills/solid-loop/playbooks/author-skill.md +11 -0
  48. package/skills/solid-loop/playbooks/bootstrap.md +10 -0
  49. package/skills/solid-loop/references/template-skill.md +26 -0
  50. package/skills/writing/SKILL.md +16 -0
  51. package/skills/writing/playbooks/comments.md +10 -0
  52. package/skills/writing/playbooks/draft.md +10 -0
  53. package/skills/writing/playbooks/tighten.md +9 -0
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: inspecting
3
+ description: Use when auditing or reviewing a specific target, diff, commit, or spec, or running final QA or a release-readiness check.
4
+ ---
5
+
6
+ # Inspecting
7
+
8
+ Run the loop in [../anchorloop/SKILL.md](../anchorloop/SKILL.md). The anchor is that every scoped item has a verdict and its evidence.
9
+
10
+ When a reviewer role contract is present, it governs scope, evidence, and report format; add only the Standards and Spec axes.
11
+
12
+ ## Playbooks
13
+
14
+ - [diff-review](playbooks/diff-review.md): a branch, pull request, worktree, or change set.
15
+ - [qa-release](playbooks/qa-release.md): final exploratory QA or release readiness.
16
+
17
+ Any other target runs the flow below directly.
18
+
19
+ ## Inspection Flow
20
+
21
+ ### Phase 1: Scale the Inspection
22
+
23
+ Choose the lightest mode that can support a trustworthy conclusion:
24
+
25
+ - **Focused:** one narrow target or claim. Inspect it directly.
26
+ - **Standard:** several clear items. State a concise checklist, then proceed.
27
+ - **High-risk or ambiguous:** security, production, destructive effects, or unclear boundaries. Present the plan; wait for confirmation only in a review the user started directly.
28
+
29
+ Include only dimensions relevant to the request: correctness, edge cases, architecture, security, performance, conventions, dependencies, and side effects. Take the blocking severity and the use to judge against from the assignment; without them, judge realistic use and count a rare edge case as blocking only when it loses, silently overwrites, or corrupts data.
30
+
31
+ ### Phase 2: Verify
32
+
33
+ For each scoped item:
34
+
35
+ 1. Identify the evidence that would prove or disprove it.
36
+ 2. Gather that evidence directly. Invoke `investigating` only when the item requires substantial research or cross-source verification.
37
+ 3. Record a verdict: pass, fail, needs attention, or insufficient evidence.
38
+ 4. Grade the evidence as `investigating` defines. For a change judged safe, name the one fact its safety rests on and take it to `executed`.
39
+
40
+ ### Phase 3: Report
41
+
42
+ ```
43
+ | Check Item | Verdict | Evidence / Notes |
44
+ |------------|---------|------------------|
45
+ | [item] | [verdict] | [evidence] |
46
+ ```
47
+
48
+ Lead with the conclusion. Prioritize failures and recommended actions by impact. Name any unverified boundary instead of implying full coverage.
49
+
@@ -0,0 +1,57 @@
1
+ # Diff review
2
+
3
+ **You own a separate verdict on each axis, measured from a fixed point.**
4
+
5
+ ## Establish the evidence boundary
6
+
7
+ 1. Resolve the fixed point supplied by the user. When none is supplied, use the
8
+ clearly configured upstream or merge target; ask only when competing bases
9
+ would materially change the diff.
10
+ 2. Resolve its merge-base with `HEAD`. Capture the committed range, commit list,
11
+ `git diff HEAD` for staged and unstaged work, and `git status --short` for
12
+ untracked files. Inspect relevant untracked files directly. Stop with
13
+ insufficient evidence when the ref is invalid or the whole change set is
14
+ empty.
15
+ 3. Identify the governing spec in this order: user-supplied artifact, issue or
16
+ change reference in commits, branch-matching `docs/specs/` material, then the
17
+ confirmed conversation. Report “no spec available” when none can be proven.
18
+ 4. Identify repository standards, project instructions, ADRs, and relevant
19
+ architectural precedent.
20
+
21
+ ## Review independently
22
+
23
+ Keep the axes separate even when evaluated in one session.
24
+
25
+ ### Standards
26
+
27
+ Find each documented-standard violation and cite its source. Tool-enforced style
28
+ is left to the tool. Use these smell heuristics only as judgment calls, with
29
+ project precedent taking priority:
30
+
31
+ - mysterious names and primitive domain concepts
32
+ - duplicated logic or recurring conditionals
33
+ - data clumps and feature envy
34
+ - shotgun surgery or divergent responsibilities
35
+ - speculative abstractions, pass-through middle layers, and message chains
36
+
37
+ ### Spec
38
+
39
+ Map each requirement to the diff and report:
40
+
41
+ - missing or partial behavior
42
+ - behavior outside the approved scope
43
+ - behavior that is present but implemented incorrectly
44
+ - missing evidence for a claimed result
45
+
46
+ Quote or point to the governing requirement for each finding. When no spec is
47
+ available, mark this axis insufficient evidence instead of reconstructing intent
48
+ from the implementation.
49
+
50
+ **Reply:** separate `Standards` and `Spec` verdicts with file/hunk evidence, and
51
+ a finding count and worst issue within each axis, never one combined score,
52
+ because success on one axis cannot mask failure on the other.
53
+
54
+ ---
55
+
56
+ Adapted from [mattpocock/skills](https://github.com/mattpocock/skills)
57
+ `code-review` (MIT License, Copyright (c) 2026 Matt Pocock).
@@ -0,0 +1,9 @@
1
+ # QA and release readiness
2
+
3
+ **You own the findings ledger.** Use an active Mini SDD `verification.md` as the ledger; otherwise the project's QA convention, or `docs/qa/discover-qa-YYYY-MM-DD.md` when findings must persist.
4
+
5
+ 1. Discover: record the scope, version or branch, environment, and primary flows, then every unexpected behavior with reproduction steps. Cover only the edges that matter here: errors, boundaries, concurrency, permissions, data consistency. Discovery ends when every declared flow was exercised and every observation is in the ledger.
6
+ 2. Resolve each finding: trace it to a falsifiable root-cause hypothesis, hand a source fix to `coding` with the finding and repro as decision input, and take the anchor evidence it returns as the re-check. Record the evidence or the unresolved gap before the next finding.
7
+ 3. Commits and pushes belong to the workflow that authorized them.
8
+
9
+ **Reply:** discovered, resolved, and deferred findings with evidence and owner. QA passes only when no unresolved finding contradicts the release criteria.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: investigating
3
+ description: Use when researching questions, diagnosing root causes without fixing them, or gathering evidence.
4
+ ---
5
+
6
+ # Investigating
7
+
8
+ Run the loop in [../anchorloop/SKILL.md](../anchorloop/SKILL.md). The anchor is the exact question and its completion boundary: answered, or the missing evidence named precisely.
9
+
10
+ 1. Gather evidence through the playbook below that fits the question.
11
+ 2. Cross-check material claims and resolve source conflicts.
12
+ 3. Grade each material claim by its strongest evidence: asserted, cited
13
+ (`file:line` or primary source), reasoned (the failure path walked and shown
14
+ not to reach), executed (a script or test against the real code), or
15
+ reproduced (observed in the running system). A claim with no evidence is
16
+ `unknown`.
17
+ 4. Report the reasoning chain with each material claim's source and grade beside it.
18
+
19
+ ## Playbooks
20
+
21
+ - [research](playbooks/research.md): how something works, what is true, or why it was built this way.
22
+ - [diagnose](playbooks/diagnose.md): why a running system misbehaves, when the deliverable is a diagnosis rather than a fix.
@@ -0,0 +1,9 @@
1
+ # Diagnose
2
+
3
+ **You own the diagnosis.** The deliverable explains the symptom; a fix goes to the `coding` bug-fix playbook.
4
+
5
+ 1. Observe the symptom first through logs, metrics, traces, a profile, or a reproduction, before forming a theory from code.
6
+ 2. Write the candidate causes with the observation each predicts, and rule them out one at a time against runtime evidence.
7
+ 3. Confirm the surviving mechanism by a prediction that would fail if it were wrong.
8
+
9
+ **Reply:** the symptom as observed, the mechanism with its evidence grade, the causes ruled out and how, and what a fix must change.
@@ -0,0 +1,9 @@
1
+ # Research
2
+
3
+ **You own the answer.** Read-only: the deliverable is a cited answer or a recommendation, not a change.
4
+
5
+ 1. Code: LSP (`read_symbol`) for symbols and ast-grep for structure; text search for prose, configuration, and literals; history (`git log -S`, blame) when the question is why or since when.
6
+ 2. External facts: current primary sources (official documentation, source code, specifications, first-party APIs) over summaries of them.
7
+ 3. **Observe, don't ask.**
8
+
9
+ **Reply:** the answer first, then the chain with each claim's source and grade; for a choice, a trade-off table and a recommendation, pushing back when the premise is wrong.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: solid-loop
3
+ description: Use when creating, editing, or auditing agent skills and instructions, applying friction notes, or bootstrapping or overhauling a project's agent system.
4
+ ---
5
+
6
+ # Solid Loop
7
+
8
+ Run the loop in [../anchorloop/SKILL.md](../anchorloop/SKILL.md). The anchor is `uv run python hooks/validate_all.py .` or the project's own validator, clean, and every edited section passing the no-op test.
9
+
10
+ The root virtue is **predictability**: each instruction sends the next run straight to the work, with no detour and no unneeded read.
11
+
12
+ ## Placement
13
+
14
+ Put each fact where it stays true. One that holds for every task type goes to the `anchorloop` core; one that holds for one task type goes to its entry skill or playbook; one that holds for one project goes to that project's `AGENTS.md` or `CLAUDE.md`. A multi-step procedure no skill owns becomes a playbook, or a skill when no entry fits.
15
+
16
+ ## Mechanism
17
+
18
+ Enforce at the highest level that works, because nothing fails when an agent skips prose: architecture that removes the wrong path; a script for repeated deterministic work; a type, lint, or test; a tool-loop lever (pi extension hook, stream rule, validator) for a check the model demonstrably skips, with a message that names the fix. Prove the check fails on the recorded mistake. Prose is for judgment calls. A `Found` fact the agent system already states in prose is a repeat: escalate it in the same change. List each enforced rule beside its enforcer in the owning instruction file's rule table, and drop the row once the mistake can no longer happen.
19
+
20
+ ## Hold the Size
21
+
22
+ Pair each added sentence with a merge or deletion in the same file, so the file ends no longer than it began. When a fix exposes one fact stated in several places, keep one authoritative statement and replace the rest with a pointer or delete them. Run the no-op test on every section you edited and delete each sentence that fails. Keep each `SKILL.md` under 300 lines by moving reference into `references/` or a playbook.
23
+
24
+ ## Craft Levers
25
+
26
+ - **Information hierarchy**: Ordered actions are steps, co-located rules are reference, and templates or deep catalogs live behind explicit context pointers.
27
+ - **Leading words**: Anchor behavior with compact pretrained concepts (*tight*, *red*, *tracer*, *reality anchor*) instead of spelled-out explanations.
28
+ - **Description as hook**: Write the situation in the user's own words that should send them here, assertively, because models under-trigger.
29
+ - **Completion criteria**: Make each criterion checkable, and demanding enough to drive thorough legwork.
30
+ - **Explain why**: Put the consequence beside the rule, and reserve capitals and absolutes for the one rule that causes real damage, stated once.
31
+ - **Name the shortcut**: List the excuses the model will reach for as excuse → reality pairs, and turn adjectives into self-test questions.
32
+ - **No-op test**: Evaluate each sentence in isolation and delete the ones that do not change behavior relative to the model's default.
33
+ - **Single source of truth**: Give each operational contract one canonical home.
34
+ - **Positive steering**: State the target behavior, because a prohibition names the unwanted pattern and makes it more likely; a prohibition or discipline skill keeps a negation only as an earned red line.
35
+ - **Pin derived copies**: Record the upstream path and revision beside the credit of a skill, rule, or role derived from another source, and keep a check that fails when that upstream changes, so the derivation is redone instead of drifting.
36
+ - **Earn the red line**: Admit a red line only when an observed failure backs it (a friction note's `Found` or a bare-run failure) and its reason or excuse → reality pair rides with it; delete the rest. The validator flags red-line inflation as an advisory.
37
+
38
+ ## Playbooks
39
+
40
+ - [apply-friction](playbooks/apply-friction.md): classified friction notes from a Reflexive pass.
41
+ - [author-skill](playbooks/author-skill.md): creating or editing a skill, playbook, or instruction file directly.
42
+ - [bootstrap](playbooks/bootstrap.md): building or overhauling a project's agent system from investigation runs.
43
+
44
+ ## References
45
+
46
+ - [Skill Template](references/template-skill.md)
47
+
48
+ ---
49
+
50
+ Placement and mechanism adapted from [google-research/harness2](https://github.com/google-research/harness2) (Apache-2.0), revision `1cfe254`, `harness2/core/prompts.py`.
@@ -0,0 +1,15 @@
1
+ # Apply friction notes
2
+
3
+ **You own one action per note.** Notes arrive classified as `misdirection` or `gap` by the Reflexive pass.
4
+
5
+ 1. A note with no before/after contrast (the failed attempt and what revealed the cause) gets no placement; record it as unsupported.
6
+ 2. Correct each misdirection: open the line named in `Led by` and rewrite it to state what `Found` established, or delete it when it has no correct form.
7
+ 3. Place each gap: search the agent system for a statement of the `Found` fact. When one exists, the run could not reach it: sharpen the pointer or description that should have led there. When none exists, write it as one direct sentence where **Placement** puts it. A fact the change itself resolved, or a tool slip no project or skill owns, needs no placement.
8
+ 4. Choose the **Mechanism** before writing prose, then **Hold the Size**.
9
+
10
+ **Reply:** one pair per note:
11
+
12
+ ```text
13
+ Friction: <Found> (misdirection | gap)
14
+ Action: <corrected line | sharpened pointer | placed at <location> | enforced by <check> | resolved by the change | unsupported>
15
+ ```
@@ -0,0 +1,11 @@
1
+ # Author a skill
2
+
3
+ **You own the skill's behavior change, and nothing beyond it.**
4
+
5
+ 1. Name the layer: knowledge (what the model lacks), prohibition (a habit to block), process (an order), taste (an aesthetic), or discipline (shortcuts and false claims). The layer sets the length, the tone, and how much the description must carry.
6
+ 2. For a new skill or playbook, have the model attempt the task without it and record where it fails; the first version covers those failures and nothing more.
7
+ 3. A new skill starts from [the template](../references/template-skill.md); a new playbook copies an existing one's shape (ownership line, steps, `Reply:`).
8
+ 4. Apply the **Craft Levers**, then **Hold the Size**.
9
+ 5. Fix a broken skill met mid-task in its own change, not tangled into the task's diff.
10
+
11
+ **Reply:** the files changed with the net line count of each, the layer, and the bare-run failures the change covers.
@@ -0,0 +1,10 @@
1
+ # Bootstrap
2
+
3
+ **You own an agent system built from evidence, not guesses.**
4
+
5
+ 1. Pick two to four investigation targets with falsifiable objectives: build and test reality (run the suites, typecheckers, linters), an architectural seam (trace one core flow end to end), and conventions (module structure, configuration, dependencies).
6
+ 2. Dispatch one isolated worker per target through `investigating`. Each records and classifies its friction notes and returns them instead of invoking `solid-loop`.
7
+ 3. Merge notes whose `Found` lines state the same fact.
8
+ 4. Apply the merged notes in one [apply-friction](apply-friction.md) pass.
9
+
10
+ **Reply:** workers dispatched and their targets, each note with its action, and the components created or updated.
@@ -0,0 +1,26 @@
1
+ # Streamlined Skill Template
2
+
3
+ Use this template as a starting point when creating new skills.
4
+ Keep the sections the skill's work needs and drop the rest.
5
+
6
+ ```markdown
7
+ ---
8
+ name: <skill-name-gerund-or-action>
9
+ description: Use when <one trigger per branch>.
10
+ ---
11
+
12
+ # <Skill Name>
13
+
14
+ <Single-paragraph overview stating the root virtue, objective, and operational context.>
15
+
16
+ ## Workflow
17
+
18
+ 1. **<Step 1 Name>**: <Direct statement of action and expected behavior.>
19
+ - **Completion Criterion**: <Observable, checkable condition confirming step is done.>
20
+ 2. **<Step 2 Name>**: <Direct statement of action and expected behavior.>
21
+ - **Completion Criterion**: <Observable, checkable condition confirming step is done.>
22
+
23
+ ## References
24
+
25
+ - [Reference Name](references/<reference-file>.md)
26
+ ```
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: writing
3
+ description: Use when writing or revising documentation, a README, an article, a PR description, or prose in general, tightening existing text, or cleaning up code comments.
4
+ ---
5
+
6
+ # Writing
7
+
8
+ Run the loop in [../anchorloop/SKILL.md](../anchorloop/SKILL.md). The anchor is a reader without the conversation's context: hand the text to a fresh subagent and check it can say what the text asks of its reader. Comment-only work also keeps the project's tests green.
9
+
10
+ Short declarative sentences; each claim carries its evidence or reads as an estimate. For Traditional Chinese articles, load `writing-in-weihung-voice` when it exists.
11
+
12
+ ## Playbooks
13
+
14
+ - [draft](playbooks/draft.md): a new document.
15
+ - [tighten](playbooks/tighten.md): revising or shortening existing text.
16
+ - [comments](playbooks/comments.md): removing or rewriting code comments.
@@ -0,0 +1,10 @@
1
+ # Comments
2
+
3
+ **You own the comments, not the code.** No behavior changes.
4
+
5
+ 1. Keep a comment only for a non-obvious why the code cannot show: a constraint, a workaround with its cause, a surprising invariant.
6
+ 2. Delete comments that narrate what the code does, mark phases, or restate names; a test or script documents its step through its assertion text.
7
+ 3. When a comment claims a constraint the code could enforce (a type, an assertion, a check), report it as a follow-up.
8
+ 4. Verify that the diff touches only comments and that the project's tests still pass.
9
+
10
+ **Reply:** comments removed and rewritten by count, the follow-ups, and the test result.
@@ -0,0 +1,10 @@
1
+ # Draft
2
+
3
+ **You own whether the reader can act on it.**
4
+
5
+ 1. Name the reader, what they already know, and the decision or action the text serves; open with that.
6
+ 2. Pick one mode (tutorial, how-to, reference, or explanation) and keep each section in it.
7
+ 3. Link to the source of a fact instead of copying it; a copied fact drifts.
8
+ 4. Open terms or decisions go to `grilling`, or to `domain-modeling` when they are domain terms.
9
+
10
+ **Reply:** the document path, its reader and purpose, and the reader check's result.
@@ -0,0 +1,9 @@
1
+ # Tighten
2
+
3
+ **You own the shorter text that says the same thing.**
4
+
5
+ 1. Delete before rewording: sentences that do not change what the reader does, restatements, hedges, and justification that manages a problem instead of fixing it.
6
+ 2. Merge what is stated twice into one place.
7
+ 3. Reword only what is left, keeping the author's voice and every fact.
8
+
9
+ **Reply:** what was cut and why, the length before and after, and any fact you were unsure was safe to remove.