@aragon-agent/cli 0.6.54 → 0.6.56
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/CHANGELOG.md +2912 -2838
- package/README.md +4226 -4042
- package/dist/agent/controller.d.ts +119 -0
- package/dist/agent/controller.js +365 -2
- package/dist/agent/governance-wiring.js +8 -1
- package/dist/agent/redteam-prompt.d.ts +47 -0
- package/dist/agent/redteam-prompt.js +161 -0
- package/dist/agent/redteam-wiring.d.ts +159 -0
- package/dist/agent/redteam-wiring.js +349 -0
- package/dist/agent/system-prompt.d.ts +39 -0
- package/dist/agent/system-prompt.js +18 -0
- package/dist/app/App.d.ts +10 -1
- package/dist/app/App.js +233 -24
- package/dist/app/use-redteam-mode.d.ts +56 -0
- package/dist/app/use-redteam-mode.js +121 -0
- package/dist/cli.js +82 -4
- package/dist/commands/builtins.js +43 -1
- package/dist/commands/catalog.js +5 -0
- package/dist/commands/index-build.js +2 -1
- package/dist/commands/redteam-command.d.ts +22 -0
- package/dist/commands/redteam-command.js +141 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/config/app-paths.d.ts +10 -0
- package/dist/config/app-paths.js +12 -0
- package/dist/config/cli-commands.d.ts +29 -0
- package/dist/config/cli-commands.js +76 -1
- package/dist/config/env.d.ts +3 -1
- package/dist/config/env.js +23 -1
- package/dist/config/load.d.ts +22 -0
- package/dist/config/load.js +22 -2
- package/dist/config/redteam-launch.d.ts +77 -0
- package/dist/config/redteam-launch.js +58 -0
- package/dist/config/store.js +21 -1
- package/dist/config/ui-state.d.ts +44 -0
- package/dist/config/ui-state.js +38 -0
- package/dist/exec/bridge/server.d.ts +7 -0
- package/dist/exec/bridge/server.js +6 -2
- package/dist/exec/cli-commands.js +4 -0
- package/dist/exec/index.js +2 -0
- package/dist/exec/options.d.ts +11 -0
- package/dist/exec/options.js +21 -1
- package/dist/gene/block.d.ts +33 -0
- package/dist/gene/block.js +51 -0
- package/dist/gene/capacity.d.ts +74 -0
- package/dist/gene/capacity.js +169 -0
- package/dist/gene/catalog-reconcile.d.ts +13 -0
- package/dist/gene/catalog-reconcile.js +105 -0
- package/dist/gene/catalog-stats.d.ts +27 -0
- package/dist/gene/catalog-stats.js +89 -0
- package/dist/gene/catalog-sync.d.ts +82 -0
- package/dist/gene/catalog-sync.js +324 -0
- package/dist/gene/catalog.d.ts +160 -0
- package/dist/gene/catalog.js +433 -0
- package/dist/gene/cli-commands.d.ts +50 -0
- package/dist/gene/cli-commands.js +500 -0
- package/dist/gene/command-report.d.ts +40 -0
- package/dist/gene/command-report.js +246 -0
- package/dist/gene/command.d.ts +29 -0
- package/dist/gene/command.js +561 -0
- package/dist/gene/commit-apply-types.d.ts +13 -0
- package/dist/gene/commit-apply-types.js +1 -0
- package/dist/gene/commit-compound.d.ts +34 -0
- package/dist/gene/commit-compound.js +212 -0
- package/dist/gene/commit-counts.d.ts +41 -0
- package/dist/gene/commit-counts.js +70 -0
- package/dist/gene/commit-exec.d.ts +42 -0
- package/dist/gene/commit-exec.js +134 -0
- package/dist/gene/commit-head.d.ts +52 -0
- package/dist/gene/commit-head.js +97 -0
- package/dist/gene/commit-plan.d.ts +95 -0
- package/dist/gene/commit-plan.js +68 -0
- package/dist/gene/commit-prepare.d.ts +63 -0
- package/dist/gene/commit-prepare.js +159 -0
- package/dist/gene/commit-types.d.ts +234 -0
- package/dist/gene/commit-types.js +3 -0
- package/dist/gene/curator/agent.d.ts +137 -0
- package/dist/gene/curator/agent.js +203 -0
- package/dist/gene/curator/budget.d.ts +69 -0
- package/dist/gene/curator/budget.js +131 -0
- package/dist/gene/curator/conflicts.d.ts +54 -0
- package/dist/gene/curator/conflicts.js +143 -0
- package/dist/gene/curator/curator.d.ts +170 -0
- package/dist/gene/curator/curator.js +617 -0
- package/dist/gene/curator/deps.d.ts +34 -0
- package/dist/gene/curator/deps.js +48 -0
- package/dist/gene/curator/deterministic.d.ts +62 -0
- package/dist/gene/curator/deterministic.js +287 -0
- package/dist/gene/curator/executors.d.ts +36 -0
- package/dist/gene/curator/executors.js +379 -0
- package/dist/gene/curator/lanes.d.ts +52 -0
- package/dist/gene/curator/lanes.js +99 -0
- package/dist/gene/curator/lease.d.ts +76 -0
- package/dist/gene/curator/lease.js +171 -0
- package/dist/gene/curator/library.d.ts +36 -0
- package/dist/gene/curator/library.js +169 -0
- package/dist/gene/curator/lifecycle.d.ts +52 -0
- package/dist/gene/curator/lifecycle.js +109 -0
- package/dist/gene/curator/maintenance.d.ts +71 -0
- package/dist/gene/curator/maintenance.js +213 -0
- package/dist/gene/curator/probation.d.ts +51 -0
- package/dist/gene/curator/probation.js +71 -0
- package/dist/gene/curator/probe.d.ts +131 -0
- package/dist/gene/curator/probe.js +534 -0
- package/dist/gene/curator/prompt.d.ts +18 -0
- package/dist/gene/curator/prompt.js +128 -0
- package/dist/gene/curator/publish.d.ts +64 -0
- package/dist/gene/curator/publish.js +113 -0
- package/dist/gene/curator/recheck.d.ts +55 -0
- package/dist/gene/curator/recheck.js +103 -0
- package/dist/gene/curator/run-events.d.ts +63 -0
- package/dist/gene/curator/run-events.js +55 -0
- package/dist/gene/curator/similarity.d.ts +13 -0
- package/dist/gene/curator/similarity.js +46 -0
- package/dist/gene/curator/switches.d.ts +78 -0
- package/dist/gene/curator/switches.js +146 -0
- package/dist/gene/curator/task-context.d.ts +93 -0
- package/dist/gene/curator/task-context.js +63 -0
- package/dist/gene/curator/task-runner.d.ts +56 -0
- package/dist/gene/curator/task-runner.js +257 -0
- package/dist/gene/curator/tool-support.d.ts +112 -0
- package/dist/gene/curator/tool-support.js +197 -0
- package/dist/gene/curator/toolkit.d.ts +49 -0
- package/dist/gene/curator/toolkit.js +104 -0
- package/dist/gene/curator/tools-read.d.ts +4 -0
- package/dist/gene/curator/tools-read.js +177 -0
- package/dist/gene/curator/tools-release.d.ts +73 -0
- package/dist/gene/curator/tools-release.js +287 -0
- package/dist/gene/curator/tools-verify.d.ts +47 -0
- package/dist/gene/curator/tools-verify.js +202 -0
- package/dist/gene/curator/tools-write.d.ts +26 -0
- package/dist/gene/curator/tools-write.js +394 -0
- package/dist/gene/curator/tools.d.ts +23 -0
- package/dist/gene/curator/tools.js +21 -0
- package/dist/gene/curator/validate/common.d.ts +87 -0
- package/dist/gene/curator/validate/common.js +132 -0
- package/dist/gene/curator/validate/evidence-tokens.d.ts +36 -0
- package/dist/gene/curator/validate/evidence-tokens.js +139 -0
- package/dist/gene/curator/validate/index.d.ts +23 -0
- package/dist/gene/curator/validate/index.js +62 -0
- package/dist/gene/curator/validate/knowledge.d.ts +25 -0
- package/dist/gene/curator/validate/knowledge.js +216 -0
- package/dist/gene/curator/validate/live-check.d.ts +14 -0
- package/dist/gene/curator/validate/live-check.js +144 -0
- package/dist/gene/curator/validate/ports.d.ts +67 -0
- package/dist/gene/curator/validate/ports.js +1 -0
- package/dist/gene/curator/validate/prompts.d.ts +41 -0
- package/dist/gene/curator/validate/prompts.js +161 -0
- package/dist/gene/curator/validate/skill.d.ts +15 -0
- package/dist/gene/curator/validate/skill.js +251 -0
- package/dist/gene/curator/validate/tool.d.ts +6 -0
- package/dist/gene/curator/validate/tool.js +217 -0
- package/dist/gene/curator/validate/types.d.ts +90 -0
- package/dist/gene/curator/validate/types.js +1 -0
- package/dist/gene/curator/validator-ports.d.ts +38 -0
- package/dist/gene/curator/validator-ports.js +29 -0
- package/dist/gene/diag.d.ts +209 -0
- package/dist/gene/diag.js +549 -0
- package/dist/gene/env.d.ts +10 -0
- package/dist/gene/env.js +214 -0
- package/dist/gene/eval-recorder.d.ts +84 -0
- package/dist/gene/eval-recorder.js +222 -0
- package/dist/gene/explain-transport.d.ts +3 -0
- package/dist/gene/explain-transport.js +39 -0
- package/dist/gene/explain.d.ts +96 -0
- package/dist/gene/explain.js +293 -0
- package/dist/gene/fs.d.ts +39 -0
- package/dist/gene/fs.js +139 -0
- package/dist/gene/fsck.d.ts +68 -0
- package/dist/gene/fsck.js +134 -0
- package/dist/gene/gc-library-sweeps.d.ts +9 -0
- package/dist/gene/gc-library-sweeps.js +220 -0
- package/dist/gene/gc-rejected-set.d.ts +15 -0
- package/dist/gene/gc-rejected-set.js +63 -0
- package/dist/gene/gc-safe.d.ts +12 -0
- package/dist/gene/gc-safe.js +74 -0
- package/dist/gene/gc-scope-sweeps.d.ts +18 -0
- package/dist/gene/gc-scope-sweeps.js +297 -0
- package/dist/gene/gc-types.d.ts +55 -0
- package/dist/gene/gc-types.js +26 -0
- package/dist/gene/gc.d.ts +42 -0
- package/dist/gene/gc.js +129 -0
- package/dist/gene/gene-errors.d.ts +23 -0
- package/dist/gene/gene-errors.js +29 -0
- package/dist/gene/hints.d.ts +91 -0
- package/dist/gene/hints.js +394 -0
- package/dist/gene/hub.d.ts +149 -0
- package/dist/gene/hub.js +371 -0
- package/dist/gene/import-plan.d.ts +80 -0
- package/dist/gene/import-plan.js +294 -0
- package/dist/gene/import-proposal.d.ts +23 -0
- package/dist/gene/import-proposal.js +101 -0
- package/dist/gene/import-skill-port.d.ts +6 -0
- package/dist/gene/import-skill-port.js +53 -0
- package/dist/gene/import-sources.d.ts +48 -0
- package/dist/gene/import-sources.js +140 -0
- package/dist/gene/index-writer.d.ts +36 -0
- package/dist/gene/index-writer.js +101 -0
- package/dist/gene/learn/learn-call.d.ts +63 -0
- package/dist/gene/learn/learn-call.js +157 -0
- package/dist/gene/learn/learn-prompt.d.ts +51 -0
- package/dist/gene/learn/learn-prompt.js +245 -0
- package/dist/gene/learn/learner.d.ts +181 -0
- package/dist/gene/learn/learner.js +426 -0
- package/dist/gene/learn/ledger.d.ts +220 -0
- package/dist/gene/learn/ledger.js +394 -0
- package/dist/gene/learn/proposal-build.d.ts +83 -0
- package/dist/gene/learn/proposal-build.js +211 -0
- package/dist/gene/learn/proposal-guard.d.ts +43 -0
- package/dist/gene/learn/proposal-guard.js +37 -0
- package/dist/gene/learn/signals-port.d.ts +47 -0
- package/dist/gene/learn/signals-port.js +86 -0
- package/dist/gene/maintenance-paths.d.ts +7 -0
- package/dist/gene/maintenance-paths.js +20 -0
- package/dist/gene/maintenance-probation.d.ts +33 -0
- package/dist/gene/maintenance-probation.js +127 -0
- package/dist/gene/maintenance-proposals.d.ts +24 -0
- package/dist/gene/maintenance-proposals.js +68 -0
- package/dist/gene/maintenance-runner.d.ts +92 -0
- package/dist/gene/maintenance-runner.js +262 -0
- package/dist/gene/maintenance-tasks.d.ts +37 -0
- package/dist/gene/maintenance-tasks.js +95 -0
- package/dist/gene/manager-actions.d.ts +12 -0
- package/dist/gene/manager-actions.js +279 -0
- package/dist/gene/manager-approve.d.ts +29 -0
- package/dist/gene/manager-approve.js +84 -0
- package/dist/gene/manager-context.d.ts +90 -0
- package/dist/gene/manager-context.js +201 -0
- package/dist/gene/manager-detail.d.ts +17 -0
- package/dist/gene/manager-detail.js +313 -0
- package/dist/gene/manager-gc.d.ts +13 -0
- package/dist/gene/manager-gc.js +81 -0
- package/dist/gene/manager-library.d.ts +39 -0
- package/dist/gene/manager-library.js +90 -0
- package/dist/gene/manager-list.d.ts +27 -0
- package/dist/gene/manager-list.js +170 -0
- package/dist/gene/manager-queue.d.ts +16 -0
- package/dist/gene/manager-queue.js +124 -0
- package/dist/gene/manager-stats.d.ts +28 -0
- package/dist/gene/manager-stats.js +53 -0
- package/dist/gene/manager-view.d.ts +27 -0
- package/dist/gene/manager-view.js +124 -0
- package/dist/gene/manager.d.ts +56 -0
- package/dist/gene/manager.js +179 -0
- package/dist/gene/orphan-scopes.d.ts +37 -0
- package/dist/gene/orphan-scopes.js +150 -0
- package/dist/gene/paths.d.ts +73 -0
- package/dist/gene/paths.js +239 -0
- package/dist/gene/plan-content.d.ts +73 -0
- package/dist/gene/plan-content.js +522 -0
- package/dist/gene/plan-lifecycle.d.ts +29 -0
- package/dist/gene/plan-lifecycle.js +310 -0
- package/dist/gene/policy.d.ts +71 -0
- package/dist/gene/policy.js +313 -0
- package/dist/gene/project-learning.d.ts +25 -0
- package/dist/gene/project-learning.js +54 -0
- package/dist/gene/propagation.d.ts +48 -0
- package/dist/gene/propagation.js +45 -0
- package/dist/gene/queue-lock.d.ts +22 -0
- package/dist/gene/queue-lock.js +99 -0
- package/dist/gene/queue-record.d.ts +57 -0
- package/dist/gene/queue-record.js +145 -0
- package/dist/gene/queue.d.ts +235 -0
- package/dist/gene/queue.js +764 -0
- package/dist/gene/read.d.ts +61 -0
- package/dist/gene/read.js +252 -0
- package/dist/gene/runlog.d.ts +101 -0
- package/dist/gene/runlog.js +404 -0
- package/dist/gene/schema-lite.d.ts +24 -0
- package/dist/gene/schema-lite.js +159 -0
- package/dist/gene/scope-guard.d.ts +23 -0
- package/dist/gene/scope-guard.js +9 -0
- package/dist/gene/scope-lock.d.ts +48 -0
- package/dist/gene/scope-lock.js +222 -0
- package/dist/gene/scope-verify.d.ts +63 -0
- package/dist/gene/scope-verify.js +123 -0
- package/dist/gene/secrets.d.ts +43 -0
- package/dist/gene/secrets.js +161 -0
- package/dist/gene/service-context.d.ts +43 -0
- package/dist/gene/service-context.js +79 -0
- package/dist/gene/service-prepare.d.ts +25 -0
- package/dist/gene/service-prepare.js +219 -0
- package/dist/gene/service-types.d.ts +196 -0
- package/dist/gene/service-types.js +1 -0
- package/dist/gene/service-view.d.ts +41 -0
- package/dist/gene/service-view.js +69 -0
- package/dist/gene/service.d.ts +114 -0
- package/dist/gene/service.js +761 -0
- package/dist/gene/session-start.d.ts +36 -0
- package/dist/gene/session-start.js +212 -0
- package/dist/gene/store-port.d.ts +88 -0
- package/dist/gene/store-port.js +10 -0
- package/dist/gene/store-rows.d.ts +36 -0
- package/dist/gene/store-rows.js +72 -0
- package/dist/gene/store.d.ts +125 -0
- package/dist/gene/store.js +622 -0
- package/dist/gene/tombstones.d.ts +47 -0
- package/dist/gene/tombstones.js +61 -0
- package/dist/gene/tool-runner.d.ts +47 -0
- package/dist/gene/tool-runner.js +154 -0
- package/dist/gene/tool-screen.d.ts +41 -0
- package/dist/gene/tool-screen.js +227 -0
- package/dist/gene/tools.d.ts +112 -0
- package/dist/gene/tools.js +539 -0
- package/dist/gene/transfer.d.ts +85 -0
- package/dist/gene/transfer.js +433 -0
- package/dist/gene/ui-hints.d.ts +15 -0
- package/dist/gene/ui-hints.js +67 -0
- package/dist/gene/usage-fold-cursor.d.ts +24 -0
- package/dist/gene/usage-fold-cursor.js +115 -0
- package/dist/gene/usage-fold.d.ts +49 -0
- package/dist/gene/usage-fold.js +397 -0
- package/dist/gene/usage.d.ts +67 -0
- package/dist/gene/usage.js +231 -0
- package/dist/gene/version-service.d.ts +118 -0
- package/dist/gene/version-service.js +453 -0
- package/dist/gene/wiring-events.d.ts +43 -0
- package/dist/gene/wiring-events.js +113 -0
- package/dist/gene/wiring-models.d.ts +46 -0
- package/dist/gene/wiring-models.js +81 -0
- package/dist/gene/wiring.d.ts +200 -0
- package/dist/gene/wiring.js +764 -0
- package/dist/governance/prompts/orchestrator-block.js +3 -2
- package/dist/host/controller-factory.d.ts +8 -0
- package/dist/host/controller-factory.js +7 -0
- package/dist/host/gene.d.ts +26 -0
- package/dist/host/gene.js +24 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/session/checkpoint.d.ts +15 -0
- package/dist/session/checkpoint.js +18 -0
- package/dist/session/persist.d.ts +21 -0
- package/dist/session/persist.js +10 -0
- package/dist/session/startup-session.d.ts +11 -2
- package/dist/session/startup-session.js +12 -2
- package/dist/session/validate-session.js +31 -0
- package/dist/team/runtime.d.ts +16 -0
- package/dist/team/runtime.js +29 -0
- package/dist/team/subagent.d.ts +55 -0
- package/dist/team/subagent.js +46 -2
- package/dist/tools/index.d.ts +60 -2
- package/dist/tools/index.js +68 -10
- package/package.json +3 -3
- package/skills/project-indexer/SKILL.md +275 -147
- package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -0
- package/skills/project-indexer/templates/config-template.md +12 -0
- package/skills/project-indexer/templates/index-template.md +4 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gene Bank on-disk layout (gene-bank spec 6.8).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
|
|
5
|
+
*
|
|
6
|
+
* EVERY PATH IS BUILT HERE AND NOWHERE ELSE. The inputs are untrusted three ways over - a
|
|
7
|
+
* model's tool argument, a desktop IPC argument and a file name found on disk - so each
|
|
8
|
+
* builder validates its identifier with the `isValid*` from the pure model and then asserts
|
|
9
|
+
* the joined result is still inside the library root. A builder that cannot produce a safe
|
|
10
|
+
* path returns `null`; callers treat `null` as "no such thing", never as an error to retry.
|
|
11
|
+
*
|
|
12
|
+
* One directory per SCOPE (`scopeDir`), and inside it everything a scope owns: heads, versions,
|
|
13
|
+
* evidence, stats, the derived index, the archive and the trash. Archive and trash live in the
|
|
14
|
+
* SAME scope directory on purpose: moving a gene between `genes/` and `archive/` is then a
|
|
15
|
+
* same-volume `rename`, never a cross-device copy that Windows reports as EXDEV / EPERM.
|
|
16
|
+
*/
|
|
17
|
+
import { join, relative, sep, isAbsolute } from 'node:path';
|
|
18
|
+
import { getGeneDir } from '../config/app-paths.js';
|
|
19
|
+
import { geneShard, isValidEvidenceRef, isValidGeneId, isValidProposalId, isValidScope, scopeId, } from '@aragon-agent/tui/model/gene/ids';
|
|
20
|
+
export { getGeneDir };
|
|
21
|
+
export function geneRoot(ctx) {
|
|
22
|
+
return ctx?.root ?? getGeneDir();
|
|
23
|
+
}
|
|
24
|
+
/** `candidate` is inside `root` (or is `root`). Compares path SEGMENTS, never string prefixes. */
|
|
25
|
+
export function isInsideRoot(root, candidate) {
|
|
26
|
+
const rel = relative(root, candidate);
|
|
27
|
+
if (rel === '')
|
|
28
|
+
return true;
|
|
29
|
+
if (isAbsolute(rel))
|
|
30
|
+
return false;
|
|
31
|
+
return rel !== '..' && !rel.startsWith(`..${sep}`);
|
|
32
|
+
}
|
|
33
|
+
function safeJoin(root, ...parts) {
|
|
34
|
+
const path = join(root, ...parts);
|
|
35
|
+
return isInsideRoot(root, path) ? path : null;
|
|
36
|
+
}
|
|
37
|
+
/** The scope's own directory. `team` resolves to the configured external directory. */
|
|
38
|
+
export function scopeDir(scope, ctx) {
|
|
39
|
+
if (!isValidScope(scope))
|
|
40
|
+
return null;
|
|
41
|
+
const root = geneRoot(ctx);
|
|
42
|
+
switch (scope.kind) {
|
|
43
|
+
case 'user':
|
|
44
|
+
return safeJoin(root, 'scopes', 'user');
|
|
45
|
+
case 'project':
|
|
46
|
+
return safeJoin(root, 'scopes', 'projects', scope.key);
|
|
47
|
+
case 'task':
|
|
48
|
+
return safeJoin(root, 'scopes', 'tasks', scope.key);
|
|
49
|
+
case 'team':
|
|
50
|
+
return ctx.teamPath.length > 0 ? join(ctx.teamPath, scope.key) : null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Is this scope's directory read-only by construction (11.1)? Only `team` is. */
|
|
54
|
+
export function isReadOnlyScope(scope) {
|
|
55
|
+
return scope.kind === 'team';
|
|
56
|
+
}
|
|
57
|
+
export function headFile(scope, id, ctx) {
|
|
58
|
+
if (!isValidGeneId(id))
|
|
59
|
+
return null;
|
|
60
|
+
const dir = scopeDir(scope, ctx);
|
|
61
|
+
return dir ? safeJoin(dir, 'genes', geneShard(id), `${id}.json`) : null;
|
|
62
|
+
}
|
|
63
|
+
export function headsDir(scope, ctx) {
|
|
64
|
+
const dir = scopeDir(scope, ctx);
|
|
65
|
+
return dir ? safeJoin(dir, 'genes') : null;
|
|
66
|
+
}
|
|
67
|
+
export function versionFile(scope, id, n, ctx) {
|
|
68
|
+
if (!isValidGeneId(id) || !Number.isInteger(n) || n < 1)
|
|
69
|
+
return null;
|
|
70
|
+
const dir = scopeDir(scope, ctx);
|
|
71
|
+
return dir ? safeJoin(dir, 'versions', id, `${n}.json`) : null;
|
|
72
|
+
}
|
|
73
|
+
export function versionsDir(scope, id, ctx) {
|
|
74
|
+
if (!isValidGeneId(id))
|
|
75
|
+
return null;
|
|
76
|
+
const dir = scopeDir(scope, ctx);
|
|
77
|
+
return dir ? safeJoin(dir, 'versions', id) : null;
|
|
78
|
+
}
|
|
79
|
+
export function evidenceFile(scope, id, ref, ctx) {
|
|
80
|
+
if (!isValidGeneId(id) || !isValidEvidenceRef(ref))
|
|
81
|
+
return null;
|
|
82
|
+
const dir = scopeDir(scope, ctx);
|
|
83
|
+
return dir ? safeJoin(dir, 'evidence', id, `${ref}.json`) : null;
|
|
84
|
+
}
|
|
85
|
+
export function evidenceDir(scope, id, ctx) {
|
|
86
|
+
if (!isValidGeneId(id))
|
|
87
|
+
return null;
|
|
88
|
+
const dir = scopeDir(scope, ctx);
|
|
89
|
+
return dir ? safeJoin(dir, 'evidence', id) : null;
|
|
90
|
+
}
|
|
91
|
+
export function statsFile(scope, shard, ctx) {
|
|
92
|
+
if (!/^[0-9a-z_]{2}$/.test(shard))
|
|
93
|
+
return null;
|
|
94
|
+
const dir = scopeDir(scope, ctx);
|
|
95
|
+
return dir ? safeJoin(dir, 'stats', `${shard}.json`) : null;
|
|
96
|
+
}
|
|
97
|
+
export function statsDir(scope, ctx) {
|
|
98
|
+
const dir = scopeDir(scope, ctx);
|
|
99
|
+
return dir ? safeJoin(dir, 'stats') : null;
|
|
100
|
+
}
|
|
101
|
+
export function indexFile(scope, name, ctx) {
|
|
102
|
+
const dir = scopeDir(scope, ctx);
|
|
103
|
+
return dir ? safeJoin(dir, 'index', name) : null;
|
|
104
|
+
}
|
|
105
|
+
export function archiveHeadFile(scope, id, ctx) {
|
|
106
|
+
if (!isValidGeneId(id))
|
|
107
|
+
return null;
|
|
108
|
+
const dir = scopeDir(scope, ctx);
|
|
109
|
+
return dir ? safeJoin(dir, 'archive', geneShard(id), `${id}.json`) : null;
|
|
110
|
+
}
|
|
111
|
+
/** Versions and evidence of an archived gene move alongside its head. */
|
|
112
|
+
export function archiveSideDir(scope, id, side, ctx) {
|
|
113
|
+
if (!isValidGeneId(id))
|
|
114
|
+
return null;
|
|
115
|
+
const dir = scopeDir(scope, ctx);
|
|
116
|
+
return dir ? safeJoin(dir, 'archive', side, id) : null;
|
|
117
|
+
}
|
|
118
|
+
export function archiveDir(scope, ctx) {
|
|
119
|
+
const dir = scopeDir(scope, ctx);
|
|
120
|
+
return dir ? safeJoin(dir, 'archive') : null;
|
|
121
|
+
}
|
|
122
|
+
export function trashDir(scope, ctx) {
|
|
123
|
+
const dir = scopeDir(scope, ctx);
|
|
124
|
+
return dir ? safeJoin(dir, 'trash') : null;
|
|
125
|
+
}
|
|
126
|
+
/** `trash/<id>.<ts>/` holds the head, versions and evidence of one deleted gene. */
|
|
127
|
+
export function trashEntryDir(scope, id, ts, ctx) {
|
|
128
|
+
if (!isValidGeneId(id) || !Number.isInteger(ts) || ts < 0)
|
|
129
|
+
return null;
|
|
130
|
+
const dir = trashDir(scope, ctx);
|
|
131
|
+
return dir ? safeJoin(dir, `${id}.${ts}`) : null;
|
|
132
|
+
}
|
|
133
|
+
export function projectMetaFile(scope, ctx) {
|
|
134
|
+
if (scope.kind !== 'project')
|
|
135
|
+
return null;
|
|
136
|
+
const dir = scopeDir(scope, ctx);
|
|
137
|
+
return dir ? safeJoin(dir, 'project.json') : null;
|
|
138
|
+
}
|
|
139
|
+
// ---- library-level files (not per scope) ----------------------------------------------
|
|
140
|
+
export function schemaFile(ctx) {
|
|
141
|
+
return join(geneRoot(ctx), 'schema.json');
|
|
142
|
+
}
|
|
143
|
+
export function scopeLockFile(scope, ctx) {
|
|
144
|
+
if (!isValidScope(scope))
|
|
145
|
+
return null;
|
|
146
|
+
return safeJoin(geneRoot(ctx), 'lock', `${scopeId(scope)}.lock`);
|
|
147
|
+
}
|
|
148
|
+
export function curatorLeaseFile(ctx) {
|
|
149
|
+
return join(geneRoot(ctx), 'lock', 'curator.lease');
|
|
150
|
+
}
|
|
151
|
+
export function queueDir(state, ctx) {
|
|
152
|
+
return join(geneRoot(ctx), 'queue', state);
|
|
153
|
+
}
|
|
154
|
+
export function claimedDir(workerId, ctx) {
|
|
155
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(workerId))
|
|
156
|
+
return null;
|
|
157
|
+
return safeJoin(geneRoot(ctx), 'queue', 'claimed', workerId);
|
|
158
|
+
}
|
|
159
|
+
export function queueFile(state, name, ctx) {
|
|
160
|
+
if (!/^[A-Za-z0-9._-]{1,200}\.json$/.test(name))
|
|
161
|
+
return null;
|
|
162
|
+
return safeJoin(queueDir(state, ctx), name);
|
|
163
|
+
}
|
|
164
|
+
export function usageFile(sessionId, ctx) {
|
|
165
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,79}$/.test(sessionId))
|
|
166
|
+
return null;
|
|
167
|
+
return safeJoin(geneRoot(ctx), 'usage', `${sessionId}.jsonl`);
|
|
168
|
+
}
|
|
169
|
+
export function usageDir(ctx) {
|
|
170
|
+
return join(geneRoot(ctx), 'usage');
|
|
171
|
+
}
|
|
172
|
+
export function usageCursorFile(ctx) {
|
|
173
|
+
return join(geneRoot(ctx), 'usage', '.cursor.json');
|
|
174
|
+
}
|
|
175
|
+
/** `yyyy-mm-dd` as produced by `dayStamp`; validated so a name cannot escape. */
|
|
176
|
+
export function runsFile(day, ctx) {
|
|
177
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(day))
|
|
178
|
+
return null;
|
|
179
|
+
return safeJoin(geneRoot(ctx), 'runs', `${day}.jsonl`);
|
|
180
|
+
}
|
|
181
|
+
export function runsDir(ctx) {
|
|
182
|
+
return join(geneRoot(ctx), 'runs');
|
|
183
|
+
}
|
|
184
|
+
export function evalFile(month, ctx) {
|
|
185
|
+
if (!/^\d{4}-\d{2}$/.test(month))
|
|
186
|
+
return null;
|
|
187
|
+
return safeJoin(geneRoot(ctx), 'eval', `${month}.jsonl`);
|
|
188
|
+
}
|
|
189
|
+
export function evalDir(ctx) {
|
|
190
|
+
return join(geneRoot(ctx), 'eval');
|
|
191
|
+
}
|
|
192
|
+
export function explainFile(id, version, lang, ctx) {
|
|
193
|
+
if (!isValidGeneId(id) || !Number.isInteger(version) || version < 1)
|
|
194
|
+
return null;
|
|
195
|
+
if (!/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})?$/.test(lang))
|
|
196
|
+
return null;
|
|
197
|
+
return safeJoin(geneRoot(ctx), 'explain', `${id}-v${version}-${lang.toLowerCase()}.txt`);
|
|
198
|
+
}
|
|
199
|
+
/** Append-only record of the sources a cold-start import has queued (`import-plan.ts`). */
|
|
200
|
+
export function importLedgerFile(ctx) {
|
|
201
|
+
return join(geneRoot(ctx), 'import-ledger.jsonl');
|
|
202
|
+
}
|
|
203
|
+
/** User-private per-project learning policy (I3-5). Absent file = empty policy (the normal case). */
|
|
204
|
+
export function policyFile(ctx) {
|
|
205
|
+
return join(geneRoot(ctx), 'policy.json');
|
|
206
|
+
}
|
|
207
|
+
/** Serialises every read-modify-write of `policy.json` across processes (I3-5, RV-45). */
|
|
208
|
+
export function policyLockFile(ctx) {
|
|
209
|
+
return join(geneRoot(ctx), 'policy.lock');
|
|
210
|
+
}
|
|
211
|
+
/** One-shot UI state (hints already shown). Never influences a decision (I3-10). */
|
|
212
|
+
export function uiStateFile(ctx) {
|
|
213
|
+
return join(geneRoot(ctx), 'ui-state.json');
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The repository-shared marker `<projectRoot>/.aragon/gene.json`. Fixed location: no lookup in
|
|
217
|
+
* parent directories, no alternative names (I3-5). `projectRoot` is the git root, not the cwd.
|
|
218
|
+
*/
|
|
219
|
+
export function projectMarkerFile(projectRoot) {
|
|
220
|
+
return join(projectRoot, '.aragon', 'gene.json');
|
|
221
|
+
}
|
|
222
|
+
export function tombstonesFile(ctx) {
|
|
223
|
+
return join(geneRoot(ctx), 'tombstones.jsonl');
|
|
224
|
+
}
|
|
225
|
+
export function scopesRoot(ctx) {
|
|
226
|
+
return join(geneRoot(ctx), 'scopes');
|
|
227
|
+
}
|
|
228
|
+
export function queueFileNameValid(name) {
|
|
229
|
+
return /^[A-Za-z0-9._-]{1,200}\.json$/.test(name);
|
|
230
|
+
}
|
|
231
|
+
export { isValidProposalId };
|
|
232
|
+
/** `yyyy-mm-dd` (UTC) for a timestamp; the run log rolls over at UTC midnight. */
|
|
233
|
+
export function dayStamp(t) {
|
|
234
|
+
return new Date(t).toISOString().slice(0, 10);
|
|
235
|
+
}
|
|
236
|
+
/** `yyyy-mm` (UTC) for a timestamp. */
|
|
237
|
+
export function monthStamp(t) {
|
|
238
|
+
return new Date(t).toISOString().slice(0, 7);
|
|
239
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planners for the operations that write CONTENT: create, edit / revise, publish a candidate,
|
|
3
|
+
* reject a candidate (gene-bank spec 6.2, 7.1, 7.4.3, 7.6, 11.3, 11.6).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
|
|
6
|
+
*
|
|
7
|
+
* WHAT THE ACTOR DECIDES. The same `edit` produces different things for different writers:
|
|
8
|
+
* - a PERSON publishes at once (trust `human`, `humanTouchedAt` set, no probation);
|
|
9
|
+
* - the CURATOR writes a CANDIDATE version that is served alongside `currentVersion` until
|
|
10
|
+
* `publishCandidate` promotes it, so a revision of a good gene never replaces it unvalidated.
|
|
11
|
+
* A candidate can never lower a human gene's trust: publishing one over `trust: 'human'` content
|
|
12
|
+
* returns a `needsHuman` outcome (head flagged `conflict_with_human`) and writes no version.
|
|
13
|
+
*
|
|
14
|
+
* VERSIONS ARE IMMUTABLE FILES. A new version is a new file; the only later mutations are the
|
|
15
|
+
* `state` flips of OTHER versions (published -> superseded, candidate -> rejected), done after the
|
|
16
|
+
* head is written because they are cosmetic for serving: readers follow `head.currentVersion`.
|
|
17
|
+
*
|
|
18
|
+
* METADATA EDITS (tags, locale hints, roles, name) write the head and no version
|
|
19
|
+
* (`isMaterialChange`); the head projection is rebuilt from the edited content so the index row
|
|
20
|
+
* and a rebuilt row agree.
|
|
21
|
+
*
|
|
22
|
+
* NO IN-LOCK HARD CEILING ON THE LIBRARY SIZE. Capacity is made BEFORE the lock (an eviction
|
|
23
|
+
* commit of its own, `capacity.ts`). Refusing here whenever a scope is at or above the cap would
|
|
24
|
+
* break the documented behaviour after `gene.capPerType` is lowered (nothing is deleted at once;
|
|
25
|
+
* every publish evicts one and converges through maintenance), so the overshoot bound of 7.2 is
|
|
26
|
+
* "at most the number of concurrent writers", not a check in this file.
|
|
27
|
+
*/
|
|
28
|
+
import type { GeneContent, GeneHead, GeneResult, GeneValidation } from '@aragon-agent/tui/model/gene/types';
|
|
29
|
+
import type { CreateChange, EditChange, GeneActor, PublishCandidateChange, RejectCandidateChange } from './commit-types.js';
|
|
30
|
+
import type { PreparedContent } from './commit-prepare.js';
|
|
31
|
+
import { type CommitPlan, type PlanEnv, type PlanInput } from './commit-plan.js';
|
|
32
|
+
/** An edit the service builds for itself (rollback, preference confirmation, merge survivor). */
|
|
33
|
+
export interface InternalEdit extends Omit<EditChange, 'op'> {
|
|
34
|
+
op: 'edit';
|
|
35
|
+
/** Publish a new version at once even for an automated actor. Never set from a public change. */
|
|
36
|
+
direct?: boolean;
|
|
37
|
+
/** Rollback restores content that was already published: skip the new-tool gates. */
|
|
38
|
+
skipToolGate?: boolean;
|
|
39
|
+
/** Mint a version even when nothing material differs (a rollback is always a new version). */
|
|
40
|
+
forceVersion?: boolean;
|
|
41
|
+
event?: 'merged' | 'rolled_back';
|
|
42
|
+
}
|
|
43
|
+
export interface CreateInput extends PlanInput<CreateChange> {
|
|
44
|
+
prepared: PreparedContent;
|
|
45
|
+
newId: string;
|
|
46
|
+
}
|
|
47
|
+
export interface EditInput extends PlanInput<InternalEdit> {
|
|
48
|
+
prepared: PreparedContent;
|
|
49
|
+
}
|
|
50
|
+
export type PublishInput = PlanInput<PublishCandidateChange>;
|
|
51
|
+
export type RejectInput = PlanInput<RejectCandidateChange> & {
|
|
52
|
+
reason: string;
|
|
53
|
+
};
|
|
54
|
+
interface ToolGateInput {
|
|
55
|
+
content: GeneContent;
|
|
56
|
+
contentHash: string;
|
|
57
|
+
actor: GeneActor;
|
|
58
|
+
confirmed: boolean;
|
|
59
|
+
validation?: GeneValidation;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The gates a tool must pass to be PUBLISHED (7.6, I-25). A person who sees the full text may
|
|
63
|
+
* confirm a high-risk tool; automation never may, and automation may publish only what the
|
|
64
|
+
* read-only auto-probe covers or what carries a person's probe approval for THIS content.
|
|
65
|
+
*/
|
|
66
|
+
export declare function toolGate(input: ToolGateInput): GeneResult<void>;
|
|
67
|
+
/** The content currently SERVED (the published version), or null for a candidate-only gene. */
|
|
68
|
+
export declare function servedContent(env: PlanEnv, head: GeneHead): Promise<GeneContent | null>;
|
|
69
|
+
export declare function planCreate(input: CreateInput): Promise<GeneResult<CommitPlan>>;
|
|
70
|
+
export declare function planEdit(input: EditInput): Promise<GeneResult<CommitPlan>>;
|
|
71
|
+
export declare function planPublishCandidate(input: PublishInput): Promise<GeneResult<CommitPlan>>;
|
|
72
|
+
export declare function planRejectCandidate(input: RejectInput): Promise<GeneResult<CommitPlan>>;
|
|
73
|
+
export {};
|