@harmoniclabs/pebble-cli 0.1.3-dev4 → 0.1.3-dev6

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.
@@ -10,11 +10,18 @@ export async function initPebbleProject() {
10
10
  message: "What is the name of your project?",
11
11
  default: "my-pebble-project",
12
12
  });
13
+ const includeClaudeMd = await confirm({
14
+ message: "Do you want to include a CLAUDE.md file? (helps AI assistants understand Pebble)",
15
+ default: true
16
+ });
13
17
  let offchain = undefined;
14
- const includeOffchain = await confirm({
18
+ const includeOffchain = /*
19
+ await confirm({
15
20
  message: "Do you want to include offchain code using buildooor?",
16
21
  default: false
17
22
  });
23
+ /*/ false;
24
+ //*/
18
25
  if (includeOffchain) {
19
26
  const network = await select({
20
27
  message: "Which network would you like to target?",
@@ -196,6 +203,123 @@ contract MyContract {
196
203
  // propose proposeGovernanceAction () {}
197
204
  }`);
198
205
  await writeFile(indexPebblePath, indexPebble);
206
+ // CLAUDE.md
207
+ if (includeClaudeMd) {
208
+ const claudeMdPath = path.join(projectRoot, "CLAUDE.md");
209
+ const claudeMd = (`# Pebble Project
210
+
211
+ This is a Pebble smart contract project. Pebble is a language with JavaScript-like syntax that compiles to UPLC for Cardano smart contracts.
212
+
213
+ ## Project structure
214
+
215
+ - \`src/index.pebble\` - main contract entry point
216
+ - \`pebble.config.json\` - compiler config (entry, outDir, removeTraces)
217
+ - \`out/\` - compiled output (generated)
218
+ ${includeOffchain ? "- \\`offchain/\\` - offchain code using buildooor\n" : ""}\
219
+ ## CLI commands
220
+
221
+ - \`pebble compile --config ./pebble.config.json\` - compile the project
222
+ - \`pebble export --function-name <name>\` - export a single function
223
+ - \`npm run compile\` - shortcut for compile
224
+
225
+ ## Pebble language reference
226
+
227
+ ### Contracts
228
+
229
+ \`\`\`pebble
230
+ contract ContractName {
231
+ param owner: PubKeyHash;
232
+
233
+ spend methodName(arg: int) {
234
+ const { tx } = context;
235
+ assert tx.requiredSigners.includes(this.owner);
236
+ }
237
+ }
238
+ \`\`\`
239
+
240
+ A contract with no methods is an always-failing validator.
241
+
242
+ ### Method types
243
+
244
+ \`spend\`, \`mint\`, \`cert\`, \`withdraw\`, \`vote\`, \`propose\`
245
+
246
+ ### Context
247
+
248
+ Inside contract methods, \`context\` provides:
249
+ - \`tx\` - the transaction (always available)
250
+ - \`spendingInputRef\` - reference to the UTxO being spent (\`spend\` methods)
251
+ - \`optionalDatum\` - optional datum on the spent UTxO (\`spend\` methods)
252
+
253
+ ### Tx fields
254
+
255
+ \`tx.inputs\`, \`tx.refInputs\`, \`tx.outputs\`, \`tx.fee\`, \`tx.mint\`,
256
+ \`tx.certificates\`, \`tx.withdrawals\`, \`tx.validityInterval\`,
257
+ \`tx.requiredSigners\`, \`tx.redeemers\`, \`tx.datums\`, \`tx.hash\`,
258
+ \`tx.votes\`, \`tx.proposals\`, \`tx.currentTreasury\`, \`tx.treasuryDonation\`
259
+
260
+ ### Structs
261
+
262
+ \`\`\`pebble
263
+ struct Order {
264
+ ownerPaymentCreds: PubKeyHash,
265
+ policy: bytes,
266
+ minAmount: int
267
+ }
268
+ \`\`\`
269
+
270
+ Sum types (data structs):
271
+
272
+ \`\`\`pebble
273
+ struct OutputDatum {
274
+ NoDatum {}
275
+ DatumHash { hash: Hash32 }
276
+ InlineDatum { datum: data }
277
+ }
278
+ \`\`\`
279
+
280
+ ### Built-in types
281
+
282
+ \`int\`, \`bytes\`, \`bool\`, \`data\`,
283
+ \`PubKeyHash\`, \`ScriptHash\`, \`Hash32\`, \`Hash28\`,
284
+ \`PolicyId\`, \`TokenName\`, \`TxHash\`,
285
+ \`Credential\`, \`Address\`, \`Value\`, \`TxOut\`, \`TxIn\`, \`TxOutRef\`,
286
+ \`List<T>\`, \`Optional<T>\`, \`LinearMap<K,V>\`, \`Interval\`
287
+
288
+ ### Variables and control flow
289
+
290
+ - \`const x = value;\` / \`let x = value;\`
291
+ - \`if/else\`, ternary \`? :\`
292
+ - \`for(const x of list)\`, \`for(let i = 0; i < n; i++)\`
293
+ - \`assert condition;\` - fails the contract if false
294
+ - \`trace value;\` - debug output
295
+ - \`fail;\` - explicitly fail
296
+
297
+ ### Pattern matching
298
+
299
+ \`\`\`pebble
300
+ assert case ownerCreds
301
+ is PubKeyHash{ hash } => tx.signatories.includes(hash)
302
+ is Validator{ hash } => tx.inputs.some(input => input.resolved.address.payment.hash() === hash);
303
+ \`\`\`
304
+
305
+ ### Datum extraction
306
+
307
+ \`\`\`pebble
308
+ const InlineDatum{ datum: { field1, field2 } as MyStruct } = someOutput.datum;
309
+ \`\`\`
310
+
311
+ ### Common operations
312
+
313
+ - \`list.includes(item)\`, \`list.filter(fn)\`, \`list.find(fn)\`, \`list.some(fn)\`
314
+ - \`list.head()\`, \`list.tail()\`, \`list.isEmpty()\`, \`list.length()\`
315
+ - \`value.lovelaces()\`, \`value.amountOf(policy, tokenName)\`
316
+ - \`credential.hash()\`
317
+ - Hex literals: \`#aabbcc\`
318
+ - Numeric separators: \`5_000_000\`
319
+ - Access contract params with \`this.paramName\`
320
+ `);
321
+ await writeFile(claudeMdPath, claudeMd);
322
+ }
199
323
  // optional offchain scaffolding
200
324
  if (includeOffchain && offchain) {
201
325
  const offchainReadme = `# Offchain
@@ -1,3 +1,3 @@
1
- export declare const PEBBLE_VERSION = "0.1.3-dev4";
2
- export declare const PEBBLE_LIB_VERSION = "0.1.3-dev4";
3
- export declare const PEBBLE_COMMIT_HASH = "a29d13ab47da3ed8bd8f3fbf597fd7e27a105cc9";
1
+ export declare const PEBBLE_VERSION = "0.1.3-dev6";
2
+ export declare const PEBBLE_LIB_VERSION = "0.1.3-dev6 (local)";
3
+ export declare const PEBBLE_COMMIT_HASH = "e6215f4969bf146ef3e6cccaa0b9802dd852690b";
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated by scripts/genVersions.js. Do not edit.
2
- export const PEBBLE_VERSION = "0.1.3-dev4";
3
- export const PEBBLE_LIB_VERSION = "0.1.3-dev4";
4
- export const PEBBLE_COMMIT_HASH = "a29d13ab47da3ed8bd8f3fbf597fd7e27a105cc9";
2
+ export const PEBBLE_VERSION = "0.1.3-dev6";
3
+ export const PEBBLE_LIB_VERSION = "0.1.3-dev6 (local)";
4
+ export const PEBBLE_COMMIT_HASH = "e6215f4969bf146ef3e6cccaa0b9802dd852690b";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmoniclabs/pebble-cli",
3
- "version": "0.1.3-dev4",
3
+ "version": "0.1.3-dev6",
4
4
  "description": "A simple, yet rock solid, functional language with an imperative bias, targeting UPLC",
5
5
  "bin": {
6
6
  "pebble": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "@harmoniclabs/crypto": "^0.3.0",
52
52
  "@harmoniclabs/obj-utils": "^1.0.0",
53
- "@harmoniclabs/pebble": "^0.1.3-dev4",
53
+ "@harmoniclabs/pebble": "harmoniclabs-pebble-0.1.3-dev6.tgz",
54
54
  "@harmoniclabs/plutus-machine": "^3.0.0",
55
55
  "@harmoniclabs/uint8array-utils": "^1.0.4",
56
56
  "@harmoniclabs/uplc": "^2.0.5",
@@ -65,4 +65,4 @@
65
65
  "typescript": "^4.6.3"
66
66
  },
67
67
  "funding": "https://github.com/sponsors/HarmonicLabs"
68
- }
68
+ }