@aiwg/cli 2026.7.19 → 2026.7.21
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 +397 -385
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/index.js +1 -0
- package/dist/src/artifacts/browser-export.js +7 -0
- package/dist/src/artifacts/citation-parser.js +96 -35
- package/dist/src/artifacts/cli.js +59 -5
- package/dist/src/artifacts/discover-facets.js +15 -0
- package/dist/src/artifacts/discovery-eval.js +290 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +1 -1
- package/dist/src/artifacts/fortemi-shard-export.js +1 -1
- package/dist/src/artifacts/index-builder.js +54 -17
- package/dist/src/artifacts/query-engine.js +10 -6
- package/dist/src/artifacts/state-transfer.js +27 -0
- package/dist/src/artifacts/stats.js +8 -0
- package/dist/src/cli/cli-extension-loader.js +73 -0
- package/dist/src/cli/handlers/help.js +2 -1
- package/dist/src/cli/handlers/index.js +6 -2
- package/dist/src/cli/handlers/resource-versions.js +247 -0
- package/dist/src/cli/handlers/sessions.js +966 -0
- package/dist/src/cli/handlers/skill-lint.js +49 -45
- package/dist/src/cli/handlers/subcommands.js +55 -3
- package/dist/src/cli/handlers/use.js +154 -59
- package/dist/src/cli/handlers/utilities.js +49 -34
- package/dist/src/cli/skill-usage.js +146 -24
- package/dist/src/config/cli.js +13 -9
- package/dist/src/config/project-artifacts-runtime.mjs +68 -0
- package/dist/src/config/project-artifacts.js +1 -68
- package/dist/src/extensions/commands/definitions.js +65 -2
- package/dist/src/extensions/manifest.js +29 -0
- package/dist/src/extensions/project-local-discovery.js +86 -2
- package/dist/src/extensions/project-local-remove.js +52 -56
- package/dist/src/extensions/shadow-resolver.js +3 -1
- package/dist/src/plugins/standalone-packager.js +143 -0
- package/dist/src/resources/cache-cleanup.js +67 -0
- package/dist/src/resources/doctor.js +107 -0
- package/dist/src/resources/lockfile.js +125 -0
- package/dist/src/resources/resolver.js +133 -0
- package/dist/src/resources/web-release.d.ts +8 -0
- package/dist/src/resources/web-release.js +159 -1
- package/dist/src/sessions/adapters/claude.js +357 -0
- package/dist/src/sessions/adapters/codex.js +521 -0
- package/dist/src/sessions/adapters/copilot.js +226 -0
- package/dist/src/sessions/adapters/cursor.js +372 -0
- package/dist/src/sessions/adapters/factory.js +345 -0
- package/dist/src/sessions/adapters/generic.js +225 -0
- package/dist/src/sessions/adapters/hermes.js +341 -0
- package/dist/src/sessions/adapters/openclaw.js +381 -0
- package/dist/src/sessions/adapters/opencode.js +454 -0
- package/dist/src/sessions/adapters/openhuman.js +315 -0
- package/dist/src/sessions/adapters/warp.js +160 -0
- package/dist/src/sessions/adapters/windsurf.js +212 -0
- package/dist/src/sessions/candidates.js +210 -0
- package/dist/src/sessions/contracts.js +310 -0
- package/dist/src/sessions/discovery.js +51 -0
- package/dist/src/sessions/fixtures.js +12 -0
- package/dist/src/sessions/importer.js +315 -0
- package/dist/src/sessions/index.js +25 -0
- package/dist/src/sessions/knowledge-shard.js +61 -0
- package/dist/src/sessions/optional-backends.js +238 -0
- package/dist/src/sessions/policy.js +192 -0
- package/dist/src/sessions/ports.js +2 -0
- package/dist/src/sessions/promotion.js +367 -0
- package/dist/src/sessions/readers.js +176 -0
- package/dist/src/sessions/repository.js +1551 -0
- package/dist/src/skills/adapters/agent-skills.js +59 -0
- package/dist/src/skills/adapters/local.js +19 -1
- package/dist/src/skills/agent-skills.js +249 -0
- package/dist/src/skills/cli.js +463 -7
- package/dist/src/skills/deployer.js +554 -0
- package/dist/src/skills/doctor.js +105 -0
- package/dist/src/skills/exporter.js +382 -0
- package/dist/src/skills/importer.js +921 -0
- package/dist/src/skills/registry.js +19 -0
- package/dist/src/skills/validator.js +323 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +5 -1
- package/dist/src/smiths/context-pipeline/claude-hook.js +21 -1
- package/dist/src/smiths/context-pipeline/finalization.js +5 -3
- package/dist/src/smiths/context-pipeline/generator.js +4 -1
- package/dist/src/smiths/context-pipeline/parallelism-section.js +34 -1
- package/dist/src/smiths/context-pipeline/workspace-context.js +15 -3
- package/dist/src/smiths/mcpsmith/example.js +3 -1
- package/dist/src/smiths/mcpsmith/generator.js +3 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -1
- package/dist/src/storage/cli.js +3 -2
- package/dist/src/storage/subsystem-cli.js +7 -2
- package/dist/src/update/notifier.mjs +1 -1
- package/dist/src/update/service.mjs +123 -0
- package/package.json +3 -2
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { open, readFile } from 'node:fs/promises';
|
|
4
|
+
import { createInterface } from 'node:readline';
|
|
5
|
+
import { SessionContractError } from './contracts.js';
|
|
6
|
+
import { authorizeSourceFile } from './policy.js';
|
|
7
|
+
export const DEFAULT_READER_LIMITS = Object.freeze({
|
|
8
|
+
maxRecords: 1_000_000,
|
|
9
|
+
maxRecordBytes: 4 * 1024 * 1024,
|
|
10
|
+
maxTotalBytes: 1024 * 1024 * 1024,
|
|
11
|
+
maxNestingDepth: 64,
|
|
12
|
+
});
|
|
13
|
+
export async function readBoundedJsonLines(authorization, options) {
|
|
14
|
+
const stream = await streamBoundedJsonLines(authorization, options);
|
|
15
|
+
const records = [];
|
|
16
|
+
for await (const record of stream)
|
|
17
|
+
records.push(record);
|
|
18
|
+
return {
|
|
19
|
+
records,
|
|
20
|
+
nextCursor: stream.nextCursor,
|
|
21
|
+
consistency: stream.consistency,
|
|
22
|
+
incompleteTail: stream.incompleteTail,
|
|
23
|
+
bytesRead: stream.bytesRead,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export async function streamBoundedJsonLines(authorization, options) {
|
|
27
|
+
const allowed = await authorizeSourceFile(authorization);
|
|
28
|
+
const limits = { ...DEFAULT_READER_LIMITS, ...options.limits };
|
|
29
|
+
const start = parseCursor(options.cursor);
|
|
30
|
+
if (start > allowed.size)
|
|
31
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'reader cursor is beyond source size');
|
|
32
|
+
let offset = start;
|
|
33
|
+
let total = 0;
|
|
34
|
+
let count = 0;
|
|
35
|
+
let incompleteTail = false;
|
|
36
|
+
const iterate = async function* () {
|
|
37
|
+
const input = createReadStream(allowed.canonicalPath, { start, encoding: 'utf8' });
|
|
38
|
+
const lines = createInterface({ input, crlfDelay: Infinity });
|
|
39
|
+
try {
|
|
40
|
+
for await (const line of lines) {
|
|
41
|
+
const bytes = Buffer.byteLength(line) + 1;
|
|
42
|
+
if (bytes > limits.maxRecordBytes || total + bytes > limits.maxTotalBytes
|
|
43
|
+
|| count + 1 > limits.maxRecords) {
|
|
44
|
+
throw new SessionContractError('RESOURCE_LIMIT_EXCEEDED', 'bounded session reader limit exceeded');
|
|
45
|
+
}
|
|
46
|
+
if (line.trim() === '') {
|
|
47
|
+
offset += bytes;
|
|
48
|
+
total += bytes;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
let value;
|
|
52
|
+
try {
|
|
53
|
+
value = JSON.parse(line);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
if (options.consistency === 'provisional') {
|
|
57
|
+
incompleteTail = true;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'malformed JSONL record in consistent source');
|
|
61
|
+
}
|
|
62
|
+
if (jsonDepth(value) > limits.maxNestingDepth) {
|
|
63
|
+
throw new SessionContractError('RESOURCE_LIMIT_EXCEEDED', 'JSON nesting depth exceeds reader limit');
|
|
64
|
+
}
|
|
65
|
+
const record = { value, sequence: count, byteOffset: offset, byteLength: bytes };
|
|
66
|
+
count += 1;
|
|
67
|
+
offset += bytes;
|
|
68
|
+
total += bytes;
|
|
69
|
+
yield record;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
lines.close();
|
|
74
|
+
input.destroy();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
get nextCursor() { return String(offset); },
|
|
79
|
+
consistency: options.consistency,
|
|
80
|
+
get incompleteTail() { return incompleteTail; },
|
|
81
|
+
get bytesRead() { return total; },
|
|
82
|
+
get recordsRead() { return count; },
|
|
83
|
+
[Symbol.asyncIterator]: iterate,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export async function readBoundedJson(authorization, limitsInput) {
|
|
87
|
+
const allowed = await authorizeSourceFile(authorization);
|
|
88
|
+
const limits = { ...DEFAULT_READER_LIMITS, ...limitsInput };
|
|
89
|
+
if (allowed.size > limits.maxTotalBytes || allowed.size > limits.maxRecordBytes) {
|
|
90
|
+
throw new SessionContractError('RESOURCE_LIMIT_EXCEEDED', 'bounded JSON source limit exceeded');
|
|
91
|
+
}
|
|
92
|
+
let value;
|
|
93
|
+
try {
|
|
94
|
+
value = JSON.parse(await readFile(allowed.canonicalPath, 'utf8'));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'malformed JSON source');
|
|
98
|
+
}
|
|
99
|
+
if (jsonDepth(value) > limits.maxNestingDepth) {
|
|
100
|
+
throw new SessionContractError('RESOURCE_LIMIT_EXCEEDED', 'JSON nesting depth exceeds reader limit');
|
|
101
|
+
}
|
|
102
|
+
return { value, bytesRead: allowed.size };
|
|
103
|
+
}
|
|
104
|
+
export async function readBoundedText(authorization, limitsInput) {
|
|
105
|
+
const allowed = await authorizeSourceFile(authorization);
|
|
106
|
+
const limits = { ...DEFAULT_READER_LIMITS, ...limitsInput };
|
|
107
|
+
if (allowed.size > limits.maxTotalBytes || allowed.size > limits.maxRecordBytes) {
|
|
108
|
+
throw new SessionContractError('RESOURCE_LIMIT_EXCEEDED', 'bounded text source limit exceeded');
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
value: await readFile(allowed.canonicalPath, 'utf8'),
|
|
112
|
+
bytesRead: allowed.size,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export async function fingerprintSourceFile(authorization) {
|
|
116
|
+
const allowed = await authorizeSourceFile(authorization);
|
|
117
|
+
const handle = await open(allowed.canonicalPath, 'r');
|
|
118
|
+
const hash = createHash('sha256');
|
|
119
|
+
try {
|
|
120
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
121
|
+
let position = 0;
|
|
122
|
+
while (position < allowed.size) {
|
|
123
|
+
const result = await handle.read(buffer, 0, Math.min(buffer.length, allowed.size - position), position);
|
|
124
|
+
if (result.bytesRead === 0)
|
|
125
|
+
break;
|
|
126
|
+
hash.update(buffer.subarray(0, result.bytesRead));
|
|
127
|
+
position += result.bytesRead;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
await handle.close();
|
|
132
|
+
}
|
|
133
|
+
return { digest: `sha256:${hash.digest('hex')}`, size: allowed.size };
|
|
134
|
+
}
|
|
135
|
+
export async function fingerprintSourcePrefix(authorization, length) {
|
|
136
|
+
const allowed = await authorizeSourceFile(authorization);
|
|
137
|
+
if (!Number.isSafeInteger(length) || length < 0 || length > allowed.size) {
|
|
138
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'checkpoint source position is beyond the current source size');
|
|
139
|
+
}
|
|
140
|
+
const handle = await open(allowed.canonicalPath, 'r');
|
|
141
|
+
const hash = createHash('sha256');
|
|
142
|
+
try {
|
|
143
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
144
|
+
let position = 0;
|
|
145
|
+
while (position < length) {
|
|
146
|
+
const result = await handle.read(buffer, 0, Math.min(buffer.length, length - position), position);
|
|
147
|
+
if (result.bytesRead === 0)
|
|
148
|
+
break;
|
|
149
|
+
hash.update(buffer.subarray(0, result.bytesRead));
|
|
150
|
+
position += result.bytesRead;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
await handle.close();
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
digest: `sha256:${hash.digest('hex')}`,
|
|
158
|
+
size: allowed.size,
|
|
159
|
+
mtimeMs: allowed.mtimeMs,
|
|
160
|
+
fileIdentity: `${allowed.dev}:${allowed.ino}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function parseCursor(cursor) {
|
|
164
|
+
if (cursor === undefined || cursor === '')
|
|
165
|
+
return 0;
|
|
166
|
+
if (!/^\d+$/.test(cursor))
|
|
167
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'invalid reader cursor');
|
|
168
|
+
return Number(cursor);
|
|
169
|
+
}
|
|
170
|
+
function jsonDepth(value, depth = 0) {
|
|
171
|
+
if (value === null || typeof value !== 'object')
|
|
172
|
+
return depth;
|
|
173
|
+
const children = Array.isArray(value) ? value : Object.values(value);
|
|
174
|
+
return children.reduce((max, child) => Math.max(max, jsonDepth(child, depth + 1)), depth);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=readers.js.map
|