@loop-lang/loop 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,34 +1,90 @@
1
1
  # @loop-lang/loop
2
2
 
3
- Install **Loop** a small natural-language DSL for self-correcting, human-gated coding loops into any repo, so **Claude Code or any agent** can author and run `.loop` files.
3
+ **Loop** is a small natural-language DSL for *loop engineering*a `.loop` file describes a
4
+ self-correcting, human-gated coding workflow: its goal, what it may read, how it verifies
5
+ itself, when it stops, and where a human steps in. Your agent then **runs that loop**,
6
+ cycling plan → act → observe and reflecting on failures until the goal is met.
7
+
8
+ This package drops Loop into any repo so **Claude Code — or any agent** — can author and run
9
+ `.loop` files.
4
10
 
5
11
  ```sh
6
12
  npx @loop-lang/loop init
7
13
  ```
8
14
 
9
- That scaffolds, into the current repo:
15
+ ## What a `.loop` looks like
16
+
17
+ ```loop
18
+ loop "fix the failing checkout tax test":
19
+ goal: the tax line on the cart is correct
20
+ look at: src/cart, and the last failure
21
+ done when "pnpm test checkout" passes
22
+ also: a security scan
23
+ after 6 tries: stop and warn "still red — needs a human"
24
+ ```
25
+
26
+ Plain words, but precise: `done when` is how the loop checks itself, `also:` adds a quality
27
+ pass once the goal is met, and the guard stops a thrashing loop instead of looping forever.
28
+ Bigger jobs scale up to a **`pipeline`** (an epic → ordered stages) or a **`flow`** (a chain
29
+ of whole `.loop` files — discover → design → build each story).
30
+
31
+ ## What `init` scaffolds
10
32
 
11
- - **`AGENTS.md`** — the full Loop language reference. Any agent that opens the repo (Claude Code, Cursor, Copilot, Codex…) now knows how to write a `.loop`.
12
- - **`.claude/skills/loop`** the Claude Code `/loop` skill (author + run loops natively in a chat).
33
+ - **`AGENTS.md`** — the full language reference. Any agent that opens the repo (Claude Code,
34
+ Cursor, Copilot, Codex…) now knows how to write a `.loop`.
35
+ - **`.claude/skills/loopflow`** — the Claude Code **`/loopflow`** skill (author + run loops
36
+ natively in a chat). *Invoked as `/loopflow`, not `/loop` — the latter is Claude Code's
37
+ built-in scheduler.*
38
+ - **`CLAUDE.md`** pointer — a standing nudge so Claude Code reaches for a `.loop` instead of
39
+ doing the work ad hoc. (Written by default; `--no-claude-md` to skip.)
13
40
  - **`examples/fix_test.loop`** — a starter loop to run.
14
41
 
15
- ### Options
42
+ ## The `/loopflow` skill — a guided tour
43
+
44
+ You don't need to know the language first. In a Claude Code chat, just describe the work:
45
+
46
+ ```
47
+ /loopflow build a rate limiter — done when the burst test passes, and run a security pass
48
+ ```
49
+
50
+ The skill **interviews you** — it scopes the purpose first (a one-test fix? a feature? a
51
+ whole app?), offers the quality passes worth adding (tests, security, code review, clean
52
+ architecture), then writes the `.loop` *in front of you*, naming each keyword as it goes.
53
+ By the end of one loop you've learned the language by building. Then it runs the loop right
54
+ in the chat, so you watch every step and answer any gate inline.
55
+
56
+ Already have a `.loop`? Run it directly:
57
+
58
+ ```
59
+ /loopflow run examples/fix_test.loop
60
+ ```
61
+
62
+ ## Options
16
63
 
17
64
  ```
18
65
  loop init [--dir <path>] [--global] [--no-skill] [--no-example]
19
- [--claude-md] [--cursor] [--copilot] [--all-agents] [--force]
66
+ [--no-claude-md] [--cursor] [--copilot] [--all-agents] [--force]
20
67
  ```
21
68
 
22
69
  - `--global` — install the skill into `~/.claude/skills` instead of the repo.
23
- - `--all-agents` — also drop memory pointers for Cursor + Copilot (and `CLAUDE.md`).
70
+ - `--no-claude-md` — skip the `CLAUDE.md` pointer (written by default).
71
+ - `--cursor` / `--copilot` / `--all-agents` — also drop memory pointers for those agents.
72
+ - `--no-skill` / `--no-example` — skip the skill or the starter loop.
24
73
  - `--force` — overwrite an existing skill / example.
25
74
 
26
- Re-running `init` is safe: the `AGENTS.md` block is managed between markers and updated in place, not duplicated.
75
+ Re-running `init` is safe: the `AGENTS.md` block is managed between markers and updated in
76
+ place, never duplicated.
77
+
78
+ ## After install
79
+
80
+ - **Claude Code:** open a chat in the repo → `/loopflow run examples/fix_test.loop`, or just
81
+ describe the work and let the skill write the `.loop`.
82
+ - **Any agent:** it reads `AGENTS.md` and authors + runs loops the same way.
83
+ - **Headless:** install the full runtime to run loops from the CLI with `loop run <file>`.
27
84
 
28
- ### After install
85
+ ## Learn more
29
86
 
30
- - **Claude Code:** open a chat in the repo → `/loop run examples/fix_test.loop`, or just describe the work and the agent writes the `.loop`.
31
- - **Any agent:** it reads `AGENTS.md` and can author + run loops the same way.
32
- - **Headless:** install the full runtime for `loop run <file>`.
87
+ The [loop-lang repo](https://github.com/tickets-forge-dev/loop-lang) tutorial, full keyword
88
+ reference, and the playable Loop Lab.
33
89
 
34
- Learn the language: the [tutorial](https://github.com/tickets-forge-dev/loop-lang), the keyword reference, and the playable Loop Lab.
90
+ Apache-2.0.
package/assets/AGENTS.md CHANGED
@@ -4,7 +4,7 @@ This file teaches an AI assistant (Claude Code, Copilot, Cursor, etc.) how to wr
4
4
  **Loop** flows. When a user asks you to design a staged, self-correcting, or human-gated
5
5
  coding workflow — "set up a loop to fix X", "turn this epic into a pipeline", "automate
6
6
  this multi-step task" — author a `.loop` file using the grammar below, then let the user
7
- run it with `loop run file.loop`.
7
+ run it with `loop-run run file.loop`.
8
8
 
9
9
  Loop is a small natural-language DSL. A `.loop` file describes the *movement* of an AI
10
10
  coding loop: its objective, the context it may read, the actions it's allowed, how it
@@ -59,7 +59,7 @@ a human approves the plan first (human authors/approves the plan before a
59
59
  a human reviews before stopping (human judges the result before the loop stops)
60
60
  a human approves before <action> (a blocking gate before a stage, e.g. deploy)
61
61
 
62
- plan from the archon project "<name>" (source the plan from Archon instead of generating)
62
+ plan from "<file>" (read the plan from a file you control instead of generating it)
63
63
 
64
64
  use the <method> method schedule: <when> runner: <agent> target: <dir> (config tier)
65
65
  models: fast <model>, strong <model> model tiering: plan/reflect/also→fast, act→strong (cascades; override e.g. `act fast`, `all strong`)
@@ -232,18 +232,17 @@ loop "add a healthcheck endpoint":
232
232
  ## Show the flow — every time it changes
233
233
 
234
234
  Whenever you create or edit a `.loop`, print its flow so the user sees the shape.
235
- Run `loop show file.loop`, or render the compact ASCII yourself: the cycle
235
+ Run `loop-run show file.loop`, or render the compact ASCII yourself: the cycle
236
236
  (`plan → act → observe`), the `↺` reflect back-edge, the `✓ done when` check, the
237
237
  `⛔` thrash guard, and any `👤` gates. For a pipeline, list stages in order; for a
238
- flow, show the file chain. `loop ls` lists every loop in the repo.
238
+ flow, show the file chain. `loop-run ls` lists every loop in the repo.
239
239
 
240
240
  ## Running what you wrote
241
241
 
242
- - `loop run file.loop` — execute it on Claude Code (plan/act/observe, reflect on failure,
242
+ - `loop-run run file.loop` — execute it on Claude Code (plan/act/observe, reflect on failure,
243
243
  verify with `done when`, pause at human gates).
244
- - `loop show file.loop` — print the loop's flow as compact ASCII (and `loop ls` to list them).
245
- - `loop viz file.loop` — open a visual HTML schematic of the flow.
246
- - `loop export file.loop` — emit an Archon workflow YAML (optional interop).
244
+ - `loop-run show file.loop` — print the loop's flow as compact ASCII (and `loop-run ls` to list them).
245
+ - `loop-run viz file.loop` — open a visual HTML schematic of the flow.
247
246
 
248
247
  ## Authoring checklist
249
248
 
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: loop
3
- description: Create and run Loop (.loop) flows — a natural-language DSL for loop engineering. Use when the user wants to author, write, run, or execute a self-correcting or human-gated AI coding loop, turn an epic into a pipeline, fix a bug "as a loop", or mentions a .loop file or "loop engineering".
2
+ name: loopflow
3
+ description: Create and run Loop (.loop) flows — a natural-language DSL for loop engineering. Use when the user wants to author, write, run, or execute a self-correcting or human-gated AI coding loop, turn an epic into a pipeline, fix a bug "as a loop", build a feature or whole app "as a loop", learn what Loop is or how to use it, or mentions a .loop file or "loop engineering". Invoked as /loopflow (the name avoids colliding with the built-in /loop scheduler).
4
4
  ---
5
5
 
6
6
  # Loop
@@ -62,36 +62,76 @@ start with `#`. An epic → a `pipeline`; each story → a `stage`.
62
62
 
63
63
  ---
64
64
 
65
- ## Creating a .loop — interview the user first
66
-
67
- Don't silently guess the loop. **Walk the five decisions with the user**, asking
68
- the high-leverage questions out loud and offering a default for the rest, so a
69
- confident user can accept everything in one reply. Ask one topic at a time:
70
-
71
- 1. **Goal (objective)** — "What's the goal — what does *done* look like?"
72
- Required; never guess this one.
73
- 2. **Verification `done when`** "How do we know it's done: a test passing, a
74
- shell command passing, a scan that must *find nothing*, or a human confirming?"
75
- The most important answer always ask.
76
- 3. **Context `look at`** "What should it read first?" Offer to infer the files
77
- from the repo; append `and the last failure`.
78
- 4. **Actions policy** "Anything risky to gate — migrations, pushes, deploys?"
79
- Default offered: edits automatically, nothing else gated.
80
- 5. **Stopping transitions + guard** confirm the default (reflect on failure,
81
- `after N tries: stop and warn`); ask for N only if they care.
82
-
83
- Then two more that shape the run:
84
-
85
- 6. **Human gates** "Approve the plan before any work? Review before it stops?"
86
- Default: none unless the work is risky.
87
- 7. **Git strategy** state the safe default ("work on a branch, commit when the
88
- goal is met, never push to `main`") and ask if they want a PR, a worktree, or
89
- to work in place.
90
-
91
- Offer the defaults inline (e.g. *"I'll gate nothing, add a 6-try guard, and work
92
- on a branch ok?"*) so the whole interview can be one exchange. Then **write the
93
- `.loop`**, scoping it with `look at:` and always giving it a real `done when` and a
94
- thrash guard. Finally **print its flow** (below) and offer to run it.
65
+ ## Creating a .loop — be a guide, not a guesser
66
+
67
+ Most people reaching for this skill don't yet know what Loop can do. Your job is to
68
+ **guide them to the right loop for their purpose** and teach the language by writing
69
+ it in front of them. Never silently guess the loop; interview first, then author. Ask
70
+ one topic at a time, and always offer a default so a confident user can accept it all
71
+ in one reply.
72
+
73
+ ### Step 0scope the purpose first (ask this before anything else)
74
+
75
+ Open with **"What do you want the loop to accomplish?"** and show the range, so the
76
+ user sees what's possible and picks a scale:
77
+
78
+ | Scale | Example purpose | Shape in Loop |
79
+ |-------|-----------------|---------------|
80
+ | **Tiny** | "Make this one failing test pass." | a single `loop` |
81
+ | **Small** | "Fix this bug across a few files; gate the migration." | a `loop` + policy + gate |
82
+ | **Medium** | "Build the checkout feature — a few stories, each tested." | a `pipeline` of `stage`s |
83
+ | **Large** | "Build a whole app, A-to-Z." | a `flow`: discover → design → build each story |
84
+
85
+ Name the shape their answer implies (*"that's a **pipeline** a sequence of stages"*)
86
+ so the vocabulary attaches to their own goal. This one question turns a vague request
87
+ into a scoped loop and teaches the three top-level forms at once.
88
+
89
+ ### Step 1 — do they already have a plan?
90
+
91
+ Ask **"Do you have a spec, plan, ticket, or epic already?"**
92
+ - **Yes** point `look at:` at it; if it's an epic / story list, turn each story into a
93
+ `stage` of a `pipeline` (or `for each` over the plan file).
94
+ - **No, and it's medium/large** begin the flow with a **discovery loop** whose
95
+ `done when` is "the plan file exists and validates" — it interviews them, writes the plan.
96
+ - **No, and it's small** → skip planning; go straight to the loop.
97
+
98
+ ### Step 2 — which quality passes? (offer the menu — don't wait to be asked)
99
+
100
+ This is what makes Loop worth running. Proactively offer the quality sub-loops:
101
+
102
+ > "Want the loop to enforce quality every cycle too? Common ones: **tests** (write/keep
103
+ > green), **security** (a scan that must find nothing), **code review**, **clean
104
+ > architecture** (boundary checks). I can add these as `also:` finishing passes on one
105
+ > loop, or as their own gated `stage`s in a pipeline."
106
+
107
+ Translate their picks into syntax in front of them so they see the mapping:
108
+ - tests → `done when "<test cmd>" passes`
109
+ - security → `also: a security scan`, or `done when "semgrep --severity=high" finds nothing`
110
+ - review / architecture → `also: <pass>`, or a `stage` with `a human approves before <X>`
111
+
112
+ ### Step 3 — the remaining decisions (defaults offered, one reply to accept)
113
+
114
+ Walk these quickly, naming the keyword each time so they learn it:
115
+ 1. **Goal** → `goal:` — "what does *done* look like?" Required; never guess this one.
116
+ 2. **Verification** → `done when` — a test passing, a command passing, a scan finding
117
+ nothing, or a human confirming. The most important line; always pin it down.
118
+ 3. **Context** → `look at:` — offer to infer the files from the repo; append `and the last failure`.
119
+ 4. **Actions** → policy — "anything risky to gate: migrations, pushes, deploys?" Default:
120
+ `allow edits automatically`, nothing else gated.
121
+ 5. **Stopping** → `after N tries: stop and warn` (default 6) + `when it fails: reflect … then plan again`.
122
+ 6. **Human gates** → `a human approves the plan first` / `a human reviews before stopping`
123
+ — default none unless the work is risky.
124
+ 7. **Git** → state the safe default ("branch, commit when the goal is met, never push to
125
+ `main`"); ask if they want a PR, a worktree, or to work in place.
126
+
127
+ Offer the defaults inline (*"I'll add a tests + security pass, gate the migration, a
128
+ 6-try guard, work on a branch — sound right?"*) so the whole interview is one exchange.
129
+ Then **write the `.loop`**, always with a real `done when` and a thrash guard, **print
130
+ its flow** (below), and offer to run it.
131
+
132
+ > **Teach by building.** As you write each clause, say what it is (*"`done when` is how
133
+ > the loop checks itself"*). By the end of one loop the user has seen the whole language —
134
+ > that is the point of authoring it here, in the open, rather than headless.
95
135
 
96
136
  ## Show the flow — every time it changes
97
137
 
@@ -223,7 +263,7 @@ Two protections are unconditional and cannot be overridden by any `git:` block:
223
263
 
224
264
  ### In-chat runner note
225
265
 
226
- When you run a loop *inside this conversation* (the `/loop` skill), you are the git
266
+ When you run a loop *inside this conversation* (the `/loopflow` skill), you are the git
227
267
  operator — you execute plan/act/observe yourself. Before acting, check the `git:` block
228
268
  and honor the policy: if `push when done` is set and the current branch is `main` or
229
269
  `master`, refuse with a clear message rather than pushing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loop-lang/loop",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Install Loop (.loop) into any repo so Claude Code — or any agent — can author and run self-correcting, human-gated coding loops.",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": { "access": "public" },
package/src/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // @loop-lang/loop — the installer CLI. `loop init` drops Loop into a repo so any
3
3
  // agent can author + run .loop files. Running loops happens in your agent (the
4
- // /loop skill) or headless via the full @loop/runtime CLI.
4
+ // /loopflow skill) or headless via the full @loop/runtime CLI.
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { dirname, join, resolve } from "node:path";
7
7
  import { init } from "./init.mjs";
@@ -17,17 +17,17 @@ usage:
17
17
 
18
18
  init options:
19
19
  --dir <path> install into <path> (default: current directory)
20
- --global install the /loop skill into ~/.claude/skills (not the repo)
21
- --no-skill don't install the Claude Code /loop skill
20
+ --global install the /loopflow skill into ~/.claude/skills (not the repo)
21
+ --no-skill don't install the Claude Code /loopflow skill
22
22
  --no-example don't write examples/fix_test.loop
23
- --claude-md also write a CLAUDE.md pointer
23
+ --no-claude-md don't write the CLAUDE.md pointer (written by default)
24
24
  --cursor also write .cursor/rules/loop.md
25
25
  --copilot also write .github/copilot-instructions.md
26
26
  --all-agents CLAUDE.md + Cursor + Copilot pointers
27
27
  --force overwrite the skill / example if they already exist
28
28
 
29
29
  after init:
30
- • Claude Code: open a chat in the repo and say /loop run examples/fix_test.loop
30
+ • Claude Code: open a chat in the repo and say /loopflow run examples/fix_test.loop
31
31
  • any agent: it reads AGENTS.md and can author + run .loop files
32
32
  • headless: install @loop/runtime for loop run <file>`;
33
33
 
@@ -45,7 +45,9 @@ async function main(argv) {
45
45
  if (cmd === "init") {
46
46
  const agents = [];
47
47
  if (flag(argv, "--all-agents")) agents.push("claude", "cursor", "copilot");
48
- if (flag(argv, "--claude-md") && !agents.includes("claude")) agents.push("claude");
48
+ // CLAUDE.md pointer is on by default (gives Claude Code a standing "author a .loop"
49
+ // nudge); --no-claude-md opts out. --claude-md still accepted as an explicit yes.
50
+ if (!flag(argv, "--no-claude-md") && !agents.includes("claude")) agents.push("claude");
49
51
  if (flag(argv, "--cursor") && !agents.includes("cursor")) agents.push("cursor");
50
52
  if (flag(argv, "--copilot") && !agents.includes("copilot")) agents.push("copilot");
51
53
 
@@ -62,14 +64,14 @@ async function main(argv) {
62
64
  console.log(`\n Loop installed into ${targetDir}\n`);
63
65
  for (const s of steps) console.log(` ✓ ${s}`);
64
66
  console.log(`\n Next:`);
65
- console.log(` • In a Claude Code chat here: /loop run examples/fix_test.loop`);
67
+ console.log(` • In a Claude Code chat here: /loopflow run examples/fix_test.loop`);
66
68
  console.log(` • Or describe the work and the agent writes the .loop for you.`);
67
69
  console.log(` • Any other agent reads AGENTS.md and can do the same.\n`);
68
70
  return;
69
71
  }
70
72
 
71
73
  if (["run", "parse", "export", "viz", "show", "ls"].includes(cmd)) {
72
- console.error(`\`loop ${cmd}\` runs in your agent (the /loop skill) or via the full runtime CLI (@loop/runtime).\nThis package installs Loop — try \`loop init\`. See \`loop help\`.`);
74
+ console.error(`\`loop ${cmd}\` runs in your agent (the /loopflow skill) or via the full runtime CLI (@loop/runtime).\nThis package installs Loop — try \`loop init\`. See \`loop help\`.`);
73
75
  process.exit(2);
74
76
  }
75
77
 
package/src/init.mjs CHANGED
@@ -11,13 +11,13 @@ const MARK_END = "<!-- loop:end -->";
11
11
  /** Short pointer dropped into an agent's memory file so it knows Loop lives here. */
12
12
  export function pointer({ skill }) {
13
13
  const run = skill
14
- ? "run it — in Claude Code via the `/loop` skill (installed at `.claude/skills/loop`), or headless with `loop run <file>`"
14
+ ? "run it — in Claude Code via the `/loopflow` skill (installed at `.claude/skills/loopflow`; note: it's `/loopflow`, not the built-in `/loop` scheduler), or headless with `loop run <file>`"
15
15
  : "run it headless with `loop run <file>`";
16
16
  return [
17
17
  "## Loop (`.loop`)",
18
18
  "",
19
19
  "This repo uses **Loop** — a small natural-language DSL for self-correcting, human-gated coding workflows.",
20
- "When the user asks to set up a loop, turn an epic into a pipeline, or automate a multi-step task, **author a `.loop` file** using the grammar in [`AGENTS.md`](./AGENTS.md), then " + run + ".",
20
+ "Whenever the user wants to build, fix, automate, or ship something as a repeatable/self-correcting workflow a bug fix, a feature, an epic, even a whole app **default to authoring a `.loop` file** rather than doing the work ad hoc. Use the grammar in [`AGENTS.md`](./AGENTS.md), interview the user for the goal/verification/gates first, then " + run + ".",
21
21
  "Every time you create or change a `.loop`, print its flow so the user can see the shape.",
22
22
  ].join("\n");
23
23
  }
@@ -66,13 +66,13 @@ export async function init(targetDir, opts, assetsDir) {
66
66
  const verb = await mergeMarkered(join(targetDir, "AGENTS.md"), agentsBody.trim());
67
67
  steps.push(`${verb} AGENTS.md (the Loop language reference — any agent)`);
68
68
 
69
- // 2. The Claude Code /loop skill.
69
+ // 2. The Claude Code /loopflow skill.
70
70
  if (withSkill) {
71
71
  const dst = skill === "global"
72
- ? join(homedir(), ".claude", "skills", "loop")
73
- : join(targetDir, ".claude", "skills", "loop");
72
+ ? join(homedir(), ".claude", "skills", "loopflow")
73
+ : join(targetDir, ".claude", "skills", "loopflow");
74
74
  const r = await copyInto(join(assetsDir, "skill"), dst, { force });
75
- steps.push(`${r === "skipped" ? "skipped (exists)" : "wrote"} ${skill === "global" ? "~/.claude/skills/loop" : ".claude/skills/loop"} (the /loop skill)`);
75
+ steps.push(`${r === "skipped" ? "skipped (exists)" : "wrote"} ${skill === "global" ? "~/.claude/skills/loopflow" : ".claude/skills/loopflow"} (the /loopflow skill)`);
76
76
  }
77
77
 
78
78
  // 3. Opt-in per-agent memory pointers.