@felixdotgo/aidlc-kit 0.1.1 → 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 (198) hide show
  1. package/DEVELOPMENT.md +14 -13
  2. package/README.md +37 -43
  3. package/dist/assets/.agents/aidlc/docker/Dockerfile.claude +7 -0
  4. package/dist/assets/.agents/aidlc/docker/Dockerfile.codex +9 -0
  5. package/dist/assets/.agents/aidlc/docker/Dockerfile.opencode +8 -0
  6. package/dist/assets/.agents/aidlc/orchestrator.md +2 -2
  7. package/dist/assets/.agents/aidlc/phase-clarify.md +1 -1
  8. package/dist/assets/.agents/aidlc/phase-plan.md +2 -2
  9. package/dist/assets/.agents/aidlc/schemas/config.schema.json +2 -1
  10. package/dist/assets/.agents/aidlc/schemas/state.schema.json +2 -0
  11. package/dist/assets/.agents/aidlc/scripts/lib/assignment-store.mjs +94 -48
  12. package/dist/assets/.agents/aidlc/scripts/lib/context-runtime.mjs +5 -4
  13. package/dist/assets/.agents/aidlc/scripts/lib/loop-authority.mjs +261 -0
  14. package/dist/assets/.agents/aidlc/scripts/lib/loop-commit-message.mjs +45 -0
  15. package/dist/assets/.agents/aidlc/scripts/lib/loop-daemon.mjs +206 -0
  16. package/dist/assets/.agents/aidlc/scripts/lib/loop-drivers.mjs +100 -14
  17. package/dist/assets/.agents/aidlc/scripts/lib/loop-env.mjs +279 -0
  18. package/dist/assets/.agents/aidlc/scripts/lib/loop-fleet-cli.mjs +105 -32
  19. package/dist/assets/.agents/aidlc/scripts/lib/loop-fleet-remote.mjs +17 -1
  20. package/dist/assets/.agents/aidlc/scripts/lib/loop-fleet-supervisor.mjs +24 -7
  21. package/dist/assets/.agents/aidlc/scripts/lib/loop-fleet.mjs +42 -16
  22. package/dist/assets/.agents/aidlc/scripts/lib/loop-git.mjs +20 -6
  23. package/dist/assets/.agents/aidlc/scripts/lib/loop-holder.mjs +376 -0
  24. package/dist/assets/.agents/aidlc/scripts/lib/loop-intake.mjs +33 -7
  25. package/dist/assets/.agents/aidlc/scripts/lib/loop-lease.mjs +67 -61
  26. package/dist/assets/.agents/aidlc/scripts/lib/loop-leases.mjs +268 -0
  27. package/dist/assets/.agents/aidlc/scripts/lib/loop-local-workers.mjs +116 -28
  28. package/dist/assets/.agents/aidlc/scripts/lib/loop-runtime.mjs +114 -12
  29. package/dist/assets/.agents/aidlc/scripts/lib/loop-stream.mjs +117 -0
  30. package/dist/assets/.agents/aidlc/scripts/lib/loop-supervisor-local.mjs +16 -56
  31. package/dist/assets/.agents/aidlc/scripts/lib/loop-supervisor-run-local.mjs +149 -6
  32. package/dist/assets/.agents/aidlc/scripts/lib/loop-supervisor.mjs +9 -1
  33. package/dist/assets/.agents/aidlc/scripts/lib/loop-worker-docker.mjs +44 -6
  34. package/dist/assets/.agents/aidlc/scripts/lib/loop-worker-image.mjs +64 -0
  35. package/dist/assets/.agents/aidlc/scripts/lib/loop-worker-log.mjs +158 -0
  36. package/dist/assets/.agents/aidlc/scripts/lib/repo-head.mjs +22 -0
  37. package/dist/assets/.agents/aidlc/scripts/lib/store.mjs +68 -2
  38. package/dist/assets/.agents/aidlc/scripts/lib/task-runtime-migrate.mjs +75 -0
  39. package/dist/assets/.agents/aidlc/scripts/lib/task-runtime.mjs +97 -0
  40. package/dist/assets/.agents/aidlc/scripts/loop-entry.mjs +168 -73
  41. package/dist/assets/.agents/aidlc/scripts/loop-gate.mjs +19 -7
  42. package/dist/assets/.agents/aidlc/scripts/loop.cmd +101 -0
  43. package/dist/assets/.agents/aidlc/scripts/loop.mjs +2 -1
  44. package/dist/assets/.agents/aidlc/scripts/loop.sh +71 -0
  45. package/dist/assets/.agents/aidlc/scripts/remote-state.mjs +10 -4
  46. package/dist/assets/.agents/aidlc/scripts/state.mjs +16 -8
  47. package/dist/assets/.agents/aidlc/templates/design.md +9 -0
  48. package/dist/assets/.agents/aidlc/templates/intent.md +4 -0
  49. package/dist/assets/.agents/aidlc/templates/workplan.md +1 -1
  50. package/dist/assets/.agents/skills/aidlc-plan/SKILL.md +1 -1
  51. package/dist/assets/ui/bulma.min.css +3 -0
  52. package/dist/assets/ui/changes.js +83 -0
  53. package/dist/assets/ui/common.js +664 -0
  54. package/dist/assets/ui/dashboard.css +636 -0
  55. package/dist/assets/ui/dashboard.js +77 -0
  56. package/dist/assets/ui/detail.js +159 -0
  57. package/dist/assets/ui/live-log.js +332 -0
  58. package/dist/services/aidlc-coordination/Dockerfile +11 -3
  59. package/dist/services/aidlc-coordination/compose.yaml +12 -0
  60. package/dist/services/aidlc-coordination/package-lock.json +3 -1
  61. package/dist/services/aidlc-coordination/package.json +9 -4
  62. package/dist/services/aidlc-coordination/src/lifecycle-core.mjs +68 -2
  63. package/dist/services/aidlc-coordination/src/repository.mjs +66 -0
  64. package/dist/services/aidlc-coordination/src/server.mjs +9 -3
  65. package/dist/services/aidlc-coordination/test/fleet.test.mjs +21 -0
  66. package/dist/services/aidlc-coordination/test/server-health-auth.test.mjs +67 -0
  67. package/dist/src/adapters.d.ts +0 -3
  68. package/dist/src/adapters.js +3 -5
  69. package/dist/src/cli/argv.d.ts +12 -0
  70. package/dist/src/cli/argv.js +68 -0
  71. package/dist/src/cli/commands.d.ts +8 -0
  72. package/dist/src/cli/commands.js +159 -0
  73. package/dist/src/cli/loop-launcher.d.ts +47 -0
  74. package/dist/src/cli/loop-launcher.js +322 -0
  75. package/dist/src/cli/options.d.ts +25 -0
  76. package/dist/src/cli/options.js +32 -0
  77. package/dist/src/cli/prompt.d.ts +9 -0
  78. package/dist/src/cli/prompt.js +66 -0
  79. package/dist/src/cli.js +28 -191
  80. package/dist/src/gate.js +3 -2
  81. package/dist/src/installer.d.ts +14 -7
  82. package/dist/src/installer.js +42 -143
  83. package/dist/src/legacy.js +1 -0
  84. package/dist/src/managed-content.d.ts +7 -0
  85. package/dist/src/managed-content.js +15 -4
  86. package/dist/src/managed-planning.d.ts +65 -0
  87. package/dist/src/managed-planning.js +219 -0
  88. package/dist/src/mcp-setup.js +3 -1
  89. package/dist/src/model/config-contracts.d.ts +65 -0
  90. package/dist/src/model/config-contracts.js +1 -0
  91. package/dist/src/model/install-contracts.d.ts +29 -0
  92. package/dist/src/model/install-contracts.js +1 -0
  93. package/dist/src/model/lifecycle-enums.d.ts +13 -0
  94. package/dist/src/model/lifecycle-enums.js +1 -0
  95. package/dist/src/model/loop.d.ts +20 -0
  96. package/dist/src/model/loop.js +1 -0
  97. package/dist/src/model/manifest.d.ts +16 -0
  98. package/dist/src/model/manifest.js +1 -0
  99. package/dist/src/model/records.d.ts +142 -0
  100. package/dist/src/model/records.js +1 -0
  101. package/dist/src/model.d.ts +11 -264
  102. package/dist/src/model.js +1 -1
  103. package/dist/src/profiles.d.ts +2 -0
  104. package/dist/src/profiles.js +53 -9
  105. package/dist/src/state/archive-record.d.ts +9 -0
  106. package/dist/src/state/archive-record.js +26 -0
  107. package/dist/src/state/commands.d.ts +18 -0
  108. package/dist/src/state/commands.js +27 -0
  109. package/dist/src/state/domain.d.ts +9 -0
  110. package/dist/src/state/domain.js +9 -0
  111. package/dist/src/state/guards.d.ts +7 -0
  112. package/dist/src/state/guards.js +17 -0
  113. package/dist/src/state/io.d.ts +10 -0
  114. package/dist/src/state/io.js +35 -0
  115. package/dist/src/state/items.d.ts +3 -4
  116. package/dist/src/state/items.js +58 -57
  117. package/dist/src/state/lessons.js +14 -7
  118. package/dist/src/state/lifecycle.js +2 -2
  119. package/dist/src/state/lock.js +7 -6
  120. package/dist/src/state/memory.js +24 -12
  121. package/dist/src/state/{archive.js → migrate.js} +7 -7
  122. package/dist/src/state/partition.d.ts +15 -0
  123. package/dist/src/state/partition.js +90 -0
  124. package/dist/src/state/paths.d.ts +11 -0
  125. package/dist/src/state/paths.js +12 -0
  126. package/dist/src/state/render.js +9 -6
  127. package/dist/src/state/store.js +9 -15
  128. package/dist/src/state/transitions.js +9 -7
  129. package/dist/src/state/validate.js +55 -7
  130. package/dist/src/state.d.ts +16 -11
  131. package/dist/src/state.js +16 -11
  132. package/dist/src/task-ui.d.ts +33 -0
  133. package/dist/src/task-ui.js +33 -0
  134. package/dist/src/ui/assets.d.ts +14 -0
  135. package/dist/src/ui/assets.js +45 -0
  136. package/dist/src/ui/changes.d.ts +83 -0
  137. package/dist/src/ui/changes.js +498 -0
  138. package/dist/src/ui/containers.d.ts +71 -0
  139. package/dist/src/ui/containers.js +214 -0
  140. package/dist/src/ui/daemon.d.ts +75 -0
  141. package/dist/src/ui/daemon.js +232 -0
  142. package/dist/src/ui/data.d.ts +42 -0
  143. package/dist/src/ui/data.js +89 -0
  144. package/dist/src/ui/docs.d.ts +13 -0
  145. package/dist/src/ui/docs.js +39 -0
  146. package/dist/src/ui/files.d.ts +3 -0
  147. package/dist/src/ui/files.js +20 -0
  148. package/dist/src/ui/http.d.ts +14 -0
  149. package/dist/src/ui/http.js +80 -0
  150. package/dist/src/ui/live.d.ts +5 -0
  151. package/dist/src/ui/live.js +43 -0
  152. package/dist/src/ui/markdown.d.ts +2 -0
  153. package/dist/src/ui/markdown.js +127 -0
  154. package/dist/src/ui/options.d.ts +48 -0
  155. package/dist/src/ui/options.js +81 -0
  156. package/dist/src/ui/security.d.ts +34 -0
  157. package/dist/src/ui/security.js +38 -0
  158. package/dist/src/ui/server.d.ts +39 -0
  159. package/dist/src/ui/server.js +347 -0
  160. package/dist/src/ui/sse.d.ts +14 -0
  161. package/dist/src/ui/sse.js +281 -0
  162. package/dist/src/ui/views/board.d.ts +7 -0
  163. package/dist/src/ui/views/board.js +131 -0
  164. package/dist/src/ui/views/changes.d.ts +19 -0
  165. package/dist/src/ui/views/changes.js +154 -0
  166. package/dist/src/ui/views/components.d.ts +56 -0
  167. package/dist/src/ui/views/components.js +113 -0
  168. package/dist/src/ui/views/docs.d.ts +15 -0
  169. package/dist/src/ui/views/docs.js +64 -0
  170. package/dist/src/ui/views/layout.d.ts +44 -0
  171. package/dist/src/ui/views/layout.js +233 -0
  172. package/dist/src/ui/views/task.d.ts +25 -0
  173. package/dist/src/ui/views/task.js +320 -0
  174. package/dist/src/upgrade-board.js +10 -10
  175. package/dist/src/upgrade.d.ts +0 -1
  176. package/dist/src/upgrade.js +24 -85
  177. package/dist/src/workflow.d.ts +4 -0
  178. package/dist/src/workflow.js +36 -4
  179. package/docs/README.md +41 -22
  180. package/docs/architecture.md +101 -37
  181. package/docs/command-reference.md +289 -52
  182. package/docs/configuration.md +70 -30
  183. package/docs/coordination-service.md +91 -30
  184. package/docs/design-decisions.md +87 -0
  185. package/docs/development.md +124 -49
  186. package/docs/loop-local-run.md +228 -0
  187. package/docs/loop-runbook.md +214 -0
  188. package/docs/operating-workflow.md +55 -42
  189. package/docs/testing-and-release.md +72 -49
  190. package/docs/troubleshooting.md +221 -0
  191. package/package.json +4 -1
  192. package/dist/src/ledger.d.ts +0 -22
  193. package/dist/src/ledger.js +0 -119
  194. package/dist/src/state/shared.d.ts +0 -29
  195. package/dist/src/state/shared.js +0 -71
  196. package/dist/src/tracker.d.ts +0 -36
  197. package/dist/src/tracker.js +0 -44
  198. /package/dist/src/state/{archive.d.ts → migrate.d.ts} +0 -0
@@ -1,13 +1,13 @@
1
- import { createHash } from "node:crypto";
2
1
  import { readdirSync, readFileSync } from "node:fs";
3
2
  import { join } from "node:path";
4
3
  import { fileURLToPath } from "node:url";
5
4
  import { defaultConfig } from "./profiles.js";
6
- import { createLessonIndex, emptyMemoryRegistry, emptyState, lessonStateDigest } from "./state.js";
5
+ import { createLessonIndex, digest, emptyMemoryRegistry, emptyState, lessonStateDigest } from "./state.js";
7
6
  const owner = "aidlc-core";
8
7
  const assetRoot = fileURLToPath(new URL("../assets/.agents", import.meta.url));
9
8
  const packageJson = JSON.parse(readFileSync(fileURLToPath(new URL("../../package.json", import.meta.url)), "utf8"));
10
- export const contentHash = (content) => createHash("sha256").update(content).digest("hex");
9
+ // node:crypto update() hashes Uint8Array bytes unchanged; the cast only satisfies digest's narrower parameter type.
10
+ export const contentHash = (content) => digest(content);
11
11
  const collect = (directory, target) => readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
12
12
  const source = join(directory, entry.name);
13
13
  const destination = `${target}/${entry.name}`;
@@ -17,11 +17,43 @@ export const coreWorkflowFiles = () => [
17
17
  ...collect(join(assetRoot, "aidlc"), ".agents/aidlc"),
18
18
  ...collect(join(assetRoot, "skills"), ".agents/skills")
19
19
  ];
20
+ /** Commented template for the loop daemon's env file; seeded once and never overwritten. */
21
+ export const LOOP_ENV_TEMPLATE = `# AI-DLC loop environment, read by \`loop.sh up\` / \`aidlc-kit loop start\` (local mode).
22
+ # Precedence: shell exports > this file > values detected from your tools' own config.
23
+ # Keep real keys here only; .agents/.gitignore excludes this file from git.
24
+ # See what the loop will use with: .agents/aidlc/scripts/loop.sh check
25
+ #
26
+ # --- OpenCode (lead or workers set to "opencode") ---
27
+ # Model as provider/model[#variant] (list them with: opencode models).
28
+ # When unset, "model" from opencode.json is used.
29
+ # AIDLC_OPENCODE_MODEL=opencode-go/<model>
30
+ # Worker key; when unset it is read from ~/.local/share/opencode/auth.json.
31
+ # The key follows the model prefix: openai/ -> OPENAI_API_KEY, anthropic/ -> ANTHROPIC_API_KEY, otherwise OPENCODE_API_KEY.
32
+ # OPENCODE_API_KEY=
33
+ #
34
+ # --- Codex workers ---
35
+ # When unset, read from ~/.codex/auth.json (after: codex login --with-api-key).
36
+ # OPENAI_API_KEY=
37
+ #
38
+ # --- Claude Code workers ---
39
+ # When unset, read from "env" in .claude/settings.local.json, .claude/settings.json, or ~/.claude/settings.json.
40
+ # ANTHROPIC_API_KEY=
41
+ #
42
+ # --- Optional ---
43
+ # Override the auto-built worker image:
44
+ # AIDLC_WORKER_DOCKER_IMAGE=
45
+ # Where worker worktrees live (default: the system temp directory):
46
+ # AIDLC_LOCAL_WORKTREES_ROOT=
47
+ `;
48
+ /** Installed files that must be executable (POSIX launchers). */
49
+ export const isExecutableAsset = (path) => path.endsWith(".sh");
20
50
  export const initialProjectFiles = () => [
21
51
  { path: ".agents/config.json", owner: "aidlc-project", ownershipClass: "project", content: `${JSON.stringify(defaultConfig(), null, 2)}\n` },
22
52
  { path: ".agents/data/state/aidlc-state.json", owner: "aidlc-state", ownershipClass: "state", content: `${JSON.stringify(emptyState(), null, 2)}\n` },
23
53
  { path: ".agents/data/lessons/index.json", owner: "aidlc-state", ownershipClass: "state", content: `${JSON.stringify(createLessonIndex([], lessonStateDigest(emptyState())), null, 2)}\n` },
24
- { path: ".agents/data/memory/agentic-memory.json", owner: "aidlc-memory", ownershipClass: "project", content: `${JSON.stringify(emptyMemoryRegistry(), null, 2)}\n` }
54
+ { path: ".agents/data/memory/agentic-memory.json", owner: "aidlc-memory", ownershipClass: "project", content: `${JSON.stringify(emptyMemoryRegistry(), null, 2)}\n` },
55
+ { path: ".agents/loop.env", owner: "aidlc-project", ownershipClass: "project", content: LOOP_ENV_TEMPLATE },
56
+ { path: ".agents/.gitignore", owner: "aidlc-project", ownershipClass: "project", content: "# Local loop credentials (aidlc-kit)\nloop.env\n# Loop daemon/process state and per-task runtime data (aidlc-kit)\ndata/loop/\ndata/tasks/*/runtime/\n" }
25
57
  ];
26
58
  export const manifestKey = (spec) => spec.strategy === "managed-block" ? `${spec.path}#${spec.owner}` : spec.path;
27
59
  export const manifestFor = (files, adapters) => ({
package/docs/README.md CHANGED
@@ -1,31 +1,50 @@
1
1
  # Documentation
2
2
 
3
- Use this page to choose the guide that matches your role and next task.
3
+ Pick a page by what you want to do. New here? Install with the [README](../README.md), then read [Operating the workflow](./operating-workflow.md).
4
4
 
5
- ## For package users and operators
5
+ > [!WARNING]
6
+ > The loop, fleet mode, and the coordination service are pre-1.0 and experimental. See [Status and stability](./loop-runbook.md#status-and-stability).
6
7
 
7
- 1. Start with the repository [README](../README.md) to install the workflow.
8
- 2. Read [Operating the workflow](./operating-workflow.md) before asking an agent to change a project.
9
- 3. Use [Configuration](./configuration.md) to configure project rules, profiles, and Codex, Claude Code, and OpenCode permissions.
10
- 4. Keep [Command reference](./command-reference.md) nearby for safe CLI usage.
11
- 5. Read [AI-DLC Coordination service](./coordination-service.md) before enabling remote canonical state — the service and the loop are **experimental and unfinished**, with known bugs and possible breaking changes in every release before `1.0.0`.
8
+ ## Get started
12
9
 
13
- ## For contributors and maintainers
10
+ | Page | Read it when… |
11
+ | --- | --- |
12
+ | [README](../README.md) | You are installing the workflow into a project. |
13
+ | [Loop setup runbook](./loop-runbook.md) | You want to enable the loop, locally or across machines. |
14
+ | [Local loop walkthrough](./loop-local-run.md) | The loop is set up and you want to add tasks, watch them, approve gates, and use the dashboard. |
14
15
 
15
- 1. Begin with [Development](./development.md) for local setup and implementation boundaries.
16
- 2. Use [Testing and release](./testing-and-release.md) for the verification and package-smoke workflow.
17
- 3. Read [Architecture](./architecture.md) before changing package, installed-runtime, migration, or asset behaviour.
16
+ ## Use and operate
18
17
 
19
- ## Documentation map
18
+ | Page | Read it when… |
19
+ | --- | --- |
20
+ | [Operating the workflow](./operating-workflow.md) | You want the lifecycle, task state, review gates, and handoffs. |
21
+ | [AI-DLC Coordination service](./coordination-service.md) | You are deploying remote state or fleet workers on several machines. |
20
22
 
21
- | Page | Audience | Purpose |
22
- | --- | --- | --- |
23
- | [Operating the workflow](./operating-workflow.md) | Operators | Lifecycle, task state, human gates, and blocked work. |
24
- | [Configuration](./configuration.md) | Operators and maintainers | Project configuration, profile precedence, rules, and Codex, Claude Code, and OpenCode permissions. |
25
- | [Command reference](./command-reference.md) | Operators | Package CLI commands, flags, previews, and safety limits. |
26
- | [Development](./development.md) | Contributors | Dependencies, source layout, local commands, and implementation rules. |
27
- | [Testing and release](./testing-and-release.md) | Maintainers | Test strategy, evaluator, package smoke test, and release checks. |
28
- | [Architecture](./architecture.md) | Contributors | Boundaries, dependency direction, and source-to-consumer flow. |
29
- | [AI-DLC Coordination service](./coordination-service.md) | Operators | Opt-in service deployment, state authority, and credential safety. Experimental and unfinished: known bugs, breaking changes possible before `1.0.0`. |
23
+ ## Reference
30
24
 
31
- When a public command, configuration field, or installed layout changes, update the relevant guide and its validation in the same change.
25
+ | Page | Read it when… |
26
+ | --- | --- |
27
+ | [Configuration](./configuration.md) | You are editing `.agents/config.json`: profiles, rules, agent permissions, loop settings. |
28
+ | [Command reference](./command-reference.md) | You need a command, flag, environment variable, or installed script. |
29
+ | [Troubleshooting](./troubleshooting.md) | You have an error code, a stuck or paused task, or a dashboard problem. |
30
+
31
+ ## Contribute
32
+
33
+ | Page | Read it when… |
34
+ | --- | --- |
35
+ | [Development](./development.md) | You are setting up this repository, dogfooding its workflow, or changing source. |
36
+ | [Testing and release](./testing-and-release.md) | You are verifying a change or preparing a release. |
37
+ | [Architecture](./architecture.md) | You are changing a package boundary, installed runtime, migration, or asset layout. |
38
+ | [Design decisions](./design-decisions.md) | You need the reasoning behind a project-wide decision, or must record one. |
39
+
40
+ ## Adding or changing a page
41
+
42
+ Pages are flat `docs/<slug>.md` files; the dashboard, tests, and external links depend on the names.
43
+
44
+ - **Shape:** `# Title`, a 1–2 sentence opening (purpose and audience), `##` headings by reader task, tables for lookups, `## Related` with 2–4 links.
45
+ - **One source of truth:** each fact lives on one page; other pages give one sentence and a link. Experimental features get only a one-line callout to [Status and stability](./loop-runbook.md#status-and-stability).
46
+ - **Links:** `./<slug>.md#anchor`. The dashboard keeps links to pages in `DOC_PAGES` (`src/ui/docs.ts`) in-app and opens the rest on GitHub. Don't rename a linked heading without updating the links.
47
+ - **Register it:** add the page to a table above; to show it in the dashboard, add it to `DOC_PAGES` and run `node --test dist/test/unit/ui-docs.test.js` after `npm run build`; if the package must always ship it, add it to the docs test in `test/unit/installer.test.ts`.
48
+ - **Versions:** pages with version-pinned commands go on the [version bump checklist](./testing-and-release.md#version-bump-checklist).
49
+
50
+ A public command, configuration field, or installed-layout change updates the relevant page and its test in the same change.
@@ -1,6 +1,6 @@
1
1
  # Architecture
2
2
 
3
- `aidlc-kit` is a single Node.js/TypeScript package that installs static AI-DLC workflow assets into another project. The package CLI is used for installation and human-authorised maintenance; an installed project runs the dependency-free workflow scripts locally.
3
+ One Node.js/TypeScript package: the CLI installs and maintains static AI-DLC workflow assets; installed projects run dependency-free scripts locally.
4
4
 
5
5
  ## Source-to-consumer flow
6
6
 
@@ -14,55 +14,117 @@ dist/assets/.agents/ + dist/src/
14
14
  consumer project: .agents/aidlc/ + .agents/skills/ + project-owned .agents/data/
15
15
  ```
16
16
 
17
- The distinction matters:
18
-
19
- - **Source layout** is this repository's editable `assets/aidlc/` and `skills/` tree.
20
- - **Bundle layout** is generated under `dist/assets/.agents/` for package publication.
21
- - **Installed layout** is written under a consumer project's `.agents/` directory.
22
-
23
- `dist/` is generated. Source assets and installed assets must remain behaviourally aligned through the bundle and package-smoke tests.
17
+ Layouts: **source** (editable `assets/aidlc/`, `skills/`), **bundle** (generated `dist/assets/.agents/`, never hand-edited), **installed** (consumer `.agents/`); bundle and package-smoke tests keep them aligned.
24
18
 
25
19
  ## Module boundaries
26
20
 
27
21
  | Boundary | Modules | Responsibility |
28
22
  | --- | --- | --- |
29
- | CLI and installation | `src/cli.ts`, `src/installer.ts`, `src/workflow.ts`, `src/adapters.ts` | Parse commands, select adapters, plan deterministic writes, install managed assets, and expose local status/doctor checks. |
30
- | Lifecycle domain | `src/model.ts`, `src/state.ts`, `src/gate.ts`, `src/context.ts` | Validate canonical state, calculate transitions and gate readiness, and build bounded phase packets. |
31
- | Profiles and project integration | `src/profiles.ts`, `src/tracker.ts` | Resolve project configuration/profiles and optional tracker integration. |
32
- | Migration | `src/upgrade.ts`, `src/project-migration.ts`, `src/legacy.ts` | Plan and apply safe legacy-data and version-layout migration with audit backups. |
33
- | Shared file semantics | `src/project-path.ts`, `src/managed-content.ts` | Keep all paths inside the project, reject unsafe symlinks, and preserve managed-content ownership. |
34
- | Development evaluator | `dev/evaluator/` | Run repository-only evaluation; never expose evaluator assets through the published package CLI. |
35
-
36
- Dependencies flow inward: CLI, installation, and migration depend on lifecycle and shared helpers; lifecycle does not depend on installation; evaluator may provision an installation but is not part of published runtime behaviour.
23
+ | CLI and installation | `src/cli.ts` + `src/cli/` (`argv`, `options`, `prompt`, `commands`), `src/installer.ts`, `src/workflow.ts`, `src/adapters.ts`, `src/mcp-setup.ts` | Parse commands, select adapters, plan deterministic writes, install managed assets (incl. coordination-service template), status/doctor. |
24
+ | Shared planning core | `src/managed-planning.ts` | Manifest reading, inventory keys, managed-file planning ladder (create/skip/update/conflict), init vs upgrade policies. |
25
+ | Lifecycle domain | `src/model/` (barrel `src/model.ts`), `src/state/` (barrel `src/state.ts`), `src/gate.ts`, `src/context.ts` | Validate state, compute transitions and gate readiness, classify next actions, build phase packets. |
26
+ | Profiles | `src/profiles.ts` | Resolve and validate config/profiles (incl. schema-only `tracker`), expand effective rules. |
27
+ | Migration | `src/upgrade.ts`, `src/project-migration.ts`, `src/legacy.ts`, `src/upgrade-board.ts` | Legacy-data and version-layout migration (incl. legacy `BOARD.md`) with audit backups. |
28
+ | Web dashboard | `src/task-ui.ts` (barrel) over `src/ui/`; browser scripts `assets/ui/*.js` | Serve `aidlc-kit ui` dependency-free; mutations only spawn installed scripts, never write state. |
29
+ | Shared file semantics | `src/project-path.ts`, `src/managed-content.ts` | Path containment, unsafe-symlink rejection, managed-block marker format. |
30
+ | Development evaluator | `dev/evaluator/` | Repository-only; never in the published CLI. |
31
+
32
+ `src/state/`: `io`, `paths`, `domain`, `guards`, `archive-record`, `items`, `commands`, `transitions`, `validate`, `store`, `memory`, `lessons`, `lifecycle`, `render`, `migrate`, `lock`.
33
+
34
+ ### Web dashboard modules
35
+
36
+ - `src/ui/server`: route table (`ROUTES`) and `startUiServer`.
37
+ - `src/ui/security`: Host and request-shape checks (Origin, `Sec-Fetch-Site`, custom header); there is no session token.
38
+ - `src/ui/containers`: per-task worker container index and raw log tail (`.agents/data/tasks/<id>/runtime/workers/`), with `docker ps` enrichment.
39
+ - `src/ui/changes`: code changes with one source order for every mode (fleet snapshot → assignments → task range from `baseCommit`/`finalCommit` → working tree).
40
+ - `src/ui/options`, `src/ui/http`: option parsing, HTTP helpers.
41
+ - `src/ui/assets`: whitelisted static CSS/JS from `assets/ui/`.
42
+ - `src/ui/daemon`: daemon status, health, spawned script actions.
43
+ - `src/ui/data`: local and fleet reads.
44
+ - `src/ui/changes`: task diffs via Git.
45
+ - `src/ui/live`, `src/ui/sse`: `/api/live` regions and `/api/events`.
46
+ - `src/ui/markdown`: Markdown rendering.
47
+ - `src/ui/docs`: read-only packaged `docs/*.md` via the fixed `DOC_PAGES` whitelist.
48
+ - `src/ui/files`: byte-range file reads, optionally refusing symlinks.
49
+ - `src/ui/views/`: `layout`, `components`, `board`, `task`, `changes`, `docs`.
50
+ - `assets/ui/*.js`: plain browser scripts `common`, `dashboard`, `detail`, `live-log`, `changes`.
51
+
52
+ New page: route in `ROUTES` (`src/ui/server.ts`) + view in `src/ui/views/`.
53
+
54
+ ### Dependency direction
55
+
56
+ - Inward only: CLI, installation, migration depend on planning core, lifecycle, shared helpers.
57
+ - Planning core depends only on `model`, `workflow`, `managed-content`, `profiles`; never on CLI, installer, or upgrade.
58
+ - Migration never imports installation (`upgrade.ts` uses `managed-planning.ts` directly); the only `installer.ts` → `project-migration.ts` edge is init-time legacy-layout planning.
59
+ - Lifecycle never depends on installation; the evaluator may provision one but is not published runtime.
60
+ - `src/ledger.ts` and `src/tracker.ts` were removed as dead code; `tracker` config is schema-only (`TrackerConfig`).
37
61
 
38
62
  ## Installed workflow runtime
39
63
 
40
- The installed kernel consists of contracts, templates, schemas, profiles, and dependency-free scripts under `.agents/aidlc/`. Thin adapter instructions connect a selected coding tool to that kernel. Project customisation belongs outside the kernel:
64
+ Kernel: contracts, templates, schemas, profiles, dependency-free scripts in `.agents/aidlc/`, reached via thin adapter instructions. Customisation stays outside:
41
65
 
42
66
  | Location | Ownership | Purpose |
43
67
  | --- | --- | --- |
44
- | `.agents/aidlc/` | Package managed | Lifecycle contracts, schemas, and scripts. |
45
- | `.agents/data/` | Project owned | Canonical state, task artifacts, derived indexes, memory, and evidence. |
46
- | `.agents/project/` | Project owned | Local profiles, rules, and evaluation material. |
68
+ | `.agents/aidlc/` | Package managed | Lifecycle contracts, schemas, scripts. |
69
+ | `.agents/data/` | Project owned | Canonical state, task artifacts, derived indexes, memory, evidence. |
70
+ | `.agents/project/` | Project owned | Local profiles, rules, evaluation material. |
47
71
 
48
- The state machine enforces the lifecycle; gates require explicit human approval; evidence is append-only. Installed scripts remain usable without an `aidlc-kit` executable or a duplicate board file.
72
+ State machine enforces the lifecycle; gates need human approval; evidence is append-only; no `aidlc-kit` executable or duplicate board file needed.
73
+
74
+ ### Loop runtime
49
75
 
50
76
  > [!WARNING]
51
- > The interactive-loop support and the end-to-end loop/fleet coordinator described below are **experimental and unfinished**: they contain known bugs and rough edges, and — because the package is still pre-1.0 (`0.x`) — their command surface, configuration fields, and state layout can change incompatibly in any release before `1.0.0`.
77
+ > Experimental, pre-1.0. See [Status and stability](./loop-runbook.md#status-and-stability).
78
+
79
+ Dispatch derives from task `nextAction` and dependency-ready work; assignment records are operational metadata; phase, evidence, gates stay canonical. Selecting a mode only configures; `loop start` (or `loop up`) runs.
52
80
 
53
- The interactive loop runs inside the current Codex, Claude Code, or OpenCode conversation. Native workers use local assignment records under `.agents/data/loop/`; those records hold claims and checkpoints while `.agents/data/state/` remains lifecycle authority. The optional headless fleet runner uses the coordination service's PostgreSQL state, fenced lead and worker claims, and Git commit handoff. Its assignment records are operational metadata; task phase, evidence, and gates stay in the canonical lifecycle state. All hosts derive dispatch from task `nextAction` and dependency-ready work.
81
+ | Variant | Authority | How it runs |
82
+ | --- | --- | --- |
83
+ | Interactive | Local `.agents/data/state/` | In the current agent conversation; native workers claim and checkpoint via assignment records in the task's `runtime/` directory. |
84
+ | Local | Local `.agents/data/state/` | Singleton daemon (`loop start` or `loop.sh up`): host-executed lead, Docker-isolated workers; gate approval only via trusted host terminal or dashboard. |
85
+ | Fleet | Coordination service | Service owns supervisor leases, gate checkpoints, reviewer approval; Docker workers hold own credentials; Git uses fenced lead/worker claims with commit handoff. SQLite single-host, PostgreSQL multi-host. |
86
+
87
+ Every variant is a wrapper around the same data: the canonical task state (including `baseCommit`/`finalCommit`, written by `state.mjs` locally and `remote-state.mjs` in fleet mode through the shared core) and the task directory `.agents/data/tasks/<id>/`. Review artifacts (`intent.md`, `design.md`, `workplan.md`) sit at its root; everything operational sits under `runtime/`, identical for the no-loop workflow, the local loop, and fleet (one helper, `lib/task-runtime.mjs`, names every path and refuses symlinked components):
88
+
89
+ | `.agents/data/tasks/<id>/runtime/` | Written by | Purpose |
90
+ | --- | --- | --- |
91
+ | `assignments.json`, `assignments.lock` | `assignment.mjs` (interactive), local supervisor | worker claims (local only; fleet claims live in the service) |
92
+ | `events.jsonl` (+ `.1`) | `loop-stream.mjs` | the task's event history (dashboard live log) |
93
+ | `run.json` | `loop-runtime.mjs` | the loop run record (run id, agent, status, session, checkpoint) |
94
+ | `intake.json`, `requirement.md` | loop intake | loop ownership and the requirement text |
95
+ | `workers/index.json`, `workers/<assignment>.log` | local and fleet workers | container index and raw output |
54
96
 
55
- Installed entry points share a strict dependency-free argv parser. Parsing and command-shape validation precede root discovery, lock acquisition, and state reads. Explicit roots are validated project directories; implicit roots use nearest-ancestor `.agents/aidlc/` discovery and never fall back to writing beneath an arbitrary working directory.
97
+ `.agents/data/loop/` holds only daemon and process state: `daemon.lock`, `daemon.log`, `daemon.stop`, the global `ui-events.jsonl`, `ui.json`/`cli.json`, task leases (`<id>.lease`), the lead checkpoint (`<id>.supervisor.json`) and gate receipt. Both directories are operational: never committed, handed off, or clean-checked, and the installer's `.agents/.gitignore` excludes them. Files written by versions before this layout are read in place and moved by `aidlc-kit loop migrate-data` or the daemon at start ([Command reference](./command-reference.md#loop)).
98
+
99
+ **Agent support.**
100
+
101
+ - Host-executed lead turns: Codex, Claude Code, OpenCode.
102
+ - Container-isolated lead turns: Codex, Claude Code; OpenCode rejected with a diagnostic (file-based credentials; `lib/loop-lead-sandbox.mjs`).
103
+ - Docker workers (local and fleet): all three; OpenCode uses environment credentials, XDG roots redirected into the ephemeral worker HOME (`lib/loop-worker-docker.mjs`).
104
+
105
+ **Leases, locks, and claims.** One holder-file primitive (`lib/loop-holder.mjs`), three meanings:
106
+
107
+ - **Lock:** short mutex around a file write (assignment records).
108
+ - **Lease:** process ownership of the singleton daemon or one task's loop run (replacing separate runner and supervisor leases); its `activity` (`waiting` or `turn`) gates approval.
109
+ - **Claim:** a worker's ownership of an item and its paths.
110
+
111
+ One file format and liveness rule; 15 s renewal, 60 s TTL; a `<file>.guard` serializes reclaim, renewal, release. `aidlc-kit loop leases` lists them; details: [Troubleshooting](./troubleshooting.md#loop-leases-locks-and-claims).
112
+
113
+ ### Installed entry points
114
+
115
+ A shared strict argv parser validates command shape before root discovery, lock acquisition, and state reads. Explicit roots must be validated project directories; implicit roots use nearest-ancestor `.agents/aidlc/` discovery, never an arbitrary cwd.
56
116
 
57
117
  ## Trust and safety boundaries
58
118
 
59
- - Workflow assets are local package assets. The manifest records `remoteUpdates: false`; status and doctor do not consult a registry.
60
- - Install/upgrade plans are conflict-first, path-contained, and reject unsafe symlink traversal.
61
- - Human-only upgrade is an intentional boundary: interactive confirmation is required and agents must not run or discover upgrades.
62
- - Codex, Claude Code, and OpenCode adapters are installed. Codex uses trusted project-scoped `.codex/config.toml` and `.codex/rules/aidlc.rules`; Claude Code scopes lifecycle-script permission through its local settings and phase skills. OpenCode gets an owner-scoped `AGENTS.md` block only, and `.opencode/` is read solely for detection, so no OpenCode configuration, MCP, or permission file is overridden.
63
- - Project commands are configured as executable-and-argument arrays rather than opaque shell strings.
64
- - Canonical state, terminal records, and rendered workplans reject symlink traversal and use same-directory atomic replacement. Lock acquisition is guard-serialized, while release verifies the owner token directly so a contended guard cannot strand the owner's main lock.
65
- - The compact master catalog remains archive authority. Recovery can replace only a valid, unreferenced terminal orphan tied by `id` and `createdAt` to the still-active catalog task; referenced, malformed, and identity-conflicting records fail closed.
119
+ - Assets are local (manifest `remoteUpdates: false`); status/doctor never consult a registry.
120
+ - Install/upgrade plans: conflict-first, path-contained, no unsafe symlink traversal.
121
+ - Upgrade is human-only (interactive confirmation); agents never run or discover upgrades.
122
+ - Codex: project-scoped `.codex/config.toml`, `.codex/rules/aidlc.rules`. Claude Code: lifecycle-script permission via local settings and phase skills. OpenCode: owner-scoped `AGENTS.md` block only; `.opencode/` read for detection only.
123
+ - Project commands: executable-and-argument arrays, never shell strings.
124
+ - Canonical state, terminal records, and rendered workplans reject symlink traversal; writes are same-directory atomic replaces.
125
+ - State lock: guard-serialized; release verifies the owner token directly, so a contended guard cannot strand it; stale when its pid is gone and it is 30 s old.
126
+ - Loop holders (`lib/loop-holder.mjs`) re-read the token under the guard on reclaim, so a reclaimer never deletes a newer holder.
127
+ - The compact master catalog is archive authority; recovery replaces only a valid, unreferenced terminal orphan matching the active catalog task by `id` and `createdAt`; referenced, malformed, or identity-conflicting records fail closed.
66
128
 
67
129
  ## Change impact guide
68
130
 
@@ -70,11 +132,13 @@ Installed entry points share a strict dependency-free argv parser. Parsing and c
70
132
  | --- | --- |
71
133
  | A lifecycle/state rule | Installed scripts, schemas, gate/context rendering, runtime parity tests. |
72
134
  | An asset or adapter | Asset builder, package inventory, installer, adapter tests, tarball smoke test. |
73
- | A configuration/profile field | Validator, schema, effective-profile behaviour, documentation, and tests. |
74
- | Migration semantics | Upgrade plan/apply logic, path safety, transaction rollback, and migration tests. |
75
- | A public command | CLI parsing, README/setup guidance, command reference, and package tests. |
76
-
77
- Use this guide with [Development](./development.md) and [Testing and release](./testing-and-release.md) before changing a cross-cutting boundary.
135
+ | A configuration/profile field | Validator, schema, effective-profile behaviour, docs, tests. |
136
+ | Migration semantics | Upgrade plan/apply logic, path safety, transaction rollback, migration tests. |
137
+ | A public command | CLI parsing, README/setup guidance, command reference, package tests. |
78
138
 
139
+ ## Related
79
140
 
80
- The optional end-to-end loop coordinator is implemented for both authorities. Local mode runs a foreground supervisor over the canonical local state: Docker-isolated workers, a read-only lead sandbox whose structured proposals are applied by a host broker, and gate approval only through the trusted host terminal. Fleet mode runs the same loop against a coordination service: the service owns supervisor leases, gate checkpoints, and reviewer approval, workers execute in Docker with their own credentials, and Git integration is fenced per backend (SQLite on one host with a local volume, or PostgreSQL across hosts). Selecting a mode configures the loop; only an explicit `loop start` runs it. Host-executed lead turns accept Codex, Claude Code, or OpenCode; container-isolated lead turns and worker containers accept Codex and Claude Code only and reject OpenCode with an explicit diagnostic because its credentials are file-based. See [Coordination service](./coordination-service.md) for deployment and recovery constraints.
141
+ - [Development guide](./development.md)
142
+ - [Testing and release](./testing-and-release.md)
143
+ - [Design decisions](./design-decisions.md)
144
+ - [Coordination service](./coordination-service.md)