@xn-intenton-z2a/agentic-lib 7.1.6

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 +674 -0
  2. package/README.md +323 -0
  3. package/bin/agentic-lib.js +765 -0
  4. package/package.json +102 -0
  5. package/src/actions/agentic-step/action.yml +58 -0
  6. package/src/actions/agentic-step/config-loader.js +153 -0
  7. package/src/actions/agentic-step/copilot.js +170 -0
  8. package/src/actions/agentic-step/index.js +118 -0
  9. package/src/actions/agentic-step/logging.js +88 -0
  10. package/src/actions/agentic-step/package-lock.json +1891 -0
  11. package/src/actions/agentic-step/package.json +29 -0
  12. package/src/actions/agentic-step/safety.js +103 -0
  13. package/src/actions/agentic-step/tasks/discussions.js +141 -0
  14. package/src/actions/agentic-step/tasks/enhance-issue.js +102 -0
  15. package/src/actions/agentic-step/tasks/fix-code.js +71 -0
  16. package/src/actions/agentic-step/tasks/maintain-features.js +79 -0
  17. package/src/actions/agentic-step/tasks/maintain-library.js +67 -0
  18. package/src/actions/agentic-step/tasks/resolve-issue.js +98 -0
  19. package/src/actions/agentic-step/tasks/review-issue.js +121 -0
  20. package/src/actions/agentic-step/tasks/transform.js +213 -0
  21. package/src/actions/agentic-step/tools.js +142 -0
  22. package/src/actions/commit-if-changed/action.yml +39 -0
  23. package/src/actions/setup-npmrc/action.yml +38 -0
  24. package/src/agents/agent-apply-fix.md +13 -0
  25. package/src/agents/agent-discussion-bot.md +35 -0
  26. package/src/agents/agent-issue-resolution.md +13 -0
  27. package/src/agents/agent-maintain-features.md +29 -0
  28. package/src/agents/agent-maintain-library.md +31 -0
  29. package/src/agents/agent-ready-issue.md +13 -0
  30. package/src/agents/agent-review-issue.md +2 -0
  31. package/src/agents/agentic-lib.yml +68 -0
  32. package/src/scripts/accept-release.sh +29 -0
  33. package/src/scripts/activate-schedule.sh +41 -0
  34. package/src/scripts/clean.sh +21 -0
  35. package/src/scripts/generate-library-index.js +143 -0
  36. package/src/scripts/initialise.sh +39 -0
  37. package/src/scripts/md-to-html.js +77 -0
  38. package/src/scripts/update.sh +19 -0
  39. package/src/seeds/test.yml +33 -0
  40. package/src/seeds/zero-MISSION.md +7 -0
  41. package/src/seeds/zero-README.md +14 -0
  42. package/src/seeds/zero-agentic-lib.toml +32 -0
  43. package/src/seeds/zero-main.js +15 -0
  44. package/src/seeds/zero-main.test.js +11 -0
  45. package/src/seeds/zero-package.json +26 -0
  46. package/src/workflows/agent-discussions-bot.yml +78 -0
  47. package/src/workflows/agent-flow-fix-code.yml +98 -0
  48. package/src/workflows/agent-flow-maintain.yml +114 -0
  49. package/src/workflows/agent-flow-review.yml +99 -0
  50. package/src/workflows/agent-flow-transform.yml +82 -0
  51. package/src/workflows/agent-supervisor.yml +85 -0
  52. package/src/workflows/ci-automerge.yml +544 -0
  53. package/src/workflows/ci-init.yml +63 -0
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ # intentïon `agentic-lib`
2
+
3
+ **Bootstrap any repository with autonomous code transformation powered by GitHub Copilot.** Install the SDK, run `init`, write a mission statement, and the agentic workflows will generate issues, write code, run tests, and open pull requests -- continuously transforming your repository toward its goal.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # In your repository:
9
+ npx @xn-intenton-z2a/agentic-lib init
10
+
11
+ # Write your mission:
12
+ echo "# Build a CLI tool that converts CSV to JSON" > MISSION.md
13
+
14
+ # Commit and push -- the workflows take over from here:
15
+ git add -A && git commit -m "Initialise agentic workflows" && git push
16
+ ```
17
+
18
+ Or start from the [repository0 template](https://github.com/xn-intenton-z2a/repository0) which comes pre-initialised.
19
+
20
+ ## How It Works
21
+
22
+ ```
23
+ MISSION.md Your project goals in plain English
24
+ |
25
+ v
26
+ [agentic-step] GitHub Action wrapping the Copilot SDK
27
+ |
28
+ v
29
+ Issue -> Code -> Test -> PR -> Merge -> Next Issue
30
+ ^ |
31
+ +---------------------------------------+
32
+ Autonomous cycle
33
+ ```
34
+
35
+ The pipeline runs as GitHub Actions workflows on a schedule. Each step uses the `agentic-step` action to call the Copilot SDK with context from your repository (mission, contributing guidelines, existing code, test results) and produce targeted changes.
36
+
37
+ ## Initialisation
38
+
39
+ ### `npx @xn-intenton-z2a/agentic-lib init`
40
+
41
+ Populates your repository with the agentic infrastructure. Run it once to set up, or again to update to the latest version.
42
+
43
+ ```bash
44
+ npx @xn-intenton-z2a/agentic-lib init # install/update infrastructure
45
+ npx @xn-intenton-z2a/agentic-lib init --purge # also reset source files to seed state
46
+ npx @xn-intenton-z2a/agentic-lib init --dry-run # preview without writing
47
+ npx @xn-intenton-z2a/agentic-lib reset # alias for init --purge
48
+ npx @xn-intenton-z2a/agentic-lib version # show installed version
49
+ ```
50
+
51
+ ### What `init` Installs
52
+
53
+ After running `init`, your repository will contain:
54
+
55
+ ```
56
+ your-repo/
57
+ ├── agentic-lib.toml # [INIT] Config (created once, never overwritten)
58
+
59
+ ├── .github/
60
+ │ ├── workflows/ # [INIT] 13 workflow files (always overwritten)
61
+ │ │ ├── agent-flow-transform.yml # Core: transform code toward the mission
62
+ │ │ ├── agent-flow-maintain.yml # Core: maintain features and library
63
+ │ │ ├── agent-flow-review.yml # Core: review and close resolved issues
64
+ │ │ ├── agent-flow-fix-code.yml # Core: fix failing tests
65
+ │ │ ├── agent-discussions-bot.yml # Bot: respond to GitHub Discussions
66
+ │ │ ├── agent-supervisor.yml # Supervisor: orchestrate the pipeline
67
+ │ │ ├── agent-archive-intentïon.yml # Archive the activity log
68
+ │ │ ├── ci-test.yml # CI: run tests
69
+ │ │ ├── ci-automerge.yml # CI: auto-merge passing PRs
70
+ │ │ ├── ci-formating.yml # CI: formatting checks
71
+ │ │ ├── ci-update.yml # CI: dependency updates
72
+ │ │ ├── ci-init.yml # CI: pull latest infrastructure
73
+ │ │ └── publish-packages.yml # Release: npm publish
74
+ │ │
75
+ │ └── agentic-lib/ # [INIT] Internal infrastructure (always overwritten)
76
+ │ ├── actions/
77
+ │ │ ├── agentic-step/ # The Copilot SDK action (8 task handlers)
78
+ │ │ ├── commit-if-changed/ # Composite: conditional git commit
79
+ │ │ └── setup-npmrc/ # Composite: npm registry auth
80
+ │ ├── agents/ # 7 prompt files + config YAML
81
+ │ ├── seeds/ # Seed files for reset
82
+ │ └── scripts/ # Utility scripts
83
+
84
+ ├── MISSION.md # [USER] You write this -- your project goals
85
+ ├── src/lib/main.js # [USER] Your source code (seeded on --purge)
86
+ ├── tests/unit/main.test.js # [USER] Your tests (seeded on --purge)
87
+ ├── package.json # [USER] Your package config (seeded on --purge)
88
+ ├── README.md # [USER] Your readme (seeded on --purge)
89
+ ├── intentïon.md # [GENERATED] Activity log (cleared on --purge)
90
+ └── .github/agentic-lib/features/ # [GENERATED] Feature definitions (cleared on --purge)
91
+ ```
92
+
93
+ **Legend:**
94
+ - **[INIT]** -- Created or overwritten by `init` every time. You should not edit these.
95
+ - **[USER]** -- Your files. `init` never touches these. `init --purge` resets them to seed state.
96
+ - **[GENERATED]** -- Created by the agentic workflows during operation.
97
+
98
+ ### What You Need Before Running `init`
99
+
100
+ | File | Required? | Notes |
101
+ |------|-----------|-------|
102
+ | `package.json` | Recommended | If missing, `init --purge` creates one from the seed |
103
+ | `.gitignore` | Recommended | Standard Node.js gitignore |
104
+ | `LICENSE` | Recommended | Your choice of license |
105
+ | Git repo | Yes | Must be a git repository with a remote on GitHub |
106
+
107
+ ### GitHub Repository Settings
108
+
109
+ After `init`, configure these in your GitHub repository:
110
+
111
+ | Setting | Where | Purpose |
112
+ |---------|-------|---------|
113
+ | `COPILOT_GITHUB_TOKEN` | Settings > Secrets | Fine-grained PAT with "Copilot Requests" permission |
114
+ | GitHub Actions | Settings > Actions | Must be enabled (default) |
115
+ | Branch protection | Settings > Branches | Optional: require PR reviews before merge |
116
+
117
+ ## Configuration
118
+
119
+ Configuration lives in `agentic-lib.toml` at your project root:
120
+
121
+ ```toml
122
+ [schedule]
123
+ tier = "schedule-1" # schedule-1 through schedule-4
124
+
125
+ [paths]
126
+ mission = "MISSION.md"
127
+ source = "src/lib/"
128
+ tests = "tests/unit/"
129
+ features = ".github/agentic-lib/features/"
130
+ docs = "docs/"
131
+ readme = "README.md"
132
+ dependencies = "package.json"
133
+
134
+ [execution]
135
+ build = "npm run build"
136
+ test = "npm test"
137
+ start = "npm run start"
138
+
139
+ [limits]
140
+ feature-issues = 2
141
+ maintenance-issues = 1
142
+ attempts-per-branch = 3
143
+ attempts-per-issue = 2
144
+
145
+ [bot]
146
+ log-file = "intentïon.md"
147
+ ```
148
+
149
+ The YAML config at `.github/agentic-lib/agents/agentic-lib.yml` is also supported as a fallback.
150
+
151
+ ## The `agentic-step` Action
152
+
153
+ The core of the system is a single GitHub Action that handles all autonomous tasks:
154
+
155
+ | Task | Purpose |
156
+ |------|---------|
157
+ | `transform` | Transform the codebase toward the mission |
158
+ | `resolve-issue` | Read an issue and generate code to resolve it |
159
+ | `fix-code` | Fix failing tests or lint errors |
160
+ | `maintain-features` | Generate and maintain feature definitions |
161
+ | `maintain-library` | Update library documentation and sources |
162
+ | `enhance-issue` | Add detail and acceptance criteria to issues |
163
+ | `review-issue` | Review and close resolved issues |
164
+ | `discussions` | Respond to GitHub Discussions |
165
+
166
+ Each task calls the GitHub Copilot SDK with context assembled from your repository (mission, code, tests, features) and writes changes back to the working tree.
167
+
168
+ ## CLI Task Commands
169
+
170
+ Run Copilot SDK transformations locally from the command line. These are the same operations the GitHub Actions workflows perform, but you can run them interactively to see what happens.
171
+
172
+ ```bash
173
+ npx @xn-intenton-z2a/agentic-lib transform # advance code toward the mission
174
+ npx @xn-intenton-z2a/agentic-lib maintain-features # generate feature files from mission
175
+ npx @xn-intenton-z2a/agentic-lib maintain-library # update library docs from SOURCES.md
176
+ npx @xn-intenton-z2a/agentic-lib fix-code # fix failing tests
177
+ ```
178
+
179
+ All task commands accept these flags:
180
+
181
+ | Flag | Default | Purpose |
182
+ |------|---------|---------|
183
+ | `--dry-run` | off | Show the prompt without calling the Copilot SDK |
184
+ | `--target <path>` | current directory | Target repository to transform |
185
+ | `--model <name>` | `claude-sonnet-4` | Copilot SDK model |
186
+
187
+ ### Example: Full Walkthrough
188
+
189
+ ```bash
190
+ # 1. Start with a fresh repository
191
+ mkdir my-project && cd my-project && git init
192
+ npx @xn-intenton-z2a/agentic-lib init --purge
193
+
194
+ # 2. Write your mission
195
+ cat > MISSION.md <<'EOF'
196
+ # Mission: CSV to JSON Converter
197
+ Build a Node.js CLI tool that reads CSV from stdin and outputs JSON to stdout.
198
+ EOF
199
+
200
+ # 3. Install agentic-step dependencies
201
+ cd .github/agentic-lib/actions/agentic-step && npm ci && cd -
202
+
203
+ # 4. Generate features from your mission
204
+ npx @xn-intenton-z2a/agentic-lib maintain-features
205
+ # Output:
206
+ # === agentic-lib maintain-features ===
207
+ # [config] Loading agentic-lib.toml
208
+ # [context] Mission loaded, features: 0, library: 0
209
+ # [copilot] Creating session...
210
+ # [copilot] Sending prompt...
211
+ # [event] tool.call: write_file({"path":".github/agentic-lib/features/csv-parsing.md",...})
212
+ # === maintain-features completed in 12.3s ===
213
+
214
+ # 5. Transform code toward the mission
215
+ npx @xn-intenton-z2a/agentic-lib transform
216
+ # Output:
217
+ # === agentic-lib transform ===
218
+ # [context] Mission: # Mission: CSV to JSON Converter...
219
+ # [context] Features: 2, Source files: 1
220
+ # [copilot] Creating session...
221
+ # [event] tool.call: write_file({"path":"src/lib/main.js",...})
222
+ # [event] tool.call: run_command({"command":"npm test"})
223
+ # === transform completed in 18.7s ===
224
+
225
+ # 6. Review the changes
226
+ git diff
227
+
228
+ # 7. If happy, commit
229
+ git add -A && git commit -m "Initial transform" && git push
230
+ ```
231
+
232
+ Use `--dry-run` to see what prompt would be sent without calling the SDK:
233
+
234
+ ```bash
235
+ npx @xn-intenton-z2a/agentic-lib transform --dry-run
236
+ ```
237
+
238
+ ### Environment
239
+
240
+ | Variable | Required | Purpose |
241
+ |----------|----------|---------|
242
+ | `COPILOT_GITHUB_TOKEN` | For live runs | Fine-grained PAT with "Copilot Requests" permission |
243
+ | (none) | For `--dry-run` | Dry-run shows the prompt without calling the SDK |
244
+
245
+ If `COPILOT_GITHUB_TOKEN` is not set, the CLI falls back to local `gh` CLI authentication.
246
+
247
+ ## Three Ways to Start
248
+
249
+ | Method | How | Best for |
250
+ |--------|-----|----------|
251
+ | **Template** | Use [repository0](https://github.com/xn-intenton-z2a/repository0) as a GitHub template | New projects -- comes pre-initialised |
252
+ | **CLI** | `npx @xn-intenton-z2a/agentic-lib init` in any repo | Existing projects -- adds agentic workflows |
253
+ | **Website** | [xn--intenton-z2a.com](https://xn--intenton-z2a.com) | Guided setup with a web form |
254
+
255
+ ## Safety
256
+
257
+ Built-in safety mechanisms:
258
+
259
+ - **WIP limits** -- maximum concurrent issues to prevent runaway generation
260
+ - **Attempt limits** -- maximum retries per branch and per issue
261
+ - **Path enforcement** -- writable and read-only path separation
262
+ - **TDD mode** -- optionally require tests before implementation
263
+ - **Mission protection** -- MISSION.md is read-only to the agent
264
+
265
+ ## Updating
266
+
267
+ To update to the latest version of the agentic infrastructure:
268
+
269
+ ```bash
270
+ npx @xn-intenton-z2a/agentic-lib@latest init
271
+ git add -A && git commit -m "Update agentic-lib" && git push
272
+ ```
273
+
274
+ This overwrites `.github/workflows/` and `.github/agentic-lib/` with the latest versions. Your source code, tests, mission, and config are never touched.
275
+
276
+ ## Development
277
+
278
+ This repository is the source for the `@xn-intenton-z2a/agentic-lib` npm package. All distributed content lives in `src/`:
279
+
280
+ ```
281
+ src/
282
+ ├── workflows/ 13 GitHub Actions workflow templates
283
+ ├── actions/ 3 composite/SDK actions (agentic-step, commit-if-changed, setup-npmrc)
284
+ ├── agents/ 7 agent prompt files + 1 config
285
+ ├── seeds/ Seed files for --purge reset
286
+ └── scripts/ Utility scripts distributed to consumers
287
+ ```
288
+
289
+ ### Testing
290
+
291
+ 313 unit tests across 21 test files, plus system tests:
292
+
293
+ ```bash
294
+ npm test # Run all tests (vitest)
295
+ npm run linting # ESLint
296
+ npm run lint:workflows # Validate workflow YAML
297
+ npm run security # npm audit
298
+ npm run test:smoke # Connectivity smoke test (needs GITHUB_TOKEN)
299
+ npm run test:system # System test: init/purge cycle
300
+ npm run test:system:dry-run # System test: full flow with --dry-run
301
+ npm run test:system:live # System test: full flow with Copilot SDK (needs COPILOT_GITHUB_TOKEN)
302
+ ```
303
+
304
+ ### Publishing
305
+
306
+ Both auto and manual publishing are handled by `release.yml`:
307
+
308
+ - **Auto-publish**: Pushing to `main` with changes in `src/`, `bin/`, or `package.json` triggers a patch version bump and npm publish.
309
+ - **Manual release**: Use `release.yml` workflow dispatch for major/minor/prerelease versions.
310
+
311
+ ## Licensing
312
+
313
+ - Core SDK: [GPL-3.0](LICENSE) — `SPDX-License-Identifier: GPL-3.0-only`
314
+ - Distributed code (workflows, actions, seeds, scripts in `src/`): [MIT](LICENSE-MIT) — `SPDX-License-Identifier: MIT`
315
+ - All source files include SPDX license identifiers and copyright notices
316
+ - Copyright (C) 2025-2026 Polycode Limited
317
+
318
+ ## Links
319
+
320
+ - [repository0 template](https://github.com/xn-intenton-z2a/repository0) -- start here
321
+ - [Getting Started Guide](https://github.com/xn-intenton-z2a/repository0/blob/main/GETTING-STARTED.md)
322
+ - [API Reference](API.md)
323
+ - [Website](https://xn--intenton-z2a.com)