@ccdd/core 3.3.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +69 -62
  2. package/dist/src/artifact-scope.d.ts +6 -0
  3. package/dist/src/artifact-scope.js +27 -0
  4. package/dist/src/artifact-scope.js.map +1 -0
  5. package/dist/src/definitions.d.ts +33 -23
  6. package/dist/src/sdk.d.ts +3 -8
  7. package/dist/src/sdk.js +2 -3
  8. package/dist/src/sdk.js.map +1 -1
  9. package/dist/src/tools/contracts.d.ts +34 -78
  10. package/examples/artifact-folders/README.md +18 -0
  11. package/examples/artifact-folders/coding-style/ccdd.json +128 -0
  12. package/examples/artifact-folders/coding-style/style.md +3 -0
  13. package/examples/artifact-folders/explosion/blind-pair.mjs +19 -0
  14. package/examples/artifact-folders/explosion/ccdd.json +220 -0
  15. package/examples/artifact-folders/explosion/effect/ccdd.json +128 -0
  16. package/examples/artifact-folders/explosion/preview/ccdd.json +142 -0
  17. package/examples/artifact-folders/theme-image/ccdd.json +128 -0
  18. package/examples/artifact-folders/theme-image/theme.png +0 -0
  19. package/examples/computed-views/README.md +12 -0
  20. package/examples/computed-views/checkout/ccdd.json +133 -0
  21. package/examples/computed-views/search/ccdd.json +133 -0
  22. package/examples/computed-views/view.mjs +13 -0
  23. package/examples/custom-text-reader/README.md +7 -19
  24. package/examples/custom-text-reader/spec/ccdd.json +60 -0
  25. package/examples/custom-text-reader/view.mjs +20 -0
  26. package/examples/custom-text-reader/why/ccdd.json +46 -0
  27. package/package.json +21 -7
  28. package/examples/artifact-groups/README.md +0 -60
  29. package/examples/artifact-groups/ccdd.config.ts +0 -37
  30. package/examples/custom-text-reader/ccdd.config.ts +0 -64
  31. package/examples/generated-artifacts/README.md +0 -55
  32. package/examples/generated-artifacts/ccdd.config.ts +0 -86
  33. /package/examples/{artifact-groups → artifact-folders/explosion/effect}/effect.md +0 -0
  34. /package/examples/{artifact-groups → artifact-folders/explosion/preview}/preview.png +0 -0
  35. /package/examples/{generated-artifacts/scenarios/checkout.json → computed-views/checkout/scenario.json} +0 -0
  36. /package/examples/{generated-artifacts/scenarios/search.json → computed-views/search/scenario.json} +0 -0
  37. /package/examples/custom-text-reader/{spec.md → spec/spec.md} +0 -0
  38. /package/examples/custom-text-reader/{why.md → why/why.md} +0 -0
@@ -1,55 +0,0 @@
1
- # Review generated scenario data
2
-
3
- This example captures two JSON scenarios as independent generated Artifacts. The scenario files are sample evidence for demonstrating review mechanics, not recorded product tests. Each Human Critic must inspect an overview and every listed detail, then make an actual judgment.
4
-
5
- `scenarioSource.prepare` reads a file from the captured project through `context.resolvePath`. It returns structured data directly; CCDD persists the fixed value outside the reviewed workspace. The source does no generation, so it declares `preparation: 'read-only'` and supports `status` and `plan`.
6
-
7
- The explicitly registered `overview` and `detail` tools use `context.readData()`. Each call receives a copy of the recorded value, including after worker restart. The full scenario determines identity even when a tool only returns one field. Initial prompts and monitor scope metadata do not contain that data.
8
-
9
- ## Run the example
10
-
11
- Use Node 22 LTS, at least 22.19.0. These APIs require CCDD 3.2.0 or later. From the source repository, build and pack core and project:
12
-
13
- ```sh
14
- npm ci
15
- npm run build
16
- CCDD_GENERATED_PACKAGES=$(mktemp -d /tmp/ccdd-generated-packages.XXXXXX)
17
- npm pack --ignore-scripts --pack-destination "$CCDD_GENERATED_PACKAGES"
18
- npm pack --ignore-scripts --workspace @ccdd/project --pack-destination "$CCDD_GENERATED_PACKAGES"
19
-
20
- CCDD_GENERATED_EXAMPLE=$(mktemp -d /tmp/ccdd-generated-example.XXXXXX)
21
- cp -R examples/generated-artifacts "$CCDD_GENERATED_EXAMPLE/project"
22
- cd "$CCDD_GENERATED_EXAMPLE/project"
23
- npm init -y
24
- npm pkg set type=module
25
- npm install --ignore-scripts "$CCDD_GENERATED_PACKAGES"/*.tgz
26
- ```
27
-
28
- Inspect the current input and execute the two data tools without starting a review:
29
-
30
- ```sh
31
- npx ccdd-project plan checkout
32
- npx ccdd-project tools check --artifact checkout --for human --tool overview --execute
33
- npx ccdd-project tools check --artifact checkout --for human --tool detail --execute --args '{"id":"summary"}'
34
- ```
35
-
36
- These tool diagnostics prepare a new snapshot and report actual tool results. They do not create a verdict or demonstrate that the scenario passes its Critic.
37
-
38
- Request both Human reviews and open the monitor:
39
-
40
- ```sh
41
- npx ccdd-project verify --all --human-inbox
42
- npx ccdd-project monitor
43
- ```
44
-
45
- Open the printed local address, choose the project and a Human request, and claim it. Execute `overview`, then call `detail` for every returned detail ID. Submit your verdict with a summary and evidence citing those IDs. Repeat for the other scenario. See the [Human reviewer guide](../../docs/reviewers.md#ask-a-person-to-review) for the claim and submission workflow.
46
-
47
- The tools are also registered for Agents. To use them, change the desired Critic to an explicitly supported Agent profile and supply credentials as described in the [reviewer guide](../../docs/reviewers.md). An Agent review makes actual Provider calls. Runtime Critics do not support generated Artifact scopes.
48
-
49
- ## Inspect reuse
50
-
51
- After completing real reviews, run `npx ccdd-project status`. Edit a detail in `scenarios/checkout.json` and run `npx ccdd-project plan --all`. Checkout now has changed input; an applicable passing search review can remain reusable because its captured data and Critic definition are unchanged. Changing an unread detail also changes checkout identity. Restoring equivalent checkout data can reuse its applicable historical evidence, subject to the existing latest-verdict and dependency rules.
52
-
53
- Changing whitespace or object-key order preserves canonical JSON identity. Array order remains significant. Keep changing scenario data in these source files rather than importing it into shared config: imported config module changes conservatively affect effective Critic definitions.
54
-
55
- See [generated Artifact contracts](../../docs/generated-artifacts.md) for identity strategies, canonicalization, size limits, preparation policy, and reopening behavior.
@@ -1,86 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { defineArtifactSource, defineConfig, defineDataTool } from '@ccdd/core';
3
- import type { JsonValue } from '@ccdd/core';
4
-
5
- function scenarioData(value: JsonValue) {
6
- if (!value || typeof value !== 'object' || Array.isArray(value)
7
- || typeof value.name !== 'string' || typeof value.objective !== 'string'
8
- || !Array.isArray(value.criteria) || value.criteria.some(item => typeof item !== 'string')
9
- || !Array.isArray(value.details) || value.details.some(item => !item || typeof item !== 'object'
10
- || Array.isArray(item) || typeof item.id !== 'string' || typeof item.observation !== 'string')) {
11
- throw new Error('Expected a scenario with name, objective, criteria, and identified details.');
12
- }
13
- return value as { name: string; objective: string; criteria: string[]; details: { id: string; observation: string }[] };
14
- }
15
-
16
- const scenarioSource = defineArtifactSource({
17
- metadata: {
18
- preparation: 'read-only',
19
- identity: { kind: 'canonical-data', namespace: 'example/scenario', version: '1' },
20
- },
21
- async prepare(context) {
22
- if (typeof context.params !== 'string') throw new Error('Expected a scenario file path.');
23
- const data: JsonValue = JSON.parse(await readFile(await context.resolvePath(context.params), 'utf8'));
24
- scenarioData(data);
25
- return { data };
26
- },
27
- });
28
-
29
- const overview = defineDataTool({
30
- metadata: {
31
- description: 'Read the objective, criteria, and available detail IDs of {artifactName}.',
32
- inputSchema: { type: 'object', properties: {}, additionalProperties: false },
33
- resultKinds: ['json'],
34
- observation: 'content',
35
- },
36
- execute(context) {
37
- const data = scenarioData(context.readData());
38
- return {
39
- content: [{ type: 'json', data: {
40
- name: data.name, objective: data.objective, criteria: data.criteria,
41
- detailIds: data.details.map(detail => detail.id),
42
- } }],
43
- observation: { kind: 'content' },
44
- };
45
- },
46
- });
47
-
48
- const detail = defineDataTool({
49
- metadata: {
50
- description: 'Read one identified detail from the captured {artifactName} scenario.',
51
- inputSchema: {
52
- type: 'object', properties: { id: { type: 'string', minLength: 1 } },
53
- required: ['id'], additionalProperties: false,
54
- },
55
- resultKinds: ['json'],
56
- observation: 'content',
57
- },
58
- execute(context, args) {
59
- const found = scenarioData(context.readData()).details.find(item => item.id === args.id);
60
- if (!found) throw new Error('Unknown scenario detail.');
61
- return { content: [{ type: 'json', data: found }], observation: { kind: 'content' } };
62
- },
63
- });
64
-
65
- export default defineConfig({
66
- artifactSources: { scenario: scenarioSource },
67
- artifactTypes: {
68
- scenario: { agentTools: { overview, detail }, humanTools: { overview, detail } },
69
- },
70
- artifacts: {
71
- checkout: { kind: 'generated', type: 'scenario', source: 'scenario', params: 'scenarios/checkout.json' },
72
- search: { kind: 'generated', type: 'scenario', source: 'scenario', params: 'scenarios/search.json' },
73
- },
74
- critics: [
75
- {
76
- id: 'checkout-review', title: 'Review the checkout scenario', target: 'checkout', deps: [],
77
- profile: { kind: 'human' },
78
- payload: { instruction: 'Read the overview of {checkout}, then inspect every listed detail. Decide whether the observations satisfy each criterion. Cite detail IDs and explain missing or contradictory evidence.' },
79
- },
80
- {
81
- id: 'search-review', title: 'Review the search scenario', target: 'search', deps: [],
82
- profile: { kind: 'human' },
83
- payload: { instruction: 'Read the overview of {search}, then inspect every listed detail. Decide whether the observations satisfy each criterion. Cite detail IDs and explain missing or contradictory evidence.' },
84
- },
85
- ],
86
- });