@aiwg/cli 2026.10.19 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/agentic/code/providers/flue/README.md +2 -1
- package/dist/src/artifacts/cli.js +3 -2
- package/dist/src/artifacts/discover-facets.js +2 -0
- package/dist/src/artifacts/discover-session-facets.js +14 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
- package/dist/src/artifacts/framework-capabilities.js +7 -3
- package/dist/src/artifacts/index-builder.js +2 -3
- package/dist/src/artifacts/query-engine-discover-output.js +3 -3
- package/dist/src/artifacts/query-engine-discover.js +61 -14
- package/dist/src/artifacts/query-engine-entries.js +52 -9
- package/dist/src/artifacts/query-engine-installation.js +27 -0
- package/dist/src/artifacts/query-engine-rules.js +1 -2
- package/dist/src/artifacts/query-engine-scoring.js +33 -31
- package/dist/src/artifacts/query-engine-show-card.js +6 -2
- package/dist/src/artifacts/query-engine-show.js +2 -2
- package/dist/src/artifacts/relations.js +17 -10
- package/dist/src/cli/handlers/bundle-declaration.js +55 -0
- package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
- package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
- package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
- package/dist/src/cli/handlers/checkpoint.js +143 -0
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/models-resource-sample.js +7 -3
- package/dist/src/cli/handlers/ralph-launcher.js +1 -1
- package/dist/src/cli/handlers/refresh-bundles.js +35 -0
- package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
- package/dist/src/cli/handlers/refresh.js +15 -52
- package/dist/src/cli/handlers/remove-bundled.js +7 -4
- package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
- package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
- package/dist/src/cli/handlers/remove.js +8 -0
- package/dist/src/cli/handlers/script-runner.js +12 -1
- package/dist/src/cli/handlers/steward-signing.js +44 -0
- package/dist/src/cli/handlers/steward.js +5 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +4 -4
- package/dist/src/cli/handlers/update.js +18 -8
- package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
- package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
- package/dist/src/cli/handlers/use-owned-counts.js +75 -0
- package/dist/src/cli/handlers/use-provider-results.js +17 -0
- package/dist/src/cli/handlers/use.js +53 -114
- package/dist/src/cli/router.js +12 -2
- package/dist/src/cli/services/deployment-verification.js +2 -1
- package/dist/src/cli/user-scope-mirror.js +3 -1
- package/dist/src/config/aiwg-config.js +15 -6
- package/dist/src/config/cli.js +1 -0
- package/dist/src/config/delivery-validation.js +21 -0
- package/dist/src/config/framework-aliases.js +14 -0
- package/dist/src/config/host-resource-report.d.mts +1 -1
- package/dist/src/config/host-resource-report.mjs +23 -4
- package/dist/src/config/host-resource-runtime.d.mts +8 -0
- package/dist/src/config/host-resource-runtime.mjs +67 -24
- package/dist/src/config/index-graph-overrides.js +4 -0
- package/dist/src/config/installed-selection.js +9 -1
- package/dist/src/config/installed-validation.js +35 -0
- package/dist/src/config/worker-attribution.d.mts +7 -0
- package/dist/src/config/worker-attribution.mjs +44 -0
- package/dist/src/delivery/git.js +62 -0
- package/dist/src/delivery/pr.js +149 -0
- package/dist/src/delivery/tracker.js +33 -0
- package/dist/src/discovery/interview.js +1 -1
- package/dist/src/extensions/claude-hooks-installer.js +1 -0
- package/dist/src/extensions/loader.js +2 -1
- package/dist/src/extensions/project-local-doctor.js +1 -1
- package/dist/src/extensions/project-local-remove.js +3 -3
- package/dist/src/issues/cli.js +12 -3
- package/dist/src/issues/external-cli.js +76 -0
- package/dist/src/issues/live.js +18 -1
- package/dist/src/issues/tracker-policy.js +17 -0
- package/dist/src/mcp/cli.mjs +12 -7
- package/dist/src/mcp/helpers.mjs +5 -1
- package/dist/src/mcp/http-options.mjs +101 -0
- package/dist/src/mcp/http-tools.mjs +51 -0
- package/dist/src/mcp/http-transport.mjs +201 -0
- package/dist/src/mcp/server.mjs +9 -7
- package/dist/src/mcp/tool-context.mjs +25 -0
- package/dist/src/mcp/tools/orchestration.mjs +2 -1
- package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
- package/dist/src/models/conductor-data-policy.d.mts +3 -2
- package/dist/src/models/conductor-data-policy.mjs +94 -5
- package/dist/src/models/worker-plan.js +3 -3
- package/dist/src/models/worker-selection-policy.js +2 -1
- package/dist/src/providers/deployment-lock.js +77 -0
- package/dist/src/providers/deployment-ownership.d.mts +12 -2
- package/dist/src/providers/deployment-ownership.mjs +127 -19
- package/dist/src/providers/deployment-preservation.d.mts +6 -0
- package/dist/src/providers/deployment-preservation.mjs +113 -0
- package/dist/src/providers/deployment-removal.js +4 -2
- package/dist/src/providers/flue-package-mode.js +19 -0
- package/dist/src/providers/provider-definitions.js +4 -0
- package/dist/src/providers/skill-ownership.mjs +1 -0
- package/dist/src/research/reference-match.js +4 -0
- package/dist/src/serve/worker-invocation-preparation.js +3 -1
- package/dist/src/serve/worker-invocation.js +2 -0
- package/dist/src/skills/run.js +5 -0
- package/dist/src/smiths/hook-bridge/codex-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +6 -0
- package/package.json +5 -2
- package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
- package/tools/agents/deploy-agents.mjs +21 -1
- package/tools/agents/deploy-options.mjs +2 -0
- package/tools/agents/providers/base-contract.mjs +7 -1
- package/tools/agents/providers/base-inventory.mjs +41 -14
- package/tools/agents/providers/base-kernel-skills.mjs +9 -5
- package/tools/agents/providers/base-migrations.mjs +1 -0
- package/tools/agents/providers/base-skill-copy.mjs +9 -1
- package/tools/agents/providers/base.mjs +1 -1
- package/tools/agents/providers/claude.mjs +2 -1
- package/tools/agents/providers/codex.mjs +5 -1
- package/tools/agents/providers/conductor-data-guard.mjs +35 -11
- package/tools/agents/providers/flue-bundles.mjs +42 -0
- package/tools/agents/providers/flue-cloudflare.mjs +20 -0
- package/tools/agents/providers/flue-project.mjs +45 -6
- package/tools/agents/providers/flue-skill-copy.mjs +25 -0
- package/tools/agents/providers/flue-skills.mjs +45 -0
- package/tools/agents/providers/flue-specialists.mjs +36 -18
- package/tools/agents/providers/flue-validation.mjs +14 -0
- package/tools/agents/providers/flue.mjs +12 -8
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
- package/tools/agents/providers/muse-hooks.mjs +4 -0
- package/tools/agents/providers/muse-prompt-discovery.mjs +22 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
- package/tools/agents/providers/rule-delivery-surface.mjs +18 -1
- package/tools/agents/providers/rule-deployment-commit.mjs +24 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +4 -0
- package/tools/agents/providers/skill-copy-prune.mjs +49 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +10 -8
- package/tools/ralph-external/lib/worker-capture.mjs +157 -0
- package/tools/ralph-external/lib/worker-health.mjs +3 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
- package/tools/ralph-external/lib/worker-launch-cli.mjs +10 -1
- package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
- package/tools/ralph-external/lib/worker-termination.mjs +56 -6
- package/tools/ralph-external/process-monitor.mjs +12 -18
- package/tools/ralph-external/session-launcher.mjs +43 -29
- package/tools/skills/codex-skill-metadata.mjs +22 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -7
- package/vscode-extension/schemas/aiwg.config.v1.json +59 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Serve artifact bodies and metadata through the show surface.
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { loadProviderModelMetadata } from '../models/provider-models.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isArtifactInstalled } from './query-engine-installation.js';
|
|
5
5
|
import { findCorpusArtifact } from './query-engine-corpus.js';
|
|
6
6
|
import { buildRunHint, DEFAULT_ARTIFACT_SEARCH_BACKEND, discoveryIdForEntry, normalizeIndexedPath, } from './query-engine-entries.js';
|
|
7
7
|
import { findShowMatches } from './query-engine-matching.js';
|
|
@@ -59,7 +59,7 @@ export async function showArtifact(cwd, params) {
|
|
|
59
59
|
process.exit(1);
|
|
60
60
|
}
|
|
61
61
|
const localPin = corpusMatch.type === 'rule' ? (await import('../rules/pin-state.js')).rulePinState(cwd, aiwgRoot).rules.find(rule => rule.path === corpusMatch.path) : undefined;
|
|
62
|
-
const installed = await
|
|
62
|
+
const installed = await isArtifactInstalled(cwd, aiwgRoot, { path: corpusMatch.path, type: corpusMatch.type }, corpusMatch.bundleKind, corpusMatch.bundleId);
|
|
63
63
|
const installHint = installed
|
|
64
64
|
? 'The installed bundle is missing from this index. Run `aiwg index build --graph framework` to refresh it.'
|
|
65
65
|
: corpusMatch.bundleKind && corpusMatch.bundleId
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { getGraphIndexDir } from './types.js';
|
|
5
|
-
import { resolveFrameworkIndexRoot } from './framework-index-paths.js';
|
|
5
|
+
import { resolveFrameworkCorpusRoot, resolveFrameworkIndexRoot } from './framework-index-paths.js';
|
|
6
6
|
import { frameworkSourceDigest } from './framework-source-digest.js';
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
8
|
import { loadRulePinConfigs, resolveRulePins } from '../rules/pins.mjs';
|
|
@@ -91,8 +91,9 @@ function selectPrebuiltRelationsSource(cwd, cacheSourceDigest = true) {
|
|
|
91
91
|
return { reader: null, reason: 'unsupported prebuilt relationship schema' };
|
|
92
92
|
if (stamp.package_version !== pkg.version)
|
|
93
93
|
return { reader: null, reason: 'prebuilt relationship package version differs' };
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const sourceDigest = frameworkSourceDigest(root, cacheSourceDigest);
|
|
95
|
+
if (stamp.source_digest !== sourceDigest)
|
|
96
|
+
return { reader: null, sourceDigest, reason: 'prebuilt relationship source digest differs (modified, added or removed corpus source)' };
|
|
96
97
|
const text = fs.readFileSync(path.join(dir, 'relations.json'), 'utf8');
|
|
97
98
|
if (createHash('sha256').update(text).digest('hex') !== stamp.checksums['relations.json'])
|
|
98
99
|
return { reader: null, reason: 'prebuilt relationship checksum differs' };
|
|
@@ -104,7 +105,7 @@ function selectPrebuiltRelationsSource(cwd, cacheSourceDigest = true) {
|
|
|
104
105
|
|| index.fingerprint?.version !== RELATIONS_VERSION || !/^sha256:[a-f0-9]{64}$/.test(index.fingerprint.sources)
|
|
105
106
|
|| !index.rules || !index.targets || !index.capabilities || !index.aliases?.targets || !index.aliases.rules)
|
|
106
107
|
return { reader: null, reason: 'unsupported prebuilt relationship table' };
|
|
107
|
-
return { reader: new RelationsReader(index) };
|
|
108
|
+
return { reader: new RelationsReader(index), sourceDigest };
|
|
108
109
|
}
|
|
109
110
|
catch {
|
|
110
111
|
return { reader: null, reason: 'prebuilt relationship tables unavailable or corrupt' };
|
|
@@ -113,24 +114,30 @@ function selectPrebuiltRelationsSource(cwd, cacheSourceDigest = true) {
|
|
|
113
114
|
/** Apply local pins only after cache validation so policy errors cannot masquerade as cache misses. */
|
|
114
115
|
export function selectPrebuiltRelations(cwd, pinCwd = cwd, cacheSourceDigest = true) {
|
|
115
116
|
const selected = selectPrebuiltRelationsSource(cwd, cacheSourceDigest);
|
|
116
|
-
return selected.reader ? { reader: readerWithPins(selected.reader.index, pinCwd) } : selected;
|
|
117
|
+
return selected.reader ? { ...selected, reader: readerWithPins(selected.reader.index, pinCwd) } : selected;
|
|
117
118
|
}
|
|
118
119
|
/** Synchronous read API: prebuilt first, then this root's built sidecar. */
|
|
119
120
|
export function loadRelations(cwd, pinCwd = cwd, cacheSourceDigest = true) {
|
|
120
121
|
return selectPrebuiltRelations(cwd, pinCwd, cacheSourceDigest).reader ?? loadBuiltRelations(cwd, pinCwd);
|
|
121
122
|
}
|
|
122
123
|
/** Read paths reconcile through the existing lock/receipt when prebuilt is stale. */
|
|
123
|
-
export async function ensureRelations(cwd, pinCwd = cwd) {
|
|
124
|
-
const selected = selectPrebuiltRelations(cwd, pinCwd);
|
|
124
|
+
export async function ensureRelations(cwd, pinCwd = cwd, options = {}) {
|
|
125
|
+
const selected = options.selection ?? selectPrebuiltRelations(cwd, pinCwd);
|
|
125
126
|
if (selected.reader)
|
|
126
127
|
return selected.reader;
|
|
127
128
|
const root = resolveFrameworkIndexRoot(cwd);
|
|
128
|
-
if (
|
|
129
|
+
if ((options.verbose || process.argv.includes('--verbose') || process.argv.includes('--debug')
|
|
130
|
+
|| ['debug', 'info'].includes(process.env.AIWG_LOG_LEVEL ?? ''))
|
|
131
|
+
&& fs.existsSync(path.join(root, PREBUILT_RELATIONS_DIR, 'manifest.json'))) {
|
|
129
132
|
console.error(`Relationship tables: ${selected.reason}; using the per-root index (rebuilding if stale).`);
|
|
130
133
|
}
|
|
131
134
|
const { refreshFrameworkCapabilities } = await import('./framework-capabilities.js');
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
if (!options.reconciled)
|
|
136
|
+
await refreshFrameworkCapabilities(root, false);
|
|
137
|
+
const reader = loadBuiltRelations(cwd, pinCwd);
|
|
138
|
+
if (!reader && (resolveFrameworkCorpusRoot(root) || fs.existsSync(path.join(root, PREBUILT_RELATIONS_DIR, 'manifest.json'))))
|
|
139
|
+
throw new Error('Relationship tables unavailable: no usable prebuilt or per-root index. Run `aiwg index build --graph framework`.');
|
|
140
|
+
return reader;
|
|
134
141
|
}
|
|
135
142
|
// Convenience entry points; use one loaded reader for a batch of lookups.
|
|
136
143
|
export function rulesForTarget(type, id, cwd = process.cwd()) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Edit bundle intent without touching provider payloads.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { emptyConfig, getProjectDir, readAiwgConfig, writeAiwgConfig, ensureProviderListed } from '../../config/aiwg-config.js';
|
|
5
|
+
import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
6
|
+
import { REGISTRY_ID_TO_USE_NAME } from '../../config/framework-aliases.js';
|
|
7
|
+
import { getProviderArtifactPathStrings } from '../../providers/provider-definitions.js';
|
|
8
|
+
import { firstRemovePositional, parseRemoveProvider } from './remove-options.js';
|
|
9
|
+
import { validateInstalled } from '../../config/installed-validation.js';
|
|
10
|
+
export async function declareBundle(ctx, remove = false) {
|
|
11
|
+
try {
|
|
12
|
+
const id = firstRemovePositional(ctx.args);
|
|
13
|
+
const { provider, error } = parseRemoveProvider(ctx.args);
|
|
14
|
+
if (!id || !provider || error)
|
|
15
|
+
return { exitCode: 2, message: error || '--declare requires a bundle and explicit --provider.' };
|
|
16
|
+
if (ctx.args.includes('--user') || ctx.args.includes('--global') || ctx.args[ctx.args.indexOf('--scope') + 1] === 'user') {
|
|
17
|
+
return { exitCode: 2, message: '--declare supports project scope only.' };
|
|
18
|
+
}
|
|
19
|
+
if (!getProviderArtifactPathStrings(provider))
|
|
20
|
+
return { exitCode: 2, message: `Unknown provider '${provider}'.` };
|
|
21
|
+
const project = getProjectDir(ctx, ctx.args);
|
|
22
|
+
const config = await readAiwgConfig(project) ?? emptyConfig([provider]);
|
|
23
|
+
const name = REGISTRY_ID_TO_USE_NAME[id] ?? id;
|
|
24
|
+
if (!remove && name !== 'all') {
|
|
25
|
+
const root = ctx.frameworkRoot || await getFrameworkRoot();
|
|
26
|
+
const exists = ['frameworks', 'addons', 'extensions'].some(group => fs.existsSync(path.join(root, 'agentic/code', group, id, 'manifest.json')) ||
|
|
27
|
+
Object.entries(REGISTRY_ID_TO_USE_NAME).some(([dir, alias]) => alias === name && fs.existsSync(path.join(root, 'agentic/code', group, dir, 'manifest.json'))) ||
|
|
28
|
+
fs.existsSync(path.join(project, '.aiwg', group, id, 'manifest.json')));
|
|
29
|
+
if (!exists)
|
|
30
|
+
return { exitCode: 2, message: `Unknown bundle '${id}'.` };
|
|
31
|
+
}
|
|
32
|
+
const key = Object.keys(config.installed).find(key => (REGISTRY_ID_TO_USE_NAME[key] ?? key) === name) ?? name;
|
|
33
|
+
if (remove) {
|
|
34
|
+
delete config.installed[key]?.deployedTo[provider];
|
|
35
|
+
if (config.installed[key] && !Object.keys(config.installed[key].deployedTo).length)
|
|
36
|
+
delete config.installed[key];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
config.installed[key] ??= { deployedTo: {} };
|
|
40
|
+
config.installed[key].deployedTo[provider] = ctx.args.includes('--copy-all') || ctx.args.includes('--copy-standard-skills') ? { copy: true } : {};
|
|
41
|
+
if (provider === 'flue' && ctx.args.includes('--package'))
|
|
42
|
+
config.installed[key].deployedTo[provider].package = true;
|
|
43
|
+
validateInstalled({ [key]: { deployedTo: { [provider]: config.installed[key].deployedTo[provider] } } });
|
|
44
|
+
ensureProviderListed(config, provider);
|
|
45
|
+
}
|
|
46
|
+
const dryRun = ctx.args.includes('--dry-run');
|
|
47
|
+
if (!dryRun)
|
|
48
|
+
await writeAiwgConfig(project, config);
|
|
49
|
+
return { exitCode: 0, message: `${dryRun ? 'Would ' : ''}${remove ? 'Undeclared' : 'Declared'} ${name} for ${provider}.` };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return { exitCode: 1, message: String(error) };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=bundle-declaration.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Retain per-provider deployment intent in the existing project ownership receipt.
|
|
2
|
+
import { writeContextFileSync } from '../../smiths/context-pipeline/context-file-safety.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { readAiwgConfig } from '../../config/aiwg-config.js';
|
|
6
|
+
import { frameworkRegistryId } from '../../config/framework-aliases.js';
|
|
7
|
+
const receiptPath = (project) => path.join(project, '.aiwg/.aiwg-manifest.json');
|
|
8
|
+
export function bundleDeploymentHistory(project) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(fs.readFileSync(receiptPath(project), 'utf8')).bundleDeployments ?? {};
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === 'ENOENT')
|
|
14
|
+
return {};
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function bundleCopyArgs(installed, id, provider) {
|
|
19
|
+
const entry = Object.entries(installed).find(([key]) => frameworkRegistryId(key) === frameworkRegistryId(id))?.[1];
|
|
20
|
+
const flags = entry?.deployedTo[provider];
|
|
21
|
+
return [...(flags?.copy === true ? ['--copy-all'] : []), ...(flags?.skipUtils === true ? ['--no-utils'] : []),
|
|
22
|
+
...(provider === 'flue' && flags?.package === true ? ['--package'] : [])];
|
|
23
|
+
}
|
|
24
|
+
export async function recordBundleDeployment(project, id, provider, args, frameworkRoot) {
|
|
25
|
+
const { expectedBundleOwners } = await import('./bundle-reconciliation.js');
|
|
26
|
+
const { getFrameworkRoot } = await import('../../channel/manager.mjs');
|
|
27
|
+
const flags = bundleDeploymentScope(id, provider, args);
|
|
28
|
+
const selected = { installed: { [id]: { deployedTo: { [provider]: flags } } } };
|
|
29
|
+
const produces = [...await expectedBundleOwners(selected, provider, frameworkRoot ?? await getFrameworkRoot())].sort();
|
|
30
|
+
const file = receiptPath(project);
|
|
31
|
+
const receipt = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : { scope: 'project', managed: {} };
|
|
32
|
+
receipt.bundleDeployments ??= {};
|
|
33
|
+
receipt.bundleDeployments[provider] ??= {};
|
|
34
|
+
receipt.bundleDeployments[provider][frameworkRegistryId(id)] = { copy: args.includes('--copy-all') || args.includes('--copy-standard-skills'), ...flags, ...(provider === 'flue' ? { package: args.includes('--package') } : {}), produces };
|
|
35
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
36
|
+
writeContextFileSync(file, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
37
|
+
}
|
|
38
|
+
// Once index-mode removal completes, later additive passes own any new surface.
|
|
39
|
+
export function markBundleReconciled(project, id, provider) {
|
|
40
|
+
const file = receiptPath(project);
|
|
41
|
+
if (!fs.existsSync(file))
|
|
42
|
+
return;
|
|
43
|
+
const receipt = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
44
|
+
if (!receipt.bundleDeployments?.[provider]?.[frameworkRegistryId(id)])
|
|
45
|
+
return;
|
|
46
|
+
receipt.bundleDeployments[provider][frameworkRegistryId(id)].reconciled = true;
|
|
47
|
+
writeContextFileSync(file, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
48
|
+
}
|
|
49
|
+
// Local/support bundles copy physically in index mode too; only operator flags prohibit cleanup.
|
|
50
|
+
export function copyCleanupArgs(args) {
|
|
51
|
+
return args.includes('--copy-all') || args.includes('--copy-standard-skills') ? [] : ['--index-mode'];
|
|
52
|
+
}
|
|
53
|
+
// Framework passes retain a separately declared local bundle's provider mode.
|
|
54
|
+
export async function projectLocalDeploymentContext(ctx, project, id, provider, explicit) {
|
|
55
|
+
if (explicit)
|
|
56
|
+
return ctx;
|
|
57
|
+
const installed = (await readAiwgConfig(project))?.installed;
|
|
58
|
+
if (!installed?.[id]?.deployedTo[provider])
|
|
59
|
+
return ctx;
|
|
60
|
+
return { ...ctx, args: [...ctx.args.filter(arg => !['--copy-all', '--copy-standard-skills'].includes(arg)), ...bundleCopyArgs(installed, id, provider)] };
|
|
61
|
+
}
|
|
62
|
+
export function projectLocalCopyMode(config, id, provider, args, explicit) {
|
|
63
|
+
const requested = args.includes('--copy-all') || args.includes('--copy-standard-skills');
|
|
64
|
+
return explicit ? requested : config.installed[id]?.deployedTo[provider]?.copy ?? requested;
|
|
65
|
+
}
|
|
66
|
+
// Match the effective framework gates used by the deployment pass.
|
|
67
|
+
export function bundleDeploymentScope(id, provider, args) {
|
|
68
|
+
return { skipUtils: args.includes('--no-utils'), kernelOnly: id === 'all' && !['pi', 'omp'].includes(provider)
|
|
69
|
+
&& !args.includes('--copy-all') && !args.includes('--copy-standard-skills') };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=bundle-deployment-mode.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Reuse project-local removal when historical provider hashes outlive its declaration.
|
|
2
|
+
import { frameworkRegistryId } from '../../config/framework-aliases.js';
|
|
3
|
+
import { bundleDeploymentHistory } from './bundle-deployment-mode.js';
|
|
4
|
+
import { getProviderArtifactPathStrings } from '../../providers/provider-definitions.js';
|
|
5
|
+
import { deployedSkillRoots } from '../../providers/deployed-skill-roots.js';
|
|
6
|
+
import { removeProjectLocalBundle } from '../../extensions/project-local-remove.js';
|
|
7
|
+
export async function pruneUndeclaredHashes(project, config, requested, dryRun) {
|
|
8
|
+
const handled = new Set();
|
|
9
|
+
for (const [id, entry] of Object.entries(config.installed)) {
|
|
10
|
+
if (entry.source !== 'project-local')
|
|
11
|
+
continue;
|
|
12
|
+
const historicalProviders = new Set([...Object.keys(entry.deployedArtifactHashes ?? {}), ...(Object.keys(entry.artifactHashes ?? {}).length ? config.providers ?? [] : [])]);
|
|
13
|
+
for (const provider of historicalProviders) {
|
|
14
|
+
if (!getProviderArtifactPathStrings(provider))
|
|
15
|
+
continue;
|
|
16
|
+
if (entry.deployedTo[provider] || requested && !requested.split(',').includes(provider))
|
|
17
|
+
continue;
|
|
18
|
+
const mode = bundleDeploymentHistory(project)[provider]?.[frameworkRegistryId(id)];
|
|
19
|
+
if (mode?.copy || mode?.package) {
|
|
20
|
+
console.log(`${id} for ${provider}: kept (${mode?.copy ? 'copy' : 'package'} mode); run \`aiwg remove ${id}\` to delete`);
|
|
21
|
+
handled.add(`${provider}:${id}`);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const others = Object.keys(entry.deployedTo).filter(other => other !== provider);
|
|
25
|
+
const preserveRoots = deployedSkillRoots(project, provider).filter(root => others.some(other => deployedSkillRoots(project, other).includes(root)));
|
|
26
|
+
const historical = structuredClone(config);
|
|
27
|
+
historical.installed[id].deployedTo[provider] = {};
|
|
28
|
+
console.log(`${dryRun ? 'Would remove' : 'Removing'} ${id} for ${provider} (recorded hashes)`);
|
|
29
|
+
const result = await removeProjectLocalBundle(historical, project, id, { provider, dryRun, keepRegistry: true, preserveRoots });
|
|
30
|
+
for (const outcome of result.outcomes)
|
|
31
|
+
console.log(` ${outcome.deployedAbsPath}: ${outcome.message}`);
|
|
32
|
+
handled.add(`${provider}:${id}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return handled;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=bundle-hash-prune.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Reconcile provider bundle declarations through the existing receipt removal path.
|
|
2
|
+
import { providerCopyMode } from '../../providers/deployment-preservation.mjs';
|
|
3
|
+
import { bundleDeploymentHistory, markBundleReconciled } from './bundle-deployment-mode.js';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { readAiwgConfig } from '../../config/aiwg-config.js';
|
|
7
|
+
import { REGISTRY_ID_TO_USE_NAME, frameworkRegistryId } from '../../config/framework-aliases.js';
|
|
8
|
+
import { getProviderArtifactPathStrings, PROVIDER_IDS } from '../../providers/provider-definitions.js';
|
|
9
|
+
import { deployedSkillRoots } from '../../providers/deployed-skill-roots.js';
|
|
10
|
+
import { pruneUndeclaredHashes } from './bundle-hash-prune.js';
|
|
11
|
+
import { removeBundledDeployment } from './remove-bundled.js';
|
|
12
|
+
import { frameworkAdditiveBundles } from './use-additive-bundles.js';
|
|
13
|
+
import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
14
|
+
export const bundleUseName = (id) => REGISTRY_ID_TO_USE_NAME[id] ?? id;
|
|
15
|
+
export function bundleProviders(installed, id, requested) {
|
|
16
|
+
const entry = Object.entries(installed).find(([key]) => frameworkRegistryId(key) === frameworkRegistryId(id))?.[1];
|
|
17
|
+
return Object.keys(entry?.deployedTo ?? {}).filter(provider => !requested || requested.split(',').includes(provider));
|
|
18
|
+
}
|
|
19
|
+
export async function expectedBundleOwners(config, provider, frameworkRoot) {
|
|
20
|
+
const selected = Object.keys(config.installed).filter(id => bundleProviders(config.installed, id, provider).length);
|
|
21
|
+
const expected = new Set(selected.map(frameworkRegistryId));
|
|
22
|
+
for (const id of selected) {
|
|
23
|
+
if (!(id === 'all' || fs.existsSync(path.join(frameworkRoot, 'agentic/code/frameworks', frameworkRegistryId(id), 'manifest.json'))
|
|
24
|
+
|| ['writing', 'general'].includes(id)))
|
|
25
|
+
continue;
|
|
26
|
+
const flags = config.installed[id].deployedTo[provider];
|
|
27
|
+
if (id === 'all' && provider !== 'flue' && (flags.skipUtils !== undefined || flags.kernelOnly !== undefined)) {
|
|
28
|
+
expected.delete('all');
|
|
29
|
+
for (const name of fs.readdirSync(path.join(frameworkRoot, 'agentic/code/frameworks'))) {
|
|
30
|
+
if (fs.existsSync(path.join(frameworkRoot, 'agentic/code/frameworks', name, 'manifest.json')))
|
|
31
|
+
expected.add(frameworkRegistryId(name));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Unknown history must retain the broader additive surface.
|
|
35
|
+
const { addons, extensions } = await frameworkAdditiveBundles(frameworkRoot, provider, flags.skipUtils === true, flags.kernelOnly === true);
|
|
36
|
+
for (const owner of [...addons, ...extensions])
|
|
37
|
+
expected.add(frameworkRegistryId(owner));
|
|
38
|
+
}
|
|
39
|
+
if (provider !== 'flue')
|
|
40
|
+
for (const id of selected) {
|
|
41
|
+
const addon = frameworkRegistryId(id);
|
|
42
|
+
if (!fs.existsSync(path.join(frameworkRoot, 'agentic/code/addons', addon, 'manifest.json')))
|
|
43
|
+
continue;
|
|
44
|
+
const { resolveRequiredAddonActivationOrder } = await import('./use.js');
|
|
45
|
+
for (const owner of await resolveRequiredAddonActivationOrder(frameworkRoot, addon))
|
|
46
|
+
expected.add(frameworkRegistryId(owner));
|
|
47
|
+
}
|
|
48
|
+
return expected;
|
|
49
|
+
}
|
|
50
|
+
function receiptOwners(project, provider) {
|
|
51
|
+
const owners = new Set();
|
|
52
|
+
const visit = (file) => {
|
|
53
|
+
const stat = fs.lstatSync(file, { throwIfNoEntry: false });
|
|
54
|
+
if (!stat || stat.isSymbolicLink())
|
|
55
|
+
return;
|
|
56
|
+
if (stat.isDirectory()) {
|
|
57
|
+
for (const name of fs.readdirSync(file))
|
|
58
|
+
visit(path.join(file, name));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (path.basename(file) !== '.aiwg-manifest.json')
|
|
62
|
+
return;
|
|
63
|
+
const receipt = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
64
|
+
for (const record of Object.values(receipt.managed ?? {})) {
|
|
65
|
+
for (const owner of record.owners ?? (record.frameworkSlug ? [record.frameworkSlug] : []))
|
|
66
|
+
owners.add(owner);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const paths = Object.values(getProviderArtifactPathStrings(provider) ?? {}).filter(Boolean);
|
|
70
|
+
// Never follow provider home paths during project reconciliation.
|
|
71
|
+
const roots = paths.filter(dir => !path.isAbsolute(dir) && !dir.startsWith('~')).map(dir => path.join(project, dir.split(/[\\/]/)[0]));
|
|
72
|
+
for (const root of new Set([...roots, ...deployedSkillRoots(project, provider).filter(dir => dir.startsWith(`${project}${path.sep}`))]))
|
|
73
|
+
visit(root);
|
|
74
|
+
// Flue's generated app modules live in the project-scoped receipt.
|
|
75
|
+
if (provider === 'flue')
|
|
76
|
+
visit(path.join(project, '.aiwg/.aiwg-manifest.json'));
|
|
77
|
+
return owners;
|
|
78
|
+
}
|
|
79
|
+
export async function pruneUndeclaredBundles(project, config, requested, dryRun = false, frameworkRoot) {
|
|
80
|
+
if (!config)
|
|
81
|
+
return 0;
|
|
82
|
+
if (requested?.split(',').some(provider => !getProviderArtifactPathStrings(provider))) {
|
|
83
|
+
console.error(`Cannot reconcile unknown provider: ${requested}`);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
const history = bundleDeploymentHistory(project);
|
|
87
|
+
const hashPruned = await pruneUndeclaredHashes(project, config, requested, dryRun);
|
|
88
|
+
let failures = 0;
|
|
89
|
+
const knownProviders = [...new Set([...Object.keys(history), ...(config.providers ?? []), ...Object.values(config.installed).flatMap(entry => Object.keys(entry.deployedTo ?? {})),
|
|
90
|
+
...PROVIDER_IDS.filter(provider => fs.existsSync(path.join(project, `.${provider}`)))])];
|
|
91
|
+
const providers = requested ? requested.split(',') : knownProviders;
|
|
92
|
+
const root = frameworkRoot ?? await getFrameworkRoot();
|
|
93
|
+
const expected = new Map();
|
|
94
|
+
for (const provider of new Set([...knownProviders, ...providers])) {
|
|
95
|
+
if (getProviderArtifactPathStrings(provider))
|
|
96
|
+
expected.set(provider, await expectedBundleOwners(config, provider, root));
|
|
97
|
+
}
|
|
98
|
+
for (const provider of providers) {
|
|
99
|
+
for (const owner of Object.keys(history[provider] ?? {})) {
|
|
100
|
+
if (!history[provider][owner].reconciled && !bundleProviders(config.installed, owner, provider).length)
|
|
101
|
+
expected.get(provider)?.delete(owner);
|
|
102
|
+
}
|
|
103
|
+
if (!getProviderArtifactPathStrings(provider))
|
|
104
|
+
continue;
|
|
105
|
+
const selected = expected.get(provider);
|
|
106
|
+
for (const owner of receiptOwners(project, provider)) {
|
|
107
|
+
if (hashPruned.has(`${provider}:${owner}`) || (selected.has('all') && provider !== 'flue') || selected.has(frameworkRegistryId(owner)))
|
|
108
|
+
continue;
|
|
109
|
+
const implicit = !history[provider]?.[frameworkRegistryId(owner)] && Object.values(history[provider] ?? {}).some(entry => entry.produces?.includes(frameworkRegistryId(owner)) || entry.produces?.includes('*'));
|
|
110
|
+
if (implicit)
|
|
111
|
+
continue;
|
|
112
|
+
if (providerCopyMode(project, provider, owner, config)) {
|
|
113
|
+
console.log(`${bundleUseName(owner)} for ${provider}: kept (copy mode); run \`aiwg remove ${bundleUseName(owner)}\` to delete`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const otherProviders = [...expected].filter(([other, owners]) => other !== provider
|
|
117
|
+
&& (history[other]?.[frameworkRegistryId(owner)]?.copy || history[other]?.[frameworkRegistryId(owner)]?.package || owners.has(frameworkRegistryId(owner)) || other !== 'flue' && owners.has('all'))).map(([other]) => other);
|
|
118
|
+
const sharedRoots = deployedSkillRoots(project, provider).filter(root => otherProviders.some(other => deployedSkillRoots(project, other).includes(root)));
|
|
119
|
+
console.log(`${dryRun ? 'Would remove' : 'Removing'} ${bundleUseName(owner)} for ${provider}`);
|
|
120
|
+
// A temporary historical record supplies context for the public per-bundle
|
|
121
|
+
// remover. --keep-registry leaves the operator's declaration byte-for-byte.
|
|
122
|
+
const historical = structuredClone(config);
|
|
123
|
+
historical.installed[owner] = { deployedTo: { [provider]: { agents: 0, commands: 0, skills: 0, rules: 0 } } };
|
|
124
|
+
const result = await removeBundledDeployment(project, owner, owner, historical, [provider], { dryRun, keepRegistry: true, preserveRoots: sharedRoots, includeProject: !otherProviders.length });
|
|
125
|
+
if (result.message)
|
|
126
|
+
console.log(result.message);
|
|
127
|
+
if (result.exitCode)
|
|
128
|
+
failures++;
|
|
129
|
+
else if (!dryRun)
|
|
130
|
+
markBundleReconciled(project, owner, provider);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return failures;
|
|
134
|
+
}
|
|
135
|
+
// Root collectors can recreate additive copies; enforce a recorded restricted scope last.
|
|
136
|
+
export async function pruneAfterScopedDeployments(project, config, requested, frameworkRoot) {
|
|
137
|
+
const restricted = Object.values(config?.installed ?? {}).some(entry => Object.entries(entry.deployedTo).some(([provider, flags]) => (!requested || requested.split(',').includes(provider)) && (flags.skipUtils === true || flags.kernelOnly === true)));
|
|
138
|
+
return restricted ? pruneUndeclaredBundles(project, await readAiwgConfig(project), requested, false, frameworkRoot) : 0;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=bundle-reconciliation.js.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Create, list, and inspect lightweight workflow checkpoints in the configured artifact root.
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { boundedExecFileSync } from '../../process/bounded-child-process.mjs';
|
|
6
|
+
import { resolveProjectAiwgDirForWrite } from '../../config/project-artifacts.js';
|
|
7
|
+
const usage = [
|
|
8
|
+
'aiwg checkpoint — Save or inspect a workflow resume position',
|
|
9
|
+
'',
|
|
10
|
+
'Usage:',
|
|
11
|
+
' aiwg checkpoint create [--name N] [--phase P] [--step S] [--artifact <path>]... [--note N]',
|
|
12
|
+
' aiwg checkpoint list [--json]',
|
|
13
|
+
' aiwg checkpoint recover [<id|name>] [--json]',
|
|
14
|
+
'',
|
|
15
|
+
'Recover reports the saved record without changing the repository.',
|
|
16
|
+
'Duplicate names select the newest matching checkpoint.',
|
|
17
|
+
].join('\n');
|
|
18
|
+
function parse(args) {
|
|
19
|
+
const [action, ...rest] = args;
|
|
20
|
+
if (!['create', 'list', 'recover'].includes(action))
|
|
21
|
+
throw new Error(`Unknown checkpoint action: ${action ?? '(missing)'}\n${usage}`);
|
|
22
|
+
const values = {};
|
|
23
|
+
const artifacts = [];
|
|
24
|
+
let lookup;
|
|
25
|
+
let json = false;
|
|
26
|
+
for (let i = 0; i < rest.length; i++) {
|
|
27
|
+
const arg = rest[i];
|
|
28
|
+
if (arg === '--json' && action !== 'create') {
|
|
29
|
+
json = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (action === 'create' && /^--(name|phase|step|artifact|note)(=|$)/.test(arg)) {
|
|
33
|
+
const eq = arg.indexOf('=');
|
|
34
|
+
const key = arg.slice(2, eq < 0 ? undefined : eq);
|
|
35
|
+
const value = eq < 0 ? rest[++i] : arg.slice(eq + 1);
|
|
36
|
+
if (!value || (eq < 0 && value.startsWith('-')))
|
|
37
|
+
throw new Error(`--${key} requires a value`);
|
|
38
|
+
if (key === 'artifact')
|
|
39
|
+
artifacts.push(value);
|
|
40
|
+
else {
|
|
41
|
+
if (key in values)
|
|
42
|
+
throw new Error(`--${key} may be given once`);
|
|
43
|
+
values[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (action === 'recover' && !arg.startsWith('-') && lookup === undefined) {
|
|
47
|
+
lookup = arg;
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
throw new Error(`Unexpected checkpoint argument: ${arg}`);
|
|
51
|
+
}
|
|
52
|
+
return { action, values, artifacts, lookup, json };
|
|
53
|
+
}
|
|
54
|
+
async function records(dir) {
|
|
55
|
+
let files;
|
|
56
|
+
try {
|
|
57
|
+
files = await readdir(dir);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error.code === 'ENOENT')
|
|
61
|
+
return [];
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
const result = await Promise.all(files.filter(file => file.endsWith('.json')).map(async (file) => {
|
|
65
|
+
const record = JSON.parse(await readFile(join(dir, file), 'utf8'));
|
|
66
|
+
if (!record || typeof record.id !== 'string' || typeof record.cwd !== 'string'
|
|
67
|
+
|| typeof record.createdAt !== 'string' || !Number.isFinite(Date.parse(record.createdAt))
|
|
68
|
+
|| !Array.isArray(record.artifacts) || !record.artifacts.every(path => typeof path === 'string')
|
|
69
|
+
|| ['name', 'gitHead', 'phase', 'step', 'note'].some(key => {
|
|
70
|
+
const value = record[key];
|
|
71
|
+
return value !== undefined && typeof value !== 'string';
|
|
72
|
+
}))
|
|
73
|
+
throw new Error(`Invalid checkpoint record: ${file}`);
|
|
74
|
+
return record;
|
|
75
|
+
}));
|
|
76
|
+
return result.sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt) || b.id.localeCompare(a.id));
|
|
77
|
+
}
|
|
78
|
+
function resumeText(record) {
|
|
79
|
+
return [
|
|
80
|
+
`Checkpoint: ${record.id}${record.name ? ` (${record.name})` : ''}`,
|
|
81
|
+
`Created: ${record.createdAt}`,
|
|
82
|
+
`Resume in: ${record.cwd}`,
|
|
83
|
+
`Phase: ${record.phase ?? '(unspecified)'}`,
|
|
84
|
+
`Step: ${record.step ?? '(unspecified)'}`,
|
|
85
|
+
...(record.gitHead ? [`Git HEAD: ${record.gitHead}`] : []),
|
|
86
|
+
`Artifacts: ${record.artifacts.length ? record.artifacts.join(', ') : '(none)'}`,
|
|
87
|
+
...(record.note !== undefined ? [`Note: ${record.note}`] : []),
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
90
|
+
export const checkpointHandler = {
|
|
91
|
+
id: 'checkpoint',
|
|
92
|
+
name: 'Workflow Checkpoints',
|
|
93
|
+
description: 'Create, list, or recover a saved workflow position',
|
|
94
|
+
category: 'workspace',
|
|
95
|
+
aliases: [],
|
|
96
|
+
async help() { return { exitCode: 0, message: usage, rawOutput: true }; },
|
|
97
|
+
async execute(ctx) {
|
|
98
|
+
if (ctx.args.includes('--help') || ctx.args.includes('-h') || ctx.args[0] === 'help') {
|
|
99
|
+
return { exitCode: 0, message: usage, rawOutput: true };
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const { action, values, artifacts, lookup, json } = parse(ctx.args);
|
|
103
|
+
const dir = join(resolveProjectAiwgDirForWrite(ctx.cwd), 'checkpoints');
|
|
104
|
+
if (action === 'create') {
|
|
105
|
+
if (ctx.dryRun)
|
|
106
|
+
return { exitCode: 0, message: `Would create checkpoint in ${dir}`, rawOutput: true };
|
|
107
|
+
let gitHead;
|
|
108
|
+
try {
|
|
109
|
+
gitHead = String(boundedExecFileSync('git', ['rev-parse', '--verify', 'HEAD'], 'quick', {
|
|
110
|
+
cwd: ctx.cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
111
|
+
})).trim();
|
|
112
|
+
}
|
|
113
|
+
catch { /* Checkpoints also work outside git repositories. */ }
|
|
114
|
+
const record = {
|
|
115
|
+
id: `ckpt_${randomUUID()}`, ...values, createdAt: new Date().toISOString(),
|
|
116
|
+
cwd: ctx.cwd, ...(gitHead ? { gitHead } : {}), artifacts,
|
|
117
|
+
};
|
|
118
|
+
await mkdir(dir, { recursive: true });
|
|
119
|
+
await writeFile(join(dir, `${record.id}.json`), `${JSON.stringify(record, null, 2)}\n`, { flag: 'wx' });
|
|
120
|
+
return { exitCode: 0, message: record.id, rawOutput: true };
|
|
121
|
+
}
|
|
122
|
+
const all = await records(dir);
|
|
123
|
+
if (action === 'list') {
|
|
124
|
+
return {
|
|
125
|
+
exitCode: 0, rawOutput: true,
|
|
126
|
+
message: json ? JSON.stringify(all, null, 2) : all.length
|
|
127
|
+
? ['ID\tName\tCreated\tPhase / Step', ...all.map(record => `${record.id}\t${record.name ?? '(unnamed)'}\t${record.createdAt}\t${record.phase ?? '-'} / ${record.step ?? '-'}`)].join('\n')
|
|
128
|
+
: 'No checkpoints found.',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const record = lookup === undefined ? all[0]
|
|
132
|
+
: all.find(record => record.id === lookup) ?? all.find(record => record.name === lookup);
|
|
133
|
+
if (!record)
|
|
134
|
+
throw new Error(lookup === undefined ? 'No checkpoints found.' : `Checkpoint not found: ${lookup}`);
|
|
135
|
+
return { exitCode: 0, message: json ? JSON.stringify(record, null, 2) : resumeText(record), rawOutput: true };
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return { exitCode: 1, message: error instanceof Error ? error.message : String(error) };
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
export const checkpointHandlers = [checkpointHandler];
|
|
143
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -116,6 +116,7 @@ function displayHelp() {
|
|
|
116
116
|
['cost-report --fleet', 'Observe OpenRouter per-bot MTD spend and correlate local activity'],
|
|
117
117
|
]);
|
|
118
118
|
helpGroup('EVIDENCE', [
|
|
119
|
+
['checkpoint create|list|recover', 'Save or inspect a workflow resume position'],
|
|
119
120
|
['evidence export --output <dir>', 'Package portable activity, report, source, eval, and provenance evidence'],
|
|
120
121
|
['evidence verify <bundle>', 'Verify every member hash and the bundle checkpoint'],
|
|
121
122
|
['effect record|lookup|reconcile', 'Record, look up or reconcile a side effect in the signed effect ledger'],
|
|
@@ -33,6 +33,7 @@ import { regenerateHandler, regenerateHandlers } from './regenerate.js';
|
|
|
33
33
|
import { workspaceContextHandler, workspaceContextHandlers } from './workspace-context.js';
|
|
34
34
|
import { artifactsHandler, artifactsHandlers } from './artifacts.js';
|
|
35
35
|
import { effectHandler, effectHandlers } from './effect.js';
|
|
36
|
+
import { checkpointHandler, checkpointHandlers } from './checkpoint.js';
|
|
36
37
|
import { mcHandler, mcHandlers } from './mc.js';
|
|
37
38
|
import { missionHandlers } from './mission.js';
|
|
38
39
|
import { sdlcAccelerateHandler } from './sdlc-accelerate.js';
|
|
@@ -88,7 +89,7 @@ newBundleHandler, quickrefHandler, newProjectHandler, sessionHandler, sessionsHa
|
|
|
88
89
|
// Workspace
|
|
89
90
|
statusHandler, wizardHandler, migrateWorkspaceHandler, rollbackWorkspaceHandler,
|
|
90
91
|
// Subcommands
|
|
91
|
-
mcpHandler, catalogHandler, modelsHandler, versionsHandler, indexHandler, artifactsHandler, effectHandler, corpusHandler, discoverHandler, showHandler, featuresHandler, skillsHandler, configHandler, opsHandler, storageHandler, activityLogHandler, commandLogHandler, skillUsageHandler, kbHandler, memoryHandler, reflectionsHandler, provenanceHandler, researchStoreHandler, researchQueryHandler, runtimeInfoHandler, agentcardHandler, uhpHandler,
|
|
92
|
+
mcpHandler, catalogHandler, modelsHandler, versionsHandler, indexHandler, artifactsHandler, effectHandler, checkpointHandler, corpusHandler, discoverHandler, showHandler, featuresHandler, skillsHandler, configHandler, opsHandler, storageHandler, activityLogHandler, commandLogHandler, skillUsageHandler, kbHandler, memoryHandler, reflectionsHandler, provenanceHandler, researchStoreHandler, researchQueryHandler, runtimeInfoHandler, agentcardHandler, uhpHandler,
|
|
92
93
|
// Agentic Tools (RLM)
|
|
93
94
|
chunkHandler, fanoutHandler, rlmPrepHandler, rlmSearchHandler, rlmStatusCliHandler, rlmCacheHandler,
|
|
94
95
|
// Utilities
|
|
@@ -124,7 +125,7 @@ repoAccessHandler,
|
|
|
124
125
|
// Lint
|
|
125
126
|
lintHandler, };
|
|
126
127
|
// Re-export handler arrays
|
|
127
|
-
export { workspaceHandlers, utilityHandlers, scaffoldingHandlers, housekeeperHandlers, ralphHandlers, subcommandHandlers, mcHandlers, missionHandlers, teamHandlers, stewardHandlers, regenerateHandlers, workspaceContextHandlers, artifactsHandlers, effectHandlers, daemonHandlers, sandboxHandlers, repoAccessHandlers, };
|
|
128
|
+
export { workspaceHandlers, utilityHandlers, scaffoldingHandlers, housekeeperHandlers, ralphHandlers, subcommandHandlers, mcHandlers, missionHandlers, teamHandlers, stewardHandlers, regenerateHandlers, workspaceContextHandlers, artifactsHandlers, effectHandlers, checkpointHandlers, daemonHandlers, sandboxHandlers, repoAccessHandlers, };
|
|
128
129
|
/**
|
|
129
130
|
* All registered command handlers
|
|
130
131
|
*
|
|
@@ -186,6 +187,7 @@ export const allHandlers = [
|
|
|
186
187
|
indexHandler,
|
|
187
188
|
artifactsHandler,
|
|
188
189
|
effectHandler,
|
|
190
|
+
checkpointHandler,
|
|
189
191
|
corpusHandler,
|
|
190
192
|
discoverHandler,
|
|
191
193
|
showHandler,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// Sample the project and actual CLI request filesystems before rendering a worker.
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { readLiveHostResources } from '../../config/host-resource-runtime.mjs';
|
|
3
|
+
import { nearestDispatchPathSync, readLiveHostResources } from '../../config/host-resource-runtime.mjs';
|
|
4
4
|
import { parseWorkerCommandArgs } from '../../serve/worker-command-request.js';
|
|
5
5
|
export function sampleWorkerHostResources(ctx, readers) {
|
|
6
6
|
const request = ctx.args[0] === 'resolve' ? parseWorkerCommandArgs(ctx.args.slice(1)) : undefined;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// A final-output folder is normally created by the launch, so sample the
|
|
8
|
+
// filesystem it will land on, under the launcher's fail-closed rules (#3856).
|
|
9
|
+
const paths = request
|
|
10
|
+
? [ctx.cwd, request.workdir, nearestDispatchPathSync(path.dirname(request.final_output))]
|
|
11
|
+
: [ctx.cwd];
|
|
12
|
+
return readLiveHostResources({ ...readers, paths, workspace: request?.workdir ?? ctx.cwd });
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=models-resource-sample.js.map
|
|
@@ -264,7 +264,7 @@ export async function launchExternalRalph(frameworkRoot, projectRoot, options) {
|
|
|
264
264
|
while (!identity && process.hrtime.bigint() < identityDeadline) {
|
|
265
265
|
if ((child.exitCode !== null && child.exitCode !== undefined) || child.signalCode)
|
|
266
266
|
break;
|
|
267
|
-
identity = capture.observe(sampleWorkerIdentity(pid));
|
|
267
|
+
identity = capture.observe(sampleWorkerIdentity(pid, { includeExited: true }));
|
|
268
268
|
if (!identity)
|
|
269
269
|
await new Promise(resolve => setTimeout(resolve, 10));
|
|
270
270
|
}
|