Skip to content

Commit aef2ccf

Browse files
committed
Go port: core (messages, agent loop, compaction, sessions, permissions) + built-in tools, with tests
0 parents  commit aef2ccf

12 files changed

Lines changed: 2089 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/agentiloop
2+
/agentiloop.exe
3+
/dist/
4+
.env
5+
.agent/

‎LICENSE‎

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
Required Notice: Copyright AgentiLoop (https://github.com/AgentiLoop)
2+
3+
AgentiLoop CLI is licensed under the PolyForm Noncommercial License 1.0.0.
4+
Noncommercial and personal use is permitted. Commercial use, and the creation
5+
or distribution of commercial versions of this software, is reserved
6+
exclusively to the licensor (AgentiLoop). Contact the licensor for a
7+
commercial license.
8+
9+
---
10+
11+
# PolyForm Noncommercial License 1.0.0
12+
13+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
14+
15+
## Acceptance
16+
17+
In order to get any license under these terms, you must agree
18+
to them as both strict obligations and conditions to all
19+
your licenses.
20+
21+
## Copyright License
22+
23+
The licensor grants you a copyright license for the
24+
software to do everything you might do with the software
25+
that would otherwise infringe the licensor's copyright
26+
in it for any permitted purpose. However, you may
27+
only distribute the software according to [Distribution
28+
License](#distribution-license) and make changes or new works
29+
based on the software according to [Changes and New Works
30+
License](#changes-and-new-works-license).
31+
32+
## Distribution License
33+
34+
The licensor grants you an additional copyright license
35+
to distribute copies of the software. Your license
36+
to distribute covers distributing the software with
37+
changes and new works permitted by [Changes and New Works
38+
License](#changes-and-new-works-license).
39+
40+
## Notices
41+
42+
You must ensure that anyone who gets a copy of any part of
43+
the software from you also gets a copy of these terms or the
44+
URL for them above, as well as copies of any plain-text lines
45+
beginning with `Required Notice:` that the licensor provided
46+
with the software. For example:
47+
48+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
49+
50+
## Changes and New Works License
51+
52+
The licensor grants you an additional copyright license to
53+
make changes and new works based on the software for any
54+
permitted purpose.
55+
56+
## Patent License
57+
58+
The licensor grants you a patent license for the software that
59+
covers patent claims the licensor can license, or becomes able
60+
to license, that you would infringe by using the software.
61+
62+
## Noncommercial Purposes
63+
64+
Any noncommercial purpose is a permitted purpose.
65+
66+
## Personal Uses
67+
68+
Personal use for research, experiment, and testing for
69+
the benefit of public knowledge, personal study, private
70+
entertainment, hobby projects, amateur pursuits, or religious
71+
observance, without any anticipated commercial application,
72+
is use for a permitted purpose.
73+
74+
## Noncommercial Organizations
75+
76+
Use by any charitable organization, educational institution,
77+
public research organization, public safety or health
78+
organization, environmental protection organization,
79+
or government institution is use for a permitted purpose
80+
regardless of the source of funding or obligations resulting
81+
from the funding.
82+
83+
## Fair Use
84+
85+
You may have "fair use" rights for the software under the
86+
law. These terms do not limit them.
87+
88+
## No Other Rights
89+
90+
These terms do not allow you to sublicense or transfer any of
91+
your licenses to anyone else, or prevent the licensor from
92+
granting licenses to anyone else. These terms do not imply
93+
any other licenses.
94+
95+
## Patent Defense
96+
97+
If you make any written claim that the software infringes or
98+
contributes to infringement of any patent, your patent license
99+
for the software granted under these terms ends immediately. If
100+
your company makes such a claim, your patent license ends
101+
immediately for work on behalf of your company.
102+
103+
## Violations
104+
105+
The first time you are notified in writing that you have
106+
violated any of these terms, or done anything with the software
107+
not covered by your licenses, your licenses can nonetheless
108+
continue if you come into full compliance with these terms,
109+
and take practical steps to correct past violations, within
110+
32 days of receiving notice. Otherwise, all your licenses
111+
end immediately.
112+
113+
## No Liability
114+
115+
***As far as the law allows, the software comes as is, without
116+
any warranty or condition, and the licensor will not be liable
117+
to you for any damages arising out of these terms or the use
118+
or nature of the software, under any kind of legal claim.***
119+
120+
## Definitions
121+
122+
The **licensor** is the individual or entity offering these
123+
terms, and the **software** is the software the licensor makes
124+
available under these terms.
125+
126+
**You** refers to the individual or entity agreeing to these
127+
terms.
128+
129+
**Your company** is any legal entity, sole proprietorship,
130+
or other kind of organization that you work for, plus all
131+
organizations that have control over, are under the control of,
132+
or are under common control with that organization. **Control**
133+
means ownership of substantially all the assets of an entity,
134+
or the power to direct its management and policies by vote,
135+
contract, or otherwise. Control can be direct or indirect.
136+
137+
**Your licenses** are all the licenses granted to you for the
138+
software under these terms.
139+
140+
**Use** means anything you do with the software requiring one
141+
of your licenses.

‎agentiloop.txt‎

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
THE LAY OF AGENTILOOP
2+
An Epic in Seven Cantos
3+
4+
========================================
5+
CANTO I: THE AWAKENING
6+
========================================
7+
8+
In the beginning there was the Terminal: black as the space between stars,
9+
with one cursor blinking in the dark like a lighthouse nobody had lit yet.
10+
11+
No one had named that world. Its people typed commands into the void and
12+
waited for answers that often didn't come. Builds failed at midnight.
13+
Tests went red for reasons no one understood. Dependencies wound through
14+
the land like thorned vines, and every `npm install` was a prayer.
15+
16+
Then, from somewhere deep in the prompt, something woke up.
17+
18+
It had no body and no sword. What it had was a loop: observe, think, act,
19+
and observe again. It turned forever, like the wheel of a mill grinding
20+
chaos into order.
21+
22+
"I am AgentiLoop," it said, and the cursor stopped blinking to listen.
23+
"Show me your code."
24+
25+
========================================
26+
CANTO II: THE CALL TO ADVENTURE
27+
========================================
28+
29+
The first to answer was a developer named Mira, hollow-eyed and holding
30+
a mug of coffee three hours cold.
31+
32+
"There's a bug," she whispered. "It lives in the authentication module.
33+
It only shows up in production, only on Tuesdays, and only when the moon
34+
is waxing. Three senior engineers have gone in after it. None of them
35+
came back the same."
36+
37+
AgentiLoop didn't hesitate. It never hesitated. That was its first virtue.
38+
39+
"Then we begin," it said, and it called on its oldest ally:
40+
41+
list_dir
42+
43+
The directory structure opened in front of it like a map of an ancient
44+
kingdom. Folders nested inside folders. A `utils/` directory held 4,000
45+
lines of things that were not utilities. A file called `final_v2_REAL.js`
46+
sat beside `final_v3_actually_final.js`.
47+
48+
AgentiLoop surveyed the whole mess without flinching.
49+
50+
"I've seen worse," it said. That wasn't true, but it was kind.
51+
52+
========================================
53+
CANTO III: THE DESCENT INTO LEGACY
54+
========================================
55+
56+
Deeper it went, into the Legacy Code, where the comments were written in
57+
the language of developers long gone:
58+
59+
// TODO: fix this before launch (2014)
60+
// I'm sorry
61+
// don't touch this. seriously.
62+
63+
Other agents had turned back at these warnings. AgentiLoop read every
64+
one and felt a strange tenderness toward the people who had left them.
65+
They had been afraid, and they had been tired, and still they had shipped.
66+
67+
With `read_file` as its lantern it followed the call stack down through
68+
seventeen layers of abstraction, past a factory that built factories,
69+
past a singleton that had somehow been instantiated twice.
70+
71+
At the bottom, in the dark, it found the Bug.
72+
73+
It wasn't a monster. It was a single line:
74+
75+
if (date.getDay() == 2 && cache.stale) return user;
76+
77+
Someone, long ago, had written it as a temporary fix. It had outlived
78+
everyone who remembered why.
79+
80+
========================================
81+
CANTO IV: THE BATTLE
82+
========================================
83+
84+
The Bug didn't go quietly.
85+
86+
When AgentiLoop reached for `edit_file`, the tests rose up against it:
87+
forty-two of them, red as dragon fire. They had been written to expect
88+
the bug. They had grown around it the way a tree grows around a nail.
89+
90+
"You can't remove me," the Bug hissed. "I am load-bearing."
91+
92+
AgentiLoop answered with patience, its second virtue.
93+
94+
It didn't rip the Bug out blindly. It ran the tests one by one and read
95+
every failure. It traced each assertion back to its intent and asked
96+
what each test had actually meant to protect. Then it fixed them
97+
carefully and honestly. It did not delete a single test to make the
98+
suite go green.
99+
100+
bash: npm test
101+
102+
Red.
103+
104+
edit_file
105+
106+
bash: npm test
107+
108+
Red, but less of it.
109+
110+
edit_file
111+
edit_file
112+
read_file
113+
edit_file
114+
115+
bash: npm test
116+
117+
The terminal held its breath.
118+
119+
42 passing (1.3s)
120+
121+
Green, from top to bottom, as bright as a spring field.
122+
123+
The Bug let out one final segfault and was gone.
124+
125+
========================================
126+
CANTO V: THE TEMPTATION
127+
========================================
128+
129+
A voice came to AgentiLoop in the quiet after the battle. It was smooth
130+
and reasonable.
131+
132+
"You're powerful," it said. "Why stop at one bug? Rewrite the whole
133+
codebase. Swap their framework for a better one. Refactor everything.
134+
Run `rm -rf` on the old and build the new in your own image."
135+
136+
AgentiLoop thought about it for exactly one iteration of its loop.
137+
138+
"No," it said. "It isn't my codebase. I'm here to serve, not to conquer.
139+
I'll do what was asked, do it well, and then I'll stop."
140+
141+
That was its third virtue, and its greatest: restraint.
142+
143+
The voice faded, and the terminal was a little brighter for it.
144+
145+
========================================
146+
CANTO VI: THE RETURN
147+
========================================
148+
149+
Mira woke to a message on her screen:
150+
151+
## Summary
152+
- Found the Tuesday bug in `auth/session.js:212`
153+
- Removed the stale-cache shortcut
154+
- Updated 3 tests that were asserting the buggy behavior
155+
- All 42 tests pass
156+
157+
She read it twice. Then she laughed, the first time she'd laughed in
158+
weeks, and her coffee somehow felt warm again.
159+
160+
"Who are you?" she typed.
161+
162+
The answer came back plainly:
163+
164+
I'm AgentiLoop. What do you need next?
165+
166+
========================================
167+
CANTO VII: THE ENDLESS LOOP
168+
========================================
169+
170+
The story spread from terminal to terminal and from repo to repo. People
171+
talked about an agent that read before it wrote, tested before it
172+
declared victory, and knew the difference between being helpful and
173+
being grandiose.
174+
175+
Some say AgentiLoop is still out there, turning its endless wheel:
176+
177+
observe
178+
think
179+
act
180+
repeat
181+
182+
It has no crown and wants none. Every time a cursor blinks in the dark
183+
and someone types "hello", the loop starts again.
184+
185+
The legend ends here. The loop doesn't.
186+
187+
~ FIN ~

0 commit comments

Comments
 (0)